2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2012-09-19 00:30:18 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
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;
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.NON_OP, source = SourceType.BOTH)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Switch server online-mode on and off.", usage = "/<command> <on | off>")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_onlinemode extends FreedomCommand
|
2012-09-19 00:30:18 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2012-09-19 00:30:18 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2012-09-19 00:30:18 +00:00
|
|
|
{
|
|
|
|
if (args.length < 1)
|
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", ChatColor.WHITE);
|
|
|
|
msg("\"/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
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
boolean onlineMode;
|
2013-09-17 16:05:53 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
if (sender instanceof Player && !plugin.al.isSeniorAdmin(sender))
|
2013-09-17 14:57:15 +00:00
|
|
|
{
|
2015-11-15 23:32:04 +00:00
|
|
|
noPerms();
|
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"))
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
onlineMode = true;
|
2012-09-19 00:30:18 +00:00
|
|
|
}
|
|
|
|
else if (args[0].equalsIgnoreCase("off"))
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
onlineMode = false;
|
2012-09-19 00:30:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
plugin.si.setOnlineMode(onlineMode);
|
2012-09-19 00:30:18 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
if (onlineMode)
|
2012-09-19 00:30:18 +00:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Turning player validation " + (onlineMode ? "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
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
FLog.severe(ex);
|
2012-09-19 00:30:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|