2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
2011-10-19 00:37:00 +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.FUtil;
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.freeze.FreezeData;
|
2014-11-20 22:20:31 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2011-10-19 00:37:00 +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.SUPER_ADMIN, source = SourceType.BOTH)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_fr extends FreedomCommand
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2014-12-21 09:23:50 +00:00
|
|
|
|
2011-10-19 00:37:00 +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)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
if (args.length == 0)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2015-11-15 23:32:04 +00:00
|
|
|
boolean allFrozen = plugin.fm.isGlobalFreeze();
|
|
|
|
plugin.fm.setGlobalFreeze(!allFrozen);
|
2012-11-24 01:22:52 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
if (!allFrozen)
|
2012-11-24 01:22:52 +00:00
|
|
|
{
|
2015-11-15 23:32:04 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Disabling global player freeze", true);
|
|
|
|
playerMsg("Players are now free to move.");
|
|
|
|
return true;
|
|
|
|
}
|
2013-07-27 21:49:25 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Disabling global player freeze", true);
|
|
|
|
playerMsg("Players are now unfrozen.");
|
2014-12-21 09:23:50 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
for (Player player : server.getOnlinePlayers())
|
|
|
|
{
|
|
|
|
if (!isAdmin(player))
|
2014-01-15 21:38:35 +00:00
|
|
|
{
|
2015-11-15 23:32:04 +00:00
|
|
|
playerMsg(player, "You have been frozen due to rulebreakers, you will be unfrozen soon.", ChatColor.RED);
|
2014-01-15 21:38:35 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
}
|
2015-11-15 23:32:04 +00:00
|
|
|
return true;
|
2012-11-24 01:22:52 +00:00
|
|
|
}
|
2014-05-04 21:03:34 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
if (args[0].equals("purge"))
|
|
|
|
{
|
|
|
|
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
|
|
|
|
plugin.fm.purge();
|
|
|
|
return true;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
final Player player = getPlayer(args[0]);
|
2014-12-21 09:23:50 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
if (player == null)
|
2014-12-21 09:23:50 +00:00
|
|
|
{
|
2015-11-15 23:32:04 +00:00
|
|
|
playerMsg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
|
|
|
return true;
|
2014-12-21 09:23:50 +00:00
|
|
|
}
|
2015-11-15 23:32:04 +00:00
|
|
|
|
|
|
|
final FreezeData fd = plugin.pl.getPlayer(player).getFreezeData();
|
|
|
|
fd.setFrozen(!fd.isFrozen());
|
|
|
|
|
|
|
|
playerMsg(player.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
|
|
|
|
playerMsg(player, "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
|
|
|
|
|
|
|
|
return true;
|
2014-12-21 09:23:50 +00:00
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|