From 2d7dd0433d4bd85c824e2dea64e0ca4734d1f79c Mon Sep 17 00:00:00 2001 From: "BT (calcastor/mame)" <43831917+calcastor@users.noreply.github.com> Date: Wed, 15 May 2024 15:38:38 -0700 Subject: [PATCH] wip: Update to Cloud 2.0 Signed-off-by: BT (calcastor/mame) <43831917+calcastor@users.noreply.github.com> Co-authored-by: Pablo Herrera --- core/pom.xml | 10 +- .../java/tc/oc/pgm/command/ActionCommand.java | 39 ++++---- .../java/tc/oc/pgm/command/AdminCommand.java | 16 ++-- .../java/tc/oc/pgm/command/CancelCommand.java | 10 +- .../java/tc/oc/pgm/command/ClassCommand.java | 12 +-- .../java/tc/oc/pgm/command/CycleCommand.java | 20 ++-- .../java/tc/oc/pgm/command/FinishCommand.java | 12 +-- .../tc/oc/pgm/command/FreeForAllCommand.java | 30 +++--- .../tc/oc/pgm/command/InventoryCommand.java | 12 +-- .../java/tc/oc/pgm/command/JoinCommand.java | 20 ++-- .../java/tc/oc/pgm/command/ListCommand.java | 6 +- .../java/tc/oc/pgm/command/MapCommand.java | 25 ++--- .../java/tc/oc/pgm/command/MapDevCommand.java | 31 ++++--- .../tc/oc/pgm/command/MapOrderCommand.java | 21 +++-- .../tc/oc/pgm/command/MapPoolCommand.java | 59 ++++++------ .../java/tc/oc/pgm/command/MatchCommand.java | 6 +- .../java/tc/oc/pgm/command/ModeCommand.java | 33 +++---- .../tc/oc/pgm/command/ProximityCommand.java | 6 +- .../tc/oc/pgm/command/RestartCommand.java | 14 +-- .../tc/oc/pgm/command/SettingCommand.java | 14 +-- .../tc/oc/pgm/command/ShowXmlCommand.java | 14 +-- .../java/tc/oc/pgm/command/StartCommand.java | 12 +-- .../java/tc/oc/pgm/command/StatsCommand.java | 6 +- .../java/tc/oc/pgm/command/TeamCommand.java | 46 +++++----- .../tc/oc/pgm/command/TimeLimitCommand.java | 15 +-- .../java/tc/oc/pgm/command/VanishCommand.java | 12 +-- .../java/tc/oc/pgm/command/VotingCommand.java | 30 +++--- .../command/injectors/AudienceProvider.java | 8 +- .../command/injectors/MapPollProvider.java | 8 +- .../injectors/MapPoolManagerProvider.java | 8 +- .../MatchModuleInjectionService.java | 16 ++-- .../injectors/MatchObjectProvider.java | 8 +- .../injectors/MatchPlayerProvider.java | 10 +- .../pgm/command/injectors/PlayerProvider.java | 10 +- .../pgm/command/parsers/DurationParser.java | 39 ++++---- .../tc/oc/pgm/command/parsers/EnumParser.java | 34 ++++--- .../command/parsers/ExposedActionParser.java | 4 +- .../command/parsers/FilterArgumentParser.java | 4 +- .../oc/pgm/command/parsers/MapInfoParser.java | 23 ++--- .../oc/pgm/command/parsers/MapPoolParser.java | 32 ++++--- .../command/parsers/MatchObjectParser.java | 25 ++--- .../command/parsers/MatchPlayerParser.java | 25 ++--- .../tc/oc/pgm/command/parsers/ModeParser.java | 4 +- .../command/parsers/OfflinePlayerParser.java | 43 ++++----- .../tc/oc/pgm/command/parsers/ParseUtils.java | 23 +++++ .../oc/pgm/command/parsers/PartyParser.java | 28 +++--- .../command/parsers/PlayerClassParser.java | 4 +- .../oc/pgm/command/parsers/PlayerParser.java | 42 ++++----- .../pgm/command/parsers/RotationParser.java | 24 +++-- .../command/parsers/SettingValueParser.java | 2 +- .../pgm/command/parsers/StringLikeParser.java | 22 ++--- .../tc/oc/pgm/command/parsers/TeamParser.java | 4 +- .../oc/pgm/command/parsers/TeamsParser.java | 28 +++--- .../pgm/command/parsers/VariableParser.java | 4 +- .../parsers/VictoryConditionParser.java | 32 +++---- .../tc/oc/pgm/command/util/CommandGraph.java | 91 ++++++++----------- .../tc/oc/pgm/command/util/CommandKeys.java | 15 +-- .../tc/oc/pgm/command/util/CommandUtils.java | 4 +- .../oc/pgm/command/util/PGMCommandGraph.java | 44 ++------- .../tc/oc/pgm/command/util/ParserBuilder.java | 6 +- .../tc/oc/pgm/listeners/ChatDispatcher.java | 22 ++--- .../src/main/java/tc/oc/pgm/util/Players.java | 11 +-- pom.xml | 16 ++-- .../main/java/tc/oc/pgm/util/StringUtils.java | 14 ++- 64 files changed, 635 insertions(+), 633 deletions(-) create mode 100644 core/src/main/java/tc/oc/pgm/command/parsers/ParseUtils.java diff --git a/core/pom.xml b/core/pom.xml index a503fd216d..75eb8a23b5 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -41,9 +41,9 @@ - cloud.commandframework + org.incendo cloud-annotations - 1.8.4 + 2.0.0-rc.1 @@ -61,7 +61,7 @@ tc.oc.pgm:*:* org.jdom:jdom2:* net.kyori:*:* - cloud.commandframework:cloud-*:* + org.incendo:cloud-*:* io.leangen.geantyref:*:* me.lucko:commodore fr.mrmicky:*:* @@ -82,8 +82,8 @@ - cloud.commandframework - tc.oc.pgm.lib.cloud.commandframework + org.incendo.cloud + tc.oc.pgm.lib.org.incendo.cloud io.leangen.geantyref diff --git a/core/src/main/java/tc/oc/pgm/command/ActionCommand.java b/core/src/main/java/tc/oc/pgm/command/ActionCommand.java index c95bf01df3..cea3cb4b5f 100644 --- a/core/src/main/java/tc/oc/pgm/command/ActionCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/ActionCommand.java @@ -3,18 +3,19 @@ import static net.kyori.adventure.text.Component.text; import static tc.oc.pgm.command.util.ParserConstants.CURRENT; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; -import cloud.commandframework.annotations.Flag; -import cloud.commandframework.annotations.specifier.Greedy; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.command.CommandSender; +import org.incendo.cloud.annotation.specifier.Greedy; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Default; +import org.incendo.cloud.annotations.Flag; +import org.incendo.cloud.annotations.Permission; import tc.oc.pgm.action.ActionMatchModule; import tc.oc.pgm.action.actions.ExposedAction; import tc.oc.pgm.api.Permissions; @@ -24,30 +25,30 @@ import tc.oc.pgm.util.PrettyPaginatedComponentResults; import tc.oc.pgm.util.text.TextFormatter; -@CommandMethod("action|actions") +@Command("action|actions") public class ActionCommand { - @CommandMethod("[page]") + @Command("[page]") @CommandDescription("List available exposed actions") - @CommandPermission(Permissions.GAMEPLAY) + @Permission(Permissions.GAMEPLAY) public void fallback( Audience audience, CommandSender sender, ActionMatchModule amm, - @Argument(value = "page", defaultValue = "1") int page, + @Argument("page") @Default("1") int page, @Flag(value = "query", aliases = "q") String query, @Flag(value = "all", aliases = "a") boolean all) { list(audience, sender, amm, page, query, all); } - @CommandMethod("list|page [page]") + @Command("list|page [page]") @CommandDescription("List available exposed actions") - @CommandPermission(Permissions.GAMEPLAY) + @Permission(Permissions.GAMEPLAY) public void list( Audience audience, CommandSender sender, ActionMatchModule amm, - @Argument(value = "page", defaultValue = "1") int page, + @Argument(value = "page") @Default("1") int page, @Flag(value = "query", aliases = "q") String query, @Flag(value = "all", aliases = "a") boolean all) { @@ -74,24 +75,24 @@ public void list( (v, i) -> text((i + 1) + ". ").append(text(v.getId(), NamedTextColor.AQUA))); } - @CommandMethod("trigger [target]") + @Command("trigger [target]") @CommandDescription("Trigger a specific action") - @CommandPermission(Permissions.GAMEPLAY) + @Permission(Permissions.GAMEPLAY) public > void triggerAction( Audience audience, @Argument("action") @Greedy ExposedAction action, - @Argument(value = "target", defaultValue = CURRENT) MatchPlayer target) { + @Argument(value = "target") @Default(CURRENT) MatchPlayer target) { action.trigger(target); audience.sendMessage(text("Triggered " + action.getId())); } - @CommandMethod("untrigger [target]") + @Command("untrigger [target]") @CommandDescription("Untrigger a specific action") - @CommandPermission(Permissions.GAMEPLAY) + @Permission(Permissions.GAMEPLAY) public > void untriggerAction( Audience audience, @Argument("action") @Greedy ExposedAction action, - @Argument(value = "target", defaultValue = CURRENT) MatchPlayer target) { + @Argument(value = "target") @Default(CURRENT) MatchPlayer target) { action.untrigger(target); audience.sendMessage(text("Untriggered " + action.getId())); } diff --git a/core/src/main/java/tc/oc/pgm/command/AdminCommand.java b/core/src/main/java/tc/oc/pgm/command/AdminCommand.java index 7437a7e115..8c314ae7be 100644 --- a/core/src/main/java/tc/oc/pgm/command/AdminCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/AdminCommand.java @@ -1,25 +1,25 @@ package tc.oc.pgm.command; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; -import cloud.commandframework.annotations.Flag; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Flag; +import org.incendo.cloud.annotations.Permission; import tc.oc.pgm.api.PGM; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.map.MapLibrary; public final class AdminCommand { - @CommandMethod("pgm reload") + @Command("pgm reload") @CommandDescription("Reload the config") - @CommandPermission(Permissions.RELOAD) + @Permission(Permissions.RELOAD) public void pgm() { PGM.get().reloadConfig(); } - @CommandMethod("loadnewmaps|findnewmaps|newmaps") + @Command("loadnewmaps|findnewmaps|newmaps") @CommandDescription("Reload the config") - @CommandPermission(Permissions.RELOAD) + @Permission(Permissions.RELOAD) public void loadNewMaps(MapLibrary library, @Flag(value = "force", aliases = "f") boolean force) { library.loadNewMaps(force); } diff --git a/core/src/main/java/tc/oc/pgm/command/CancelCommand.java b/core/src/main/java/tc/oc/pgm/command/CancelCommand.java index de2e8bf333..96aa4d7eaf 100644 --- a/core/src/main/java/tc/oc/pgm/command/CancelCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/CancelCommand.java @@ -3,11 +3,11 @@ import static net.kyori.adventure.text.Component.translatable; import static tc.oc.pgm.util.player.PlayerComponent.player; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.command.CommandSender; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Permission; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.match.Match; import tc.oc.pgm.listeners.ChatDispatcher; @@ -21,9 +21,9 @@ public final class CancelCommand { - @CommandMethod("cancel|cancelrestart|cr") + @Command("cancel|cancelrestart|cr") @CommandDescription("Cancels all countdowns") - @CommandPermission(Permissions.STOP) + @Permission(Permissions.STOP) public void cancel(CommandSender sender, Audience audience, Match match) { if (RestartManager.isQueued()) { match.callEvent(new CancelRestartEvent()); diff --git a/core/src/main/java/tc/oc/pgm/command/ClassCommand.java b/core/src/main/java/tc/oc/pgm/command/ClassCommand.java index e61211fd6c..73d080ae28 100644 --- a/core/src/main/java/tc/oc/pgm/command/ClassCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/ClassCommand.java @@ -4,13 +4,13 @@ import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.translatable; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.specifier.Greedy; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; +import org.incendo.cloud.annotation.specifier.Greedy; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; import tc.oc.pgm.api.player.MatchPlayer; import tc.oc.pgm.classes.ClassMatchModule; import tc.oc.pgm.classes.PlayerClass; @@ -18,7 +18,7 @@ public final class ClassCommand { - @CommandMethod("class|selectclass|c|cl [class]") + @Command("class|selectclass|c|cl [class]") @CommandDescription("Select your class") public void classSelect( ClassMatchModule classes, @@ -46,7 +46,7 @@ public void classSelect( } } - @CommandMethod("classlist|classes|listclasses|cls") + @Command("classlist|classes|listclasses|cls") @CommandDescription("List all available classes") public void classList(ClassMatchModule classes, MatchPlayer player) { final PlayerClass currentClass = classes.getSelectedClass(player.getId()); diff --git a/core/src/main/java/tc/oc/pgm/command/CycleCommand.java b/core/src/main/java/tc/oc/pgm/command/CycleCommand.java index d4cb9c79a0..213b931ab5 100644 --- a/core/src/main/java/tc/oc/pgm/command/CycleCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/CycleCommand.java @@ -2,14 +2,14 @@ import static tc.oc.pgm.util.text.TextException.exception; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; -import cloud.commandframework.annotations.Flag; -import cloud.commandframework.annotations.specifier.FlagYielding; import java.time.Duration; import org.bukkit.command.CommandSender; +import org.incendo.cloud.annotation.specifier.FlagYielding; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Flag; +import org.incendo.cloud.annotations.Permission; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.map.MapInfo; import tc.oc.pgm.api.map.MapOrder; @@ -18,9 +18,9 @@ public final class CycleCommand { - @CommandMethod("cycle [duration] [map]") + @Command("cycle [duration] [map]") @CommandDescription("Cycle to the next match") - @CommandPermission(Permissions.START) + @Permission(Permissions.START) public void cycle( CommandSender sender, Match match, @@ -40,9 +40,9 @@ public void cycle( match.needModule(CycleMatchModule.class).startCountdown(duration); } - @CommandMethod("recycle|rematch [duration]") + @Command("recycle|rematch [duration]") @CommandDescription("Reload (cycle to) the current map") - @CommandPermission(Permissions.START) + @Permission(Permissions.START) public void recycle( CommandSender sender, Match match, diff --git a/core/src/main/java/tc/oc/pgm/command/FinishCommand.java b/core/src/main/java/tc/oc/pgm/command/FinishCommand.java index b41dd3d15a..c05e6d67d0 100644 --- a/core/src/main/java/tc/oc/pgm/command/FinishCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/FinishCommand.java @@ -2,19 +2,19 @@ import static tc.oc.pgm.util.text.TextException.exception; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Permission; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.match.Match; import tc.oc.pgm.teams.Team; public final class FinishCommand { - @CommandMethod("finish|end [team]") + @Command("finish|end [team]") @CommandDescription("End the match") - @CommandPermission(Permissions.STOP) + @Permission(Permissions.STOP) public void end(Match match, @Argument("team") Team team) { if (!match.finish(team)) { throw exception("admin.end.unknownError"); diff --git a/core/src/main/java/tc/oc/pgm/command/FreeForAllCommand.java b/core/src/main/java/tc/oc/pgm/command/FreeForAllCommand.java index 8ade751bbe..d3be7c8e24 100644 --- a/core/src/main/java/tc/oc/pgm/command/FreeForAllCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/FreeForAllCommand.java @@ -4,13 +4,13 @@ import static net.kyori.adventure.text.Component.translatable; import static tc.oc.pgm.util.player.PlayerComponent.player; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; import com.google.common.collect.Range; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.command.CommandSender; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Permission; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.match.Match; import tc.oc.pgm.ffa.FreeForAllMatchModule; @@ -18,12 +18,12 @@ import tc.oc.pgm.util.named.NameStyle; import tc.oc.pgm.util.text.TextParser; -@CommandMethod("ffa|players") +@Command("ffa|players") public final class FreeForAllCommand { - @CommandMethod("min ") + @Command("min ") @CommandDescription("Set the min players") - @CommandPermission(Permissions.RESIZE) + @Permission(Permissions.RESIZE) public void min( Match match, CommandSender sender, @@ -35,17 +35,17 @@ public void min( sendResizedMessage(match, sender, "min", ffa.getMinPlayers()); } - @CommandMethod("min reset") + @Command("min reset") @CommandDescription("Reset the min players") - @CommandPermission(Permissions.RESIZE) + @Permission(Permissions.RESIZE) public void min(Match match, CommandSender sender, FreeForAllMatchModule ffa) { ffa.setMinPlayers(null); sendResizedMessage(match, sender, "min", ffa.getMinPlayers()); } - @CommandMethod("scale ") + @Command("scale ") @CommandDescription("Scale the max players by a given factor") - @CommandPermission(Permissions.RESIZE) + @Permission(Permissions.RESIZE) public void max( Match match, CommandSender sender, @@ -58,9 +58,9 @@ public void max( sendResizedMessage(match, sender, "max", ffa.getMaxPlayers()); } - @CommandMethod("max [max-overfill]") + @Command("max [max-overfill]") @CommandDescription("Set the max players") - @CommandPermission(Permissions.RESIZE) + @Permission(Permissions.RESIZE) public void max( Match match, CommandSender sender, @@ -77,9 +77,9 @@ public void max( sendResizedMessage(match, sender, "max", ffa.getMaxPlayers()); } - @CommandMethod("max reset") + @Command("max reset") @CommandDescription("Reset the max players") - @CommandPermission(Permissions.RESIZE) + @Permission(Permissions.RESIZE) public void max(Match match, CommandSender sender, FreeForAllMatchModule ffa) { ffa.setMaxPlayers(null, null); sendResizedMessage(match, sender, "max", ffa.getMaxPlayers()); diff --git a/core/src/main/java/tc/oc/pgm/command/InventoryCommand.java b/core/src/main/java/tc/oc/pgm/command/InventoryCommand.java index 82435fb6ce..2b9e9f6dce 100644 --- a/core/src/main/java/tc/oc/pgm/command/InventoryCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/InventoryCommand.java @@ -2,18 +2,18 @@ import static tc.oc.pgm.util.text.TextException.exception; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Permission; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.player.MatchPlayer; import tc.oc.pgm.inventory.ViewInventoryMatchModule; public final class InventoryCommand { - @CommandMethod("inventory|inv|vi ") + @Command("inventory|inv|vi ") @CommandDescription("View a player's inventory") - @CommandPermission(Permissions.VIEW_INVENTORY) + @Permission(Permissions.VIEW_INVENTORY) public void inventory( ViewInventoryMatchModule inventories, MatchPlayer viewer, diff --git a/core/src/main/java/tc/oc/pgm/command/JoinCommand.java b/core/src/main/java/tc/oc/pgm/command/JoinCommand.java index 3fe2a7bf1d..cc8a16808f 100644 --- a/core/src/main/java/tc/oc/pgm/command/JoinCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/JoinCommand.java @@ -1,11 +1,11 @@ package tc.oc.pgm.command; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; -import cloud.commandframework.annotations.Flag; -import cloud.commandframework.annotations.specifier.FlagYielding; +import org.incendo.cloud.annotation.specifier.FlagYielding; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Flag; +import org.incendo.cloud.annotations.Permission; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.party.Competitor; import tc.oc.pgm.api.party.Party; @@ -15,9 +15,9 @@ public final class JoinCommand { - @CommandMethod("join|play [team]") + @Command("join|play [team]") @CommandDescription("Join the match") - @CommandPermission(Permissions.JOIN) + @Permission(Permissions.JOIN) public void join( JoinMatchModule joiner, MatchPlayer player, @@ -35,9 +35,9 @@ public void join( } } - @CommandMethod("leave|obs|spectator|spec") + @Command("leave|obs|spectator|spec") @CommandDescription("Leave the match") - @CommandPermission(Permissions.LEAVE) + @Permission(Permissions.LEAVE) public void leave(JoinMatchModule joiner, MatchPlayer player) { joiner.leave(player, JoinRequest.empty()); } diff --git a/core/src/main/java/tc/oc/pgm/command/ListCommand.java b/core/src/main/java/tc/oc/pgm/command/ListCommand.java index aa6d8b231e..b6b7cdaff0 100644 --- a/core/src/main/java/tc/oc/pgm/command/ListCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/ListCommand.java @@ -5,14 +5,14 @@ import static net.kyori.adventure.text.Component.translatable; import static tc.oc.pgm.api.integration.Integration.isVanished; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.command.CommandSender; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.match.Match; import tc.oc.pgm.api.player.MatchPlayer; @@ -24,7 +24,7 @@ public final class ListCommand { - @CommandMethod("list|who|online|ls") + @Command("list|who|online|ls") @CommandDescription("View a list of online players") public void list(CommandSender sender, Audience viewer, Match match) { TeamMatchModule tmm = match.getModule(TeamMatchModule.class); diff --git a/core/src/main/java/tc/oc/pgm/command/MapCommand.java b/core/src/main/java/tc/oc/pgm/command/MapCommand.java index 9298c9a8a6..ee89c5f59a 100644 --- a/core/src/main/java/tc/oc/pgm/command/MapCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/MapCommand.java @@ -10,14 +10,6 @@ import static tc.oc.pgm.command.util.ParserConstants.CURRENT; import static tc.oc.pgm.util.Assert.assertNotNull; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.Flag; -import cloud.commandframework.annotations.specifier.Greedy; -import cloud.commandframework.annotations.specifier.Range; -import cloud.commandframework.annotations.suggestions.Suggestions; -import cloud.commandframework.context.CommandContext; import com.google.common.collect.ImmutableList; import java.time.LocalDate; import java.time.format.DateTimeFormatter; @@ -32,6 +24,15 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.command.CommandSender; +import org.incendo.cloud.annotation.specifier.Greedy; +import org.incendo.cloud.annotation.specifier.Range; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Default; +import org.incendo.cloud.annotations.Flag; +import org.incendo.cloud.annotations.suggestion.Suggestions; +import org.incendo.cloud.context.CommandContext; import org.jetbrains.annotations.NotNull; import org.yaml.snakeyaml.util.UriEncoder; import tc.oc.pgm.api.PGM; @@ -55,13 +56,13 @@ public final class MapCommand { - @CommandMethod("maps|maplist|ml [page]") + @Command("maps|maplist|ml [page]") @CommandDescription("List all maps loaded") public void maps( Audience audience, CommandSender sender, MapLibrary library, - @Argument(value = "page", defaultValue = "1") @Range(min = "1") int page, + @Argument(value = "page") @Default("1") @Range(min = "1") int page, @Flag(value = "tags", aliases = "t", repeatable = true, suggestions = "maptags") List tags, @Flag(value = "author", aliases = "a") String author, @@ -172,12 +173,12 @@ private static boolean matchesAuthor(MapInfo map, String query, boolean exact) { return false; } - @CommandMethod("map|mapinfo [map]") + @Command("map|mapinfo [map]") @CommandDescription("Show info about a map") public void map( Audience audience, CommandSender sender, - @Argument(value = "map", defaultValue = CURRENT) @Greedy MapInfo map) { + @Argument(value = "map") @Default(CURRENT) @Greedy MapInfo map) { audience.sendMessage( TextFormatter.horizontalLineHeading( sender, diff --git a/core/src/main/java/tc/oc/pgm/command/MapDevCommand.java b/core/src/main/java/tc/oc/pgm/command/MapDevCommand.java index e067d0bc32..2b684c2aea 100644 --- a/core/src/main/java/tc/oc/pgm/command/MapDevCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/MapDevCommand.java @@ -4,11 +4,6 @@ import static net.kyori.adventure.text.Component.text; import static tc.oc.pgm.command.util.ParserConstants.CURRENT; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; -import cloud.commandframework.annotations.Flag; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; @@ -17,6 +12,12 @@ import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.command.CommandSender; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Default; +import org.incendo.cloud.annotations.Flag; +import org.incendo.cloud.annotations.Permission; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.filter.Filter; import tc.oc.pgm.api.match.Match; @@ -32,15 +33,15 @@ public class MapDevCommand { // Avoid showing too many values. Messages that are too long kick the client. private static final int ARRAY_CAP = 16; - @CommandMethod("variables [target] [page]") + @Command("variables [target] [page]") @CommandDescription("Inspect variables for a player") - @CommandPermission(Permissions.DEBUG) + @Permission(Permissions.DEBUG) public void showVariables( Audience audience, CommandSender sender, Match match, - @Argument(value = "target", defaultValue = CURRENT) MatchPlayer target, - @Argument(value = "page", defaultValue = "1") int page, + @Argument(value = "target") @Default(CURRENT) MatchPlayer target, + @Argument(value = "page") @Default("1") int page, @Flag(value = "query", aliases = "q") String query, @Flag(value = "all", aliases = "a") boolean all) { @@ -90,15 +91,15 @@ public void showVariables( }); } - @CommandMethod("variable set [target]") + @Command("variable set [target]") @CommandDescription("Inspect variables for a player") - @CommandPermission(Permissions.DEBUG) + @Permission(Permissions.DEBUG) @SuppressWarnings({"rawtypes", "unchecked"}) public void setVariable( Audience audience, @Argument("variable") Variable variable, @Argument("value") double value, - @Argument(value = "target", defaultValue = CURRENT) MatchPlayer target) { + @Argument(value = "target") @Default(CURRENT) MatchPlayer target) { variable.setValue(target, value); audience.sendMessage( text("Variable ", NamedTextColor.YELLOW) @@ -109,13 +110,13 @@ public void setVariable( .append(target.getName())); } - @CommandMethod("filter [target]") + @Command("filter [target]") @CommandDescription("Match a filter against a player") - @CommandPermission(Permissions.DEBUG) + @Permission(Permissions.DEBUG) public void evaluateFilter( Audience audience, @Argument("filter") Filter filter, - @Argument(value = "target", defaultValue = CURRENT) MatchPlayer target) { + @Argument(value = "target") @Default(CURRENT) MatchPlayer target) { audience.sendMessage( text("Filter responded with ", NamedTextColor.YELLOW) .append(text(filter.query(target) + "", NamedTextColor.AQUA)) diff --git a/core/src/main/java/tc/oc/pgm/command/MapOrderCommand.java b/core/src/main/java/tc/oc/pgm/command/MapOrderCommand.java index 8c28d3f3c1..2c2bebab02 100644 --- a/core/src/main/java/tc/oc/pgm/command/MapOrderCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/MapOrderCommand.java @@ -5,15 +5,16 @@ import static tc.oc.pgm.command.util.ParserConstants.CURRENT; import static tc.oc.pgm.util.text.TextException.exception; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; -import cloud.commandframework.annotations.Flag; -import cloud.commandframework.annotations.specifier.FlagYielding; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.command.CommandSender; +import org.incendo.cloud.annotation.specifier.FlagYielding; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Default; +import org.incendo.cloud.annotations.Flag; +import org.incendo.cloud.annotations.Permission; import org.jetbrains.annotations.NotNull; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.map.MapInfo; @@ -27,7 +28,7 @@ public final class MapOrderCommand { - @CommandMethod("nextmap|mn|mapnext|nm|next") + @Command("nextmap|mn|mapnext|nm|next") @CommandDescription("Show which map is playing next") public void nextmap(Audience audience, MapOrder mapOrder) { final MapInfo next = mapOrder.getNextMap(); @@ -41,9 +42,9 @@ public void nextmap(Audience audience, MapOrder mapOrder) { next.getStyledName(MapNameStyle.COLOR_WITH_AUTHORS))); } - @CommandMethod("setnext|sn [map]") + @Command("setnext|sn [map]") @CommandDescription("Change the next map") - @CommandPermission(Permissions.SETNEXT) + @Permission(Permissions.SETNEXT) public void setNext( Audience viewer, CommandSender sender, @@ -51,7 +52,7 @@ public void setNext( Match match, @Flag(value = "force", aliases = "f") boolean force, @Flag(value = "reset", aliases = "r") boolean reset, - @Argument(value = "map", defaultValue = CURRENT) @FlagYielding MapInfo map) { + @Argument(value = "map") @Default(CURRENT) @FlagYielding MapInfo map) { if (RestartManager.isQueued() && !force) { throw exception("map.setNext.confirm"); } diff --git a/core/src/main/java/tc/oc/pgm/command/MapPoolCommand.java b/core/src/main/java/tc/oc/pgm/command/MapPoolCommand.java index 5f3d4e163e..fe314d99a0 100644 --- a/core/src/main/java/tc/oc/pgm/command/MapPoolCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/MapPoolCommand.java @@ -6,14 +6,6 @@ import static net.kyori.adventure.text.event.HoverEvent.showText; import static tc.oc.pgm.util.text.TextException.exception; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; -import cloud.commandframework.annotations.Flag; -import cloud.commandframework.annotations.injection.RawArgs; -import cloud.commandframework.annotations.specifier.FlagYielding; -import cloud.commandframework.annotations.specifier.Range; import java.text.DecimalFormat; import java.time.Duration; import java.util.Comparator; @@ -28,6 +20,15 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.command.CommandSender; +import org.incendo.cloud.annotation.specifier.FlagYielding; +import org.incendo.cloud.annotation.specifier.Range; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Default; +import org.incendo.cloud.annotations.Flag; +import org.incendo.cloud.annotations.Permission; +import org.incendo.cloud.annotations.injection.RawArgs; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.map.MapInfo; import tc.oc.pgm.api.match.Match; @@ -49,13 +50,13 @@ public final class MapPoolCommand { private static final DecimalFormat SCORE_FORMAT = new DecimalFormat("00.00%"); - @CommandMethod("pool [page]") + @Command("pool [page]") @CommandDescription("List the maps in the map pool") public void pool( Audience sender, CommandSender source, MapPoolManager poolManager, - @Argument(value = "page", defaultValue = "1") @Range(min = "1") int page, + @Argument(value = "page") @Default("1") @Range(min = "1") int page, @Flag(value = "type", aliases = "t") MapPoolType type, @Flag(value = "pool", aliases = "p") MapPool mapPool, @Flag(value = "score", aliases = "s") boolean scores, @@ -133,13 +134,13 @@ public Component format(MapInfo map, int index) { }.display(sender, maps, page); } - @CommandMethod("pools [page]") + @Command("pools [page]") @CommandDescription("List all the map pools") public void pools( Audience sender, CommandSender source, MapPoolManager poolManager, - @Argument(value = "page", defaultValue = "1") @Range(min = "1") int page, + @Argument(value = "page") @Default("1") @Range(min = "1") int page, @Flag(value = "type", aliases = "t") MapPoolType type, @Flag(value = "dynamic", aliases = "d") boolean dynamicOnly) { @@ -205,9 +206,9 @@ public Component format(MapPool mapPool, int index) { }.display(sender, mapPools, page); } - @CommandMethod("setpool ") + @Command("setpool ") @CommandDescription("Change the map pool") - @CommandPermission(Permissions.SETNEXT) + @Permission(Permissions.SETNEXT) public void setPool( Audience sender, CommandSender source, @@ -234,9 +235,9 @@ public void setPool( newPool, match, true, source, timeLimit, matchLimit != null ? matchLimit : 0); } - @CommandMethod("setpool reset") + @Command("setpool reset") @CommandDescription("Reset the pool back to appropriate default dynamic pool") - @CommandPermission(Permissions.SETNEXT) + @Permission(Permissions.SETNEXT) public void resetPool( Audience sender, CommandSender source, @@ -254,13 +255,13 @@ public void resetPool( matchLimit); } - @CommandMethod("skip [positions]") + @Command("skip [positions]") @CommandDescription("Skip the next map") - @CommandPermission(Permissions.SETNEXT) + @Permission(Permissions.SETNEXT) public void skip( Audience sender, MapPoolManager poolManager, - @Argument(value = "positions", defaultValue = "1") @Range(min = "1") int positions) { + @Argument(value = "positions") @Default("1") @Range(min = "1") int positions) { MapPool pool = poolManager.getActiveMapPool(); if (!(pool instanceof Rotation)) throw exception("pool.noRotation"); @@ -282,7 +283,7 @@ public void skip( sender.sendMessage(message); } - @CommandMethod("votenext [map]") + @Command("votenext [map]") @CommandDescription("Vote for the next map") public void voteNext( MatchPlayer player, @@ -299,7 +300,7 @@ public void voteNext( poll.sendBook(player, forceOpen); } - @CommandMethod("votebook") + @Command("votebook") @CommandDescription("Spawn a vote book") public void voteBook(MatchPlayer player, MapPoll poll) { poll.sendBook(player, false); @@ -307,14 +308,14 @@ public void voteBook(MatchPlayer player, MapPoll poll) { // Legacy rotation command aliases - @CommandMethod("rot [page]") + @Command("rot [page]") @CommandDescription("List the maps in the rotation. Use /pool to see unfiltered results.") @RawArgs public void rot( Audience sender, CommandSender source, MapPoolManager poolManager, - @Argument(value = "page", defaultValue = "1") @Range(min = "1") int page, + @Argument(value = "page") @Default("1") @Range(min = "1") int page, @Flag(value = "all", aliases = "a") boolean all, String[] rawArgs) { wrapLegacy( @@ -339,23 +340,23 @@ public void rot( }); } - @CommandMethod("rots [page]") + @Command("rots [page]") @CommandDescription("List all the rotations. Use /pools to see unfiltered results.") @RawArgs public void rots( Audience sender, CommandSender source, MapPoolManager poolManager, - @Argument(value = "page", defaultValue = "1") @Range(min = "1") int page, + @Argument(value = "page") @Default("1") @Range(min = "1") int page, String[] rawArgs) { pools(sender, source, poolManager, page, MapPoolType.ORDERED, false); // Always follow-up, as they're filtered results that may not error out sender.sendMessage(alternativeUsage(rawArgs, "pools")); } - @CommandMethod("setrot ") + @Command("setrot ") @CommandDescription("Set a rotation as current pool. Use /setpool to set other types of pools.") - @CommandPermission(Permissions.SETNEXT) + @Permission(Permissions.SETNEXT) @RawArgs public void setRot( Audience sender, @@ -373,10 +374,10 @@ public void setRot( () -> setPool(sender, source, match, poolManager, rotation, timeLimit, matchLimit)); } - @CommandMethod("setrot reset") + @Command("setrot reset") @CommandDescription( "Reset the rotation to default. Use /setpool to reset to other types of pools.") - @CommandPermission(Permissions.SETNEXT) + @Permission(Permissions.SETNEXT) @RawArgs public void resetRot( Audience sender, diff --git a/core/src/main/java/tc/oc/pgm/command/MatchCommand.java b/core/src/main/java/tc/oc/pgm/command/MatchCommand.java index 2af974cdc2..d86fbb72ad 100644 --- a/core/src/main/java/tc/oc/pgm/command/MatchCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/MatchCommand.java @@ -7,8 +7,6 @@ import static net.kyori.adventure.text.Component.translatable; import static tc.oc.pgm.util.text.TemporalComponent.clock; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; @@ -23,6 +21,8 @@ import net.kyori.adventure.text.format.TextColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; import org.jetbrains.annotations.Nullable; import tc.oc.pgm.api.integration.Integration; import tc.oc.pgm.api.match.Match; @@ -44,7 +44,7 @@ public final class MatchCommand { - @CommandMethod("match|matchinfo") + @Command("match|matchinfo") @CommandDescription("Show the match info") public void match(Audience viewer, CommandSender sender, Match match) { // indicates whether we have game information from the match yet diff --git a/core/src/main/java/tc/oc/pgm/command/ModeCommand.java b/core/src/main/java/tc/oc/pgm/command/ModeCommand.java index a53afc35fa..37df72f567 100644 --- a/core/src/main/java/tc/oc/pgm/command/ModeCommand.java +++ b/core/src/main/java/tc/oc/pgm/command/ModeCommand.java @@ -6,17 +6,18 @@ import static tc.oc.pgm.util.text.TemporalComponent.clock; import static tc.oc.pgm.util.text.TextException.exception; -import cloud.commandframework.annotations.Argument; -import cloud.commandframework.annotations.CommandDescription; -import cloud.commandframework.annotations.CommandMethod; -import cloud.commandframework.annotations.CommandPermission; -import cloud.commandframework.annotations.specifier.Range; import java.time.Duration; import java.util.List; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.NamedTextColor; import org.apache.commons.lang.WordUtils; +import org.incendo.cloud.annotation.specifier.Range; +import org.incendo.cloud.annotations.Argument; +import org.incendo.cloud.annotations.Command; +import org.incendo.cloud.annotations.CommandDescription; +import org.incendo.cloud.annotations.Default; +import org.incendo.cloud.annotations.Permission; import tc.oc.pgm.api.Permissions; import tc.oc.pgm.api.match.Match; import tc.oc.pgm.countdowns.CountdownContext; @@ -27,10 +28,10 @@ import tc.oc.pgm.util.Audience; import tc.oc.pgm.util.text.TextFormatter; -@CommandMethod("mode|modes") +@Command("mode|modes") public final class ModeCommand { - @CommandMethod("next") + @Command("next") @CommandDescription("Show the next objective mode") public void next(Audience audience, ObjectiveModesMatchModule modes) { List countdowns = modes.getActiveCountdowns(); @@ -64,21 +65,21 @@ public void next(Audience audience, ObjectiveModesMatchModule modes) { audience.sendMessage(builder.build()); } - @CommandMethod("[page]") + @Command("[page]") @CommandDescription("List all objective modes") public void fallback( Audience audience, ObjectiveModesMatchModule modes, - @Argument(value = "page", defaultValue = "1") @Range(min = "1") int page) { + @Argument(value = "page") @Default("1") @Range(min = "1") int page) { list(audience, modes, page); } - @CommandMethod("list|page [page]") + @Command("list|page [page]") @CommandDescription("List all objective modes") public void list( Audience audience, ObjectiveModesMatchModule modes, - @Argument(value = "page", defaultValue = "1") @Range(min = "1") int page) { + @Argument(value = "page") @Default("1") @Range(min = "1") int page) { List modeList = modes.getSortedCountdowns(true); int resultsPerPage = 8; int pages = (modeList.size() + resultsPerPage - 1) / resultsPerPage; @@ -94,9 +95,9 @@ public void list( new ModesPaginatedResult(header, resultsPerPage, modes).display(audience, modeList, page); } - @CommandMethod("push