fix: resolve 266/375 checkstyle violations, add lolib jar
This commit is contained in:
parent
7df0c13ac4
commit
bfeecb0866
79 changed files with 773 additions and 292 deletions
|
|
@ -79,11 +79,15 @@ public class LoParkourCommand implements CommandExecutor, TabCompleter {
|
|||
admin.handle(a1, a2, sender, p);
|
||||
return;
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
|
||||
if (p == null) return;
|
||||
if (p == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (a1.equalsIgnoreCase("create") && p.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||
if ("create".equalsIgnoreCase(a1) && p.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||
SchematicCommandHandler.handleCreateDifficultyOnly(a2, sender, p, player);
|
||||
return;
|
||||
}
|
||||
|
|
@ -98,17 +102,23 @@ public class LoParkourCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
SchematicCommandHandler.handleSubcommand(a2, sender, p, player);
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── 3-arg routing ──────────────────────────────────────────────────────────
|
||||
|
||||
private void handle3(String a1, String a2, String a3, CommandSender sender, @Nullable Player p) {
|
||||
if (p == null) return;
|
||||
if (!p.hasPermission(ParkourOption.ADMIN.permission)) return;
|
||||
if (p == null) {
|
||||
return;
|
||||
}
|
||||
if (!p.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (a1.equalsIgnoreCase("schematic")) {
|
||||
if (a2.equalsIgnoreCase("create")) {
|
||||
if ("schematic".equalsIgnoreCase(a1)) {
|
||||
if ("create".equalsIgnoreCase(a2)) {
|
||||
SchematicCommandHandler.handleCreateDifficultyOnly(a3, sender, p, player);
|
||||
return;
|
||||
}
|
||||
|
|
@ -117,29 +127,48 @@ public class LoParkourCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
private void handle4(String a1, String a2, String a3, String a4, CommandSender sender, @Nullable Player p) {
|
||||
if (p == null) return;
|
||||
if (!p.hasPermission(ParkourOption.ADMIN.permission)) return;
|
||||
if (!a1.equalsIgnoreCase("schematic") || !a2.equalsIgnoreCase("create")) return;
|
||||
if (p == null) {
|
||||
return;
|
||||
}
|
||||
if (!p.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||
return;
|
||||
}
|
||||
if (!"schematic".equalsIgnoreCase(a1) || !"create".equalsIgnoreCase(a2)) {
|
||||
return;
|
||||
}
|
||||
SchematicCommandHandler.handleCreateWithDifficulty(a3, a4, sender, p, player);
|
||||
}
|
||||
|
||||
// ── join logic ─────────────────────────────────────────────────────────────
|
||||
|
||||
private void handleJoin(String arg, CommandSender sender, Player p) {
|
||||
if (!player.cooldown(sender, "join", 2500) || !ParkourOption.JOIN.mayPerform(p)) return;
|
||||
if (!player.cooldown(sender, "join", 2500) || !ParkourOption.JOIN.mayPerform(p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Mode mode = Registry.getMode(arg);
|
||||
if (mode != null) { mode.create(p); return; }
|
||||
if (mode != null) {
|
||||
mode.create(p);
|
||||
return;
|
||||
}
|
||||
|
||||
Player other = Bukkit.getPlayer(arg);
|
||||
if (other == null) { send(sender, LoParkour.PREFIX + Locales.getString(sender, "commands.unknown_player")); return; }
|
||||
if (other == null) {
|
||||
send(sender, LoParkour.PREFIX + Locales.getString(sender, "commands.unknown_player"));
|
||||
return;
|
||||
}
|
||||
|
||||
ParkourPlayer pp = ParkourPlayer.getPlayer(other);
|
||||
if (pp == null) { send(sender, LoParkour.PREFIX + Locales.getString(sender, "commands.not_playing")); return; }
|
||||
if (pp == null) {
|
||||
send(sender, LoParkour.PREFIX + Locales.getString(sender, "commands.not_playing"));
|
||||
return;
|
||||
}
|
||||
|
||||
ParkourUser user = ParkourUser.getUser(p);
|
||||
Session session = pp.session;
|
||||
if (user != null && user.session == session) return;
|
||||
if (user != null && user.session == session) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (session.isAcceptingPlayers()) {
|
||||
Mode sessionMode = session.generator.getMode();
|
||||
|
|
|
|||
|
|
@ -38,18 +38,24 @@ public class AdminCommandHandler {
|
|||
public void handle(@NotNull String arg1, @NotNull String arg2,
|
||||
@NotNull CommandSender sender, @Nullable Player player) {
|
||||
|
||||
if (!sender.hasPermission(ParkourOption.ADMIN.permission)) return;
|
||||
if (!sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (arg1.toLowerCase()) {
|
||||
case "forcejoin" -> handleForceJoin(arg2, sender);
|
||||
case "forceleave" -> handleForceLeave(arg2, sender);
|
||||
case "reset" -> handleReset(arg2, sender);
|
||||
case "recoverinventory" -> handleRecoverInventory(arg2, sender);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
|
||||
if (player == null) return;
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg1.equals("schematic")) {
|
||||
if ("schematic".equals(arg1)) {
|
||||
SchematicCommandHandler.handleSubcommand(arg2, sender, player, base);
|
||||
}
|
||||
}
|
||||
|
|
@ -57,52 +63,72 @@ public class AdminCommandHandler {
|
|||
// ── forcejoin ──────────────────────────────────────────────────────────────
|
||||
|
||||
private void handleForceJoin(String target, CommandSender sender) {
|
||||
if (!base.cooldown(sender, "forcejoin", 2500, Locales.getString(sender, "admin.cooldown"))) return;
|
||||
if (!base.cooldown(sender, "forcejoin", 2500, Locales.getString(sender, "admin.cooldown"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.equalsIgnoreCase("everyone")) {
|
||||
if ("everyone".equalsIgnoreCase(target)) {
|
||||
Bukkit.getOnlinePlayers().forEach(p -> Modes.DEFAULT.create(p));
|
||||
send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.force_join_everyone"));
|
||||
return;
|
||||
}
|
||||
if (target.equalsIgnoreCase("nearest")) {
|
||||
if ("nearest".equalsIgnoreCase(target)) {
|
||||
Player closest = findNearest(sender);
|
||||
if (closest == null) return;
|
||||
if (closest == null) {
|
||||
return;
|
||||
}
|
||||
Modes.DEFAULT.create(closest);
|
||||
send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.force_join_player").formatted(closest.getName()));
|
||||
return;
|
||||
}
|
||||
Player other = Bukkit.getPlayer(target);
|
||||
if (other == null) { send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.player_not_online")); return; }
|
||||
if (other == null) {
|
||||
send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.player_not_online"));
|
||||
return;
|
||||
}
|
||||
Modes.DEFAULT.create(other);
|
||||
}
|
||||
|
||||
// ── forceleave ─────────────────────────────────────────────────────────────
|
||||
|
||||
private void handleForceLeave(String target, CommandSender sender) {
|
||||
if (!base.cooldown(sender, "forceleave", 2500, Locales.getString(sender, "admin.cooldown"))) return;
|
||||
if (!base.cooldown(sender, "forceleave", 2500, Locales.getString(sender, "admin.cooldown"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.equalsIgnoreCase("everyone")) {
|
||||
if ("everyone".equalsIgnoreCase(target)) {
|
||||
ParkourPlayer.getPlayers().forEach(ParkourUser::leave);
|
||||
send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.force_leave_everyone"));
|
||||
return;
|
||||
}
|
||||
Player other = Bukkit.getPlayer(target);
|
||||
if (other == null) { send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.player_not_online")); return; }
|
||||
if (other == null) {
|
||||
send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.player_not_online"));
|
||||
return;
|
||||
}
|
||||
ParkourUser user = ParkourUser.getUser(other);
|
||||
if (user == null) { send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.player_not_playing")); return; }
|
||||
if (user == null) {
|
||||
send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.player_not_playing"));
|
||||
return;
|
||||
}
|
||||
ParkourUser.leave(user);
|
||||
}
|
||||
|
||||
// ── reset ──────────────────────────────────────────────────────────────────
|
||||
|
||||
private void handleReset(String target, CommandSender sender) {
|
||||
if (!base.cooldown(sender, "reset", 2500, Locales.getString(sender, "admin.cooldown"))) return;
|
||||
if (!base.cooldown(sender, "reset", 2500, Locales.getString(sender, "admin.cooldown"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.equalsIgnoreCase("everyone")) {
|
||||
if ("everyone".equalsIgnoreCase(target)) {
|
||||
Registry.getModes().stream()
|
||||
.map(Mode::getLeaderboard)
|
||||
.filter(lb -> lb != null)
|
||||
.forEach(lb -> { lb.resetAll(); lb.write(true); });
|
||||
.forEach(lb -> {
|
||||
lb.resetAll();
|
||||
lb.write(true);
|
||||
});
|
||||
send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.reset_all"));
|
||||
return;
|
||||
}
|
||||
|
|
@ -113,7 +139,10 @@ public class AdminCommandHandler {
|
|||
Registry.getModes().stream()
|
||||
.map(Mode::getLeaderboard)
|
||||
.filter(lb -> lb != null)
|
||||
.forEach(lb -> { lb.remove(uuid); lb.write(true); });
|
||||
.forEach(lb -> {
|
||||
lb.remove(uuid);
|
||||
lb.write(true);
|
||||
});
|
||||
|
||||
send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.reset_player").formatted(name));
|
||||
}
|
||||
|
|
@ -121,9 +150,14 @@ public class AdminCommandHandler {
|
|||
// ── recoverinventory ───────────────────────────────────────────────────────
|
||||
|
||||
private void handleRecoverInventory(String target, CommandSender sender) {
|
||||
if (!base.cooldown(sender, "recoverinventory", 2500, Locales.getString(sender, "admin.cooldown"))) return;
|
||||
if (!base.cooldown(sender, "recoverinventory", 2500, Locales.getString(sender, "admin.cooldown"))) {
|
||||
return;
|
||||
}
|
||||
Player other = Bukkit.getPlayer(target);
|
||||
if (other == null) { send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.player_not_online")); return; }
|
||||
if (other == null) {
|
||||
send(sender, LoParkour.PREFIX + Locales.getString(sender, "admin.player_not_online"));
|
||||
return;
|
||||
}
|
||||
|
||||
new InventoryData(other).load(result -> {
|
||||
if (result != null) {
|
||||
|
|
@ -140,7 +174,9 @@ public class AdminCommandHandler {
|
|||
Location from = sender instanceof Player p ? p.getLocation()
|
||||
: sender instanceof BlockCommandSender b ? b.getBlock().getLocation()
|
||||
: null;
|
||||
if (from == null || from.getWorld() == null) return null;
|
||||
if (from == null || from.getWorld() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return from.getWorld().getPlayers().stream()
|
||||
.min((a, b) -> Double.compare(a.getLocation().distance(from), b.getLocation().distance(from)))
|
||||
|
|
@ -150,7 +186,9 @@ public class AdminCommandHandler {
|
|||
@SuppressWarnings("deprecation") // Bukkit: name-based OfflinePlayer lookup (admin-only)
|
||||
private UUID resolveUUID(String input) {
|
||||
Player online = Bukkit.getPlayerExact(input);
|
||||
if (online != null) return online.getUniqueId();
|
||||
if (online != null) {
|
||||
return online.getUniqueId();
|
||||
}
|
||||
if (input.contains("-")) {
|
||||
try {
|
||||
return UUID.fromString(input);
|
||||
|
|
@ -163,7 +201,9 @@ public class AdminCommandHandler {
|
|||
|
||||
private String resolvePlayerName(String input, UUID uuid) {
|
||||
Player online = Bukkit.getPlayerExact(input);
|
||||
if (online != null) return online.getName();
|
||||
if (online != null) {
|
||||
return online.getName();
|
||||
}
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(uuid);
|
||||
return op.getName() != null ? op.getName() : input;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,29 +37,43 @@ public class PlayerCommandHandler {
|
|||
switch (arg.toLowerCase()) {
|
||||
case "help" -> sendHelp(sender);
|
||||
case "reload" -> handleReload(sender, player);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
|
||||
if (player == null) return;
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (arg.toLowerCase()) {
|
||||
case "join" -> {
|
||||
if (!cooldown(sender, "join", 2500)) return;
|
||||
if (!cooldown(sender, "join", 2500)) {
|
||||
return;
|
||||
}
|
||||
if (!ParkourOption.JOIN.mayPerform(player)) {
|
||||
send(sender, Locales.getString(player, "other.no_do"));
|
||||
return;
|
||||
}
|
||||
if (ParkourUser.getUser(player) != null) return;
|
||||
if (ParkourUser.getUser(player) != null) {
|
||||
return;
|
||||
}
|
||||
Modes.DEFAULT.create(player);
|
||||
}
|
||||
case "leave" -> {
|
||||
if (!cooldown(sender, "leave", 2500)) return;
|
||||
if (!cooldown(sender, "leave", 2500)) {
|
||||
return;
|
||||
}
|
||||
ParkourUser.leave(player);
|
||||
}
|
||||
case "play" -> {
|
||||
if (ParkourOption.PLAY.mayPerform(player)) Menus.PLAY.open(player);
|
||||
if (ParkourOption.PLAY.mayPerform(player)) {
|
||||
Menus.PLAY.open(player);
|
||||
}
|
||||
}
|
||||
case "menu", "main" -> {
|
||||
if (ParkourOption.MAIN.mayPerform(player)) Menus.MAIN.open(player);
|
||||
if (ParkourOption.MAIN.mayPerform(player)) {
|
||||
Menus.MAIN.open(player);
|
||||
}
|
||||
}
|
||||
case "leaderboard" -> {
|
||||
if (!ParkourOption.LEADERBOARDS.mayPerform(player)) {
|
||||
|
|
@ -75,11 +89,15 @@ public class PlayerCommandHandler {
|
|||
}
|
||||
SchematicCommandHandler.sendHelp(player);
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleReload(@NotNull CommandSender sender, @Nullable Player player) {
|
||||
if (!cooldown(sender, "reload", 2500)) return;
|
||||
if (!cooldown(sender, "reload", 2500)) {
|
||||
return;
|
||||
}
|
||||
if (!sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||
send(sender, Locales.getString(sender, "other.no_do"));
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,10 @@ import java.util.Map;
|
|||
*/
|
||||
public class SchematicCommandHandler {
|
||||
|
||||
public static final Map<Player, Location[]> selections = new HashMap<>();
|
||||
private SchematicCommandHandler() {
|
||||
}
|
||||
|
||||
public static final Map<Player, Location[]> SELECTIONS = new HashMap<>();
|
||||
public static final NamespacedKey WAND_KEY = new NamespacedKey(LoParkour.getPlugin(), "schematic_wand");
|
||||
|
||||
private static ItemStack cachedWand;
|
||||
|
|
@ -53,10 +56,10 @@ public class SchematicCommandHandler {
|
|||
|
||||
@NotNull
|
||||
public static Location[] getSelection(@NotNull Player player) {
|
||||
Location[] sel = selections.get(player);
|
||||
Location[] sel = SELECTIONS.get(player);
|
||||
if (sel == null) {
|
||||
sel = new Location[]{null, null};
|
||||
selections.put(player, sel);
|
||||
SELECTIONS.put(player, sel);
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
|
|
@ -64,7 +67,7 @@ public class SchematicCommandHandler {
|
|||
public static void setPos(@NotNull Player player, @NotNull Location loc, int index) {
|
||||
Location[] updated = getSelection(player).clone();
|
||||
updated[index] = loc.clone();
|
||||
selections.put(player, updated);
|
||||
SELECTIONS.put(player, updated);
|
||||
}
|
||||
|
||||
public static void clearWandCache() {
|
||||
|
|
@ -161,7 +164,7 @@ public class SchematicCommandHandler {
|
|||
CommandSender sender,
|
||||
Player player
|
||||
) {
|
||||
Location[] sel = selections.get(player);
|
||||
Location[] sel = SELECTIONS.get(player);
|
||||
if (sel == null || sel[0] == null || sel[1] == null) {
|
||||
send(player, LoParkour.PREFIX + Locales.getString(player, "schematic.selection_incomplete"));
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue