@@ -27,12 +27,15 @@ define([ | |||
hoverFilter: false, | |||
blockedPlayers: [], | |||
postRender: function () { | |||
this.onEvent('onGetMessages', this.onGetMessages.bind(this)); | |||
this.onEvent('onDoWhisper', this.onDoWhisper.bind(this)); | |||
this.onEvent('onJoinChannel', this.onJoinChannel.bind(this)); | |||
this.onEvent('onLeaveChannel', this.onLeaveChannel.bind(this)); | |||
this.onEvent('onGetCustomChatChannels', this.onGetCustomChatChannels.bind(this)); | |||
this.onEvent('onGetBlockedPlayers', this.onGetBlockedPlayers.bind(this)); | |||
this.find('input') | |||
.on('keydown', this.sendChat.bind(this)) | |||
@@ -77,6 +80,10 @@ define([ | |||
textbox.val(val); | |||
}, | |||
onGetBlockedPlayers: function (list) { | |||
this.blockedPlayers = list; | |||
}, | |||
onGetCustomChatChannels: function (channels) { | |||
channels.forEach(function (c) { | |||
this.onJoinChannel(c); | |||
@@ -149,12 +156,15 @@ define([ | |||
let container = this.find('.list'); | |||
messages.forEach(function (m) { | |||
messages.forEach(m => { | |||
let message = m.message; | |||
if (m.item) { | |||
let source = message.split(':')[0] + ': '; | |||
message = source + '<span class="q' + (m.item.quality || 0) + '">' + message.replace(source, '') + '</span>'; | |||
} | |||
let source = message.split(':')[0]; | |||
let sourceName = source.split(')').pop(); | |||
if (this.blockedPlayers.includes(sourceName)) | |||
return; | |||
if (m.item) | |||
message = source + ': <span class="q' + (m.item.quality || 0) + '">' + message.replace(source + ': ', '') + '</span>'; | |||
let el = $('<div class="list-message ' + m.class + '">' + message + '</div>') | |||
.appendTo(container); | |||
@@ -182,7 +192,7 @@ define([ | |||
ttl: this.maxTtl, | |||
el: el | |||
}); | |||
}, this); | |||
}); | |||
container.scrollTop(9999999); | |||
}, | |||
@@ -10,6 +10,8 @@ let commandRoles = { | |||
leave: 0, | |||
unEq: 0, | |||
roll: 0, | |||
block: 0, | |||
unblock: 0, | |||
//Mods | |||
mute: 5, | |||
@@ -38,7 +40,9 @@ let localCommands = [ | |||
'unmute', | |||
'setPassword', | |||
'roll', | |||
'giveSkin' | |||
'giveSkin', | |||
'block', | |||
'unblock' | |||
]; | |||
module.exports = { | |||
@@ -205,6 +209,54 @@ module.exports = { | |||
}); | |||
}, | |||
block: function (target) { | |||
if (!this.blockedPlayers.includes(target)) { | |||
this.sendMessage('That player has already been blocked', 'color-redA'); | |||
return; | |||
} | |||
let o = connections.players.find(f => (f.name === target)); | |||
if (!o) | |||
return; | |||
let role = roles.getRoleLevel(o); | |||
if (role >= this.roleLevel) { | |||
this.sendMessage('You cannot block players with a higher role level than you', 'color-redA'); | |||
return; | |||
} | |||
this.blockedPlayers.push(target); | |||
this.sendMessage(`Successfully blocked ${target}`, 'color-yellowB'); | |||
this.updateMainThread({ | |||
blockedPlayers: this.blockedPlayers | |||
}); | |||
this.obj.socket.emit('event', { | |||
event: 'onGetBlockedPlayers', | |||
data: this.blockedPlayers | |||
}); | |||
}, | |||
unblock: function (target) { | |||
if (!this.blockedPlayers.includes(target)) { | |||
this.sendMessage('That player is not blocked', 'color-redA'); | |||
return; | |||
} | |||
this.blockedPlayers.spliceWhere(f => f === target); | |||
this.sendMessage(`Successfully unblocked ${target}`, 'color-yellowB'); | |||
this.updateMainThread({ | |||
blockedPlayers: this.blockedPlayers | |||
}); | |||
this.obj.socket.emit('event', { | |||
event: 'onGetBlockedPlayers', | |||
data: this.blockedPlayers | |||
}); | |||
}, | |||
isInChannel: function (character, channel) { | |||
return character.auth.customChannels.some(c => (c === channel)); | |||
}, | |||
@@ -521,15 +521,22 @@ module.exports = { | |||
}); | |||
}, | |||
onCheckCharExists: function (msg, item, res) { | |||
onCheckCharExists: async function (msg, item, res) { | |||
if (!res) { | |||
this.resolveCallback(msg, 'Recipient does not exist'); | |||
return; | |||
} else if (!this.findItem(msg.itemId)) | |||
return; | |||
this.obj.instance.mail.sendMail(msg.recipient, [extend({}, item)]); | |||
let blocked = false; | |||
if (res.components) { | |||
let social = res.components.find(f => f.type === 'social'); | |||
if (!social.blockedPlayers && social.blockedPlayers.includes(this.obj.name)) | |||
blocked = true; | |||
} | |||
if (!blocked) | |||
this.obj.instance.mail.sendMail(msg.recipient, [extend({}, item)]); | |||
this.destroyItem(item.id); | |||
this.resolveCallback(msg); | |||
@@ -9,6 +9,7 @@ module.exports = { | |||
party: null, | |||
customChannels: null, | |||
blockedPlayers: [], | |||
messageHistory: [], | |||
@@ -23,6 +24,7 @@ module.exports = { | |||
type: 'social', | |||
party: this.party, | |||
customChannels: self ? this.customChannels : null, | |||
blockedPlayers: self ? this.blockedPlayers : null, | |||
muted: this.muted | |||
}; | |||
}, | |||
@@ -31,6 +33,7 @@ module.exports = { | |||
return { | |||
type: 'social', | |||
customChannels: this.customChannels, | |||
blockedPlayers: this.blockedPlayers, | |||
muted: this.muted | |||
}; | |||
}, | |||
@@ -288,19 +291,19 @@ module.exports = { | |||
if (!this.party) { | |||
this.isPartyLeader = true; | |||
this.party = [this.obj.id]; | |||
this.updatePartyOnThread(); | |||
this.updateMainThread('party', this.party); | |||
} | |||
// Only add if not yet in party | |||
if (!this.party.find(id => (id === sourceId))) | |||
this.party.push(sourceId); | |||
this.updatePartyOnThread(); | |||
this.updateMainThread('party', this.party); | |||
this.party.forEach(function (p) { | |||
let player = cons.players.find(c => c.id === p); | |||
player.social.party = this.party; | |||
player.social.updatePartyOnThread(); | |||
player.social.updateMainThread('party', player.social.party); | |||
let returnMsg = source.name + ' has joined the party'; | |||
if (p === sourceId) | |||
@@ -345,7 +348,7 @@ module.exports = { | |||
player.social.isPartyLeader = false; | |||
player.social.party = null; | |||
player.social.updatePartyOnThread(); | |||
player.social.updateMainThread('party', player.social.party); | |||
party = null; | |||
} | |||
@@ -389,7 +392,7 @@ module.exports = { | |||
} | |||
this.party = null; | |||
this.updatePartyOnThread(); | |||
this.updateMainThread('party', this.party); | |||
}, | |||
//Gets called on the player that requested the removal | |||
@@ -430,22 +433,22 @@ module.exports = { | |||
target.social.party = null; | |||
target.social.isPartyLeader = false; | |||
target.social.updatePartyOnThread(); | |||
target.social.updateMainThread('party', target.social.party); | |||
if (this.party.length === 1) { | |||
this.party = null; | |||
this.isPartyLeader = null; | |||
this.updatePartyOnThread(); | |||
this.updateMainThread('party', this.party); | |||
this.sendMessage('your party has been disbanded', 'color-yellowB'); | |||
} | |||
}, | |||
updatePartyOnThread: function () { | |||
updateMainThread: function (property, value) { | |||
atlas.updateObject(this.obj, { | |||
components: [{ | |||
type: 'social', | |||
party: this.party | |||
[property]: value | |||
}] | |||
}); | |||
} | |||