Added silent/loud option to primerestart
Also using Tabs for formatting
This commit is contained in:
parent
9bb8713714
commit
806550a625
3 changed files with 35 additions and 15 deletions
11
.idea/inspectionProfiles/Project_Default.xml
Normal file
11
.idea/inspectionProfiles/Project_Default.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="WeakerAccess" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="false" />
|
||||
<option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="false" />
|
||||
<option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" />
|
||||
<disabledExtension id="moduleInfo" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
|
@ -40,10 +40,12 @@ public class PlayerListener implements Listener {
|
|||
&& !event.getQuitMessage().equalsIgnoreCase("Server closed")
|
||||
&& !event.getQuitMessage().equalsIgnoreCase("Server is restarting")) {
|
||||
if (Bukkit.getOnlinePlayers().size() <= 1) {
|
||||
if (PrimeRestartCommand.isLoud())
|
||||
Bukkit.broadcastMessage("§cNobody is online anymore. Restarting.");
|
||||
Bukkit.spigot().restart();
|
||||
} else if (!(event.getPlayer() instanceof IDiscordSender) && System.nanoTime() - 10 * 1000000000L - lasttime > 0) { //Ten seconds passed since last reminder
|
||||
lasttime = System.nanoTime();
|
||||
if (PrimeRestartCommand.isLoud())
|
||||
Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,15 @@ import org.bukkit.command.CommandSender;
|
|||
public class PrimeRestartCommand extends TBMCCommandBase {
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
loud = args.length > 0;
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
sender.sendMessage("§bPlayers online, restart delayed.");
|
||||
if (loud)
|
||||
Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online.");
|
||||
plsrestart = true;
|
||||
} else {
|
||||
sender.sendMessage("§bNobody is online. Restarting now.");
|
||||
if (loud)
|
||||
Bukkit.broadcastMessage("§cNobody is online. Restarting server.");
|
||||
Bukkit.spigot().restart();
|
||||
}
|
||||
|
@ -25,12 +28,16 @@ public class PrimeRestartCommand extends TBMCCommandBase {
|
|||
|
||||
@Getter
|
||||
private static boolean plsrestart = false;
|
||||
@Getter
|
||||
private static boolean loud = false;
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
return new String[]{ //
|
||||
"§6---- Prime restart ----", //
|
||||
"Restarts the server as soon as nobody is online." //
|
||||
"Restarts the server as soon as nobody is online.", //
|
||||
"To be loud, type something after, like /primerestart lol (it doesn't matter what you write)", //
|
||||
"To be silent, don't type anything" //
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue