fix player remove + use bot.players in *list

This commit is contained in:
ChomeNS 2022-10-13 15:35:28 +07:00
parent c1ae25270a
commit de7904896f
3 changed files with 10 additions and 14 deletions

View file

@ -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')

View file

@ -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'));

View file

@ -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);