2012-09-19 00:30:18 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
|
|
|
2014-12-21 09:23:50 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
|
2012-09-19 00:30:18 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
2012-12-09 03:42:29 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
2012-09-19 00:30:18 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
2013-01-07 14:56:53 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2012-09-19 00:30:18 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2013-09-17 16:05:53 +00:00
|
|
|
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Switch server online-mode on and off.", usage = "/<command> <on | off>")
|
2012-09-19 00:30:18 +00:00
|
|
|
public class Command_onlinemode extends TFM_Command
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
|
|
|
if (args.length < 1)
|
|
|
|
{
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", ChatColor.WHITE);
|
2013-09-17 16:05:53 +00:00
|
|
|
playerMsg("\"/onlinemode on\" and \"/onlinemode off\" can be used to change online mode from the console.", ChatColor.WHITE);
|
2012-09-19 00:30:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
boolean online_mode;
|
2013-09-17 16:05:53 +00:00
|
|
|
|
2014-04-09 20:33:03 +00:00
|
|
|
if (sender instanceof Player && !TFM_AdminList.isSeniorAdmin(sender, true))
|
2013-09-17 14:57:15 +00:00
|
|
|
{
|
2014-08-23 18:19:25 +00:00
|
|
|
playerMsg(TFM_Command.MSG_NO_PERMS);
|
2013-09-17 14:57:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-09-17 16:05:53 +00:00
|
|
|
|
2012-09-19 00:30:18 +00:00
|
|
|
if (args[0].equalsIgnoreCase("on"))
|
|
|
|
{
|
|
|
|
online_mode = true;
|
|
|
|
}
|
|
|
|
else if (args[0].equalsIgnoreCase("off"))
|
|
|
|
{
|
|
|
|
online_mode = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2012-12-09 03:42:29 +00:00
|
|
|
TFM_ServerInterface.setOnlineMode(online_mode);
|
2012-09-19 00:30:18 +00:00
|
|
|
|
|
|
|
if (online_mode)
|
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
for (Player player : server.getOnlinePlayers())
|
2012-09-19 00:30:18 +00:00
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
player.kickPlayer("Server is activating \"online-mode=true\". Please reconnect.");
|
2012-09-19 00:30:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-22 21:03:43 +00:00
|
|
|
TFM_Util.adminAction(sender.getName(), "Turning player validation " + (online_mode ? "on" : "off") + ".", true);
|
2012-09-19 00:30:18 +00:00
|
|
|
|
|
|
|
server.reload();
|
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (Exception ex)
|
2012-09-19 00:30:18 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_Log.severe(ex);
|
2012-09-19 00:30:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|