From 78eeba20bbab1a761b24efb8c017af9e2863dc86 Mon Sep 17 00:00:00 2001 From: TylerS1066 Date: Thu, 25 Jul 2024 07:41:14 -0500 Subject: [PATCH] Add click event to /siege list (#38) --- .../warfare/commands/SiegeCommand.java | 25 ++++++++++++------- .../features/assault/AssaultRepair.java | 2 ++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/countercraft/movecraft/warfare/commands/SiegeCommand.java b/src/main/java/net/countercraft/movecraft/warfare/commands/SiegeCommand.java index 74697e1..1b0022a 100644 --- a/src/main/java/net/countercraft/movecraft/warfare/commands/SiegeCommand.java +++ b/src/main/java/net/countercraft/movecraft/warfare/commands/SiegeCommand.java @@ -17,6 +17,7 @@ import net.countercraft.movecraft.warfare.localisation.I18nSupport; import net.countercraft.movecraft.worldguard.MovecraftWorldGuard; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.event.ClickEvent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -232,9 +233,10 @@ private String secondsIntToString(int seconds) { return String.format("%02d", seconds / 60) + ":" + String.format("%02d", seconds % 60); } - private boolean listCommand(CommandSender commandSender, String[] args) { - if (!commandSender.hasPermission("movecraft.siege.list")) { - commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Insufficient Permissions")); + private boolean listCommand(@NotNull CommandSender sender, String[] args) { + if (!sender.hasPermission("movecraft.siege.list")) { + sender.sendMessage(ChatUtils.commandPrefix().append( + I18nSupport.getInternationalisedComponent("Insufficient Permissions"))); return true; } @@ -246,8 +248,12 @@ private boolean listCommand(CommandSender commandSender, String[] args) { else page = Integer.parseInt(args[1]); } catch (NumberFormatException e) { - commandSender.sendMessage(MOVECRAFT_COMMAND_PREFIX - + I18nSupport.getInternationalisedString("Paginator - Invalid Page") + " \"" + args[1] + "\""); + sender.sendMessage(Component.empty() + .append(ChatUtils.commandPrefix()) + .append(net.countercraft.movecraft.localisation.I18nSupport.getInternationalisedComponent("Paginator - Invalid page")) + .append(Component.text(" \"")) + .append(Component.text(args[1])) + .append(Component.text("\""))); return true; } @@ -255,19 +261,20 @@ private boolean listCommand(CommandSender commandSender, String[] args) { Component.text("Sieges"), pageNumber -> "/siege list " + pageNumber); for (Siege siege : siegeManager.getSieges()) { - paginator.addLine(Component.text("- ").append(Component.text(siege.getName()))); + paginator.addLine(Component.text("- ").append( + Component.text(siege.getName()).clickEvent(ClickEvent.runCommand("/siege info " + siege.getName())))); } if (!paginator.isInBounds(page)) { - commandSender.sendMessage(Component.empty() + sender.sendMessage(Component.empty() .append(ChatUtils.commandPrefix()) .append(net.countercraft.movecraft.localisation.I18nSupport.getInternationalisedComponent("Paginator - Invalid page")) .append(Component.text(" \"")) - .append(Component.text(args[0])) + .append(Component.text(args[1])) .append(Component.text("\""))); return true; } for (Component line : paginator.getPage(page)) - commandSender.sendMessage(line); + sender.sendMessage(line); return true; } diff --git a/src/main/java/net/countercraft/movecraft/warfare/features/assault/AssaultRepair.java b/src/main/java/net/countercraft/movecraft/warfare/features/assault/AssaultRepair.java index 4642f1f..d6020d4 100644 --- a/src/main/java/net/countercraft/movecraft/warfare/features/assault/AssaultRepair.java +++ b/src/main/java/net/countercraft/movecraft/warfare/features/assault/AssaultRepair.java @@ -1,6 +1,7 @@ package net.countercraft.movecraft.warfare.features.assault; import net.countercraft.movecraft.MovecraftLocation; +import net.countercraft.movecraft.repair.MovecraftRepair; import net.countercraft.movecraft.repair.util.WarfareUtils; import net.countercraft.movecraft.util.Pair; import net.countercraft.movecraft.warfare.MovecraftWarfare; @@ -54,6 +55,7 @@ public boolean repairRegionRepairState(World world, String regionName, @Nullable ChunkRepairTask repairTask = new ChunkRepairTask(world, regionName, chunks, saveDirectory, regionTester, player); repairTask.runTaskTimer(MovecraftWarfare.getInstance(), 2, Config.AssaultChunkRepairPeriod); + MovecraftRepair.getInstance().getLogger().info("Repairing region " + regionName + " in " + world.getName() + (player != null ? " for " + player.getName() : "")); return true; }