diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5f9d5cb3..0afb9512 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,9 +4,7 @@
-
-
-
+
@@ -97,13 +95,6 @@
1680245437032
-
- 1681806777109
-
-
-
- 1681806777109
-
1681882635433
@@ -440,7 +431,14 @@
1682644881919
-
+
+ 1682654933076
+
+
+
+ 1682654933076
+
+
@@ -455,7 +453,6 @@
-
@@ -480,7 +477,8 @@
-
+
+
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java
index a891c73f..eee46278 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java
@@ -63,6 +63,7 @@ public class Bot {
@Getter private MazePlugin maze;
@Getter private ExploitsPlugin exploits;
@Getter private FilterPlugin filter;
+ @Getter private CommandSuggestionPlugin commandSuggestion;
public Bot (Configuration.BotOption botOption, List bots, Configuration config) {
this.host = botOption.host;
@@ -105,6 +106,7 @@ public class Bot {
this.maze = new MazePlugin(this);
this.exploits = new ExploitsPlugin(this);
this.filter = new FilterPlugin(this);
+ this.commandSuggestion = new CommandSuggestionPlugin(this);
reconnect();
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSuggestionPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSuggestionPlugin.java
new file mode 100644
index 00000000..9ce68cd0
--- /dev/null
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSuggestionPlugin.java
@@ -0,0 +1,61 @@
+package land.chipmunk.chayapak.chomens_bot.plugins;
+
+import land.chipmunk.chayapak.chomens_bot.Bot;
+import land.chipmunk.chayapak.chomens_bot.command.Command;
+import lombok.Getter;
+import lombok.Setter;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.JoinConfiguration;
+import net.kyori.adventure.text.TextComponent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CommandSuggestionPlugin extends ChatPlugin.ChatListener {
+ private final Bot bot;
+
+ @Getter @Setter private String id = "chomens_bot_command_suggestion";
+
+ public CommandSuggestionPlugin (Bot bot) {
+ this.bot = bot;
+ bot.chat().addListener(this);
+ }
+
+ @Override
+ public void systemMessageReceived(Component component) {
+ try {
+ final String tag = ((TextComponent) component).content();
+
+ if (!tag.equals(id)) return;
+
+ final List children = component.children();
+
+ if (children.size() < 2) return;
+
+ final int transactionId = Integer.parseInt(((TextComponent) children.get(0)).content());
+ final String player = ((TextComponent) children.get(1)).content();
+
+ Component inputComponent;
+ try {
+ inputComponent = children.get(2);
+ } catch (IndexOutOfBoundsException e) {
+ inputComponent = Component.text("");
+ }
+ final String input = ((TextComponent) inputComponent).content();
+
+ System.out.println("input is \"" + input + "\"");
+
+ final List output = new ArrayList<>();
+ output.add(Component.text(id));
+ output.add(Component.text(transactionId));
+
+ for (Command command : bot.commandHandler().commands()) {
+ if (!command.name().startsWith(input)) continue;
+
+ output.add(Component.text(command.name()));
+ }
+
+ bot.chat().tellraw(Component.join(JoinConfiguration.noSeparators(), output), player);
+ } catch (Exception ignored) {}
+ }
+}