diff --git a/pom.xml b/pom.xml index e525468..2238389 100644 --- a/pom.xml +++ b/pom.xml @@ -53,9 +53,9 @@ provided - com.github.PGMDev + dev.pgm Events - master-9671be2b43-1 + 1.0.0-SNAPSHOT provided diff --git a/src/main/java/rip/bolt/ingame/commands/AdminCommands.java b/src/main/java/rip/bolt/ingame/commands/AdminCommands.java index 3effeac..4c01737 100644 --- a/src/main/java/rip/bolt/ingame/commands/AdminCommands.java +++ b/src/main/java/rip/bolt/ingame/commands/AdminCommands.java @@ -21,20 +21,20 @@ import tc.oc.pgm.api.match.Match; import tc.oc.pgm.api.match.MatchPhase; import tc.oc.pgm.api.player.MatchPlayer; -import tc.oc.pgm.lib.cloud.commandframework.annotations.Argument; -import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandDescription; -import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandMethod; -import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandPermission; -import tc.oc.pgm.lib.cloud.commandframework.annotations.Flag; -import tc.oc.pgm.lib.cloud.commandframework.annotations.specifier.Greedy; +import tc.oc.pgm.lib.org.incendo.cloud.annotation.specifier.Greedy; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.Argument; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.Command; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.CommandDescription; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.Flag; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.Permission; import tc.oc.pgm.util.Audience; -@CommandMethod("ingame") +@Command("ingame") public class AdminCommands { - @CommandMethod("poll") + @Command("poll") @CommandDescription("Poll the API once for a new Bolt match") - @CommandPermission("ingame.staff.poll") + @Permission("ingame.staff.poll") public void poll( MatchManager matchManager, CommandSender sender, @@ -52,9 +52,9 @@ public void poll( text("Manual poll has been triggered, checking API for match.", NamedTextColor.GRAY)); } - @CommandMethod("clear|reset") + @Command("clear|reset") @CommandDescription("Clear the currently stored Bolt match") - @CommandPermission("ingame.staff.clear") + @Permission("ingame.staff.clear") public void clear(MatchManager matchManager, CommandSender sender) throws CommandException { BoltMatch match = matchManager.getMatch(); if (match == null) @@ -70,9 +70,9 @@ public void clear(MatchManager matchManager, CommandSender sender) throws Comman NamedTextColor.GRAY)); } - @CommandMethod("match") + @Command("match") @CommandDescription("View info about the current Bolt match") - @CommandPermission("ingame.staff.match") + @Permission("ingame.staff.match") public void match(MatchManager matchManager, CommandSender sender) throws CommandException { BoltMatch boltMatch = matchManager.getMatch(); if (boltMatch == null) @@ -83,9 +83,9 @@ public void match(MatchManager matchManager, CommandSender sender) throws Comman if (AppData.Web.getMatchLink() != null) audience.sendMessage(Messages.matchLink(boltMatch)); } - @CommandMethod("status") + @Command("status") @CommandDescription("View the status of the API polling") - @CommandPermission("ingame.staff.status") + @Permission("ingame.staff.status") public void status(MatchManager matchManager, CommandSender sender) throws CommandException { GameManager gameTypeManager = matchManager.getGameManager(); String gameManager = gameTypeManager.getClass().getSimpleName(); @@ -119,9 +119,9 @@ public void status(MatchManager matchManager, CommandSender sender) throws Comma newline().append(apiPolling.append(newline().append(websocketConnected))))); } - @CommandMethod("cancel") + @Command("cancel") @CommandDescription("Report the current Bolt match as cancelled") - @CommandPermission("ingame.staff.cancel") + @Permission("ingame.staff.cancel") public void cancel(MatchManager matchManager, CommandSender sender, Match match) throws CommandException { BoltMatch boltMatch = matchManager.getMatch(); @@ -142,9 +142,9 @@ public void cancel(MatchManager matchManager, CommandSender sender, Match match) match.sendMessage(text("Match has been cancelled by an admin.", NamedTextColor.RED)); } - @CommandMethod("ban [reason]") + @Command("ban [reason]") @CommandDescription("Manually queue bans a player") - @CommandPermission("ingame.staff.ban") + @Permission("ingame.staff.ban") public void ban( CommandSender sender, @Argument("player") MatchPlayer target, @@ -159,9 +159,9 @@ public void ban( Ingame.get(), () -> Ingame.get().getApiManager().postPlayerPunishment(punishment)); } - @CommandMethod("reconnect") + @Command("reconnect") @CommandDescription("Reconnect to the matches websocket") - @CommandPermission("ingame.staff.reconnect") + @Permission("ingame.staff.reconnect") public void reconnect(MatchManager matchManager, CommandSender sender) throws CommandException { GameManager gameManager = matchManager.getGameManager(); if (!(gameManager instanceof PugManager)) @@ -173,9 +173,9 @@ public void reconnect(MatchManager matchManager, CommandSender sender) throws Co ((PugManager) gameManager).connect(matchManager.getMatch()); } - @CommandMethod("disconnect") + @Command("disconnect") @CommandDescription("Disconnect from the matches websocket") - @CommandPermission("ingame.staff.reconnect") + @Permission("ingame.staff.reconnect") public void disconnect(MatchManager matchManager, CommandSender sender) throws CommandException { GameManager gameManager = matchManager.getGameManager(); if (!(gameManager instanceof PugManager)) diff --git a/src/main/java/rip/bolt/ingame/commands/ForfeitCommands.java b/src/main/java/rip/bolt/ingame/commands/ForfeitCommands.java index aaaaaf1..ee15f41 100644 --- a/src/main/java/rip/bolt/ingame/commands/ForfeitCommands.java +++ b/src/main/java/rip/bolt/ingame/commands/ForfeitCommands.java @@ -13,12 +13,12 @@ import tc.oc.pgm.api.match.MatchPhase; import tc.oc.pgm.api.party.Competitor; import tc.oc.pgm.api.player.MatchPlayer; -import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandDescription; -import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandMethod; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.Command; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.CommandDescription; public class ForfeitCommands { - @CommandMethod("forfeit|ff") + @Command("forfeit|ff") @CommandDescription("Accept that you have no chance of winning") public void forfeit(MatchManager matchManager, MatchPlayer sender, Match match) throws CommandException { diff --git a/src/main/java/rip/bolt/ingame/commands/IngameCommandGraph.java b/src/main/java/rip/bolt/ingame/commands/IngameCommandGraph.java index db04f3f..4994e51 100644 --- a/src/main/java/rip/bolt/ingame/commands/IngameCommandGraph.java +++ b/src/main/java/rip/bolt/ingame/commands/IngameCommandGraph.java @@ -13,6 +13,7 @@ import tc.oc.pgm.api.match.Match; import tc.oc.pgm.api.party.Party; import tc.oc.pgm.api.player.MatchPlayer; +import tc.oc.pgm.command.injectors.AudienceProvider; import tc.oc.pgm.command.injectors.MatchPlayerProvider; import tc.oc.pgm.command.injectors.MatchProvider; import tc.oc.pgm.command.injectors.PlayerProvider; @@ -25,9 +26,8 @@ import tc.oc.pgm.command.parsers.TeamParser; import tc.oc.pgm.command.parsers.TeamsParser; import tc.oc.pgm.command.util.CommandGraph; -import tc.oc.pgm.lib.cloud.commandframework.extra.confirmation.CommandConfirmationManager; -import tc.oc.pgm.lib.cloud.commandframework.minecraft.extras.MinecraftHelp; import tc.oc.pgm.lib.io.leangen.geantyref.TypeFactory; +import tc.oc.pgm.lib.org.incendo.cloud.minecraft.extras.MinecraftHelp; import tc.oc.pgm.teams.Team; import tc.oc.pgm.teams.TeamMatchModule; import tc.oc.pgm.util.Audience; @@ -40,12 +40,7 @@ public IngameCommandGraph(Ingame ingame) throws Exception { @Override protected MinecraftHelp createHelp() { - return new MinecraftHelp<>("/ingame help", Audience::get, manager); - } - - @Override - protected CommandConfirmationManager createConfirmationManager() { - return null; + return MinecraftHelp.create("/ingame help", manager, Audience::get); } @Override @@ -56,7 +51,7 @@ protected void setupInjectors() { registerInjector(MapOrder.class, () -> PGM.get().getMapOrder()); registerInjector(MatchManager.class, () -> Ingame.get().getMatchManager()); - registerInjector(Audience.class, (c, s) -> Audience.get(c.getSender())); + registerInjector(Audience.class, new AudienceProvider()); registerInjector(Match.class, new MatchProvider()); registerInjector(MatchPlayer.class, new MatchPlayerProvider()); registerInjector(Player.class, new PlayerProvider()); diff --git a/src/main/java/rip/bolt/ingame/commands/PugCommands.java b/src/main/java/rip/bolt/ingame/commands/PugCommands.java index bc45623..d79e894 100644 --- a/src/main/java/rip/bolt/ingame/commands/PugCommands.java +++ b/src/main/java/rip/bolt/ingame/commands/PugCommands.java @@ -8,6 +8,7 @@ import java.util.stream.Collectors; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; import rip.bolt.ingame.api.definitions.pug.PugCommand; import rip.bolt.ingame.api.definitions.pug.PugTeam; import rip.bolt.ingame.managers.GameManager; @@ -19,18 +20,16 @@ import tc.oc.pgm.api.party.Party; import tc.oc.pgm.api.player.MatchPlayer; import tc.oc.pgm.join.JoinRequest; -import tc.oc.pgm.lib.cloud.commandframework.CommandTree; -import tc.oc.pgm.lib.cloud.commandframework.annotations.Argument; -import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandDescription; -import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandMethod; -import tc.oc.pgm.lib.cloud.commandframework.annotations.specifier.FlagYielding; -import tc.oc.pgm.lib.cloud.commandframework.annotations.specifier.Greedy; -import tc.oc.pgm.lib.cloud.commandframework.arguments.CommandArgument; -import tc.oc.pgm.lib.cloud.commandframework.arguments.StaticArgument; +import tc.oc.pgm.lib.org.incendo.cloud.annotation.specifier.FlagYielding; +import tc.oc.pgm.lib.org.incendo.cloud.annotation.specifier.Greedy; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.Argument; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.Command; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.CommandDescription; +import tc.oc.pgm.lib.org.incendo.cloud.internal.CommandNode; import tc.oc.pgm.teams.Team; import tc.oc.pgm.teams.TeamMatchModule; -@CommandMethod("pug") +@Command("pug") public class PugCommands { private final MatchManager matchManager; @@ -48,17 +47,15 @@ public static Collection getCommandList() { return commandList; } - public static void setupSubCommands(CommandTree.Node> pugNode) { + public static void setupSubCommands(@Nullable CommandNode pugNode) { if (pugNode == null) { commandList = Collections.emptyList(); return; } commandList = - pugNode.getChildren().stream() - .map(CommandTree.Node::getValue) - .filter(v -> v instanceof StaticArgument) - .flatMap(value -> ((StaticArgument) value).getAliases().stream()) + pugNode.children().stream() + .flatMap(n -> n.component().aliases().stream()) .collect(Collectors.toList()); } @@ -69,13 +66,13 @@ private PugManager needPugManager() { return (PugManager) gm; } - @CommandMethod("leave|obs|spectator|spec") + @Command("leave|obs|spectator|spec") @CommandDescription("Leave the match") public void leave(Player sender) { needPugManager().write(PugCommand.joinObs(sender)); } - @CommandMethod("join|play [team]") + @Command("join|play [team]") @CommandDescription("Join the match") public void join(MatchPlayer player, Match match, @Argument("team") @FlagYielding Party team) { PugManager pm = needPugManager(); @@ -97,20 +94,20 @@ public void join(MatchPlayer player, Match match, @Argument("team") @FlagYieldin else throw exception("command.teamNotFound"); } - @CommandMethod("start|begin [duration]") + @Command("start|begin [duration]") @CommandDescription("Start the match") public void start(MatchPlayer sender, @Argument("duration") Duration duration) { needPugManager().write(PugCommand.startMatch(sender.getBukkit(), duration)); } - @CommandMethod("setnext|sn [map]") + @Command("setnext|sn [map]") @CommandDescription("Change the next map") public void setNext(MatchPlayer sender, @Argument("map") @FlagYielding MapInfo map) { if (map == null) throw exception("Map not found!"); needPugManager().write(PugCommand.setMap(sender.getBukkit(), map)); } - @CommandMethod("cycle [duration] [map]") + @Command("cycle [duration] [map]") @CommandDescription("Cycle to the next match") public void cycle( MatchPlayer sender, @@ -121,7 +118,7 @@ public void cycle( else pm.write(PugCommand.cycleMatch(sender.getBukkit())); } - @CommandMethod("recycle|rematch [duration]") + @Command("recycle|rematch [duration]") @CommandDescription("Reload (cycle to) the current map") public void recycle( MatchManager matchManager, MatchPlayer sender, @Argument("duration") Duration duration) { @@ -133,10 +130,10 @@ public void recycle( pm.write(PugCommand.cycleMatch(sender.getBukkit(), matchManager.getMatch().getMap())); } - @CommandMethod("pug team") + @Command("pug team") public class TeamCommands { - @CommandMethod("force [team]") + @Command("force [team]") @CommandDescription("Force a player onto a team") public void force( MatchPlayer sender, @Argument("player") MatchPlayer player, @Argument("team") Party team) { @@ -153,25 +150,25 @@ public void force( pm.write(PugCommand.movePlayer(sender.getBukkit(), player.getBukkit(), pugTeam)); } - @CommandMethod("balance") + @Command("balance") @CommandDescription("Balance teams according to MMR") public void balance(Player sender) { needPugManager().write(PugCommand.balance(sender)); } - @CommandMethod("shuffle") + @Command("shuffle") @CommandDescription("Shuffle players among the teams") public void shuffle(Player sender) { needPugManager().write(PugCommand.shuffle(sender)); } - @CommandMethod("clear") + @Command("clear") @CommandDescription("Clear all teams") public void clear(Player sender) { needPugManager().write(PugCommand.clear(sender)); } - @CommandMethod("alias ") + @Command("alias ") @CommandDescription("Rename a team") public void alias( MatchPlayer sender, @@ -188,7 +185,7 @@ public void alias( pm.write(PugCommand.setTeamName(sender.getBukkit(), pugTeam, newName)); } - @CommandMethod("size ") + @Command("size ") @CommandDescription("Set the max players on a team") public void size( Player sender, @Argument("team") String ignore, @Argument("max-players") Integer max) { diff --git a/src/main/java/rip/bolt/ingame/commands/RequeueCommands.java b/src/main/java/rip/bolt/ingame/commands/RequeueCommands.java index 10b0c88..67af583 100644 --- a/src/main/java/rip/bolt/ingame/commands/RequeueCommands.java +++ b/src/main/java/rip/bolt/ingame/commands/RequeueCommands.java @@ -10,12 +10,12 @@ import tc.oc.pgm.api.match.Match; import tc.oc.pgm.api.match.MatchPhase; import tc.oc.pgm.api.player.MatchPlayer; -import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandDescription; -import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandMethod; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.Command; +import tc.oc.pgm.lib.org.incendo.cloud.annotations.CommandDescription; public class RequeueCommands { - @CommandMethod("requeue") + @Command("requeue") @CommandDescription("Requeue for another ranked match") public void requeue(MatchManager matchManager, MatchPlayer sender, Match match) throws CommandException {