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 org.bukkit.GameMode;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2013-03-19 22:05:20 +00:00
|
|
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
2013-09-26 00:46:03 +00:00
|
|
|
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [outermaterial] [innermaterial]>")
|
2011-10-19 00:37:00 +00:00
|
|
|
public class Command_cage extends TFM_Command
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2012-11-23 03:48:28 +00:00
|
|
|
if (args.length == 0)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-23 03:48:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
2013-08-26 22:44:18 +00:00
|
|
|
|
2014-05-05 13:31:12 +00:00
|
|
|
if ("off".equals(args[0]) && sender instanceof Player)
|
2013-08-26 13:04:36 +00:00
|
|
|
{
|
2013-08-26 15:22:35 +00:00
|
|
|
TFM_Util.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
2013-08-26 13:04:36 +00:00
|
|
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(sender_p);
|
2013-08-26 22:44:18 +00:00
|
|
|
|
2013-08-26 13:04:36 +00:00
|
|
|
playerdata.setCaged(false);
|
|
|
|
playerdata.regenerateHistory();
|
|
|
|
playerdata.clearHistory();
|
2013-09-26 00:46:03 +00:00
|
|
|
|
2013-08-26 13:04:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-05-05 13:31:12 +00:00
|
|
|
else if ("purge".equals(args[0]))
|
2013-09-26 00:33:44 +00:00
|
|
|
{
|
2014-05-05 14:10:14 +00:00
|
|
|
TFM_Util.adminAction(sender.getName(), "Uncaging all players", true);
|
2013-09-26 00:46:03 +00:00
|
|
|
|
|
|
|
for (Player player : server.getOnlinePlayers())
|
2013-09-26 00:33:44 +00:00
|
|
|
{
|
2013-09-26 00:46:03 +00:00
|
|
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
2013-09-26 00:33:44 +00:00
|
|
|
playerdata.setCaged(false);
|
|
|
|
playerdata.regenerateHistory();
|
|
|
|
playerdata.clearHistory();
|
|
|
|
}
|
2013-09-26 00:46:03 +00:00
|
|
|
|
2013-09-26 00:33:44 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
final Player player = getPlayer(args[0]);
|
2014-05-04 21:03:34 +00:00
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
if (player == null)
|
2012-11-23 03:48:28 +00:00
|
|
|
{
|
2014-08-23 18:19:25 +00:00
|
|
|
sender.sendMessage(TFM_Command.PLAYER_NOT_FOUND);
|
2012-11-23 03:48:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
2012-11-23 03:48:28 +00:00
|
|
|
|
2013-08-25 23:08:53 +00:00
|
|
|
Material outerMaterial = Material.GLASS;
|
|
|
|
Material innerMaterial = Material.AIR;
|
2013-08-26 22:44:18 +00:00
|
|
|
|
2012-11-23 03:48:28 +00:00
|
|
|
if (args.length >= 2)
|
|
|
|
{
|
2014-05-05 13:31:12 +00:00
|
|
|
if ("off".equals(args[1]))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-25 23:08:53 +00:00
|
|
|
TFM_Util.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
|
2012-12-01 19:26:08 +00:00
|
|
|
|
2012-11-23 03:48:28 +00:00
|
|
|
playerdata.setCaged(false);
|
|
|
|
playerdata.regenerateHistory();
|
|
|
|
playerdata.clearHistory();
|
2012-12-01 19:26:08 +00:00
|
|
|
|
2011-10-19 02:52:32 +00:00
|
|
|
return true;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2012-11-23 03:48:28 +00:00
|
|
|
else
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-25 23:08:53 +00:00
|
|
|
if ("darth".equalsIgnoreCase(args[1]))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-25 23:08:53 +00:00
|
|
|
outerMaterial = Material.SKULL;
|
|
|
|
}
|
|
|
|
else if (Material.matchMaterial(args[1]) != null)
|
|
|
|
{
|
|
|
|
outerMaterial = Material.matchMaterial(args[1]);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-23 03:48:28 +00:00
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-23 03:48:28 +00:00
|
|
|
if (args.length >= 3)
|
|
|
|
{
|
|
|
|
if (args[2].equalsIgnoreCase("water"))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-25 23:08:53 +00:00
|
|
|
innerMaterial = Material.STATIONARY_WATER;
|
2012-11-23 03:48:28 +00:00
|
|
|
}
|
|
|
|
else if (args[2].equalsIgnoreCase("lava"))
|
|
|
|
{
|
2013-08-25 23:08:53 +00:00
|
|
|
innerMaterial = Material.STATIONARY_LAVA;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-25 23:08:53 +00:00
|
|
|
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
|
|
|
playerdata.setCaged(true, targetPos, outerMaterial, innerMaterial);
|
2012-11-23 03:48:28 +00:00
|
|
|
playerdata.regenerateHistory();
|
|
|
|
playerdata.clearHistory();
|
2013-08-14 14:55:37 +00:00
|
|
|
TFM_Util.buildHistory(targetPos, 2, playerdata);
|
2013-08-26 13:04:36 +00:00
|
|
|
TFM_Util.generateHollowCube(targetPos, 2, outerMaterial);
|
2013-08-25 23:08:53 +00:00
|
|
|
TFM_Util.generateCube(targetPos, 1, innerMaterial);
|
2012-12-01 19:26:08 +00:00
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
player.setGameMode(GameMode.SURVIVAL);
|
2012-12-01 19:26:08 +00:00
|
|
|
|
2013-08-25 23:08:53 +00:00
|
|
|
if (outerMaterial != Material.SKULL)
|
2013-08-26 22:44:18 +00:00
|
|
|
{
|
2013-08-25 23:08:53 +00:00
|
|
|
TFM_Util.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TFM_Util.adminAction(sender.getName(), "Caging " + player.getName() + " in PURE_DARTH", true);
|
|
|
|
}
|
2012-12-01 19:26:08 +00:00
|
|
|
|
2011-10-19 00:37:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|