MutablePlayerListEntry -> PlayerEntry + lazy fix
This commit is contained in:
parent
c90597003d
commit
2411b97ea0
25 changed files with 97 additions and 96 deletions
|
@ -32,11 +32,12 @@ repositories {
|
|||
maven {
|
||||
url = uri('https://repo.maven.apache.org/maven2/')
|
||||
}
|
||||
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.steveice10:mcprotocollib:1.20-1-SNAPSHOT'
|
||||
implementation 'com.github.steveice10:mcauthlib:1.5-SNAPSHOT'
|
||||
implementation 'net.kyori:adventure-text-serializer-ansi:4.14.0'
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
implementation 'com.google.guava:guava:31.1-jre'
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.github.steveice10.mc.auth.data.GameProfile;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.ChatParser;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -37,8 +37,8 @@ public class CreayunChatParser implements ChatParser {
|
|||
final String displayName = matcher.group(1);
|
||||
final String contents = matcher.group(2);
|
||||
|
||||
MutablePlayerListEntry sender = bot.players.getEntry(displayName);
|
||||
if (sender == null) sender = new MutablePlayerListEntry(new GameProfile(new UUID(0L, 0L), displayName), GameMode.SURVIVAL, 0, Component.text(displayName), 0L, null, new byte[0], true);
|
||||
PlayerEntry sender = bot.players.getEntry(displayName);
|
||||
if (sender == null) sender = new PlayerEntry(new GameProfile(new UUID(0L, 0L), displayName), GameMode.SURVIVAL, 0, Component.text(displayName), 0L, null, new byte[0], true);
|
||||
|
||||
return new PlayerMessage(sender, Component.text(displayName), Component.text(contents));
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.github.steveice10.mc.auth.data.GameProfile;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.ChatParser;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
|
@ -43,9 +43,9 @@ public class KaboomChatParser implements ChatParser {
|
|||
return null;
|
||||
}
|
||||
|
||||
MutablePlayerListEntry sender = bot.players.getEntry(Component.empty().append(prefix).append(displayName));
|
||||
PlayerEntry sender = bot.players.getEntry(Component.empty().append(prefix).append(displayName));
|
||||
if (sender == null) sender = bot.players.getEntry(prefix.append(displayName)); // old
|
||||
if (sender == null) sender = new MutablePlayerListEntry(new GameProfile(new UUID(0L, 0L), null), GameMode.SURVIVAL, 0, displayName, 0L, null, new byte[0], true); // new and currently using
|
||||
if (sender == null) sender = new PlayerEntry(new GameProfile(new UUID(0L, 0L), null), GameMode.SURVIVAL, 0, displayName, 0L, null, new byte[0], true); // new and currently using
|
||||
|
||||
return new PlayerMessage(sender, displayName, contents);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package land.chipmunk.chayapak.chomens_bot.chatParsers;
|
|||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.ChatParser;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -41,7 +41,7 @@ public class MinecraftChatParser implements ChatParser {
|
|||
final Component senderComponent = args.get(0);
|
||||
final Component contents = args.get(1);
|
||||
|
||||
MutablePlayerListEntry sender;
|
||||
PlayerEntry sender;
|
||||
|
||||
final HoverEvent<?> hoverEvent = senderComponent.hoverEvent();
|
||||
if (hoverEvent != null && hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) {
|
||||
|
|
|
@ -2,7 +2,7 @@ package land.chipmunk.chayapak.chomens_bot.chatParsers;
|
|||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.ChatParser;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -34,7 +34,7 @@ public class U203aChatParser implements ChatParser {
|
|||
final Component senderComponent = args.get(1);
|
||||
final Component contents = args.get(2);
|
||||
|
||||
MutablePlayerListEntry sender;
|
||||
PlayerEntry sender;
|
||||
final HoverEvent<?> hoverEvent = senderComponent.hoverEvent();
|
||||
if (hoverEvent != null && hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) {
|
||||
HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity) hoverEvent.value();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.command;
|
||||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class CommandContext {
|
||||
|
@ -9,14 +9,14 @@ public class CommandContext {
|
|||
|
||||
public final String prefix;
|
||||
|
||||
public final MutablePlayerListEntry sender;
|
||||
public final PlayerEntry sender;
|
||||
|
||||
public final String hash;
|
||||
public final String ownerHash;
|
||||
|
||||
public final boolean inGame;
|
||||
|
||||
public CommandContext(Bot bot, String prefix, MutablePlayerListEntry sender, String hash, String ownerHash, boolean inGame) {
|
||||
public CommandContext(Bot bot, String prefix, PlayerEntry sender, String hash, String ownerHash, boolean inGame) {
|
||||
this.bot = bot;
|
||||
this.prefix = prefix;
|
||||
this.sender = sender;
|
||||
|
|
|
@ -2,7 +2,7 @@ package land.chipmunk.chayapak.chomens_bot.command;
|
|||
|
||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.CodeBlockUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
|
@ -23,7 +23,7 @@ public class DiscordCommandContext extends CommandContext {
|
|||
super(
|
||||
bot,
|
||||
prefix,
|
||||
new MutablePlayerListEntry(
|
||||
new PlayerEntry(
|
||||
new GameProfile(
|
||||
UUID.nameUUIDFromBytes(("OfflinePlayer:" + event.getAuthor().getName()).getBytes()),
|
||||
event.getAuthor().getName()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.command;
|
||||
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
|
@ -11,7 +11,7 @@ public class PlayerCommandContext extends CommandContext {
|
|||
|
||||
private final Bot bot;
|
||||
|
||||
public PlayerCommandContext (Bot bot, String playerName, String prefix, String selector, MutablePlayerListEntry sender, String hash, String ownerHash) {
|
||||
public PlayerCommandContext (Bot bot, String playerName, String prefix, String selector, PlayerEntry sender, String hash, String ownerHash) {
|
||||
super(bot, prefix, sender, hash, ownerHash, true);
|
||||
this.bot = bot;
|
||||
this.playerName = playerName;
|
||||
|
|
|
@ -2,7 +2,7 @@ package land.chipmunk.chayapak.chomens_bot.commands;
|
|||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.TrustLevel;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.Command;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -26,7 +26,7 @@ public class ClearChatCommand extends Command {
|
|||
final Bot bot = context.bot;
|
||||
|
||||
if (args.length > 0) {
|
||||
final MutablePlayerListEntry entry = bot.players.getEntry(String.join(" ", args));
|
||||
final PlayerEntry entry = bot.players.getEntry(String.join(" ", args));
|
||||
|
||||
if (entry == null) return Component.text("Invalid player name").color(NamedTextColor.RED);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import land.chipmunk.chayapak.chomens_bot.Bot;
|
|||
import land.chipmunk.chayapak.chomens_bot.command.Command;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.TrustLevel;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
@ -26,7 +26,7 @@ public class KickCommand extends Command {
|
|||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot;
|
||||
|
||||
final MutablePlayerListEntry entry = bot.players.getEntry(String.join(" ", args));
|
||||
final PlayerEntry entry = bot.players.getEntry(String.join(" ", args));
|
||||
|
||||
if (entry == null) return Component.text("Invalid player name").color(NamedTextColor.RED);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package land.chipmunk.chayapak.chomens_bot.commands;
|
|||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.TrustLevel;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.Command;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||
|
@ -30,11 +30,11 @@ public class ListCommand extends Command {
|
|||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot;
|
||||
|
||||
final List<MutablePlayerListEntry> list = bot.players.list;
|
||||
final List<PlayerEntry> list = bot.players.list;
|
||||
|
||||
final List<Component> playersComponent = new ArrayList<>();
|
||||
|
||||
for (MutablePlayerListEntry entry : list) {
|
||||
for (PlayerEntry entry : list) {
|
||||
playersComponent.add(
|
||||
Component.translatable(
|
||||
"%s › %s",
|
||||
|
|
|
@ -9,7 +9,7 @@ import land.chipmunk.chayapak.chomens_bot.command.Command;
|
|||
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.TrustLevel;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.Mail;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.plugins.MailPlugin;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
|
@ -47,7 +47,7 @@ public class MailCommand extends Command {
|
|||
|
||||
final Bot bot = context.bot;
|
||||
|
||||
final MutablePlayerListEntry sender = context.sender;
|
||||
final PlayerEntry sender = context.sender;
|
||||
|
||||
final Gson gson = new Gson();
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import land.chipmunk.chayapak.chomens_bot.Bot;
|
|||
import land.chipmunk.chayapak.chomens_bot.command.Command;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.TrustLevel;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.MathUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -25,7 +25,7 @@ public class RandomTeleportCommand extends Command {
|
|||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot;
|
||||
|
||||
final MutablePlayerListEntry sender = context.sender;
|
||||
final PlayerEntry sender = context.sender;
|
||||
|
||||
final int positionX = MathUtilities.between(-1_000_000, 1_000_000);
|
||||
final int positionZ = MathUtilities.between(-1_000_000, 1_000_000);
|
||||
|
|
|
@ -4,7 +4,7 @@ import land.chipmunk.chayapak.chomens_bot.Bot;
|
|||
import land.chipmunk.chayapak.chomens_bot.command.Command;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.TrustLevel;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
@ -27,7 +27,7 @@ public class UUIDCommand extends Command {
|
|||
final Bot bot = context.bot;
|
||||
|
||||
if (args.length > 0) {
|
||||
final MutablePlayerListEntry entry = bot.players.getEntry(String.join(" ", args));
|
||||
final PlayerEntry entry = bot.players.getEntry(String.join(" ", args));
|
||||
|
||||
if (entry == null) return Component.text("Invalid player name").color(NamedTextColor.RED);
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class UUIDCommand extends Command {
|
|||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid))
|
||||
).color(NamedTextColor.GREEN);
|
||||
} else {
|
||||
final MutablePlayerListEntry entry = context.sender;
|
||||
final PlayerEntry entry = context.sender;
|
||||
|
||||
final String uuid = entry.profile.getIdAsString();
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.kyori.adventure.text.Component;
|
|||
|
||||
import java.security.PublicKey;
|
||||
|
||||
public class MutablePlayerListEntry {
|
||||
public class PlayerEntry {
|
||||
public final GameProfile profile;
|
||||
public GameMode gamemode;
|
||||
public int latency;
|
||||
|
@ -17,7 +17,7 @@ public class MutablePlayerListEntry {
|
|||
public final byte[] keySignature;
|
||||
public boolean listed;
|
||||
|
||||
public MutablePlayerListEntry (
|
||||
public PlayerEntry(
|
||||
GameProfile profile,
|
||||
GameMode gamemode,
|
||||
int latency,
|
||||
|
@ -37,7 +37,7 @@ public class MutablePlayerListEntry {
|
|||
this.listed = listed;
|
||||
}
|
||||
|
||||
public MutablePlayerListEntry (PlayerListEntry entry) {
|
||||
public PlayerEntry(PlayerListEntry entry) {
|
||||
this(entry.getProfile(), entry.getGameMode(), entry.getLatency(), entry.getDisplayName(), entry.getExpiresAt(), entry.getPublicKey(), entry.getKeySignature(), entry.isListed());
|
||||
}
|
||||
}
|
|
@ -3,12 +3,12 @@ package land.chipmunk.chayapak.chomens_bot.data.chat;
|
|||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class PlayerMessage {
|
||||
public final MutablePlayerListEntry sender;
|
||||
public final PlayerEntry sender;
|
||||
public final Component displayName;
|
||||
public final Component contents;
|
||||
|
||||
public PlayerMessage (
|
||||
MutablePlayerListEntry sender,
|
||||
PlayerEntry sender,
|
||||
Component displayName,
|
||||
Component contents
|
||||
) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.github.steveice10.packetlib.packet.Packet;
|
|||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.BossBar;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.BotBossBar;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
|
|||
|
||||
bot.players.addListener(new PlayersPlugin.Listener() {
|
||||
@Override
|
||||
public void playerJoined(MutablePlayerListEntry target) {
|
||||
public void playerJoined(PlayerEntry target) {
|
||||
BossbarManagerPlugin.this.playerJoined();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.plugins;
|
||||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.PlayerCommandContext;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
|
@ -26,7 +26,7 @@ public class ChatCommandHandlerPlugin extends ChatPlugin.Listener {
|
|||
|
||||
bot.commandSpy.addListener(new CommandSpyPlugin.Listener() {
|
||||
@Override
|
||||
public void commandReceived(MutablePlayerListEntry sender, String command) {
|
||||
public void commandReceived(PlayerEntry sender, String command) {
|
||||
ChatCommandHandlerPlugin.this.commandSpyMessageReceived(sender, command);
|
||||
}
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ public class ChatCommandHandlerPlugin extends ChatPlugin.Listener {
|
|||
if (output != null) context.sendOutput(output);
|
||||
}
|
||||
|
||||
public void commandSpyMessageReceived (MutablePlayerListEntry sender, String command) {
|
||||
public void commandSpyMessageReceived (PlayerEntry sender, String command) {
|
||||
try {
|
||||
if (sender.profile.getId().equals(bot.profile.getId())) return;
|
||||
} catch (Exception ignored) {
|
||||
|
|
|
@ -13,7 +13,7 @@ import land.chipmunk.chayapak.chomens_bot.chatParsers.KaboomChatParser;
|
|||
import land.chipmunk.chayapak.chomens_bot.chatParsers.MinecraftChatParser;
|
||||
import land.chipmunk.chayapak.chomens_bot.chatParsers.U203aChatParser;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.ChatParser;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.IllegalCharactersUtilities;
|
||||
|
@ -111,7 +111,7 @@ public class ChatPlugin extends Bot.Listener {
|
|||
public void packetReceived (ClientboundPlayerChatPacket packet) {
|
||||
final UUID senderUUID = packet.getSender();
|
||||
|
||||
final MutablePlayerListEntry entry = bot.players.getEntry(senderUUID);
|
||||
final PlayerEntry entry = bot.players.getEntry(senderUUID);
|
||||
|
||||
if (entry == null) return;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.plugins;
|
||||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
|
@ -44,7 +44,7 @@ public class CommandSpyPlugin extends ChatPlugin.Listener {
|
|||
final String username = textComponent.content();
|
||||
final String command = ComponentUtilities.stringify(children.get(1));
|
||||
|
||||
final MutablePlayerListEntry sender = bot.players.getEntry(username);
|
||||
final PlayerEntry sender = bot.players.getEntry(username);
|
||||
|
||||
if (sender == null) return;
|
||||
|
||||
|
@ -55,6 +55,6 @@ public class CommandSpyPlugin extends ChatPlugin.Listener {
|
|||
public void addListener (Listener listener) { listeners.add(listener); }
|
||||
|
||||
public static class Listener {
|
||||
public void commandReceived (MutablePlayerListEntry sender, String command) {}
|
||||
public void commandReceived (PlayerEntry sender, String command) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.google.gson.JsonArray;
|
|||
import com.google.gson.JsonElement;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.FilteredPlayer;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.PersistentDataUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities;
|
||||
|
@ -42,7 +42,7 @@ public class FilterPlugin extends PlayersPlugin.Listener {
|
|||
|
||||
bot.commandSpy.addListener(new CommandSpyPlugin.Listener() {
|
||||
@Override
|
||||
public void commandReceived(MutablePlayerListEntry sender, String command) {
|
||||
public void commandReceived(PlayerEntry sender, String command) {
|
||||
FilterPlugin.this.commandSpyMessageReceived(sender);
|
||||
}
|
||||
});
|
||||
|
@ -94,7 +94,7 @@ public class FilterPlugin extends PlayersPlugin.Listener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void playerJoined (MutablePlayerListEntry target) {
|
||||
public void playerJoined (PlayerEntry target) {
|
||||
final FilteredPlayer player = getPlayer(target.profile.getName());
|
||||
|
||||
if (player == null) return;
|
||||
|
@ -105,7 +105,7 @@ public class FilterPlugin extends PlayersPlugin.Listener {
|
|||
bot.exploits.kick(target.profile.getId());
|
||||
}
|
||||
|
||||
public void commandSpyMessageReceived (MutablePlayerListEntry sender) {
|
||||
public void commandSpyMessageReceived (PlayerEntry sender) {
|
||||
final FilteredPlayer player = getPlayer(sender.profile.getName());
|
||||
|
||||
if (player == null) return;
|
||||
|
@ -124,16 +124,16 @@ public class FilterPlugin extends PlayersPlugin.Listener {
|
|||
mute(message.sender);
|
||||
}
|
||||
|
||||
private void mute (MutablePlayerListEntry target) {
|
||||
private void mute (PlayerEntry target) {
|
||||
bot.core.run("essentials:mute " + target.profile.getIdAsString() + " 10y");
|
||||
}
|
||||
|
||||
private void deOp (MutablePlayerListEntry target) {
|
||||
private void deOp (PlayerEntry target) {
|
||||
bot.core.run("minecraft:execute run deop " + UUIDUtilities.selector(target.profile.getId()));
|
||||
}
|
||||
|
||||
public void kick () {
|
||||
for (MutablePlayerListEntry target : bot.players.list) {
|
||||
for (PlayerEntry target : bot.players.list) {
|
||||
final FilteredPlayer player = getPlayer(target.profile.getName());
|
||||
|
||||
if (player == null) continue;
|
||||
|
@ -147,7 +147,7 @@ public class FilterPlugin extends PlayersPlugin.Listener {
|
|||
|
||||
PersistentDataUtilities.put("filters", filteredPlayers);
|
||||
|
||||
final MutablePlayerListEntry target = bot.players.getEntry(playerName); // fix not working for regex and ignorecase
|
||||
final PlayerEntry target = bot.players.getEntry(playerName); // fix not working for regex and ignorecase
|
||||
|
||||
if (target == null) return;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.google.gson.JsonArray;
|
|||
import com.google.gson.JsonElement;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.Mail;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.PersistentDataUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -34,7 +34,7 @@ public class MailPlugin extends PlayersPlugin.Listener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void playerJoined(MutablePlayerListEntry target) {
|
||||
public void playerJoined(PlayerEntry target) {
|
||||
final String name = target.profile.getName();
|
||||
|
||||
final List<String> sendTos = new ArrayList<>(); // confusing name,.,.
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
|||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.google.gson.JsonObject;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.PersistentDataUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
|
@ -23,7 +23,7 @@ import java.util.UUID;
|
|||
public class PlayersPlugin extends Bot.Listener {
|
||||
private final Bot bot;
|
||||
|
||||
public final List<MutablePlayerListEntry> list = new ArrayList<>();
|
||||
public final List<PlayerEntry> list = new ArrayList<>();
|
||||
|
||||
private final List<Listener> listeners = new ArrayList<>();
|
||||
|
||||
|
@ -69,8 +69,8 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
}
|
||||
}
|
||||
|
||||
public final MutablePlayerListEntry getEntry (UUID uuid) {
|
||||
for (MutablePlayerListEntry candidate : list) {
|
||||
public final PlayerEntry getEntry (UUID uuid) {
|
||||
for (PlayerEntry candidate : list) {
|
||||
if (candidate.profile.getId().equals(uuid)) {
|
||||
return candidate;
|
||||
}
|
||||
|
@ -79,8 +79,8 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
return null;
|
||||
}
|
||||
|
||||
public final MutablePlayerListEntry getEntry (String username) {
|
||||
for (MutablePlayerListEntry candidate : list) {
|
||||
public final PlayerEntry getEntry (String username) {
|
||||
for (PlayerEntry candidate : list) {
|
||||
if (getName(candidate).equals(username)) {
|
||||
return candidate;
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
return null;
|
||||
}
|
||||
|
||||
public final MutablePlayerListEntry getEntry (Component displayName) {
|
||||
for (MutablePlayerListEntry candidate : list) {
|
||||
public final PlayerEntry getEntry (Component displayName) {
|
||||
for (PlayerEntry candidate : list) {
|
||||
if (candidate.displayName != null && candidate.displayName.equals(displayName)) {
|
||||
return candidate;
|
||||
}
|
||||
|
@ -99,35 +99,35 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
return null;
|
||||
}
|
||||
|
||||
public MutablePlayerListEntry getBotEntry () { return getEntry(bot.username); }
|
||||
public PlayerEntry getBotEntry () { return getEntry(bot.username); }
|
||||
|
||||
private MutablePlayerListEntry getEntry (PlayerListEntry other) {
|
||||
private PlayerEntry getEntry (PlayerListEntry other) {
|
||||
return getEntry(other.getProfile().getId());
|
||||
}
|
||||
|
||||
private void initializeChat (PlayerListEntry newEntry) {
|
||||
final MutablePlayerListEntry target = getEntry(newEntry);
|
||||
final PlayerEntry target = getEntry(newEntry);
|
||||
if (target == null) return;
|
||||
|
||||
target.publicKey = newEntry.getPublicKey();
|
||||
}
|
||||
|
||||
private void updateListed (PlayerListEntry newEntry) {
|
||||
final MutablePlayerListEntry target = getEntry(newEntry);
|
||||
final PlayerEntry target = getEntry(newEntry);
|
||||
if (target == null) return;
|
||||
|
||||
target.listed = newEntry.isListed();
|
||||
}
|
||||
|
||||
private String getName(MutablePlayerListEntry target) {
|
||||
private String getName(PlayerEntry target) {
|
||||
return bot.options.creayun ? target.profile.getName().replaceAll("§.", "") : target.profile.getName();
|
||||
}
|
||||
|
||||
private void addPlayer (PlayerListEntry newEntry) {
|
||||
final MutablePlayerListEntry duplicate = getEntry(newEntry);
|
||||
final PlayerEntry duplicate = getEntry(newEntry);
|
||||
if (duplicate != null) list.remove(duplicate);
|
||||
|
||||
final MutablePlayerListEntry target = new MutablePlayerListEntry(newEntry);
|
||||
final PlayerEntry target = new PlayerEntry(newEntry);
|
||||
|
||||
list.add(target);
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
private void updateGamemode (PlayerListEntry newEntry) {
|
||||
final MutablePlayerListEntry target = getEntry(newEntry);
|
||||
final PlayerEntry target = getEntry(newEntry);
|
||||
if (target == null) return;
|
||||
|
||||
final GameMode gameMode = newEntry.getGameMode();
|
||||
|
@ -159,7 +159,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
private void updateLatency (PlayerListEntry newEntry) {
|
||||
final MutablePlayerListEntry target = getEntry(newEntry);
|
||||
final PlayerEntry target = getEntry(newEntry);
|
||||
if (target == null) return;
|
||||
|
||||
final int ping = newEntry.getLatency();
|
||||
|
@ -170,7 +170,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
private void updateDisplayName (PlayerListEntry newEntry) {
|
||||
final MutablePlayerListEntry target = getEntry(newEntry);
|
||||
final PlayerEntry target = getEntry(newEntry);
|
||||
if (target == null) return;
|
||||
|
||||
final Component displayName = newEntry.getDisplayName();
|
||||
|
@ -181,7 +181,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
private void removePlayer (UUID uuid) {
|
||||
final MutablePlayerListEntry target = getEntry(uuid);
|
||||
final PlayerEntry target = getEntry(uuid);
|
||||
if (target == null) return;
|
||||
|
||||
bot.tabComplete.tabComplete("/minecraft:scoreboard players add ").thenApply(packet -> {
|
||||
|
@ -227,12 +227,12 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
public void addListener (Listener listener) { listeners.add(listener); }
|
||||
|
||||
public static class Listener {
|
||||
public void playerJoined (MutablePlayerListEntry target) {}
|
||||
public void playerUnVanished (MutablePlayerListEntry target) {}
|
||||
public void playerGameModeUpdated (MutablePlayerListEntry target, GameMode gameMode) {}
|
||||
public void playerLatencyUpdated (MutablePlayerListEntry target, int ping) {}
|
||||
public void playerDisplayNameUpdated (MutablePlayerListEntry target, Component displayName) {}
|
||||
public void playerLeft (MutablePlayerListEntry target) {}
|
||||
public void playerVanished (MutablePlayerListEntry target) {}
|
||||
public void playerJoined (PlayerEntry target) {}
|
||||
public void playerUnVanished (PlayerEntry target) {}
|
||||
public void playerGameModeUpdated (PlayerEntry target, GameMode gameMode) {}
|
||||
public void playerLatencyUpdated (PlayerEntry target, int ping) {}
|
||||
public void playerDisplayNameUpdated (PlayerEntry target, Component displayName) {}
|
||||
public void playerLeft (PlayerEntry target) {}
|
||||
public void playerVanished (PlayerEntry target) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.github.steveice10.packetlib.Session;
|
|||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.Rotation;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
|
||||
public Vector3i position = Vector3i.from(0, 0, 0);
|
||||
|
||||
private final Map<Integer, MutablePlayerListEntry> entityIdMap = new HashMap<>();
|
||||
private final Map<Integer, PlayerEntry> entityIdMap = new HashMap<>();
|
||||
private final Map<Integer, Vector3f> positionMap = new HashMap<>();
|
||||
private final Map<Integer, Rotation> rotationMap = new HashMap<>();
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
public void packetReceived (ClientboundAddPlayerPacket packet) {
|
||||
final MutablePlayerListEntry entry = bot.players.getEntry(packet.getUuid());
|
||||
final PlayerEntry entry = bot.players.getEntry(packet.getUuid());
|
||||
|
||||
if (entry == null) return;
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
public void packetReceived (ClientboundMoveEntityRotPacket packet) {
|
||||
final MutablePlayerListEntry player = entityIdMap.get(packet.getEntityId());
|
||||
final PlayerEntry player = entityIdMap.get(packet.getEntityId());
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
public void packetReceived (ClientboundMoveEntityPosPacket packet) {
|
||||
final MutablePlayerListEntry player = entityIdMap.get(packet.getEntityId());
|
||||
final PlayerEntry player = entityIdMap.get(packet.getEntityId());
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
public void packetReceived (ClientboundMoveEntityPosRotPacket packet) {
|
||||
final MutablePlayerListEntry player = entityIdMap.get(packet.getEntityId());
|
||||
final PlayerEntry player = entityIdMap.get(packet.getEntityId());
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
|
||||
public Vector3f getPlayerPosition (String playerName) {
|
||||
int entityId = -1;
|
||||
for (Map.Entry<Integer, MutablePlayerListEntry> entry : entityIdMap.entrySet()) {
|
||||
for (Map.Entry<Integer, PlayerEntry> entry : entityIdMap.entrySet()) {
|
||||
if (entry.getValue().profile.getName().equals(playerName)) entityId = entry.getKey();
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
|
||||
public Rotation getPlayerRotation (String playerName) {
|
||||
int entityId = -1;
|
||||
for (Map.Entry<Integer, MutablePlayerListEntry> entry : entityIdMap.entrySet()) {
|
||||
for (Map.Entry<Integer, PlayerEntry> entry : entityIdMap.entrySet()) {
|
||||
if (entry.getValue().profile.getName().equals(playerName)) entityId = entry.getKey();
|
||||
}
|
||||
|
||||
|
@ -168,6 +168,6 @@ public class PositionPlugin extends Bot.Listener {
|
|||
|
||||
public static class Listener {
|
||||
public void positionChange (Vector3i position) {}
|
||||
public void playerMoved (MutablePlayerListEntry player, Vector3f position, Rotation rotation) {}
|
||||
public void playerMoved (PlayerEntry player, Vector3f position, Rotation rotation) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.plugins;
|
||||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
@ -39,7 +39,7 @@ public class TrustedPlugin extends PlayersPlugin.Listener {
|
|||
bot.logger.custom(Component.text("Trusted Broadcast").color(NamedTextColor.AQUA), component);
|
||||
|
||||
for (String player : list) {
|
||||
final MutablePlayerListEntry entry = bot.players.getEntry(player);
|
||||
final PlayerEntry entry = bot.players.getEntry(player);
|
||||
|
||||
if (entry == null) continue;
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class TrustedPlugin extends PlayersPlugin.Listener {
|
|||
public void broadcast (Component message) { broadcast(message, null); }
|
||||
|
||||
@Override
|
||||
public void playerJoined (MutablePlayerListEntry target) {
|
||||
public void playerJoined (PlayerEntry target) {
|
||||
if (!list.contains(target.profile.getName())) return;
|
||||
|
||||
// based (VERY)
|
||||
|
@ -95,7 +95,7 @@ public class TrustedPlugin extends PlayersPlugin.Listener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void playerLeft (MutablePlayerListEntry target) {
|
||||
public void playerLeft (PlayerEntry target) {
|
||||
if (!list.contains(target.profile.getName())) return;
|
||||
|
||||
broadcast(
|
||||
|
|
Loading…
Reference in a new issue