From 5bb3b25b0a2a342ed37fb50842bf0a50cf7fd318 Mon Sep 17 00:00:00 2001 From: Tofpu Date: Sun, 28 Jan 2024 23:21:19 +0200 Subject: [PATCH] Add command descriptions --- .../bukkit/command/PluginCommandHolder.java | 16 +++++++--------- .../bukkit/command/subcommand/CoreCommand.java | 3 ++- .../bukkit/command/subcommand/GameCommand.java | 9 +++++---- .../bukkit/command/subcommand/SetupCommand.java | 3 +++ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/PluginCommandHolder.java b/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/PluginCommandHolder.java index aa4f50e1..f800e1a0 100644 --- a/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/PluginCommandHolder.java +++ b/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/PluginCommandHolder.java @@ -3,19 +3,12 @@ import com.github.tofpu.speedbridge2.bukkit.BukkitMessages; import com.github.tofpu.speedbridge2.bukkit.plugin.BukkitPlugin; import com.github.tofpu.speedbridge2.bukkit.util.MessageBuilder; -import com.github.tofpu.speedbridge2.common.game.BridgeSystem; import com.github.tofpu.speedbridge2.common.game.score.BridgeScoreService; import com.github.tofpu.speedbridge2.common.game.score.object.Score; -import com.github.tofpu.speedbridge2.common.island.IslandService; import com.github.tofpu.speedbridge2.common.lobby.LobbyService; -import com.github.tofpu.speedbridge2.common.setup.GameSetupSystem; import com.github.tofpu.speedbridge2.configuration.message.ConfigurableMessageService; import com.github.tofpu.speedbridge2.object.player.OnlinePlayer; -import revxrsal.commands.annotation.Command; -import revxrsal.commands.annotation.Default; -import revxrsal.commands.annotation.Optional; -import revxrsal.commands.annotation.Subcommand; -import revxrsal.commands.exception.CommandErrorException; +import revxrsal.commands.annotation.*; import revxrsal.commands.help.CommandHelp; import java.util.Map; @@ -38,6 +31,7 @@ public PluginCommandHolder(BukkitPlugin bukkitPlugin) { } @Subcommand("lobby") + @Description("Teleport to the lobby") public void lobby(final OnlinePlayer player) { if (!lobbyService.isLobbyAvailable()) { player.sendMessage(BukkitMessages.LOBBY_NOT_AVAILABLE); @@ -47,12 +41,14 @@ public void lobby(final OnlinePlayer player) { } @Subcommand("setlobby") + @Description("Set the lobby location") public void setLobby(final OnlinePlayer player) { lobbyService.updateLocation(player.getPosition()); player.sendMessage(BukkitMessages.LOBBY_SET); } @Subcommand("score") + @Description("View your score") public void score(final OnlinePlayer player, @Optional Integer islandSlot) { String message; if (islandSlot == null) { @@ -70,6 +66,7 @@ public void score(final OnlinePlayer player, @Optional Integer islandSlot) { } @Subcommand("help") + @Description("View the available commands") public void help(final OnlinePlayer player, final CommandHelp helpEntries, final @Default("1") int page) { MessageBuilder messageBuilder = new MessageBuilder() .appendNewLine() @@ -79,7 +76,7 @@ public void help(final OnlinePlayer player, final CommandHelp helpEntrie .append("&8|-> &7Author:").appendSpace().append("&fTofpu").appendNewLine() .append("&8|-> &7Discord:").appendSpace().append("&fhttps://discord.gg/cNwykvym2x").appendNewLine() .appendNewLine() - .append("&8&l|- &eCommands:").appendSpace().append("&7[" + page + " out of " + helpEntries.getPageSize(7) + " pages]").appendNewLine(); + .append("&8&l|- &eCommands:").appendSpace().append("&8[page " + page + " of " + helpEntries.getPageSize(7) + "]").appendNewLine(); for (String entry : helpEntries.paginate(page, 7)) { messageBuilder.append(entry).appendNewLine(); @@ -115,6 +112,7 @@ private String bestScoresOnAllIslands(OnlinePlayer player) { } @Subcommand("reload") + @Description("Reload plugin config") public void reload(final OnlinePlayer player) { try { configurableMessageService.reload(); diff --git a/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/CoreCommand.java b/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/CoreCommand.java index ffce54a1..25e9e61b 100644 --- a/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/CoreCommand.java +++ b/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/CoreCommand.java @@ -5,8 +5,8 @@ import com.github.tofpu.speedbridge2.object.player.OnlinePlayer; import org.apache.commons.lang.WordUtils; import org.jetbrains.annotations.NotNull; +import revxrsal.commands.annotation.Description; import revxrsal.commands.annotation.Subcommand; -import revxrsal.commands.help.CommandHelp; import revxrsal.commands.orphan.OrphanCommand; public abstract class CoreCommand implements OrphanCommand { @@ -14,6 +14,7 @@ public abstract class CoreCommand implements OrphanCommand { public abstract String name(); @Subcommand("help") + @Description("View the available commands") public void help(final OnlinePlayer player, final MinimalCommandHelp helpEntries) { MessageBuilder messageBuilder = new MessageBuilder() .appendNewLine() diff --git a/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/GameCommand.java b/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/GameCommand.java index 95e705b9..f8f20df9 100644 --- a/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/GameCommand.java +++ b/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/GameCommand.java @@ -2,13 +2,12 @@ import com.github.tofpu.speedbridge2.bukkit.BukkitMessages; import com.github.tofpu.speedbridge2.bukkit.command.annotation.RequireLobbyToBeAvailable; -import com.github.tofpu.speedbridge2.bukkit.util.MessageBuilder; import com.github.tofpu.speedbridge2.common.game.BridgeSystem; import com.github.tofpu.speedbridge2.common.island.Island; import com.github.tofpu.speedbridge2.object.player.OnlinePlayer; import org.jetbrains.annotations.NotNull; +import revxrsal.commands.annotation.Description; import revxrsal.commands.annotation.Subcommand; -import revxrsal.commands.help.CommandHelp; class GameCommand extends CoreCommand { private final BridgeSystem bridgeSystem; @@ -18,14 +17,16 @@ public GameCommand(BridgeSystem bridgeSystem) { } @Subcommand("join") + @Description("Join a game") @RequireLobbyToBeAvailable public void gameJoin(final OnlinePlayer player, final Island island) { bridgeSystem.joinGame(player, island); } - @Subcommand("end") + @Subcommand("leave") + @Description("Leave your game") @RequireLobbyToBeAvailable - public void gameEnd(final OnlinePlayer player) { + public void gameLeave(final OnlinePlayer player) { if (!bridgeSystem.isInGame(player.id())) { player.sendMessage(BukkitMessages.NOT_IN_GAME); return; diff --git a/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/SetupCommand.java b/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/SetupCommand.java index 4ed3f5dc..4d301603 100644 --- a/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/SetupCommand.java +++ b/platform/bukkit/src/main/java/com/github/tofpu/speedbridge2/bukkit/command/subcommand/SetupCommand.java @@ -6,6 +6,7 @@ import com.github.tofpu.speedbridge2.object.player.OnlinePlayer; import org.jetbrains.annotations.NotNull; import revxrsal.commands.annotation.AutoComplete; +import revxrsal.commands.annotation.Description; import revxrsal.commands.annotation.Subcommand; class SetupCommand extends CoreCommand { @@ -17,6 +18,7 @@ public SetupCommand(GameSetupSystem setupSystem) { @Subcommand("create") @AutoComplete("* @schematics") + @Description("Setup a game") @RequireLobbyToBeAvailable public void gameSetup(final OnlinePlayer player, final int slot, final String schematicName) { if (setupSystem.isInSetup(player.id())) { @@ -28,6 +30,7 @@ public void gameSetup(final OnlinePlayer player, final int slot, final String sc } @Subcommand("cancel") + @Description("Cancel your game setup") @RequireLobbyToBeAvailable public void gameSetupCancel(final OnlinePlayer player) { int setupSlot = setupSystem.getSetupSlot(player.id());