Skip to content

Commit

Permalink
Update to Cloud 2.0
Browse files Browse the repository at this point in the history
Signed-off-by: BT (calcastor/mame) <[email protected]>
  • Loading branch information
calcastor committed May 20, 2024
1 parent 6e85b8e commit c96121c
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 67 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.PGMDev</groupId>
<groupId>dev.pgm</groupId>
<artifactId>Events</artifactId>
<version>master-9671be2b43-1</version>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
46 changes: 23 additions & 23 deletions src/main/java/rip/bolt/ingame/commands/AdminCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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 <player> [reason]")
@Command("ban <player> [reason]")
@CommandDescription("Manually queue bans a player")
@CommandPermission("ingame.staff.ban")
@Permission("ingame.staff.ban")
public void ban(
CommandSender sender,
@Argument("player") MatchPlayer target,
Expand All @@ -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))
Expand All @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/rip/bolt/ingame/commands/ForfeitCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 4 additions & 9 deletions src/main/java/rip/bolt/ingame/commands/IngameCommandGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -40,12 +40,7 @@ public IngameCommandGraph(Ingame ingame) throws Exception {

@Override
protected MinecraftHelp<CommandSender> createHelp() {
return new MinecraftHelp<>("/ingame help", Audience::get, manager);
}

@Override
protected CommandConfirmationManager<CommandSender> createConfirmationManager() {
return null;
return MinecraftHelp.create("/ingame help", manager, Audience::get);
}

@Override
Expand All @@ -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());
Expand Down
51 changes: 24 additions & 27 deletions src/main/java/rip/bolt/ingame/commands/PugCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -48,17 +47,15 @@ public static Collection<String> getCommandList() {
return commandList;
}

public static void setupSubCommands(CommandTree.Node<CommandArgument<CommandSender, ?>> pugNode) {
public static void setupSubCommands(@Nullable CommandNode<CommandSender> 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());
}

Expand All @@ -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();
Expand All @@ -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,
Expand All @@ -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) {
Expand All @@ -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 <player> [team]")
@Command("force <player> [team]")
@CommandDescription("Force a player onto a team")
public void force(
MatchPlayer sender, @Argument("player") MatchPlayer player, @Argument("team") Party team) {
Expand All @@ -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 <team> <name>")
@Command("alias <team> <name>")
@CommandDescription("Rename a team")
public void alias(
MatchPlayer sender,
Expand All @@ -188,7 +185,7 @@ public void alias(
pm.write(PugCommand.setTeamName(sender.getBukkit(), pugTeam, newName));
}

@CommandMethod("size <team> <max-players>")
@Command("size <team> <max-players>")
@CommandDescription("Set the max players on a team")
public void size(
Player sender, @Argument("team") String ignore, @Argument("max-players") Integer max) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/rip/bolt/ingame/commands/RequeueCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c96121c

Please sign in to comment.