parent
7e63ae12e6
commit
4519d5f64a
5 changed files with 41 additions and 1 deletions
|
@ -39,6 +39,7 @@ public class MainPlugin extends JavaPlugin {
|
|||
saveConfig();
|
||||
TBMCChatAPI.AddCommand(this, UpdatePluginCommand.class);
|
||||
TBMCChatAPI.AddCommand(this, ScheduledRestartCommand.class);
|
||||
TBMCChatAPI.AddCommand(this, PrimeRestartCommand.class);
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
|
||||
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class);
|
||||
TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fOOC§f", Color.White, "ooc", null));
|
||||
|
|
|
@ -19,6 +19,10 @@ public class PlayerListener implements Listener {
|
|||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void OnPlayerLeave(PlayerQuitEvent event) {
|
||||
TBMCPlayerBase.quitPlayer(event.getPlayer());
|
||||
if (PrimeRestartCommand.isPlsrestart() && Bukkit.getOnlinePlayers().size() <= 1) {
|
||||
Bukkit.broadcastMessage("§cNobody is online anymore. Restarting.");
|
||||
Bukkit.spigot().restart();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package buttondevteam.core;
|
||||
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandClass(path = "primerestart", modOnly = true)
|
||||
public class PrimeRestartCommand extends TBMCCommandBase {
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
sender.sendMessage("§bPlayers online, restart delayed.");
|
||||
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.");
|
||||
Bukkit.broadcastMessage("§cNobody is online. Restarting server.");
|
||||
Bukkit.spigot().restart();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private static boolean plsrestart = false;
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -7,3 +7,5 @@ commands:
|
|||
description: Update a TBMC plugin
|
||||
schrestart:
|
||||
description: Schedules a restart for a given time.
|
||||
primerestart:
|
||||
description: Restarts the server as soon as nobody is online.
|
||||
|
|
|
@ -6,5 +6,5 @@ if [ $1 = 'production' ]; then
|
|||
echo Production mode
|
||||
echo $UPLOAD_KEY > upload_key
|
||||
chmod 400 upload_key
|
||||
yes | scp -B -i upload_key -o StrictHostKeyChecking=no $FILENAME travis@server.figytuna.com:/minecraft/main/plugins
|
||||
yes | scp -B -i upload_key -o StrictHostKeyChecking=no $FILENAME travis@server.figytuna.com:/minecraft/main/TBMC/pluginupdates
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue