1
0
forked from xjboss/KCauldronX

Make configurable messages, close #244

This commit is contained in:
Sergey Shatunov
2016-01-05 13:54:34 +07:00
parent 955af15697
commit 0aad7977fc
5 changed files with 42 additions and 13 deletions

View File

@ -2,9 +2,12 @@ package org.spigotmc;
import java.io.File;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.entity.Player;
public class RestartCommand extends Command
{
@ -40,12 +43,14 @@ public class RestartCommand extends Command
{
System.out.println( "Attempting to restart with " + SpigotConfig.restartScript );
// Forbid new logons
net.minecraft.server.dedicated.DedicatedServer.allowPlayerLogins = false;
// Kick all players
for ( net.minecraft.entity.player.EntityPlayerMP p : (List< net.minecraft.entity.player.EntityPlayerMP>) net.minecraft.server.MinecraftServer.getServer().getConfigurationManager().playerEntityList )
{
p.playerNetServerHandler.kickPlayerFromServer(SpigotConfig.restartMessage);
p.playerNetServerHandler.netManager.isChannelOpen();
for (Player player : Bukkit.getOnlinePlayers()) {
player.kickPlayer(SpigotConfig.restartMessage);
}
// Give the socket a chance to send the packets
try
{
@ -67,7 +72,7 @@ public class RestartCommand extends Command
// Actually shutdown
try
{
net.minecraft.server.MinecraftServer.getServer().stopServer();
Bukkit.shutdown();
} catch ( Throwable t )
{
}
@ -88,7 +93,7 @@ public class RestartCommand extends Command
{
Runtime.getRuntime().exec( new String[]
{
"sh", file.getPath()
"/bin/sh", file.getPath()
} );
}
} catch ( Exception e )