From de7904896f6922723cc62c0e5c63e557d902e39a Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Thu, 13 Oct 2022 15:35:28 +0700 Subject: [PATCH] fix player remove + use bot.players in *list --- commands/list.js | 12 ++++++------ index.js | 4 ---- plugins/players.js | 8 ++++---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/commands/list.js b/commands/list.js index 976c6cd..6aa9ed4 100644 --- a/commands/list.js +++ b/commands/list.js @@ -11,9 +11,9 @@ module.exports = { try { bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'Players:', color: 'green'}])); await sleep(60); - for (const property of bot.tabcompleteplayers) { - if (property.match.startsWith('@')) continue; - bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: `${property.match}`, color: 'yellow'}, {text: ' › ', color: 'aqua'}, {text: `${bot.players.getPlayer(property.match).UUID}`, color: 'aqua'}])); + for (const property of bot.players.list) { + // if (property.match.startsWith('@')) continue; + bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: `${property.name}`, color: 'yellow'}, {text: ' › ', color: 'aqua'}, {text: `${property.UUID}`, color: 'aqua'}])); } } catch (e) { return; @@ -22,9 +22,9 @@ module.exports = { discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) { try { let players = ''; - for (const property of bot.tabcompleteplayers) { - if (property.match.startsWith('@')) continue; - players += `\`${property.match}\` › \`${bot.players.getPlayer(property.match).UUID}\`` + '\n'; + for (const property of bot.players.list) { + // if (property.match.startsWith('@')) continue; + players += `\`${property.name}\` › \`${property.UUID}\`` + '\n'; } const Embed = new MessageEmbed() .setColor('#FFFF00') diff --git a/index.js b/index.js index 7efe971..fbffaad 100644 --- a/index.js +++ b/index.js @@ -354,10 +354,6 @@ function main() { bot.getplayerusername[player.UUID] = player.name; }); - bot.on('player_removed', (player) => { - delete players[player.name]; - }); - bot._client.on('end', function(reason) { bot.emit('end', reason, 'end'); // onerror('end event: ' + util.inspect(reason).replaceAll('runner', 'chayapak1')); diff --git a/plugins/players.js b/plugins/players.js index 0ff27c2..6f7ac6a 100644 --- a/plugins/players.js +++ b/plugins/players.js @@ -107,8 +107,8 @@ function inject(bot) { }); function addPlayer(player, packet) { - if (bot.players.getPlayer(player)) bot.emit('player_unvanished', player, packet); - else bot.emit('player_added', player, packet); + // if (bot.players.getPlayer(player)) bot.emit('player_unvanished', player, packet); + /* else */bot.emit('player_added', player, packet); bot.players.addPlayer(player); } @@ -144,7 +144,7 @@ function inject(bot) { } async function removePlayer(player, packet) { - const fullPlayer = bot.players.getPlayer(player); + /* const fullPlayer = bot.players.getPlayer(player); const players = await bot.requester.getPlayerList(); @@ -152,7 +152,7 @@ function inject(bot) { bot.emit('player_vanished', player); return; - } + } */ bot.emit('player_removed', player, packet);