2011-10-19 00:37:00 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
|
|
|
2013-01-21 18:58:42 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
2011-10-19 00:37:00 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
2013-07-27 21:49:25 +00:00
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2013-03-19 22:05:20 +00:00
|
|
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]")
|
2011-10-19 00:37:00 +00:00
|
|
|
public class Command_fr extends TFM_Command
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
if (args.length == 0)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
TotalFreedomMod.allPlayersFrozen = !TotalFreedomMod.allPlayersFrozen;
|
|
|
|
|
|
|
|
if (TotalFreedomMod.allPlayersFrozen)
|
|
|
|
{
|
2014-01-09 00:34:57 +00:00
|
|
|
TFM_Util.adminAction(sender.getName(), "Freezing all players due to rule breakers", false);
|
2013-01-16 14:48:56 +00:00
|
|
|
TotalFreedomMod.allPlayersFrozen = true;
|
2013-07-27 21:49:25 +00:00
|
|
|
|
|
|
|
if (TotalFreedomMod.freezePurgeTask != null)
|
|
|
|
{
|
|
|
|
TotalFreedomMod.freezePurgeTask.cancel();
|
|
|
|
}
|
|
|
|
TotalFreedomMod.freezePurgeTask = new BukkitRunnable()
|
2013-01-16 14:48:56 +00:00
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
TFM_Util.adminAction("FreezeTimer", "Unfreezing all players", false);
|
|
|
|
TotalFreedomMod.allPlayersFrozen = false;
|
|
|
|
}
|
2013-07-27 21:49:25 +00:00
|
|
|
}.runTaskLater(plugin, 20L * 60L * 5L);
|
|
|
|
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg("Players are now frozen.");
|
2012-11-24 01:22:52 +00:00
|
|
|
}
|
|
|
|
else
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
TFM_Util.adminAction(sender.getName(), "Unfreezing all players", false);
|
2013-01-16 14:48:56 +00:00
|
|
|
TotalFreedomMod.allPlayersFrozen = false;
|
2013-07-27 21:49:25 +00:00
|
|
|
if (TotalFreedomMod.freezePurgeTask != null)
|
2013-01-16 14:48:56 +00:00
|
|
|
{
|
2013-07-27 21:49:25 +00:00
|
|
|
TotalFreedomMod.freezePurgeTask.cancel();
|
2013-01-16 14:48:56 +00:00
|
|
|
}
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg("Players are now free to move.");
|
2012-11-24 01:22:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (args[0].toLowerCase().equals("purge"))
|
|
|
|
{
|
|
|
|
TotalFreedomMod.allPlayersFrozen = false;
|
2013-07-29 17:37:31 +00:00
|
|
|
if (TotalFreedomMod.freezePurgeTask != null)
|
|
|
|
{
|
|
|
|
TotalFreedomMod.freezePurgeTask.cancel();
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
for (Player player : server.getOnlinePlayers())
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
2012-11-24 01:22:52 +00:00
|
|
|
playerdata.setFrozen(false);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
|
|
|
|
TFM_Util.adminAction(sender.getName(), "Lifting all global and player freezes", false);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
Player player;
|
2012-11-24 01:22:52 +00:00
|
|
|
try
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
player = getPlayer(args[0]);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (PlayerNotFoundException ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
playerMsg(ex.getMessage(), ChatColor.RED);
|
2012-11-24 01:22:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
2012-11-24 01:22:52 +00:00
|
|
|
playerdata.setFrozen(!playerdata.isFrozen());
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
playerMsg(player.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
|
|
|
playerMsg(player, "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|