How to install:
Place this plugin in all your servers BUT not the backup one yes including the hub etc...
edit
with your backup server nameCode (yaml):sendserver: backuphub
Info:
When /reboot is performed and user has permission it will send a request to all servers that have this plugin on your network, it will then move all players to a defined server in the config then it will shut down the servers BUT won't shut down the backup one.
This plugin is only good if say your updating all your servers with a new build or adding a plugin to all servers.
Note: -_- Remember NOT to put this into the backuphub server .
This is only good if you have a auto restart script such as this otherwise your server will not start back up
Commands:Code (javascript):
echo "----------------"
echo "Launching..."
echo "----------------"
#!/bin/sh
BINDIR=$(dirname "$(readlink -fn "$0")")
cd "$BINDIR"
while : ; do
echo "----------------"
echo "Starting up..."
echo "----------------"
sleep 1
java -jar spigot.jar
echo "Restarting in 3 seconds, or press CTRL + C to cancel."
sleep 1
echo "Restarting in 2 seconds, or press CTRL + C to cancel."
sleep 1
echo "Restarting in 1 second, or press CTRL + C to cancel."
sleep 1
done
/reboot
Permissions:
reboot.perform - /reboot
Code (javascript):
package me.shawshark.reboot;
import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import lilypad.client.connect.api.Connect;
import lilypad.client.connect.api.event.EventListener;
import lilypad.client.connect.api.event.MessageEvent;
import lilypad.client.connect.api.request.RequestException;
import lilypad.client.connect.api.request.impl.MessageRequest;
import lilypad.client.connect.api.request.impl.RedirectRequest;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class main extends JavaPlugin implements Listener {
public Connect connect;
public void onEnable() {
try {
getConfig().options().copyDefaults(true);
saveConfig();
Bukkit.getPluginManager().registerEvents(this, this);
connect = Bukkit.getServer().getServicesManager().getRegistration(Connect.class).getProvider();
connect.registerEvents(this);
} catch(Exception ex) {
ex.printStackTrace();
}
}
public void onDisable() {
try {
connect = null;
} catch(Exception ex) {
ex.printStackTrace();
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player)sender;
if(command.getName().equalsIgnoreCase("reboot")) {
if(p.hasPermission("reboot.perform")) {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
sendshutdownrequest(p.getName(), dateFormat.format(date));
p.sendMessage(ChatColor.GOLD + "Request Sent!");
} else {
String message = getConfig().getString("noperms");
p.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
}
}
return false;
}
public void sendshutdownrequest(String player, String time) {
try {
MessageRequest request = new MessageRequest(Collections.<String> emptyList(), "Reboot",
player + "%,%" + time);
connect.request(request);
} catch (UnsupportedEncodingException | RequestException e1) {
e1.printStackTrace();
}
}
@EventListener
public void onMessage(MessageEvent event) {
String[] data = null;
if(event.getChannel().equalsIgnoreCase("Reboot")) {
try {
data = event.getMessageAsString().split("%,%");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return;
}
String player = data[0];
String time = data[1];
getConfig().set("request.log." + time, player);
prepare();
}
else if(event.getChannel().equalsIgnoreCase("Reboot.Sendback")) {
try {
data = event.getMessageAsString().split("%,%");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return;
}
String servername = data[0];
String test = data[1];
redirect(servername, test);
}
}
public void prepare() {
for(Player p : getServer().getOnlinePlayers()) {
String message = getConfig().getString("onsendmessage");
p.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
redirect(getConfig().getString("sendserver"), p.getName());
}
shutdown();
}
public void shutdown() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
getServer().shutdown();
}
}, 150);
}
public void redirect(String server, String player) {
try {
connect.request(new RedirectRequest(server, player));
} catch (RequestException e) { e.printStackTrace();
}
}
}
-
Welcome to LilyPad. Download the project, explore the forums, and create your own LilyPad network.
If you use the software and enjoy it or have a question, or would like to contribute to the future of the software directly or through resources, please sign up and join our little community.