From 82f95139b04c48d4d8ac638b4ff3779b27af84b7 Mon Sep 17 00:00:00 2001
From: ChomeNS <95471003+ChomeNS@users.noreply.github.com>
Date: Mon, 24 Apr 2023 15:20:50 +0700
Subject: [PATCH] improve returning output of commands
---
.idea/workspace.xml | 78 ++++++++++++-----
.../command/DiscordCommandContext.java | 12 ---
.../chomens_bot/commands/BotUserCommand.java | 56 ++++++-------
.../commands/BotVisibilityCommand.java | 28 +++----
.../chomens_bot/commands/BruhifyCommand.java | 2 +-
.../commands/ClearChatCommand.java | 2 +-
.../commands/ClearChatQueueCommand.java | 2 +-
.../chomens_bot/commands/CloopCommand.java | 28 ++-----
.../commands/CommandBlockCommand.java | 2 +-
.../chomens_bot/commands/CowsayCommand.java | 4 +-
.../chomens_bot/commands/CreatorCommand.java | 12 +--
.../chomens_bot/commands/DiscordCommand.java | 20 ++---
.../chomens_bot/commands/EchoCommand.java | 2 +-
.../chomens_bot/commands/EndCommand.java | 2 +-
.../chomens_bot/commands/FilterCommand.java | 30 +++----
.../commands/GenerateMazeCommand.java | 2 +-
.../chomens_bot/commands/GrepLogCommand.java | 5 +-
.../chomens_bot/commands/HelpCommand.java | 13 +--
.../chomens_bot/commands/KickCommand.java | 10 +--
.../chomens_bot/commands/ListCommand.java | 6 +-
.../chomens_bot/commands/MusicCommand.java | 83 +++++++------------
.../commands/NetMessageCommand.java | 2 +-
.../commands/RandomTeleportCommand.java | 16 ++--
.../commands/RefillCoreCommand.java | 2 +-
.../commands/ServerEvalCommand.java | 4 +-
.../commands/ServerInfoCommand.java | 4 +-
.../chomens_bot/commands/SudoAllCommand.java | 2 +-
.../chomens_bot/commands/TPSBarCommand.java | 18 ++--
.../chomens_bot/commands/TestCommand.java | 6 +-
.../chomens_bot/commands/TimeCommand.java | 12 +--
.../commands/TranslateCommand.java | 16 ++--
.../chomens_bot/commands/UUIDCommand.java | 60 ++++++--------
.../chomens_bot/commands/UrbanCommand.java | 2 +-
.../chomens_bot/commands/ValidateCommand.java | 8 +-
.../chomens_bot/commands/WeatherCommand.java | 6 +-
.../commands/WikipediaCommand.java | 6 +-
.../plugins/ChatCommandHandlerPlugin.java | 6 +-
.../chomens_bot/plugins/ConsolePlugin.java | 4 +-
.../chomens_bot/plugins/DiscordPlugin.java | 6 +-
.../chomens_bot/plugins/FilterPlugin.java | 4 +-
40 files changed, 243 insertions(+), 340 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 61eeed9..f681581 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,9 +4,47 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -98,20 +136,6 @@
1680245437032
-
- 1681607369880
-
-
-
- 1681607369882
-
-
- 1681613674861
-
-
-
- 1681613674862
-
1681617940254
@@ -441,7 +465,21 @@
1682321509974
-
+
+ 1682322013136
+
+
+
+ 1682322013139
+
+
+ 1682322237090
+
+
+
+ 1682322237090
+
+
@@ -456,8 +494,6 @@
-
-
@@ -481,7 +517,9 @@
-
+
+
+
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/command/DiscordCommandContext.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/command/DiscordCommandContext.java
index c61a9ff..f5bcf93 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/command/DiscordCommandContext.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/command/DiscordCommandContext.java
@@ -56,18 +56,6 @@ public class DiscordCommandContext extends CommandContext {
event.getMessage().replyEmbeds(embed).queue();
}
- public void sendError (Component component) {
- final String output = ComponentUtilities.stringifyAnsi(component);
- final EmbedBuilder builder = new EmbedBuilder();
- builder.setTitle("Error");
- builder.setColor(Color.decode(bot.config().discord().embedColors().error()));
- builder.setDescription("```ansi\n" + output + "\n```");
-
- final MessageEmbed embed = builder.build();
-
- event.getMessage().replyEmbeds(embed).queue();
- }
-
@Override
public Component displayName () {
return Component.text(event.getAuthor().getName());
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java
index b537578..49aeb22 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java
@@ -42,38 +42,34 @@ public class BotUserCommand implements Command {
final String username = bot.username();
final String uuid = bot.players().getBotEntry().profile().getIdAsString();
- context.sendOutput(
- Component.translatable(
- "The bot's username is: %s and the UUID is: %s",
- Component
- .text(username)
- .hoverEvent(
- HoverEvent.showText(
- Component
- .text("Click here to copy the username to your clipboard")
- .color(NamedTextColor.GREEN)
- )
+ return Component.translatable(
+ "The bot's username is: %s and the UUID is: %s",
+ Component
+ .text(username)
+ .hoverEvent(
+ HoverEvent.showText(
+ Component
+ .text("Click here to copy the username to your clipboard")
+ .color(NamedTextColor.GREEN)
)
- .clickEvent(
- ClickEvent.copyToClipboard(username)
+ )
+ .clickEvent(
+ ClickEvent.copyToClipboard(username)
+ )
+ .color(NamedTextColor.GOLD),
+ Component
+ .text(uuid)
+ .hoverEvent(
+ HoverEvent.showText(
+ Component
+ .text("Click here to copy the UUID to your clipboard")
+ .color(NamedTextColor.GREEN)
)
- .color(NamedTextColor.GOLD),
- Component
- .text(uuid)
- .hoverEvent(
- HoverEvent.showText(
- Component
- .text("Click here to copy the UUID to your clipboard")
- .color(NamedTextColor.GREEN)
- )
- )
- .clickEvent(
- ClickEvent.copyToClipboard(uuid)
- )
- .color(NamedTextColor.AQUA)
- )
+ )
+ .clickEvent(
+ ClickEvent.copyToClipboard(uuid)
+ )
+ .color(NamedTextColor.AQUA)
);
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotVisibilityCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotVisibilityCommand.java
index 565e7f6..50a7d05 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotVisibilityCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotVisibilityCommand.java
@@ -49,37 +49,29 @@ public class BotVisibilityCommand implements Command {
final String visibleOrInvisible = bot.selfCare().visibility() ? "visible" : "invisible";
final String disableOrEnable = bot.selfCare().visibility() ? "disable" : "enable";
bot.chat().send("/essentials:vanish " + disableOrEnable);
- context.sendOutput(
- Component.empty()
- .append(Component.text("The bot's visibility is now "))
- .append(Component.text(visibleOrInvisible).color(greenOrGold))
- );
+ return Component.empty()
+ .append(Component.text("The bot's visibility is now "))
+ .append(Component.text(visibleOrInvisible).color(greenOrGold));
} else {
switch (args[0]) {
case "on", "true" -> {
bot.selfCare().visibility(true);
bot.chat().send("/essentials:vanish disable");
- context.sendOutput(
- Component.empty()
- .append(Component.text("The bot's visibility is now "))
- .append(Component.text("visible").color(NamedTextColor.GREEN))
- );
+ return Component.empty()
+ .append(Component.text("The bot's visibility is now "))
+ .append(Component.text("visible").color(NamedTextColor.GREEN));
}
case "off", "false" -> {
bot.selfCare().visibility(false);
bot.chat().send("/essentials:vanish enable");
- context.sendOutput(
- Component.empty()
- .append(Component.text("The bot's visibility is now "))
- .append(Component.text("invisible").color(NamedTextColor.GOLD))
- );
+ return Component.empty()
+ .append(Component.text("The bot's visibility is now "))
+ .append(Component.text("invisible").color(NamedTextColor.GOLD));
}
default -> {
-
+ return Component.text("Invalid argument").color(NamedTextColor.RED);
}
}
}
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BruhifyCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BruhifyCommand.java
index 2a0f64e..a6fc094 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BruhifyCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BruhifyCommand.java
@@ -42,6 +42,6 @@ public class BruhifyCommand implements Command {
bot.bruhify().bruhifyText(String.join(" ", args));
}
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatCommand.java
index d9a241c..e22e34c 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatCommand.java
@@ -65,6 +65,6 @@ public class ClearChatCommand implements Command {
);
}
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatQueueCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatQueueCommand.java
index 749876d..b7a7d16 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatQueueCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatQueueCommand.java
@@ -38,6 +38,6 @@ public class ClearChatQueueCommand implements Command {
bot.chat().queue().clear();
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java
index c7332da..b86eeda 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java
@@ -58,12 +58,10 @@ public class CloopCommand implements Command {
bot.cloop().add(interval, command);
- context.sendOutput(
- Component.translatable(
- "Added %s with interval %s to the cloops",
- Component.text(command).color(NamedTextColor.AQUA),
- Component.text(interval).color(NamedTextColor.GOLD)
- )
+ return Component.translatable(
+ "Added %s with interval %s to the cloops",
+ Component.text(command).color(NamedTextColor.AQUA),
+ Component.text(interval).color(NamedTextColor.GOLD)
);
}
case "remove" -> {
@@ -71,11 +69,9 @@ public class CloopCommand implements Command {
final int index = Integer.parseInt(args[1]);
bot.cloop().remove(index);
- context.sendOutput(
- Component.translatable(
- "Removed cloop %s",
- Component.text(index).color(NamedTextColor.GOLD)
- )
+ return Component.translatable(
+ "Removed cloop %s",
+ Component.text(index).color(NamedTextColor.GOLD)
);
} catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) {
return Component.text("Invalid index").color(NamedTextColor.RED);
@@ -83,9 +79,7 @@ public class CloopCommand implements Command {
}
case "clear" -> {
bot.cloop().clear();
- context.sendOutput(
- Component.text("Cleared all cloops")
- );
+ return Component.text("Cleared all cloops");
}
case "list" -> {
final List cloopsComponent = new ArrayList<>();
@@ -103,7 +97,7 @@ public class CloopCommand implements Command {
index++;
}
- final Component component = Component.empty()
+ return Component.empty()
.append(Component.text("Cloops ").color(NamedTextColor.GREEN))
.append(Component.text("(").color(NamedTextColor.DARK_GRAY))
.append(Component.text(bot.cloop().loops().size()).color(NamedTextColor.GRAY))
@@ -112,14 +106,10 @@ public class CloopCommand implements Command {
.append(
Component.join(JoinConfiguration.newlines(), cloopsComponent)
);
-
- context.sendOutput(component);
}
default -> {
return Component.text("Invalid argument").color(NamedTextColor.RED);
}
}
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CommandBlockCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CommandBlockCommand.java
index 8698331..5671405 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CommandBlockCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CommandBlockCommand.java
@@ -60,6 +60,6 @@ public class CommandBlockCommand implements Command {
return tags;
});
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CowsayCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CowsayCommand.java
index af27d86..df698b7 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CowsayCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CowsayCommand.java
@@ -44,8 +44,6 @@ public class CowsayCommand implements Command {
final String result = cowExecutor.execute();
- context.sendOutput(Component.text(result));
-
- return Component.text("success");
+ return Component.text(result);
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java
index 77ad406..16fcdf5 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java
@@ -37,13 +37,9 @@ public class CreatorCommand implements Command {
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot();
- context.sendOutput(
- Component.empty()
- .append(Component.text("ChomeNS Bot ").color(NamedTextColor.YELLOW))
- .append(Component.text("was created by ").color(NamedTextColor.WHITE))
- .append(Component.text(bot.config().ownerName()).color(NamedTextColor.GREEN))
- );
-
- return Component.text("success");
+ return Component.empty()
+ .append(Component.text("ChomeNS Bot ").color(NamedTextColor.YELLOW))
+ .append(Component.text("was created by ").color(NamedTextColor.WHITE))
+ .append(Component.text(bot.config().ownerName()).color(NamedTextColor.GREEN));
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/DiscordCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/DiscordCommand.java
index aad9eb3..c3733d8 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/DiscordCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/DiscordCommand.java
@@ -36,17 +36,13 @@ public class DiscordCommand implements Command {
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final String link = "https://discord.gg/xdgCkUyaA4";
- context.sendOutput(
- Component.empty()
- .append(Component.text("The Discord invite is ").color(NamedTextColor.WHITE))
- .append(
- Component
- .text(link)
- .clickEvent(ClickEvent.openUrl(link))
- .color(NamedTextColor.BLUE)
- )
- );
-
- return Component.text("success");
+ return Component.empty()
+ .append(Component.text("The Discord invite is ").color(NamedTextColor.WHITE))
+ .append(
+ Component
+ .text(link)
+ .clickEvent(ClickEvent.openUrl(link))
+ .color(NamedTextColor.BLUE)
+ );
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EchoCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EchoCommand.java
index 652acb6..8bb2087 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EchoCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EchoCommand.java
@@ -38,6 +38,6 @@ public class EchoCommand implements Command {
bot.chat().send(String.join(" ", args));
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EndCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EndCommand.java
index ee69cda..65a5ad6 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EndCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EndCommand.java
@@ -38,6 +38,6 @@ public class EndCommand implements Command {
bot.session().disconnect("End command");
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/FilterCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/FilterCommand.java
index 86a4693..b644641 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/FilterCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/FilterCommand.java
@@ -74,34 +74,28 @@ public class FilterCommand implements Command {
final String player = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
bot.filter().add(player, regex, ignoreCase);
- context.sendOutput(
- Component.translatable(
- "Added %s to the filters",
- Component.text(player).color(NamedTextColor.AQUA)
- )
+ return Component.translatable(
+ "Added %s to the filters",
+ Component.text(player).color(NamedTextColor.AQUA)
);
}
case "remove" -> {
try {
final int index = Integer.parseInt(args[1]);
- context.sendOutput(
- Component.translatable(
- "Removed %s from the filters",
- Component.text(bot.filter().filteredPlayers().get(index).playerName).color(NamedTextColor.AQUA)
- )
- );
+ final FilteredPlayer removed = bot.filter().remove(index);
- bot.filter().remove(index);
+ return Component.translatable(
+ "Removed %s from the filters",
+ Component.text(removed.playerName).color(NamedTextColor.AQUA)
+ );
} catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) {
return Component.text("Invalid index").color(NamedTextColor.RED);
}
}
case "clear" -> {
bot.filter().clear();
- context.sendOutput(
- Component.text("Cleared the filter")
- );
+ return Component.text("Cleared the filter");
}
case "list" -> {
final List filtersComponents = new ArrayList<>();
@@ -119,7 +113,7 @@ public class FilterCommand implements Command {
index++;
}
- final Component component = Component.empty()
+ return Component.empty()
.append(Component.text("Filtered players ").color(NamedTextColor.GREEN))
.append(Component.text("(").color(NamedTextColor.DARK_GRAY))
.append(Component.text(bot.filter().filteredPlayers().size()).color(NamedTextColor.GRAY))
@@ -128,14 +122,10 @@ public class FilterCommand implements Command {
.append(
Component.join(JoinConfiguration.newlines(), filtersComponents)
);
-
- context.sendOutput(component);
}
default -> {
return Component.text("Invalid argument").color(NamedTextColor.RED);
}
}
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GenerateMazeCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GenerateMazeCommand.java
index f4380a7..68c8abd 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GenerateMazeCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GenerateMazeCommand.java
@@ -56,6 +56,6 @@ public class GenerateMazeCommand implements Command {
return Component.text("Invalid position/size").color(NamedTextColor.RED);
}
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GrepLogCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GrepLogCommand.java
index afa4488..d63bd76 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GrepLogCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GrepLogCommand.java
@@ -54,8 +54,7 @@ public class GrepLogCommand implements Command {
bot.grepLog().thread().interrupt();
bot.grepLog().thread(null);
- context.sendOutput(Component.text("Log query stopped"));
- return Component.text("success");
+ return Component.text("Log query stopped");
}
if (bot.grepLog().thread() != null) return Component.text("Another query is already running").color(NamedTextColor.RED);
@@ -79,6 +78,6 @@ public class GrepLogCommand implements Command {
bot.grepLog().query(String.join(" ", args), regex, ignoreCase);
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java
index 25d87a7..5966f91 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java
@@ -43,20 +43,19 @@ public class HelpCommand implements Command {
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
this.bot = context.bot();
if (args.length == 0) {
- sendCommandList(context);
- return Component.text("success");
+ return sendCommandList();
} else {
return sendUsages(context, args);
}
}
- public void sendCommandList(CommandContext context) {
+ public Component sendCommandList () {
final List list = new ArrayList<>();
list.addAll(getCommandListByTrustLevel(0));
list.addAll(getCommandListByTrustLevel(1));
list.addAll(getCommandListByTrustLevel(2));
- final Component component = Component.empty()
+ return Component.empty()
.append(Component.text("Commands ").color(NamedTextColor.GRAY))
.append(Component.text("(").color(NamedTextColor.DARK_GRAY))
.append(Component.text("Length: ").color(NamedTextColor.GRAY))
@@ -68,8 +67,6 @@ public class HelpCommand implements Command {
.append(Component.text("Owner").color(NamedTextColor.DARK_RED))
.append(Component.text(") - ").color(NamedTextColor.DARK_GRAY))
.append(Component.join(JoinConfiguration.separator(Component.space()), list));
-
- context.sendOutput(component);
}
public List getCommandListByTrustLevel(int trustLevel) {
@@ -138,9 +135,7 @@ public class HelpCommand implements Command {
);
}
- context.sendOutput(Component.join(JoinConfiguration.separator(Component.newline()), usages));
-
- return Component.text("success");
+ return Component.join(JoinConfiguration.separator(Component.newline()), usages);
}
return Component.text("Unknown command").color(NamedTextColor.RED);
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/KickCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/KickCommand.java
index fc3e7ce..ffe390b 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/KickCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/KickCommand.java
@@ -46,14 +46,10 @@ public class KickCommand implements Command {
final String name = entry.profile().getName();
final UUID uuid = entry.profile().getId();
- context.sendOutput(
- Component.empty()
- .append(Component.text("Kicking player "))
- .append(Component.text(name).color(NamedTextColor.GOLD))
- );
-
bot.exploits().kick(uuid);
- return Component.text("success");
+ return Component.empty()
+ .append(Component.text("Kicking player "))
+ .append(Component.text(name).color(NamedTextColor.GOLD));
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ListCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ListCommand.java
index 3140368..f24738f 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ListCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ListCommand.java
@@ -75,7 +75,7 @@ public class ListCommand implements Command {
);
}
- final Component component = Component.empty()
+ return Component.empty()
.append(Component.text("Players ").color(NamedTextColor.GREEN))
.append(Component.text("(").color(NamedTextColor.DARK_GRAY))
.append(Component.text(list.size()).color(NamedTextColor.GRAY))
@@ -84,9 +84,5 @@ public class ListCommand implements Command {
.append(
Component.join(JoinConfiguration.newlines(), playersComponent)
);
-
- context.sendOutput(component);
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java
index 6457239..13151c8 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java
@@ -66,7 +66,9 @@ public class MusicCommand implements Command {
case "play", "playurl", "playnbs", "playnbsurl" -> {
return play(context, args);
}
- case "stop" -> stop(context);
+ case "stop" -> {
+ return stop(context);
+ }
case "loop" -> {
return loop(context, args);
}
@@ -79,7 +81,9 @@ public class MusicCommand implements Command {
case "nowplaying" -> {
return nowplaying(context);
}
- case "queue" -> queue(context);
+ case "queue" -> {
+ return queue(context);
+ }
case "goto" -> {
return goTo(context, args);
}
@@ -99,8 +103,6 @@ public class MusicCommand implements Command {
return Component.text("Invalid argument").color(NamedTextColor.RED);
}
}
-
- return Component.text("success");
}
public Component play (CommandContext context, String[] args) {
@@ -157,15 +159,15 @@ public class MusicCommand implements Command {
return Component.text(e.toString()).color(NamedTextColor.RED);
}
- return Component.text("success");
+ return null;
}
- public void stop (CommandContext context) {
+ public Component stop (CommandContext context) {
final Bot bot = context.bot();
bot.music().stopPlaying();
bot.music().songQueue().clear();
- context.sendOutput(Component.text("Cleared the song queue"));
+ return Component.text("Cleared the song queue");
}
public Component loop (CommandContext context, String[] args) {
@@ -202,7 +204,7 @@ public class MusicCommand implements Command {
bot.music().loop(loop);
- return Component.text("success");
+ return null;
}
public Component list (CommandContext context, String[] args) {
@@ -266,49 +268,40 @@ public class MusicCommand implements Command {
list.clear();
}
- return Component.text("success");
+ return null;
}
public Component skip (CommandContext context) {
final MusicPlayerPlugin music = context.bot().music();
if (music.currentSong() == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);
- context.sendOutput(
- Component.empty()
- .append(Component.text("Skipping "))
- .append(music.currentSong().name.color(NamedTextColor.GOLD))
- );
-
music.skip();
- return Component.text("success");
+ return Component.empty()
+ .append(Component.text("Skipping "))
+ .append(music.currentSong().name.color(NamedTextColor.GOLD));
}
public Component nowplaying (CommandContext context) {
final Bot bot = context.bot();
final Song song = bot.music().currentSong();
if (song == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);
- context.sendOutput(
- Component.empty()
- .append(Component.text("Now playing "))
- .append(song.name.color(NamedTextColor.GOLD))
- );
- return Component.text("success");
+ return Component.empty()
+ .append(Component.text("Now playing "))
+ .append(song.name.color(NamedTextColor.GOLD));
}
- public void queue (CommandContext context) {
+ public Component queue (CommandContext context) {
final Bot bot = context.bot();
final LinkedList queue = bot.music().songQueue();
final List queueWithNames = new ArrayList<>();
for (Song song : queue) queueWithNames.add(song.name);
- context.sendOutput(
- Component.empty()
- .append(Component.text("Queue: ").color(NamedTextColor.GREEN))
- .append(Component.join(JoinConfiguration.separator(Component.text(", ")), queueWithNames).color(NamedTextColor.AQUA))
- );
+ return Component.empty()
+ .append(Component.text("Queue: ").color(NamedTextColor.GREEN))
+ .append(Component.join(JoinConfiguration.separator(Component.text(", ")), queueWithNames).color(NamedTextColor.AQUA));
}
// lazy fix for java using "goto" as keyword real
@@ -328,7 +321,7 @@ public class MusicCommand implements Command {
currentSong.setTime(milliseconds);
- return Component.text("success");
+ return null;
}
public Component pitch (CommandContext context, String[] args) {
@@ -343,13 +336,9 @@ public class MusicCommand implements Command {
bot.music().pitch(pitch);
- context.sendOutput(
- Component.empty()
- .append(Component.text("Set the pitch to "))
- .append(Component.text(pitch).color(NamedTextColor.GOLD))
- );
-
- return Component.text("success");
+ return Component.empty()
+ .append(Component.text("Set the pitch to "))
+ .append(Component.text(pitch).color(NamedTextColor.GOLD));
}
public Component speed (CommandContext context, String[] args) {
@@ -364,13 +353,9 @@ public class MusicCommand implements Command {
bot.music().speed(speed);
- context.sendOutput(
- Component.empty()
- .append(Component.text("Set the speed to "))
- .append(Component.text(speed).color(NamedTextColor.GOLD))
- );
-
- return Component.text("success");
+ return Component.empty()
+ .append(Component.text("Set the speed to "))
+ .append(Component.text(speed).color(NamedTextColor.GOLD));
}
public Component pause (CommandContext context) {
@@ -381,13 +366,11 @@ public class MusicCommand implements Command {
if (currentSong.paused) {
currentSong.play();
- context.sendOutput(Component.text("Resumed the current song"));
+ return Component.text("Resumed the current song");
} else {
currentSong.pause();
- context.sendOutput(Component.text("Paused the current song"));
+ return Component.text("Paused the current song");
}
-
- return Component.text("success");
}
public Component info (CommandContext context) {
@@ -402,7 +385,7 @@ public class MusicCommand implements Command {
final String songOriginalAuthor = currentSong.songOriginalAuthor == null || currentSong.songOriginalAuthor.equals("") ? "N/A" : currentSong.songOriginalAuthor;
final String songDescription = currentSong.songDescription == null || currentSong.songDescription.equals("") ? "N/A" : currentSong.songDescription;
- final Component component = Component.translatable(
+ return Component.translatable(
"""
Title/Filename: %s
Author: %s
@@ -413,9 +396,5 @@ public class MusicCommand implements Command {
Component.text(songOriginalAuthor).color(NamedTextColor.AQUA),
Component.text(songDescription).color(NamedTextColor.AQUA)
).color(NamedTextColor.GOLD);
-
- context.sendOutput(component);
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/NetMessageCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/NetMessageCommand.java
index f47c9b0..31709c9 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/NetMessageCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/NetMessageCommand.java
@@ -65,6 +65,6 @@ public class NetMessageCommand implements Command {
allBot.chat().tellraw(component);
}
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RandomTeleportCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RandomTeleportCommand.java
index 5967a12..c897574 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RandomTeleportCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RandomTeleportCommand.java
@@ -45,17 +45,13 @@ public class RandomTeleportCommand implements Command {
final int positionZ = NumberUtilities.between(1_000, 1_000_000);
final String stringPosition = positionX + " 100 " + positionZ; // very 100 y
- context.sendOutput(
- Component.empty()
- .append(Component.text("Teleporting "))
- .append(Component.text(sender.profile().getName()).color(NamedTextColor.AQUA))
- .append(Component.text(" to ").color(NamedTextColor.WHITE))
- .append(Component.text(stringPosition).color(NamedTextColor.GREEN))
- .append(Component.text("...").color(NamedTextColor.WHITE))
- );
-
bot.core().run("essentials:teleport " + sender.profile().getIdAsString() + " " + stringPosition);
- return Component.text("success");
+ return Component.empty()
+ .append(Component.text("Teleporting "))
+ .append(Component.text(sender.profile().getName()).color(NamedTextColor.AQUA))
+ .append(Component.text(" to ").color(NamedTextColor.WHITE))
+ .append(Component.text(stringPosition).color(NamedTextColor.GREEN))
+ .append(Component.text("...").color(NamedTextColor.WHITE));
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RefillCoreCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RefillCoreCommand.java
index fc27d44..c86a0c8 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RefillCoreCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RefillCoreCommand.java
@@ -39,6 +39,6 @@ public class RefillCoreCommand implements Command {
bot.core().reset();
bot.core().refill();
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerEvalCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerEvalCommand.java
index 438db7b..1d8d913 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerEvalCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerEvalCommand.java
@@ -44,11 +44,9 @@ public class ServerEvalCommand implements Command {
final LuaValue output = context.bot().eval().run(String.join(" ", args));
- context.sendOutput(Component.text(output.toString()).color(NamedTextColor.GREEN));
+ return Component.text(output.toString()).color(NamedTextColor.GREEN);
} catch (Exception e) {
return Component.text(e.toString()).color(NamedTextColor.RED);
}
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java
index cd59c0a..9041024 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java
@@ -109,9 +109,9 @@ public class ServerInfoCommand implements Command {
).color(NamedTextColor.AQUA)
).color(NamedTextColor.GOLD);
- context.sendOutput(component);
+ return component;
} catch (UnknownHostException ignored) {}
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/SudoAllCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/SudoAllCommand.java
index 7ee88b1..304a818 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/SudoAllCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/SudoAllCommand.java
@@ -42,6 +42,6 @@ public class SudoAllCommand implements Command {
bot.core().run("essentials:sudo " + entry.profile().getName() + " " + String.join(" ", args));
}
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TPSBarCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TPSBarCommand.java
index a22972b..c7dc1dd 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TPSBarCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TPSBarCommand.java
@@ -40,25 +40,19 @@ public class TPSBarCommand implements Command {
switch (args[0]) {
case "on" -> {
bot.tps().on();
- context.sendOutput(
- Component.empty()
- .append(Component.text("TPSBar is now "))
- .append(Component.text("enabled").color(NamedTextColor.GREEN))
- );
+ return Component.empty()
+ .append(Component.text("TPSBar is now "))
+ .append(Component.text("enabled").color(NamedTextColor.GREEN));
}
case "off" -> {
bot.tps().off();
- context.sendOutput(
- Component.empty()
- .append(Component.text("TPSBar is now "))
- .append(Component.text("disabled").color(NamedTextColor.RED))
- );
+ return Component.empty()
+ .append(Component.text("TPSBar is now "))
+ .append(Component.text("disabled").color(NamedTextColor.RED));
}
default -> {
return Component.text("Invalid argument").color(NamedTextColor.RED);
}
}
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java
index 76a20bf..c5c940f 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java
@@ -34,16 +34,12 @@ public class TestCommand implements Command {
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
- final Component component = Component.translatable(
+ return Component.translatable(
"Hello, World! Username: %s, Sender UUID: %s, Prefix: %s, Args: %s",
Component.text(context.sender().profile().getName()),
Component.text(context.sender().profile().getIdAsString()),
Component.text(context.prefix()),
Component.text(String.join(", ", args))
).color(NamedTextColor.GREEN);
-
- context.sendOutput(component);
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TimeCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TimeCommand.java
index 04aeca1..69e7390 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TimeCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TimeCommand.java
@@ -53,14 +53,10 @@ public class TimeCommand implements Command {
final DateTimeFormatter formatter = DateTimeFormat.forPattern("EEEE, MMMM d, YYYY, hh:mm:ss a");
final String formattedTime = formatter.print(dateTime);
- context.sendOutput(
- Component.translatable(
- "The current date and time for the timezone %s is: %s",
- Component.text(timezone).color(NamedTextColor.AQUA),
- Component.text(formattedTime).color(NamedTextColor.GREEN)
- )
+ return Component.translatable(
+ "The current date and time for the timezone %s is: %s",
+ Component.text(timezone).color(NamedTextColor.AQUA),
+ Component.text(formattedTime).color(NamedTextColor.GREEN)
);
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TranslateCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TranslateCommand.java
index 2d7b03b..400c3f2 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TranslateCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TranslateCommand.java
@@ -74,18 +74,14 @@ public class TranslateCommand implements Command {
final String output = translation.get("trans").getAsString();
- context.sendOutput(
- Component
- .translatable(
- "Result: %s",
- Component.text(output).color(NamedTextColor.GREEN)
- )
- .color(NamedTextColor.GOLD)
- );
+ return Component
+ .translatable(
+ "Result: %s",
+ Component.text(output).color(NamedTextColor.GREEN)
+ )
+ .color(NamedTextColor.GOLD);
} catch (Exception e) {
return Component.text(e.toString()).color(NamedTextColor.RED);
}
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UUIDCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UUIDCommand.java
index f68505d..d4d7498 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UUIDCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UUIDCommand.java
@@ -48,46 +48,40 @@ public class UUIDCommand implements Command {
final String name = entry.profile().getName();
final String uuid = entry.profile().getIdAsString();
- context.sendOutput(
- Component.translatable(
- "%s's UUID: %s",
- Component.text(name),
- Component
- .text(uuid)
- .hoverEvent(
- HoverEvent.showText(
- Component.text("Click here to copy the UUID to your clipboard").color(NamedTextColor.GREEN)
- )
+ return Component.translatable(
+ "%s's UUID: %s",
+ Component.text(name),
+ Component
+ .text(uuid)
+ .hoverEvent(
+ HoverEvent.showText(
+ Component.text("Click here to copy the UUID to your clipboard").color(NamedTextColor.GREEN)
)
- .clickEvent(
- ClickEvent.copyToClipboard(uuid)
- )
- .color(NamedTextColor.AQUA)
- ).color(NamedTextColor.GREEN)
- );
+ )
+ .clickEvent(
+ ClickEvent.copyToClipboard(uuid)
+ )
+ .color(NamedTextColor.AQUA)
+ ).color(NamedTextColor.GREEN);
} else {
final MutablePlayerListEntry entry = context.sender();
final String uuid = entry.profile().getIdAsString();
- context.sendOutput(
- Component.translatable(
- "Your UUID: %s",
- Component
- .text(uuid)
- .hoverEvent(
- HoverEvent.showText(
- Component.text("Click here to copy the UUID to your clipboard").color(NamedTextColor.GREEN)
- )
+ return Component.translatable(
+ "Your UUID: %s",
+ Component
+ .text(uuid)
+ .hoverEvent(
+ HoverEvent.showText(
+ Component.text("Click here to copy the UUID to your clipboard").color(NamedTextColor.GREEN)
)
- .clickEvent(
- ClickEvent.copyToClipboard(uuid)
- )
- .color(NamedTextColor.AQUA)
- ).color(NamedTextColor.GREEN)
- );
+ )
+ .clickEvent(
+ ClickEvent.copyToClipboard(uuid)
+ )
+ .color(NamedTextColor.AQUA)
+ ).color(NamedTextColor.GREEN);
}
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UrbanCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UrbanCommand.java
index a42b046..0ecf2fd 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UrbanCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UrbanCommand.java
@@ -79,6 +79,6 @@ public class UrbanCommand implements Command {
return Component.text(e.toString()).color(NamedTextColor.RED);
}
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ValidateCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ValidateCommand.java
index 28391ba..9b643cc 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ValidateCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ValidateCommand.java
@@ -1,6 +1,5 @@
package land.chipmunk.chayapak.chomens_bot.commands;
-import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.command.Command;
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
import net.kyori.adventure.text.Component;
@@ -35,12 +34,11 @@ public class ValidateCommand implements Command {
}
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
- final Bot bot = context.bot();
final String hash = fullArgs[0];
- if (hash.equals(context.hash())) context.sendOutput(Component.text("Valid hash").color(NamedTextColor.GREEN));
- else if (hash.equals(context.ownerHash())) context.sendOutput(Component.text("Valid OwnerHash").color(NamedTextColor.GREEN));
+ if (hash.equals(context.hash())) return Component.text("Valid hash").color(NamedTextColor.GREEN);
+ else if (hash.equals(context.ownerHash())) return Component.text("Valid OwnerHash").color(NamedTextColor.GREEN);
- return Component.text("success");
+ return null;
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java
index 3319ea8..74bfb40 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java
@@ -73,7 +73,7 @@ public class WeatherCommand implements Command {
final String time = formatter.print(dateTime);
- final Component component = Component.translatable(
+ return Component.translatable(
"Weather forecast for %s, %s:\n%s, feels like %s\nTime: %s",
Component.text(jsonObject.get("location").getAsJsonObject().get("name").getAsString()).color(NamedTextColor.AQUA),
Component.text(jsonObject.get("location").getAsJsonObject().get("country").getAsString()).color(NamedTextColor.AQUA),
@@ -82,12 +82,8 @@ public class WeatherCommand implements Command {
Component.text(time).color(NamedTextColor.AQUA)
);
-
- context.sendOutput(component);
} catch (Exception e) {
return Component.text("Location \"" + location + "\" not found").color(NamedTextColor.RED);
}
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WikipediaCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WikipediaCommand.java
index d8886cf..9cd4ef8 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WikipediaCommand.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WikipediaCommand.java
@@ -58,15 +58,11 @@ public class WikipediaCommand implements Command {
final JsonObject jsonObject = gson.fromJson(jsonOutput, JsonObject.class);
- context.sendOutput(
- Component.text(jsonObject.get("extract").getAsString()).color(NamedTextColor.GREEN)
- );
+ return Component.text(jsonObject.get("extract").getAsString()).color(NamedTextColor.GREEN);
} catch (FileNotFoundException ignored) {
return Component.text("Cannot find page: " + page).color(NamedTextColor.RED);
} catch (Exception e) {
return Component.text(e.toString()).color(NamedTextColor.RED);
}
-
- return Component.text("success");
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatCommandHandlerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatCommandHandlerPlugin.java
index 97fb628..18d45f2 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatCommandHandlerPlugin.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatCommandHandlerPlugin.java
@@ -1,13 +1,12 @@
package land.chipmunk.chayapak.chomens_bot.plugins;
-import lombok.Getter;
import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.chatParsers.data.PlayerMessage;
import land.chipmunk.chayapak.chomens_bot.command.PlayerCommandContext;
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities;
+import lombok.Getter;
import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.TextComponent;
import java.util.List;
@@ -56,9 +55,8 @@ public class ChatCommandHandlerPlugin extends ChatPlugin.ChatListener {
final PlayerCommandContext context = new PlayerCommandContext(bot, displayName, prefix, selector, message.sender(), bot.hashing().hash(), bot.hashing().ownerHash());
final Component output = bot.commandHandler().executeCommand(commandString, context, true, false, false, bot.hashing().hash(), bot.hashing().ownerHash(), null);
- final String textOutput = ((TextComponent) output).content();
- if (!textOutput.equals("success")) {
+ if (output != null) {
context.sendOutput(output);
}
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java
index 72e3e50..5b1648c 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java
@@ -6,7 +6,6 @@ import land.chipmunk.chayapak.chomens_bot.command.ConsoleCommandContext;
import lombok.Getter;
import net.dv8tion.jda.api.JDA;
import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
@@ -90,9 +89,8 @@ public class ConsolePlugin {
final ConsoleCommandContext context = new ConsoleCommandContext(bot, prefix);
final Component output = bot.commandHandler().executeCommand(line.substring(prefix.length()), context, false, false, true, null, null, null);
- final String textOutput = ((TextComponent) output).content();
- if (!textOutput.equals("success")) {
+ if (output != null) {
context.sendOutput(output);
}
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java
index 8d78117..bad6e8e 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java
@@ -16,7 +16,6 @@ import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
@@ -79,10 +78,9 @@ public class DiscordPlugin {
final DiscordCommandContext context = new DiscordCommandContext(bot, prefix, event, null, null);
final Component output = bot.commandHandler().executeCommand(message.substring(prefix.length()), context, false, true, false, null, null, event);
- final String textOutput = ((TextComponent) output).content();
- if (!textOutput.equals("success")) {
- context.sendError(output);
+ if (output != null) {
+ context.sendOutput(output);
}
return;
diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/FilterPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/FilterPlugin.java
index 46113a3..8e4aa82 100644
--- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/FilterPlugin.java
+++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/FilterPlugin.java
@@ -93,8 +93,8 @@ public class FilterPlugin extends PlayersPlugin.PlayerListener {
filteredPlayers.add(new FilteredPlayer(playerName, regex, ignoreCase));
}
- public void remove (int index) {
- filteredPlayers.remove(index);
+ public FilteredPlayer remove (int index) {
+ return filteredPlayers.remove(index);
}
public void clear () {