From 0cdfcb9ff4ea2a12b0ba41aa229ad9fc37beb01f Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 27 Feb 2019 16:39:45 +0100 Subject: [PATCH] Restart impr. --- .idea/compiler.xml | 2 +- .../restart/PrimeRestartCommand.java | 4 +-- .../component/restart/RestartComponent.java | 6 +++-- .../restart/ScheduledRestartCommand.java | 27 +++++++++---------- ButtonProcessor/ButtonProcessor.iml | 1 + 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index ba952b2..b761e6a 100755 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -12,7 +12,7 @@ - + diff --git a/ButtonCore/src/main/java/buttondevteam/core/component/restart/PrimeRestartCommand.java b/ButtonCore/src/main/java/buttondevteam/core/component/restart/PrimeRestartCommand.java index f387b1d..389da82 100644 --- a/ButtonCore/src/main/java/buttondevteam/core/component/restart/PrimeRestartCommand.java +++ b/ButtonCore/src/main/java/buttondevteam/core/component/restart/PrimeRestartCommand.java @@ -20,12 +20,12 @@ public class PrimeRestartCommand extends TBMCCommandBase { if (Bukkit.getOnlinePlayers().size() > 0) { sender.sendMessage("§bPlayers online, restart delayed."); if (loud) - TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, ChatColor.DARK_RED + "The server will restart as soon as nobody is online.", component.restartBroadcast); + TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, ChatColor.DARK_RED + "The server will restart as soon as nobody is online.", component.getRestartBroadcast()); plsrestart = true; } else { sender.sendMessage("§bNobody is online. Restarting now."); if (loud) - TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, "§cNobody is online. Restarting server.", component.restartBroadcast); + TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, "§cNobody is online. Restarting server.", component.getRestartBroadcast()); Bukkit.spigot().restart(); } return true; diff --git a/ButtonCore/src/main/java/buttondevteam/core/component/restart/RestartComponent.java b/ButtonCore/src/main/java/buttondevteam/core/component/restart/RestartComponent.java index 332f9dc..f8eeb11 100644 --- a/ButtonCore/src/main/java/buttondevteam/core/component/restart/RestartComponent.java +++ b/ButtonCore/src/main/java/buttondevteam/core/component/restart/RestartComponent.java @@ -5,6 +5,7 @@ import buttondevteam.lib.TBMCSystemChatEvent; import buttondevteam.lib.architecture.Component; import buttondevteam.lib.chat.IFakePlayer; import buttondevteam.lib.chat.TBMCChatAPI; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.event.EventHandler; @@ -15,7 +16,7 @@ public class RestartComponent extends Component implements Listener { @Override public void enable() { //TODO: Permissions for the commands - TBMCChatAPI.AddCommand(this, new ScheduledRestartCommand(this)); + registerCommand(new ScheduledRestartCommand(this)); TBMCChatAPI.AddCommand(this, new PrimeRestartCommand(this)); registerListener(this); restartBroadcast = TBMCSystemChatEvent.BroadcastTarget.add("restartCountdown"); @@ -27,7 +28,8 @@ public class RestartComponent extends Component implements Listener { } private long lasttime = 0; - TBMCSystemChatEvent.BroadcastTarget restartBroadcast; + @Getter + private TBMCSystemChatEvent.BroadcastTarget restartBroadcast; @EventHandler public void onPlayerLeave(PlayerQuitEvent event) { diff --git a/ButtonCore/src/main/java/buttondevteam/core/component/restart/ScheduledRestartCommand.java b/ButtonCore/src/main/java/buttondevteam/core/component/restart/ScheduledRestartCommand.java index 3f83e48..dabd48a 100755 --- a/ButtonCore/src/main/java/buttondevteam/core/component/restart/ScheduledRestartCommand.java +++ b/ButtonCore/src/main/java/buttondevteam/core/component/restart/ScheduledRestartCommand.java @@ -3,9 +3,10 @@ package buttondevteam.core.component.restart; import buttondevteam.core.MainPlugin; import buttondevteam.core.component.channel.Channel; import buttondevteam.lib.ScheduledServerRestartEvent; +import buttondevteam.lib.chat.Command2; import buttondevteam.lib.chat.CommandClass; +import buttondevteam.lib.chat.ICommand2MC; import buttondevteam.lib.chat.TBMCChatAPI; -import buttondevteam.lib.chat.TBMCCommandBase; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Setter; @@ -17,18 +18,23 @@ import org.bukkit.boss.BossBar; import org.bukkit.command.CommandSender; import org.bukkit.scheduler.BukkitTask; -@CommandClass(modOnly = true, path = "schrestart") +@CommandClass(modOnly = true, path = "schrestart", helpText = { + "Scheduled restart", // + "This command restarts the server 1 minute after it's executed, warning players every 10 seconds.", // + "You can optionally set the amount of seconds to wait before the restart." // +}) @RequiredArgsConstructor -public class ScheduledRestartCommand extends TBMCCommandBase { +public class ScheduledRestartCommand extends ICommand2MC { @Getter @Setter private int restartCounter; private BukkitTask restarttask; private volatile BossBar restartbar; + @Getter private final RestartComponent component; - @Override - public boolean OnCommand(CommandSender sender, String alias, String[] args) { + @Command2.Subcommand + public boolean def(CommandSender sender, String alias, String[] args) { int secs = 60; try { if (args.length > 0) @@ -56,20 +62,11 @@ public class ScheduledRestartCommand extends TBMCCommandBase { Bukkit.spigot().restart(); } if (restartCounter % 200 == 0) - TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, "§c-- The server is restarting in " + restartCounter / 20 + " seconds! (/press)", component.restartBroadcast); + TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, "§c-- The server is restarting in " + restartCounter / 20 + " seconds! (/press)", component.getRestartBroadcast()); restartbar.setProgress(restartCounter / (double) restarttime); restartbar.setTitle(String.format("Server restart in %.2f", restartCounter / 20f)); restartCounter--; }, 1, 1); return true; } - - @Override - public String[] GetHelpText(String alias) { - return new String[] { // - "§6---- Scheduled restart ----", // - "This command restarts the server 1 minute after it's executed, warning players every 10 seconds.", // - "You can optionally set the amount of ticks to wait before the restart." // - }; - } } diff --git a/ButtonProcessor/ButtonProcessor.iml b/ButtonProcessor/ButtonProcessor.iml index 35bfd14..3c6a51e 100755 --- a/ButtonProcessor/ButtonProcessor.iml +++ b/ButtonProcessor/ButtonProcessor.iml @@ -13,6 +13,7 @@ +