diff --git a/plugins/!chat.js b/plugins/!chat.js index 381e6a1..ebc7d7f 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -20,8 +20,7 @@ module.exports={ const json=parse1204(data.message); const parsed=parse(json)[1]; let split=parsed.split(": "); - const beforeColon = split.splice(0,1)[0].split(" "); - const chatName = beforeColon[beforeColon.length-1] + const chatName = split.splice(0,1)[0] const username=b.findRealName(chatName); const uuid=b.findUUID(username) b.emit("chat",{json,type:"profileless",uuid,message: split.join(": "), username}) @@ -40,8 +39,7 @@ module.exports={ const json=parse1204(data.content); const parsed=parse(json)[1]; let split=parsed.split(": "); - const beforeColon = split.splice(0,1)[0].split(" "); - const chatName = beforeColon[beforeColon.length-1] + const chatName = split.splice(0,1)[0] const username=b.findRealName(chatName); const uuid=b.findUUID(username) b.emit("chat",{json,type:"system",uuid, message: split.join(": "), username}) @@ -52,23 +50,21 @@ module.exports={ const json=parse1204(data.message); const parsed=parse(json)[1]; let split=parsed.split(": "); - const beforeColon = split.splice(0,1)[0].split(" "); - const chatName = beforeColon[beforeColon.length-1] + const chatName = split.splice(0,1)[0] const username=b.findRealName(chatName); const uuid=b.findUUID(username) b.emit("chat",{json,type:"legacy",uuid:data.uuid?data.uuid:uuid, message: split.join(": "), username}) }) b.on("chat",(data)=>{ const msg=parse(data.json); - console2.write(data.username+" ("+data.uuid+"): "+data.message) console2.write(`[${b.id}] [${data.type}] `+msg[0]) - let fullCommand = ""; - if(data.type=="player") fullCommand=data.message; + let fullCommand = data.message; + //console.log(name, fullCommand) for(const i in b.prefix){ if(fullCommand.startsWith(b.prefix[i])){ const command=fullCommand.slice(b.prefix[i].length); - b.runCommand("N/A",data.uuid,command,b.prefix[i]); + b.runCommand(data.username,data.uuid,command,b.prefix[i]); } } }) diff --git a/plugins/player.js b/plugins/player.js index bb32af9..8f308c9 100644 --- a/plugins/player.js +++ b/plugins/player.js @@ -1,11 +1,48 @@ +const parse = require("../util/chatparse.js") +const parse1204 = require("../util/chatparse_1204.js") module.exports={ load:()=>{ }, loadBot:(b)=>{ + b.players={}; + b._client.on("player_info",(data)=>{ + console.log + let buffer2={}; + for(const i in data.data){ + let uuid; + if(data.data[i].uuid){ + uuid=data.data[i].uuid + } else if(data.data[i].UUID){ + uuid=data.data[i].UUID + } + if(data.data[i].player && data.data[i].player.name!==undefined){ + buffer2[uuid]={realName: data.data[i].player.name, displayName: parse(parse1204(data.data[i].displayName))[1]} + } else if(data.data[i].name!==undefined){ + buffer2[uuid]={realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName))[1]} + } else if(data.data[i].displayName!==undefined){ + buffer2[uuid]={displayName: parse(parse1204(data.data[i].displayName))[1]} + } + } + for(const uuid in buffer2){ + if(!b.players[uuid]) b.players[uuid]={displayName:"",realName:""}; + if(buffer2[uuid].displayName) b.players[uuid].displayName=buffer2[uuid].displayName; + if(buffer2[uuid].realName) b.players[uuid].realName=buffer2[uuid].realName; + } + }) b.findUUID=(name)=>{ + for(const i in b.players){ + if(b.players[i].realName==name){ + return i; + } + } return "00000000-0000-0000-0000-000000000000" } b.findRealName=(name)=>{ + for(const i in b.players){ + if(b.players[i].displayName==name){ + return b.players[i].realName + } + } return "Stereo Madness" } }