TotalFreedomMod/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cage.java

88 lines
2.8 KiB
Java
Raw Normal View History

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;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@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)
{
if (args.length == 0)
2011-10-19 00:37:00 +00:00
{
return false;
}
2011-10-19 00:37:00 +00:00
Player p;
try
{
p = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
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
{
TFM_Util.adminAction(sender.getName(), "Uncaging " + p.getName() + ".", true);
playerdata.setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
return true;
2011-10-19 00:37:00 +00:00
}
else
2011-10-19 00:37:00 +00:00
{
cage_material_outer = Material.matchMaterial(args[1]);
if (cage_material_outer == null)
2011-10-19 00:37:00 +00:00
{
cage_material_outer = Material.GLASS;
2011-10-19 00:37:00 +00:00
}
}
}
2011-10-19 00:37:00 +00:00
if (args.length >= 3)
{
if (args[2].equalsIgnoreCase("water"))
2011-10-19 00:37:00 +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
}
}
Location target_pos = p.getLocation().add(0, 1, 0);
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));
p.setGameMode(GameMode.SURVIVAL);
TFM_Util.adminAction(sender.getName(), "Caging " + p.getName() + ".", true);
2011-10-19 00:37:00 +00:00
return true;
}
}