diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index ee3a1402..5d654d65 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -523,8 +523,14 @@ BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht TICK_STEP_HELP = §8/§etick step §8<§7Ticks§8> §8- §7Spule n Ticks vor TICK_STEP_SINGLE_HELP = §8/§etick step §8- §7Spule einen Ticks vor TICK_WARP_HELP = §8/§etick warp §8<§7Ticks§8> §8- §7Warpe n Ticks vor +TICK_CANCEL_HELP = §8/§etick cancel §8- §7Cancelt den Tick Warp oder Step +TICK_ERROR = §cDu kannst keinen weiteren §8'§e/tick step§8'§c oder §8'§e/tick warp§8'§c anmachen +TICK_CANCEL_ERROR = §cDu hast keinen §8'§e/tick step§8'§c oder §8'§e/tick warp§8'§c aktiv TICK_STEP = §eSpult {0} Ticks vor +TICK_STEP_LEFT = §eSpult noch {0} Ticks vor TICK_WARP = §eWarpe {0} Ticks vor +TICK_WARP_LEFT = §eWarpe noch {0} Ticks vor +TICK_CANCEL = §eWarps und Steps abgebrochen TPSLIMIT_GUI_ITEM_NAME = §eTPS Limiter TPSLIMIT_GUI_ITEM_LORE = §7Aktuell: §e{0} TPSLIMIT_ANVIL_GUI = Neues TPS Limit diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TickCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TickCommand.java index ffd34cda..8e4b7c86 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TickCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TickCommand.java @@ -29,12 +29,14 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; @Linked(LinkageType.COMMAND) public class TickCommand extends SWCommand { private AtomicInteger ticksLeft = null; private Runnable disableTask = null; + private Consumer ticksLeftActionBar = null; public TickCommand() { super("tick"); @@ -55,19 +57,18 @@ public class TickCommand extends SWCommand { disableTask = null; ticksLeft = null; } + if (ticksLeftActionBar != null && ticksLeft != null) { + ticksLeftActionBar.accept(ticksLeft.get()); + } } }.runTaskTimer(BauSystem.getInstance(), 0L, 1L); } - @Register(value = {"step"}, description = "TICK_STEP_SINGLE_HELP") - public void stepCommand(Player p) { - stepCommand(p, 1); - } - - @Register(value = {"step"}, description = "TICK_STEP_HELP") - public void stepCommand(Player p, @OptionalValue("1") int ticks) { // TODO: Fix OptionalValue + @Register(value = {"step"}, description = {"TICK_STEP_SINGLE_HELP", "TICK_STEP_HELP"}) + public void stepCommand(Player p, @OptionalValue("1") int ticks) { if (!TPSLimitCommand.permissionCheck(p)) return; if (ticksLeft != null) { + BauSystem.MESSAGE.send("TICK_ERROR", p); return; } Bukkit.getOnlinePlayers().forEach(player -> { @@ -76,12 +77,18 @@ public class TickCommand extends SWCommand { FreezeUtils.unfreeze(); ticksLeft = new AtomicInteger(ticks); disableTask = FreezeUtils::freeze; + ticksLeftActionBar = currentTicksLeft -> { + Bukkit.getOnlinePlayers().forEach(player -> { + SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TICK_STEP_LEFT", player, currentTicksLeft)); + }); + }; } @Register(value = {"warp"}, description = "TICK_WARP_HELP") public void warpCommand(Player p, int ticks) { if (!TPSLimitCommand.permissionCheck(p)) return; if (ticksLeft != null) { + BauSystem.MESSAGE.send("TICK_ERROR", p); return; } Bukkit.getOnlinePlayers().forEach(player -> { @@ -101,5 +108,23 @@ public class TickCommand extends SWCommand { TPSLimitUtils.currentTPSLimit = currentTPSLimit; TPSLimitUtils.tpsLimiter(); }; + ticksLeftActionBar = currentTicksLeft -> { + Bukkit.getOnlinePlayers().forEach(player -> { + SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TICK_WARP_LEFT", player, currentTicksLeft)); + }); + }; + } + + @Register(value = {"cancel"}, description = "TICK_CANCEL_HELP") + public void cancelCommand(Player p) { + if (!TPSLimitCommand.permissionCheck(p)) return; + if (ticksLeft == null) { + BauSystem.MESSAGE.send("TICK_CANCEL_ERROR", p); + return; + } + ticksLeft.set(0); + Bukkit.getOnlinePlayers().forEach(player -> { + SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TICK_CANCEL", player)); + }); } }