Added /primerestart

And started using new plugin updater
#34
This commit is contained in:
Norbi Peti 2018-05-31 03:07:12 +02:00
parent 7e63ae12e6
commit 4519d5f64a
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
5 changed files with 41 additions and 1 deletions

View file

@ -39,6 +39,7 @@ public class MainPlugin extends JavaPlugin {
saveConfig(); saveConfig();
TBMCChatAPI.AddCommand(this, UpdatePluginCommand.class); TBMCChatAPI.AddCommand(this, UpdatePluginCommand.class);
TBMCChatAPI.AddCommand(this, ScheduledRestartCommand.class); TBMCChatAPI.AddCommand(this, ScheduledRestartCommand.class);
TBMCChatAPI.AddCommand(this, PrimeRestartCommand.class);
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this); TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class); TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class);
TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fOOC§f", Color.White, "ooc", null)); TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fOOC§f", Color.White, "ooc", null));

View file

@ -19,6 +19,10 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void OnPlayerLeave(PlayerQuitEvent event) { public void OnPlayerLeave(PlayerQuitEvent event) {
TBMCPlayerBase.quitPlayer(event.getPlayer()); 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) @EventHandler(priority = EventPriority.HIGHEST)

View file

@ -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];
}
}

View file

@ -7,3 +7,5 @@ commands:
description: Update a TBMC plugin description: Update a TBMC plugin
schrestart: schrestart:
description: Schedules a restart for a given time. description: Schedules a restart for a given time.
primerestart:
description: Restarts the server as soon as nobody is online.

View file

@ -6,5 +6,5 @@ if [ $1 = 'production' ]; then
echo Production mode echo Production mode
echo $UPLOAD_KEY > upload_key echo $UPLOAD_KEY > upload_key
chmod 400 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 fi