fix: use UUID for clearchat name announcing

refactor: CommandSpyPlugin
This commit is contained in:
ChomeNS
2025-06-16 18:04:47 +07:00
parent 0960e8e834
commit c4e7c9e799
2 changed files with 17 additions and 17 deletions

View File

@@ -19,16 +19,19 @@ public class ClearChatNameAnnouncerPlugin implements Listener {
@Override
public void onCommandSpyMessageReceived (final PlayerEntry sender, final String command) {
if (!bot.config.announceClearChatUsername) return;
if (
command.equals("/clearchat") ||
command.equals("/cc") ||
command.equals("/extras:clearchat") ||
command.equals("/extras:cc")
command.equals("/clearchat")
|| command.equals("/cc")
|| command.equals("/extras:clearchat")
|| command.equals("/extras:cc")
) {
bot.chat.tellraw(
Component.translatable("%s cleared the chat")
.arguments(Component.selector(sender.profile.getName()))
.color(NamedTextColor.DARK_GREEN)
Component.translatable(
"%s cleared the chat", NamedTextColor.DARK_GREEN,
Component.selector(sender.profile.getIdAsString())
)
);
}
}

View File

@@ -24,21 +24,18 @@ public class CommandSpyPlugin implements Listener {
final List<Component> children = component.children();
if (
!(component instanceof final TextComponent textComponent) ||
children.size() != 2 ||
textComponent.style().isEmpty() ||
(
textComponent.color() != NamedTextColor.AQUA &&
textComponent.color() != NamedTextColor.YELLOW
) ||
!(children.getFirst() instanceof TextComponent) ||
!(children.getLast() instanceof TextComponent)
!(component instanceof final TextComponent textComponent)
|| children.size() != 2
|| textComponent.style().isEmpty()
|| (textComponent.color() != NamedTextColor.AQUA && textComponent.color() != NamedTextColor.YELLOW)
|| !(children.getFirst() instanceof TextComponent)
|| !(children.getLast() instanceof TextComponent)
) return true;
final String username = textComponent.content();
final String command = ComponentUtilities.stringify(children.getLast());
final PlayerEntry sender = bot.players.getEntry(username);
final PlayerEntry sender = bot.players.getEntry(username, false, false);
if (sender == null) return true;