Skip to content

Commit

Permalink
Add command descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofpu committed Jan 28, 2024
1 parent 0e7419c commit 5bb3b25
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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<String> helpEntries, final @Default("1") int page) {
MessageBuilder messageBuilder = new MessageBuilder()
.appendNewLine()
Expand All @@ -79,7 +76,7 @@ public void help(final OnlinePlayer player, final CommandHelp<String> 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();
Expand Down Expand Up @@ -115,6 +112,7 @@ private String bestScoresOnAllIslands(OnlinePlayer player) {
}

@Subcommand("reload")
@Description("Reload plugin config")
public void reload(final OnlinePlayer player) {
try {
configurableMessageService.reload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
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 {
@NotNull
public abstract String name();

@Subcommand("help")
@Description("View the available commands")
public void help(final OnlinePlayer player, final MinimalCommandHelp<String> helpEntries) {
MessageBuilder messageBuilder = new MessageBuilder()
.appendNewLine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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())) {
Expand All @@ -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());
Expand Down

0 comments on commit 5bb3b25

Please sign in to comment.