add command suggestions i guess
This commit is contained in:
parent
9610850424
commit
c5df71e792
3 changed files with 74 additions and 13 deletions
|
@ -4,9 +4,7 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="amogus">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
</list>
|
||||
<list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="patch sus?" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
|
@ -97,13 +95,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680245437032</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00081" summary="mabe">
|
||||
<created>1681806777109</created>
|
||||
<option name="number" value="00081" />
|
||||
<option name="presentableId" value="LOCAL-00081" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1681806777109</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00082" summary="mess with the pitch correction again to fix the sus problem">
|
||||
<created>1681882635433</created>
|
||||
<option name="number" value="00082" />
|
||||
|
@ -440,7 +431,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1682644881919</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="130" />
|
||||
<task id="LOCAL-00130" summary="patch sus?">
|
||||
<created>1682654933076</created>
|
||||
<option name="number" value="00130" />
|
||||
<option name="presentableId" value="LOCAL-00130" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1682654933076</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="131" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -455,7 +453,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="improve bot options? mabe mabe" />
|
||||
<MESSAGE value="put the setter back" />
|
||||
<MESSAGE value="use serverName instead of host:port for console i guess" />
|
||||
<MESSAGE value="actually revert greplog update because it breaks stuff" />
|
||||
|
@ -480,7 +477,8 @@
|
|||
<MESSAGE value="new 1.19.4 update i guess" />
|
||||
<MESSAGE value="bots mabe" />
|
||||
<MESSAGE value="amogus" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="amogus" />
|
||||
<MESSAGE value="patch sus?" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="patch sus?" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
|
|
@ -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<Bot> 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();
|
||||
}
|
||||
|
|
|
@ -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<Component> 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<Component> 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) {}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue