forked from ChomeNS/chomens-bot-java
some stuff about the command suggestions
This commit is contained in:
parent
c7ee378b46
commit
16c79115ee
2 changed files with 20 additions and 7 deletions
|
@ -19,6 +19,7 @@ import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
|||
import land.chipmunk.chayapak.chomens_bot.util.IllegalCharactersUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
|
@ -84,8 +85,17 @@ public class ChatPlugin extends Bot.Listener {
|
|||
if (playerMessage != null) break;
|
||||
}
|
||||
|
||||
boolean isCommandSuggestions = false;
|
||||
try {
|
||||
final String id = ((TextComponent) component).content();
|
||||
|
||||
if (id.equals(bot.commandSuggestion.id)) isCommandSuggestions = true;
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
for (Listener listener : listeners) {
|
||||
listener.systemMessageReceived(component);
|
||||
if (!isCommandSuggestions) listener.systemMessageReceived(component);
|
||||
listener.systemMessageReceived(component, isCommandSuggestions);
|
||||
|
||||
if (playerMessage != null) listener.playerMessageReceived(playerMessage);
|
||||
}
|
||||
}
|
||||
|
@ -316,5 +326,6 @@ public class ChatPlugin extends Bot.Listener {
|
|||
public static class Listener {
|
||||
public void playerMessageReceived (PlayerMessage message) {}
|
||||
public void systemMessageReceived (Component component) {}
|
||||
public void systemMessageReceived (Component component, boolean isCommandSuggestions) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,10 @@ public class CommandSuggestionPlugin extends ChatPlugin.Listener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void systemMessageReceived(Component component) {
|
||||
public void systemMessageReceived(Component component, boolean isCommandSuggestions) {
|
||||
if (!isCommandSuggestions) return;
|
||||
|
||||
try {
|
||||
final String tag = ((TextComponent) component).content();
|
||||
|
||||
if (!tag.equals(id)) return;
|
||||
|
||||
final List<Component> children = component.children();
|
||||
|
||||
if (children.size() != 1) return;
|
||||
|
@ -36,7 +34,11 @@ public class CommandSuggestionPlugin extends ChatPlugin.Listener {
|
|||
output.add(Component.text(id));
|
||||
|
||||
for (Command command : bot.commandHandler.commands) {
|
||||
output.add(Component.text(command.name));
|
||||
output.add(
|
||||
Component
|
||||
.text(command.name)
|
||||
.append(Component.text(command.trustLevel.name()))
|
||||
);
|
||||
}
|
||||
|
||||
bot.chat.tellraw(Component.join(JoinConfiguration.noSeparators(), output), player);
|
||||
|
|
Loading…
Reference in a new issue