package dev.loki.loparkour.command.admin; import dev.loki.loparkour.command.player.PlayerCommandHandler; import dev.loki.loparkour.command.schematic.SchematicCommandHandler; import dev.loki.loparkour.menu.core.ParkourOption; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Handles admin-only /LoParkour sub-commands: * forcejoin, forceleave, reset, recoverinventory. */ public class AdminCommandHandler { private final PlayerCommandHandler base; private final ForceJoinExecutor forceJoin; private final ForceLeaveExecutor forceLeave; private final ResetExecutor reset; private final RecoverInventoryExecutor recoverInventory; public AdminCommandHandler(PlayerCommandHandler base) { this.base = base; this.forceJoin = new ForceJoinExecutor(base); this.forceLeave = new ForceLeaveExecutor(base); this.reset = new ResetExecutor(base); this.recoverInventory = new RecoverInventoryExecutor(base); } public void handle(@NotNull String arg1, @NotNull String arg2, @NotNull CommandSender sender, @Nullable Player player) { if (!sender.hasPermission(ParkourOption.ADMIN.permission)) { return; } dispatchAdmin(arg1, arg2, sender); dispatchSchematic(arg1, arg2, sender, player); } private void dispatchAdmin(@NotNull String arg1, @NotNull String arg2, @NotNull CommandSender sender) { switch (arg1.toLowerCase()) { case "forcejoin" -> { forceJoin.execute(arg2, sender); } case "forceleave" -> { forceLeave.execute(arg2, sender); } case "reset" -> { reset.execute(arg2, sender); } case "recoverinventory" -> { recoverInventory.execute(arg2, sender); } default -> { /* unknown admin subcommand: handle() falls through to schematic */ } } } private void dispatchSchematic(@NotNull String arg1, @NotNull String arg2, @NotNull CommandSender sender, @Nullable Player player) { if (player == null) { return; } if ("schematic".equals(arg1)) { SchematicCommandHandler.handleSubcommand(arg2, sender, player, base); } } }