Restart impr.
This commit is contained in:
parent
e4f5850ad6
commit
0cdfcb9ff4
5 changed files with 20 additions and 20 deletions
|
@ -12,7 +12,7 @@
|
|||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="BuildConfigUpdater" target="1.8" />
|
||||
<module name="BuildConfigUpdater" target="1.5" />
|
||||
<module name="ButtonCore" target="1.5" />
|
||||
<module name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" target="1.8" />
|
||||
<module name="ButtonProcessor" target="1.8" />
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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." //
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.21" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.21" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
|
|
Loading…
Reference in a new issue