Skip to content

Commit

Permalink
wip: Update to Cloud 2.0
Browse files Browse the repository at this point in the history
Signed-off-by: BT (calcastor/mame) <[email protected]>
Co-authored-by: Pablo Herrera <[email protected]>
  • Loading branch information
calcastor and Pablete1234 committed May 18, 2024
1 parent 3bffdeb commit 2d7dd04
Show file tree
Hide file tree
Showing 64 changed files with 635 additions and 633 deletions.
10 changes: 5 additions & 5 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
<configuration>
<annotationProcessorPaths>
<path>
<groupId>cloud.commandframework</groupId>
<groupId>org.incendo</groupId>
<artifactId>cloud-annotations</artifactId>
<version>1.8.4</version>
<version>2.0.0-rc.1</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand All @@ -61,7 +61,7 @@
<include>tc.oc.pgm:*:*</include>
<include>org.jdom:jdom2:*</include>
<include>net.kyori:*:*</include>
<include>cloud.commandframework:cloud-*:*</include>
<include>org.incendo:cloud-*:*</include>
<include>io.leangen.geantyref:*:*</include>
<include>me.lucko:commodore</include>
<include>fr.mrmicky:*:*</include>
Expand All @@ -82,8 +82,8 @@
</filters>
<relocations combine.children="append">
<relocation>
<pattern>cloud.commandframework</pattern>
<shadedPattern>tc.oc.pgm.lib.cloud.commandframework</shadedPattern>
<pattern>org.incendo.cloud</pattern>
<shadedPattern>tc.oc.pgm.lib.org.incendo.cloud</shadedPattern>
</relocation>
<relocation>
<pattern>io.leangen.geantyref</pattern>
Expand Down
39 changes: 20 additions & 19 deletions core/src/main/java/tc/oc/pgm/command/ActionCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {

Expand All @@ -74,24 +75,24 @@ public void list(
(v, i) -> text((i + 1) + ". ").append(text(v.getId(), NamedTextColor.AQUA)));
}

@CommandMethod("trigger <action> [target]")
@Command("trigger <action> [target]")
@CommandDescription("Trigger a specific action")
@CommandPermission(Permissions.GAMEPLAY)
@Permission(Permissions.GAMEPLAY)
public <T extends Filterable<?>> 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 <action> [target]")
@Command("untrigger <action> [target]")
@CommandDescription("Untrigger a specific action")
@CommandPermission(Permissions.GAMEPLAY)
@Permission(Permissions.GAMEPLAY)
public <T extends Filterable<?>> 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()));
}
Expand Down
16 changes: 8 additions & 8 deletions core/src/main/java/tc/oc/pgm/command/AdminCommand.java
Original file line number Diff line number Diff line change
@@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/tc/oc/pgm/command/CancelCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/tc/oc/pgm/command/ClassCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
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;
import tc.oc.pgm.util.text.TextFormatter;

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,
Expand Down Expand Up @@ -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());
Expand Down
20 changes: 10 additions & 10 deletions core/src/main/java/tc/oc/pgm/command/CycleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/tc/oc/pgm/command/FinishCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
30 changes: 15 additions & 15 deletions core/src/main/java/tc/oc/pgm/command/FreeForAllCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
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;
import tc.oc.pgm.listeners.ChatDispatcher;
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 <min-players>")
@Command("min <min-players>")
@CommandDescription("Set the min players")
@CommandPermission(Permissions.RESIZE)
@Permission(Permissions.RESIZE)
public void min(
Match match,
CommandSender sender,
Expand All @@ -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 <factor>")
@Command("scale <factor>")
@CommandDescription("Scale the max players by a given factor")
@CommandPermission(Permissions.RESIZE)
@Permission(Permissions.RESIZE)
public void max(
Match match,
CommandSender sender,
Expand All @@ -58,9 +58,9 @@ public void max(
sendResizedMessage(match, sender, "max", ffa.getMaxPlayers());
}

@CommandMethod("max <max-players> [max-overfill]")
@Command("max <max-players> [max-overfill]")
@CommandDescription("Set the max players")
@CommandPermission(Permissions.RESIZE)
@Permission(Permissions.RESIZE)
public void max(
Match match,
CommandSender sender,
Expand All @@ -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());
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/tc/oc/pgm/command/InventoryCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <player>")
@Command("inventory|inv|vi <player>")
@CommandDescription("View a player's inventory")
@CommandPermission(Permissions.VIEW_INVENTORY)
@Permission(Permissions.VIEW_INVENTORY)
public void inventory(
ViewInventoryMatchModule inventories,
MatchPlayer viewer,
Expand Down
Loading

0 comments on commit 2d7dd04

Please sign in to comment.