revert commit

This commit is contained in:
Chayapak 2023-04-28 18:10:47 +07:00
parent 1b424778dd
commit c430cd894d
40 changed files with 319 additions and 184 deletions

View file

@ -4,7 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="use alphanumeric"> <list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="revert commit">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/Command.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/Command.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/Command.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/Command.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java" afterDir="false" />
@ -43,6 +43,8 @@
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WikipediaCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WikipediaCommand.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WikipediaCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WikipediaCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSuggestionPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSuggestionPlugin.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/util/ElementUtilities.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/util/ElementUtilities.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -61,6 +63,7 @@
</component> </component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="RESET_MODE" value="HARD" />
</component> </component>
<component name="MarkdownSettingsMigration"> <component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" /> <option name="stateVersion" value="1" />
@ -134,6 +137,13 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1680245437032</updated> <updated>1680245437032</updated>
</task> </task>
<task id="LOCAL-00087" summary="add/improve/fix stuff&#10;ig mabe mabe mabe&#10;useCore!1!1!">
<created>1682060041610</created>
<option name="number" value="00087" />
<option name="presentableId" value="LOCAL-00087" />
<option name="project" value="LOCAL" />
<updated>1682060041611</updated>
</task>
<task id="LOCAL-00088" summary="ig fix music filename mabe mabe"> <task id="LOCAL-00088" summary="ig fix music filename mabe mabe">
<created>1682073074933</created> <created>1682073074933</created>
<option name="number" value="00088" /> <option name="number" value="00088" />
@ -470,14 +480,7 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1682673335876</updated> <updated>1682673335876</updated>
</task> </task>
<task id="LOCAL-00136" summary="use alphanumeric"> <option name="localTasksCounter" value="136" />
<created>1682676091534</created>
<option name="number" value="00136" />
<option name="presentableId" value="LOCAL-00136" />
<option name="project" value="LOCAL" />
<updated>1682676091535</updated>
</task>
<option name="localTasksCounter" value="137" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
@ -516,8 +519,8 @@
<MESSAGE value="use block change and multi block change packets&#10;and also change the core refill delay !!!" /> <MESSAGE value="use block change and multi block change packets&#10;and also change the core refill delay !!!" />
<MESSAGE value="actually i forgor 1 thing&#10;its the command block update thing which we want to ignore it" /> <MESSAGE value="actually i forgor 1 thing&#10;its the command block update thing which we want to ignore it" />
<MESSAGE value="port a thing from chomens bot js to java" /> <MESSAGE value="port a thing from chomens bot js to java" />
<MESSAGE value="use alphanumeric" /> <MESSAGE value="revert commit" />
<option name="LAST_COMMIT_MESSAGE" value="use alphanumeric" /> <option name="LAST_COMMIT_MESSAGE" value="revert commit" />
</component> </component>
<component name="XSLT-Support.FileAssociations.UIState"> <component name="XSLT-Support.FileAssociations.UIState">
<expand /> <expand />

View file

@ -1,23 +1,15 @@
package land.chipmunk.chayapak.chomens_bot.command; package land.chipmunk.chayapak.chomens_bot.command;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.RandomStringUtils;
import java.util.Collections;
import java.util.List; import java.util.List;
public class Command { public interface Command {
public String name = "unnamed" + RandomStringUtils.randomNumeric(4); String name();
public String description = "No Description"; String description();
public List<String> usage () { List<String> usage();
return Collections.emptyList(); List<String> alias();
} int trustLevel();
public List<String> alias () {
return Collections.emptyList();
}
public int trustLevel = 0;
public Component execute(CommandContext context, String[] args, String[] fullArgs) throws Exception { Component execute(CommandContext context, String[] args, String[] fullArgs) throws Exception;
return null;
}
} }

View file

@ -11,10 +11,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class BotUserCommand extends Command { public class BotUserCommand implements Command {
public String name = "botuser"; public String name() { return "botuser"; }
public String description = "Shows the bot's username and UUID"; public String description() {
return "Shows the bot's username and UUID";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -30,7 +32,9 @@ public class BotUserCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -9,10 +9,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class BotVisibilityCommand extends Command { public class BotVisibilityCommand implements Command {
public String name = "botvisibility"; public String name() { return "botvisibility"; }
public String description = "Changes the bot's visibility"; public String description() {
return "Changes the bot's visibility";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -32,7 +34,9 @@ public class BotVisibilityCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 1; public int trustLevel() {
return 1;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -8,10 +8,12 @@ import net.kyori.adventure.text.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class BruhifyCommand extends Command { public class BruhifyCommand implements Command {
public String name = "bruhify"; public String name() { return "bruhify"; }
public String description = "RecycleBot bruhify but actionbar"; public String description() {
return "RecycleBot bruhify but actionbar";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -27,7 +29,9 @@ public class BruhifyCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -11,10 +11,12 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
public class ClearChatCommand extends Command { public class ClearChatCommand implements Command {
public String name = "clearchat"; public String name() { return "clearchat"; }
public String description = "Clears the chat"; public String description() {
return "Clears the chat";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -30,7 +32,9 @@ public class ClearChatCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -8,10 +8,12 @@ import net.kyori.adventure.text.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ClearChatQueueCommand extends Command { public class ClearChatQueueCommand implements Command {
public String name = "clearchatqueue"; public String name() { return "clearchatqueue"; }
public String description = "Clears the bot's chat queue"; public String description() {
return "Clears the bot's chat queue";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -27,7 +29,9 @@ public class ClearChatQueueCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -12,10 +12,12 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class CloopCommand extends Command { public class CloopCommand implements Command {
public String name = "cloop"; public String name() { return "cloop"; }
public String description = "Loop commands"; public String description() {
return "Loop commands";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -34,7 +36,9 @@ public class CloopCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 1; public int trustLevel() {
return 1;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -14,10 +14,12 @@ import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
public class CommandBlockCommand extends Command { public class CommandBlockCommand implements Command {
public String name = "cb"; public String name() { return "cb"; }
public String description = "Executes a command in the command core and return it's output"; public String description() {
return "Executes a command in the command core and return it's output";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -35,7 +37,9 @@ public class CommandBlockCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) throws ExecutionException, InterruptedException { public Component execute(CommandContext context, String[] args, String[] fullArgs) throws ExecutionException, InterruptedException {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -9,10 +9,12 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class CowsayCommand extends Command { public class CowsayCommand implements Command {
public String name = "cowsay"; public String name() { return "cowsay"; }
public String description = "Moo"; public String description() {
return "Moo";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -28,7 +30,9 @@ public class CowsayCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final String cow = args[0]; final String cow = args[0];

View file

@ -9,10 +9,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class CreatorCommand extends Command { public class CreatorCommand implements Command {
public String name = "creator"; public String name() { return "creator"; }
public String description = "Shows the bot's creator"; public String description() {
return "Shows the bot's creator";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -28,7 +30,9 @@ public class CreatorCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -9,10 +9,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class DiscordCommand extends Command { public class DiscordCommand implements Command {
public String name = "discord"; public String name() { return "discord"; }
public String description = "Shows the Discord invite"; public String description() {
return "Shows the Discord invite";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -28,7 +30,9 @@ public class DiscordCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final String link = "https://discord.gg/xdgCkUyaA4"; final String link = "https://discord.gg/xdgCkUyaA4";

View file

@ -8,10 +8,12 @@ import net.kyori.adventure.text.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class EchoCommand extends Command { public class EchoCommand implements Command {
public String name = "echo"; public String name() { return "echo"; }
public String description = "Says a message"; public String description() {
return "Says a message";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -27,7 +29,9 @@ public class EchoCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -8,10 +8,12 @@ import net.kyori.adventure.text.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class EndCommand extends Command { public class EndCommand implements Command {
public String name = "end"; public String name() { return "end"; }
public String description = "End/Restarts the bot"; public String description() {
return "End/Restarts the bot";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -27,7 +29,9 @@ public class EndCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 1; public int trustLevel() {
return 1;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -12,10 +12,12 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class FilterCommand extends Command { public class FilterCommand implements Command {
public String name = "filter"; public String name() { return "filter"; }
public String description = "Filter players"; public String description() {
return "Filter players";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -37,7 +39,9 @@ public class FilterCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 1; public int trustLevel() {
return 1;
}
// most of these codes are from cloop and greplog // most of these codes are from cloop and greplog
public Component execute(CommandContext context, String[] _args, String[] fullArgs) { public Component execute(CommandContext context, String[] _args, String[] fullArgs) {

View file

@ -10,10 +10,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class GenerateMazeCommand extends Command { public class GenerateMazeCommand implements Command {
public String name = "generatemaze"; public String name() { return "generatemaze"; }
public String description = "Generates a maze"; public String description() {
return "Generates a maze";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -30,7 +32,9 @@ public class GenerateMazeCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -10,10 +10,12 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class GrepLogCommand extends Command { public class GrepLogCommand implements Command {
public String name = "greplog"; public String name() { return "greplog"; }
public String description = "Queries the bot's log files"; public String description() {
return "Queries the bot's log files";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -34,7 +36,9 @@ public class GrepLogCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] _args, String[] fullArgs) { public Component execute(CommandContext context, String[] _args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -11,10 +11,12 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
public class HelpCommand extends Command { public class HelpCommand implements Command {
public String name = "help"; public String name() { return "help"; }
public String description = "Shows the help"; public String description() {
return "Shows the help";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -32,7 +34,9 @@ public class HelpCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
private Bot bot; private Bot bot;
@ -71,9 +75,9 @@ public class HelpCommand extends Command {
List<String> commandNames = new ArrayList<>(); List<String> commandNames = new ArrayList<>();
for (Command command : bot.commandHandler().commands()) { for (Command command : bot.commandHandler().commands()) {
if (command.trustLevel != trustLevel) continue; if (command.trustLevel() != trustLevel) continue;
commandNames.add(command.name); commandNames.add(command.name());
} }
Collections.sort(commandNames); Collections.sort(commandNames);
@ -100,9 +104,9 @@ public class HelpCommand extends Command {
final String prefix = context.prefix(); final String prefix = context.prefix();
for (Command command : bot.commandHandler().commands()) { for (Command command : bot.commandHandler().commands()) {
if (!command.name.equals(args[0]) && !command.alias().contains(args[0])) continue; if (!command.name().equals(args[0]) && !command.alias().contains(args[0])) continue;
final String commandName = command.name; final String commandName = command.name();
final List<Component> usages = new ArrayList<>(); final List<Component> usages = new ArrayList<>();
usages.add( usages.add(
@ -113,13 +117,13 @@ public class HelpCommand extends Command {
" (" + String.join(", ", command.alias()) + ")" : " (" + String.join(", ", command.alias()) + ")" :
"" ""
)) ))
.append(Component.text(" - " + command.description).color(NamedTextColor.GRAY)) .append(Component.text(" - " + command.description()).color(NamedTextColor.GRAY))
); );
usages.add( usages.add(
Component.empty() Component.empty()
.append(Component.text("Trust level: ").color(NamedTextColor.GREEN)) .append(Component.text("Trust level: ").color(NamedTextColor.GREEN))
.append(Component.text(command.trustLevel).color(NamedTextColor.YELLOW)) .append(Component.text(command.trustLevel()).color(NamedTextColor.YELLOW))
); );
for (String usage : command.usage()) { for (String usage : command.usage()) {

View file

@ -11,10 +11,12 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
public class KickCommand extends Command { public class KickCommand implements Command {
public String name = "kick"; public String name() { return "kick"; }
public String description = "Kicks a player"; public String description() {
return "Kicks a player";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -30,7 +32,9 @@ public class KickCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 1; public int trustLevel() {
return 1;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -13,10 +13,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ListCommand extends Command { public class ListCommand implements Command {
public String name = "list"; public String name() { return "list"; }
public String description = "Lists all players in the server (including vanished)"; public String description() {
return "Lists all players in the server (including vanished)";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -32,7 +34,9 @@ public class ListCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -21,12 +21,14 @@ import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
public class MusicCommand extends Command { public class MusicCommand implements Command {
private Path root; private Path root;
public String name = "music"; public String name() { return "music"; }
public String description = "Plays music"; public String description() {
return "Plays music";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -54,7 +56,9 @@ public class MusicCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
root = Path.of(MusicPlayerPlugin.SONG_DIR.getPath()); root = Path.of(MusicPlayerPlugin.SONG_DIR.getPath());
@ -241,7 +245,7 @@ public class MusicCommand extends Command {
.clickEvent( .clickEvent(
ClickEvent.suggestCommand( ClickEvent.suggestCommand(
prefix + prefix +
name + // command name !!! name() +
(file.isFile() ? " play " : " list ") + (file.isFile() ? " play " : " list ") +
joinedPath joinedPath
) )

View file

@ -11,10 +11,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class NetMessageCommand extends Command { public class NetMessageCommand implements Command {
public String name = "netmsg"; public String name() { return "netmsg"; }
public String description = "Broadcasts a message to all of the servers that the bot is connected"; public String description() {
return "Broadcasts a message to all of the servers that the bot is connected";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -31,7 +33,9 @@ public class NetMessageCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -11,10 +11,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class RandomTeleportCommand extends Command { public class RandomTeleportCommand implements Command {
public String name = "rtp"; public String name() { return "rtp"; }
public String description = "Randomly teleports you"; public String description() {
return "Randomly teleports you";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -30,7 +32,9 @@ public class RandomTeleportCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -8,10 +8,12 @@ import net.kyori.adventure.text.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class RefillCoreCommand extends Command { public class RefillCoreCommand implements Command {
public String name = "refillcore"; public String name() { return "refillcore"; }
public String description = "Refills and resets the bot's command core"; public String description() {
return "Refills and resets the bot's command core";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -27,7 +29,9 @@ public class RefillCoreCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -11,10 +11,12 @@ import org.luaj.vm2.lib.jse.CoerceJavaToLua;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ServerEvalCommand extends Command { public class ServerEvalCommand implements Command {
public String name = "servereval"; public String name() { return "servereval"; }
public String description = "Evaluate codes using LuaJ"; public String description() {
return "Evaluate codes using LuaJ";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -30,7 +32,9 @@ public class ServerEvalCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 2; public int trustLevel() {
return 2;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
try { try {

View file

@ -19,10 +19,12 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
public class ServerInfoCommand extends Command { public class ServerInfoCommand implements Command {
public String name = "serverinfo"; public String name() { return "serverinfo"; }
public String description = "Shows the info about the server that is hosting the bot"; public String description() {
return "Shows the info about the server that is hosting the bot";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -38,7 +40,9 @@ public class ServerInfoCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
// totallynotskidded from extras' serverinfo // totallynotskidded from extras' serverinfo

View file

@ -10,10 +10,12 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
// ayunsudo renamed. // ayunsudo renamed.
public class SudoAllCommand extends Command { public class SudoAllCommand implements Command {
public String name = "sudoall"; public String name() { return "sudoall"; }
public String description = "Sudoes everyone"; public String description() {
return "Sudoes everyone";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -29,7 +31,9 @@ public class SudoAllCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 1; public int trustLevel() {
return 1;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -9,10 +9,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class TPSBarCommand extends Command { public class TPSBarCommand implements Command {
public String name = "tpsbar"; public String name() { return "tpsbar"; }
public String description = "Shows the server's TPS using Minecraft Bossbar"; public String description() {
return "Shows the server's TPS using Minecraft Bossbar";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -28,7 +30,9 @@ public class TPSBarCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -8,10 +8,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class TestCommand extends Command { public class TestCommand implements Command {
public String name = "test"; public String name() { return "test"; }
public String description = "Tests if the bot is working"; public String description() {
return "Tests if the bot is working";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -27,7 +29,9 @@ public class TestCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
return Component.translatable( return Component.translatable(

View file

@ -7,10 +7,12 @@ import net.kyori.adventure.text.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ThrowCommand extends Command { public class ThrowCommand implements Command {
public String name = "throw"; public String name() { return "throw"; }
public String description = "A command to throw an error, kinda useless"; public String description() {
return "A command to throw an error, kinda useless";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -26,7 +28,9 @@ public class ThrowCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) throws Exception { public Component execute(CommandContext context, String[] args, String[] fullArgs) throws Exception {
final String message = String.join(" ", args); final String message = String.join(" ", args);

View file

@ -12,10 +12,12 @@ import org.joda.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class TimeCommand extends Command { public class TimeCommand implements Command {
public String name = "time"; public String name() { return "time"; }
public String description = "Shows the date and time for the specified timezone"; public String description() {
return "Shows the date and time for the specified timezone";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -32,7 +34,9 @@ public class TimeCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final String timezone = args[0]; final String timezone = args[0];

View file

@ -16,10 +16,12 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class TranslateCommand extends Command { public class TranslateCommand implements Command {
public String name = "translate"; public String name() { return "translate"; }
public String description = "Translate a message using Google Translate"; public String description() {
return "Translate a message using Google Translate";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -35,7 +37,9 @@ public class TranslateCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final String from = args[0]; final String from = args[0];

View file

@ -12,10 +12,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class UUIDCommand extends Command { public class UUIDCommand implements Command {
public String name = "uuid"; public String name() { return "uuid"; }
public String description = "Shows your UUID or other player's UUID"; public String description() {
return "Shows your UUID or other player's UUID";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -31,7 +33,9 @@ public class UUIDCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -16,10 +16,12 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class UrbanCommand extends Command { public class UrbanCommand implements Command {
public String name = "urban"; public String name() { return "urban"; }
public String description = "Urban Dictionary in Minecraft"; public String description() {
return "Urban Dictionary in Minecraft";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -35,7 +37,9 @@ public class UrbanCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute (CommandContext context, String[] args, String[] fullArgs) { public Component execute (CommandContext context, String[] args, String[] fullArgs) {
final String term = String.join(" ", args); final String term = String.join(" ", args);

View file

@ -8,10 +8,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ValidateCommand extends Command { public class ValidateCommand implements Command {
public String name = "validate"; public String name() { return "validate"; }
public String description = "Validates a hash"; public String description() {
return "Validates a hash";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -27,7 +29,9 @@ public class ValidateCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 1; public int trustLevel() {
return 1;
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final String hash = fullArgs[0]; final String hash = fullArgs[0];

View file

@ -19,10 +19,12 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class WeatherCommand extends Command { public class WeatherCommand implements Command {
public String name = "weather"; public String name() { return "weather"; }
public String description = "Shows the weather in a place"; public String description() {
return "Shows the weather in a place";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -38,7 +40,9 @@ public class WeatherCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute (CommandContext context, String[] args, String[] fullArgs) { public Component execute (CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot();

View file

@ -15,10 +15,12 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class WikipediaCommand extends Command { public class WikipediaCommand implements Command {
public String name = "wikipedia"; public String name() { return "wikipedia"; }
public String description = "Wikipedia in Minecraft"; public String description() {
return "Wikipedia in Minecraft";
}
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
@ -34,7 +36,9 @@ public class WikipediaCommand extends Command {
return aliases; return aliases;
} }
public int trustLevel = 0; public int trustLevel() {
return 0;
}
public Component execute (CommandContext context, String[] args, String[] fullArgs) { public Component execute (CommandContext context, String[] args, String[] fullArgs) {
final String page = String.join(" ", args); final String page = String.join(" ", args);

View file

@ -81,13 +81,13 @@ public class CommandHandlerPlugin {
if (command == null) return Component.text("Unknown command: " + commandName).color(NamedTextColor.RED); if (command == null) return Component.text("Unknown command: " + commandName).color(NamedTextColor.RED);
final int trustLevel = command.trustLevel; final int trustLevel = command.trustLevel();
final String[] fullArgs = Arrays.copyOfRange(splitInput, 1, splitInput.length); final String[] fullArgs = Arrays.copyOfRange(splitInput, 1, splitInput.length);
final int longestUsageIndex = getLongestUsageIndex(command.usage()); final int longestUsageIndex = getLongestUsageIndex(command.usage());
final String usage = command.usage().get(longestUsageIndex); final String usage = command.usage().get(longestUsageIndex);
final int minimumArgs = getMinimumArgs(usage, inGame, command.trustLevel); final int minimumArgs = getMinimumArgs(usage, inGame, command.trustLevel());
final int maximumArgs = getMaximumArgs(usage, inGame, command.trustLevel); final int maximumArgs = getMaximumArgs(usage, inGame, command.trustLevel());
if (fullArgs.length < minimumArgs) return Component.text("Excepted minimum of " + minimumArgs + " argument(s), got " + fullArgs.length).color(NamedTextColor.RED); if (fullArgs.length < minimumArgs) return Component.text("Excepted minimum of " + minimumArgs + " argument(s), got " + fullArgs.length).color(NamedTextColor.RED);
if (fullArgs.length > maximumArgs && !usage.contains("{")) return Component.text("Too much arguments, expected " + maximumArgs + " max").color(NamedTextColor.RED); if (fullArgs.length > maximumArgs && !usage.contains("{")) return Component.text("Too much arguments, expected " + maximumArgs + " max").color(NamedTextColor.RED);
@ -98,7 +98,7 @@ public class CommandHandlerPlugin {
final String[] args = Arrays.copyOfRange(splitInput, (trustLevel > 0 && inGame) ? 2 : 1, splitInput.length); final String[] args = Arrays.copyOfRange(splitInput, (trustLevel > 0 && inGame) ? 2 : 1, splitInput.length);
if (command.trustLevel > 0 && !console) { if (command.trustLevel() > 0 && !console) {
if (discord) { if (discord) {
final List<Role> roles = event.getMember().getRoles(); final List<Role> roles = event.getMember().getRoles();
@ -106,24 +106,24 @@ public class CommandHandlerPlugin {
final String adminRoleName = bot.config().discord().adminRoleName(); final String adminRoleName = bot.config().discord().adminRoleName();
if ( if (
command.trustLevel == 1 && command.trustLevel() == 1 &&
roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(trustedRoleName)) && roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(trustedRoleName)) &&
roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(adminRoleName)) roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(adminRoleName))
) return Component.text("You're not in the trusted role!").color(NamedTextColor.RED); ) return Component.text("You're not in the trusted role!").color(NamedTextColor.RED);
if ( if (
command.trustLevel == 2 && command.trustLevel() == 2 &&
roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(adminRoleName)) roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(adminRoleName))
) return Component.text("You're not in the admin role!").color(NamedTextColor.RED); ) return Component.text("You're not in the admin role!").color(NamedTextColor.RED);
} else { } else {
if ( if (
command.trustLevel == 1 && command.trustLevel() == 1 &&
!userHash.equals(hash) && !userHash.equals(hash) &&
!userHash.equals(ownerHash) !userHash.equals(ownerHash)
) return Component.text("Invalid hash").color(NamedTextColor.RED); ) return Component.text("Invalid hash").color(NamedTextColor.RED);
if ( if (
command.trustLevel == 2 && command.trustLevel() == 2 &&
!userHash.equals(ownerHash) !userHash.equals(ownerHash)
) return Component.text("Invalid OwnerHash").color(NamedTextColor.RED); ) return Component.text("Invalid OwnerHash").color(NamedTextColor.RED);
} }

View file

@ -48,9 +48,9 @@ public class CommandSuggestionPlugin extends ChatPlugin.ChatListener {
output.add(Component.text(transactionId)); output.add(Component.text(transactionId));
for (Command command : bot.commandHandler().commands()) { for (Command command : bot.commandHandler().commands()) {
if (!command.name.startsWith(input)) continue; if (!command.name().startsWith(input)) continue;
output.add(Component.text(command.name)); output.add(Component.text(command.name()));
} }
bot.chat().tellraw(Component.join(JoinConfiguration.noSeparators(), output), player); bot.chat().tellraw(Component.join(JoinConfiguration.noSeparators(), output), player);

View file

@ -9,7 +9,7 @@ public class ElementUtilities {
for (Command command : commands) { for (Command command : commands) {
if ( if (
( (
command.name.equals(searchTerm.toLowerCase()) || command.name().equals(searchTerm.toLowerCase()) ||
command.alias().contains(searchTerm.toLowerCase()) command.alias().contains(searchTerm.toLowerCase())
) && ) &&
!searchTerm.equals("") // ig yup !searchTerm.equals("") // ig yup