fix: use UUID for clearchat name announcing
refactor: CommandSpyPlugin
This commit is contained in:
@@ -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())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user