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-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <partialname> <off | [[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;
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2013-08-14 13:28:19 +00:00
|
|
|
Player p;
|
2012-11-23 03:48:28 +00:00
|
|
|
try
|
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
p = getPlayer(args[0]);
|
2012-11-23 03:48:28 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (PlayerNotFoundException ex)
|
2012-11-23 03:48:28 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
sender.sendMessage(ex.getMessage());
|
2012-11-23 03:48:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
2012-11-23 03:48:28 +00:00
|
|
|
|
|
|
|
Material cage_material_outer = Material.GLASS;
|
|
|
|
Material cage_material_inner = Material.AIR;
|
|
|
|
if (args.length >= 2)
|
|
|
|
{
|
|
|
|
if (TFM_Util.isStopCommand(args[1]))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_Util.adminAction(sender.getName(), "Uncaging " + p.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
|
|
|
{
|
2012-11-23 03:48:28 +00:00
|
|
|
cage_material_outer = Material.matchMaterial(args[1]);
|
|
|
|
if (cage_material_outer == null)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-23 03:48:28 +00:00
|
|
|
cage_material_outer = Material.GLASS;
|
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
|
|
|
{
|
2012-11-23 03:48:28 +00:00
|
|
|
cage_material_inner = Material.STATIONARY_WATER;
|
|
|
|
}
|
|
|
|
else if (args[2].equalsIgnoreCase("lava"))
|
|
|
|
{
|
|
|
|
cage_material_inner = Material.STATIONARY_LAVA;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-14 13:28:19 +00:00
|
|
|
Location target_pos = p.getLocation().add(0, 1, 0);
|
2012-11-23 03:48:28 +00:00
|
|
|
playerdata.setCaged(true, target_pos, cage_material_outer, cage_material_inner);
|
|
|
|
playerdata.regenerateHistory();
|
|
|
|
playerdata.clearHistory();
|
|
|
|
TFM_Util.buildHistory(target_pos, 2, playerdata);
|
2013-01-21 18:58:42 +00:00
|
|
|
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER));
|
|
|
|
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
|
2012-12-01 19:26:08 +00:00
|
|
|
|
2013-08-14 13:28:19 +00:00
|
|
|
p.setGameMode(GameMode.SURVIVAL);
|
2012-12-01 19:26:08 +00:00
|
|
|
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_Util.adminAction(sender.getName(), "Caging " + p.getName() + ".", true);
|
2012-12-01 19:26:08 +00:00
|
|
|
|
2011-10-19 00:37:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|