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

93 lines
3.2 KiB
Java
Raw Normal View History

2011-10-19 00:37:00 +00:00
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
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 = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.BOTH, ignore_permissions = false)
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 (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
TFM_UserInfo playerdata = TFM_UserInfo.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
{
2012-11-27 19:56:42 +00:00
TFM_Util.adminAction(sender.getName(), "Uncaging " + p.getName(), true);
playerdata.setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
sender.sendMessage(ChatColor.GREEN + p.getName() + " uncaged.");
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
{
2012-11-21 16:03:00 +00:00
TFM_Util.adminAction(sender.getName(), "Uncaging " + p.getName(), true);
2011-10-19 00:37:00 +00:00
playerdata.setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
2011-10-24 02:43:52 +00:00
sender.sendMessage(ChatColor.GREEN + p.getName() + " uncaged.");
2011-10-19 00:37:00 +00:00
return true;
}
else
{
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);
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER));
p.setGameMode(GameMode.SURVIVAL);
2012-11-27 19:56:42 +00:00
TFM_Util.adminAction(sender.getName(), "Caging " + p.getName(), true);
2011-10-19 00:37:00 +00:00
return true;
}
}