improve returning output of commands
This commit is contained in:
parent
287b02256e
commit
82f95139b0
40 changed files with 243 additions and 340 deletions
|
@ -4,9 +4,47 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="fix test?">
|
||||
<list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="actually improve the systemMessageReceived thing">
|
||||
<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/plugins/ChatPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/DiscordCommandContext.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/DiscordCommandContext.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/BotVisibilityCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotVisibilityCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BruhifyCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BruhifyCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatQueueCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ClearChatQueueCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CommandBlockCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CommandBlockCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CowsayCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CowsayCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/DiscordCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/DiscordCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EchoCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EchoCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EndCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/EndCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/FilterCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/FilterCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GenerateMazeCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GenerateMazeCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GrepLogCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GrepLogCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/KickCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/KickCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ListCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ListCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/NetMessageCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/NetMessageCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RandomTeleportCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RandomTeleportCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RefillCoreCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RefillCoreCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerEvalCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerEvalCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/SudoAllCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/SudoAllCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TPSBarCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TPSBarCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TestCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TimeCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TimeCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TranslateCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TranslateCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UUIDCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UUIDCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UrbanCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UrbanCommand.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ValidateCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ValidateCommand.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/plugins/ChatCommandHandlerPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatCommandHandlerPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/FilterPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/FilterPlugin.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -98,20 +136,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680245437032</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00064" summary="hopefully fix the core problem?">
|
||||
<created>1681607369880</created>
|
||||
<option name="number" value="00064" />
|
||||
<option name="presentableId" value="LOCAL-00064" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1681607369882</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00065" summary="maybe patch the sus">
|
||||
<created>1681613674861</created>
|
||||
<option name="number" value="00065" />
|
||||
<option name="presentableId" value="LOCAL-00065" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1681613674862</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00066" summary="fix music list it took me ages to figure this out that i need to just CLONE THE LIST">
|
||||
<created>1681617940254</created>
|
||||
<option name="number" value="00066" />
|
||||
|
@ -441,7 +465,21 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1682321509974</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="113" />
|
||||
<task id="LOCAL-00113" summary="fix extras chat">
|
||||
<created>1682322013136</created>
|
||||
<option name="number" value="00113" />
|
||||
<option name="presentableId" value="LOCAL-00113" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1682322013139</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00114" summary="actually improve the systemMessageReceived thing">
|
||||
<created>1682322237090</created>
|
||||
<option name="number" value="00114" />
|
||||
<option name="presentableId" value="LOCAL-00114" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1682322237090</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="115" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -456,8 +494,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="ig fix music filename mabe mabe" />
|
||||
<MESSAGE value="probally fix bossbar plugin with actionbar mabe" />
|
||||
<MESSAGE value="hopefully fix the broken players plugin" />
|
||||
<MESSAGE value="f" />
|
||||
<MESSAGE value="fard" />
|
||||
|
@ -481,7 +517,9 @@
|
|||
<MESSAGE value="fix chat (/say and /me) i guess" />
|
||||
<MESSAGE value="actually fix the fix the first "fix" is just fix like just fix,.., then the second one is the last commit, "fix chat (/say and /me) i guess"" />
|
||||
<MESSAGE value="fix test?" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="fix test?" />
|
||||
<MESSAGE value="fix extras chat" />
|
||||
<MESSAGE value="actually improve the systemMessageReceived thing" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="actually improve the systemMessageReceived thing" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,6 @@ public class BruhifyCommand implements Command {
|
|||
bot.bruhify().bruhifyText(String.join(" ", args));
|
||||
}
|
||||
|
||||
return Component.text("success");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,6 @@ public class ClearChatCommand implements Command {
|
|||
);
|
||||
}
|
||||
|
||||
return Component.text("success");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,6 @@ public class ClearChatQueueCommand implements Command {
|
|||
|
||||
bot.chat().queue().clear();
|
||||
|
||||
return Component.text("success");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Component> 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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,6 @@ public class CommandBlockCommand implements Command {
|
|||
return tags;
|
||||
});
|
||||
|
||||
return Component.text("success");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,6 @@ public class EchoCommand implements Command {
|
|||
|
||||
bot.chat().send(String.join(" ", args));
|
||||
|
||||
return Component.text("success");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,6 @@ public class EndCommand implements Command {
|
|||
|
||||
bot.session().disconnect("End command");
|
||||
|
||||
return Component.text("success");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Component> 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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,6 @@ public class GenerateMazeCommand implements Command {
|
|||
return Component.text("Invalid position/size").color(NamedTextColor.RED);
|
||||
}
|
||||
|
||||
return Component.text("success");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Component> 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<Component> 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);
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Song> queue = bot.music().songQueue();
|
||||
|
||||
final List<Component> 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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,6 @@ public class NetMessageCommand implements Command {
|
|||
allBot.chat().tellraw(component);
|
||||
}
|
||||
|
||||
return Component.text("success");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,6 @@ public class RefillCoreCommand implements Command {
|
|||
bot.core().reset();
|
||||
bot.core().refill();
|
||||
|
||||
return Component.text("success");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,6 @@ public class UrbanCommand implements Command {
|
|||
return Component.text(e.toString()).color(NamedTextColor.RED);
|
||||
}
|
||||
|
||||
return Component.text("success");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Reference in a new issue