Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add click event to /siege list #38

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -246,28 +248,33 @@ 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;
}

ComponentPaginator paginator = new ComponentPaginator(
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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down