Skip to content

Commit

Permalink
Update to Cloud 2.0 and adapt to upstream changes (#59)
Browse files Browse the repository at this point in the history
Signed-off-by: BT (calcastor/mame) <[email protected]>
  • Loading branch information
calcastor authored Jun 12, 2024
1 parent a7b0506 commit 384d715
Show file tree
Hide file tree
Showing 39 changed files with 426 additions and 459 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import dev.pgm.community.utils.CommandAudience;
import java.util.Optional;
import org.bukkit.entity.Player;
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.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;

public class PlayerHelpCommand extends CommunityCommand {

Expand All @@ -23,7 +23,7 @@ public PlayerHelpCommand() {
this.moderation = Community.get().getFeatures().getModeration();
}

@CommandMethod("assistance|assist|helpop|helpme <reason>")
@Command("assistance|assist|helpop|helpme <reason>")
@CommandDescription("Request help from a staff member")
public void assistanceCommand(
CommandAudience viewer, Player player, @Argument("reason") @Greedy String reason) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
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.cloud.commandframework.annotations.specifier.Range;
import tc.oc.pgm.lib.org.incendo.cloud.annotation.specifier.Greedy;
import tc.oc.pgm.lib.org.incendo.cloud.annotation.specifier.Range;
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.Default;
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.named.NameStyle;
import tc.oc.pgm.util.player.PlayerComponent;
import tc.oc.pgm.util.text.TemporalComponent;
Expand All @@ -51,7 +52,7 @@ public ReportCommands() {
this.moderation = Community.get().getFeatures().getModeration();
}

@CommandMethod("report <username> [reason]")
@Command("report <username> [reason]")
@CommandDescription("Report a player who is breaking the rules")
public void report(
CommandAudience viewer,
Expand All @@ -78,12 +79,12 @@ public void report(
}
}

@CommandMethod("reports|reporthistory|reps [page]")
@Command("reports|reporthistory|reps [page]")
@CommandDescription("View report history")
@CommandPermission(CommunityPermissions.REPORTS)
@Permission(CommunityPermissions.REPORTS)
public void recentReports(
CommandAudience audience,
@Argument(value = "page", defaultValue = "1") @Range(min = "1") int page,
@Argument("page") @Default("1") @Range(min = "1") int page,
@Flag(value = "player", aliases = "p") String player) {
checkEnabled();

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/dev/pgm/community/broadcast/BroadcastCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import dev.pgm.community.Community;
import dev.pgm.community.CommunityCommand;
import dev.pgm.community.CommunityPermissions;
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.FlagYielding;
import tc.oc.pgm.lib.org.incendo.cloud.annotation.specifier.FlagYielding;
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;

public class BroadcastCommand extends CommunityCommand {

Expand All @@ -18,9 +18,9 @@ public BroadcastCommand() {
this.broadcast = Community.get().getFeatures().getBroadcast();
}

@CommandMethod("broadcast|announce|bc <message>")
@Command("broadcast|announce|bc <message>")
@CommandDescription("Broadcast an announcement to everyone")
@CommandPermission(CommunityPermissions.BROADCAST)
@Permission(CommunityPermissions.BROADCAST)
public void broadcastChat(
@Argument("message") @FlagYielding String message,
@Flag(value = "title", aliases = "t") boolean title) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
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.org.incendo.cloud.annotations.Command;
import tc.oc.pgm.lib.org.incendo.cloud.annotations.CommandDescription;
import tc.oc.pgm.lib.org.incendo.cloud.annotations.Permission;
import tc.oc.pgm.util.text.TextFormatter;

@CommandMethod("chat")
@Command("chat")
public class ChatManagementCommand extends CommunityCommand {

private final ChatManagementFeature chat;
Expand All @@ -24,9 +24,9 @@ public ChatManagementCommand() {
this.chat = Community.get().getFeatures().getChatManagement();
}

@CommandMethod("")
@Command("")
@CommandDescription("View the current chat mode status")
@CommandPermission(CommunityPermissions.CHAT_MANAGEMENT)
@Permission(CommunityPermissions.CHAT_MANAGEMENT)
public void viewStatus(CommandAudience audience) {
audience.sendMessage(
TextFormatter.horizontalLineHeading(
Expand All @@ -35,23 +35,23 @@ public void viewStatus(CommandAudience audience) {
audience.sendMessage(formatStatus(text("Chat Slowmode"), chat.isSlowmode()));
}

@CommandMethod("lock")
@Command("lock")
@CommandDescription("Toggle lock status for the chat")
@CommandPermission(CommunityPermissions.CHAT_MANAGEMENT)
@Permission(CommunityPermissions.CHAT_MANAGEMENT)
public void toggleLock(CommandAudience viewer) {
chat.toggleLockdown(viewer.getSender());
}

@CommandMethod("slow")
@Command("slow")
@CommandDescription("Toggle chat slowmode")
@CommandPermission(CommunityPermissions.CHAT_MANAGEMENT)
@Permission(CommunityPermissions.CHAT_MANAGEMENT)
public void toggleSlowmode(CommandAudience viewer) {
chat.toggleSlowmode(viewer.getSender());
}

@CommandMethod("clear")
@Command("clear")
@CommandDescription("Clear the global chat")
@CommandPermission(CommunityPermissions.CHAT_MANAGEMENT)
@Permission(CommunityPermissions.CHAT_MANAGEMENT)
public void clearChat(CommandAudience viewer) {
for (int i = 0; i < 100; i++) {
BroadcastUtils.sendGlobalMessage(Component.empty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import dev.pgm.community.users.feature.UsersFeature;
import dev.pgm.community.utils.CommandAudience;
import net.kyori.adventure.text.format.NamedTextColor;
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.org.incendo.cloud.annotations.Command;
import tc.oc.pgm.lib.org.incendo.cloud.annotations.CommandDescription;
import tc.oc.pgm.lib.org.incendo.cloud.annotations.Permission;
import tc.oc.pgm.util.text.TextFormatter;

public class CommunityPluginCommand extends CommunityCommand {
Expand All @@ -28,17 +28,17 @@ public CommunityPluginCommand() {
this.reports = Community.get().getFeatures().getReports();
}

@CommandMethod("community reload")
@Command("community reload")
@CommandDescription("Reload the plugin")
@CommandPermission(CommunityPermissions.RELOAD)
@Permission(CommunityPermissions.RELOAD)
public void reload(CommandAudience audience) {
Community.get().reload();
audience.sendWarning(text("Community has been reloaded")); // TODO: translate
}

@CommandMethod("community stats")
@Command("community stats")
@CommandDescription("View database stats")
@CommandPermission(CommunityPermissions.RELOAD)
@Permission(CommunityPermissions.RELOAD)
public void stats(CommandAudience audience) {
audience.sendMessage(
TextFormatter.horizontalLineHeading(
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/dev/pgm/community/commands/ContainerCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.InventoryHolder;
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.org.incendo.cloud.annotations.Command;
import tc.oc.pgm.lib.org.incendo.cloud.annotations.CommandDescription;
import tc.oc.pgm.lib.org.incendo.cloud.annotations.Permission;
import tc.oc.pgm.util.Audience;

public class ContainerCommand extends CommunityCommand implements Listener {
Expand All @@ -40,9 +40,9 @@ public ContainerCommand() {
Community.get().getServer().getPluginManager().registerEvents(this, Community.get());
}

@CommandMethod("chestedit|ce|cedit|containeredit")
@Command("chestedit|ce|cedit|containeredit")
@CommandDescription("Edit inventory contents of a target container block")
@CommandPermission(CommunityPermissions.CONTAINER)
@Permission(CommunityPermissions.CONTAINER)
public void containerEditCommand(CommandAudience audience, Player player) {
if (isChoosing(player)) {
clickingPlayers.remove(player.getUniqueId());
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/dev/pgm/community/commands/FlightCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
import dev.pgm.community.utils.CommandAudience;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.entity.Player;
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.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.Permission;
import tc.oc.pgm.util.Audience;

public class FlightCommand extends CommunityCommand {

@CommandMethod("fly|flight [target]")
@Command("fly|flight [target]")
@CommandDescription("Toggle flight mode for yourself or other players")
@CommandPermission(CommunityPermissions.FLIGHT)
@Permission(CommunityPermissions.FLIGHT)
public void fly(CommandAudience sender, @Argument("target") TargetPlayer target) {
if (sender.isPlayer() && target == null) {
toggleFlight(sender.getPlayer());
Expand All @@ -38,9 +38,9 @@ public void fly(CommandAudience sender, @Argument("target") TargetPlayer target)
}
}

@CommandMethod("flyspeed [speed]")
@Command("flyspeed [speed]")
@CommandDescription("Adjust your flight speed")
@CommandPermission(CommunityPermissions.FLIGHT_SPEED)
@Permission(CommunityPermissions.FLIGHT_SPEED)
public void flySpeed(CommandAudience audience, Player player, @Argument("speed") Float speed) {
if (speed == null) {
audience.sendMessage(
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/dev/pgm/community/commands/GamemodeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
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.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;

public class GamemodeCommand extends CommunityCommand {

@CommandMethod("gamemode|gm [gamemode] [target]")
@Command("gamemode|gm [gamemode] [target]")
@CommandDescription("Adjust your or another player's gamemode")
@CommandPermission(CommunityPermissions.GAMEMODE)
@Permission(CommunityPermissions.GAMEMODE)
public void gamemode(
CommandAudience viewer,
@Argument("gamemode") GameMode gamemode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.time.Duration;
import java.time.Instant;
import net.kyori.adventure.text.format.NamedTextColor;
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;
import tc.oc.pgm.util.text.TemporalComponent;

public class ServerInfoCommand extends CommunityCommand {
Expand All @@ -19,7 +19,7 @@ public ServerInfoCommand() {
this.startTime = Instant.now();
}

@CommandMethod("uptime")
@Command("uptime")
@CommandDescription("View how long the server has been online")
public void uptime(CommandAudience sender) {
Duration uptime = Duration.between(startTime, Instant.now());
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/dev/pgm/community/commands/StaffCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
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;
import tc.oc.pgm.util.named.NameStyle;
import tc.oc.pgm.util.player.PlayerComponent;
import tc.oc.pgm.util.text.TextFormatter;

public class StaffCommand extends CommunityCommand {

@CommandMethod("staff|mods|admins|ops")
@Command("staff|mods|admins|ops")
@CommandDescription("View a list of online staff members")
public void staff(CommandAudience viewer) {
List<Component> onlineStaff =
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/dev/pgm/community/commands/SudoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
import dev.pgm.community.CommunityPermissions;
import dev.pgm.community.utils.CommandAudience;
import net.kyori.adventure.text.format.NamedTextColor;
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.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.Permission;

public class SudoCommand extends CommunityCommand {

@CommandMethod("sudo|force <targets> <command>")
@Command("sudo|force <targets> <command>")
@CommandDescription("Force targets to perform given command")
@CommandPermission(CommunityPermissions.ADMIN)
@Permission(CommunityPermissions.ADMIN)
public void sudo(
CommandAudience sender,
@Argument("targets") String targets,
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/dev/pgm/community/commands/VanishedCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import tc.oc.pgm.api.integration.Integration;
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.org.incendo.cloud.annotations.Command;
import tc.oc.pgm.lib.org.incendo.cloud.annotations.CommandDescription;
import tc.oc.pgm.lib.org.incendo.cloud.annotations.Permission;
import tc.oc.pgm.util.named.NameStyle;
import tc.oc.pgm.util.player.PlayerComponent;
import tc.oc.pgm.util.text.TextFormatter;

public class VanishedCommand extends CommunityCommand {
@CommandMethod("vanished")
@Command("vanished")
@CommandDescription("View a list of online vanished players")
@CommandPermission(CommunityPermissions.VIEW_VANISHED)
@Permission(CommunityPermissions.VIEW_VANISHED)
public void viewVanished(CommandAudience viewer) {
List<Component> vanishedNames =
Bukkit.getOnlinePlayers().stream()
Expand Down
Loading

0 comments on commit 384d715

Please sign in to comment.