- Decompose all 11 god-classes (>200 lines) into facade + collaborators (command/, schematic/, config/, generator/, mode/, papi/, adaptive/, storage/, player/, leaderboard/) — every file is now <=200 lines - Add PMD 7 (report-only) + stricter checkstyle rules (NPath, IllegalCatch, NestedDepth, Whitespace, MissingOverride); fix real bugs found (printStackTrace, resource leaks in ConfigLoader/SQLStatsStorage) - docs/ARCHITECTURE.md: target structure + 'one folder = one purpose' rule - Pilot restructure: command/core|util/, mode/impl/solo|multi|barrier/, hook/papi/resolver/; cross-package classes made public - TODO.md: track warning cleanup (132-138) + restructure progress
71 lines
2.4 KiB
Java
71 lines
2.4 KiB
Java
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);
|
|
}
|
|
}
|
|
}
|