Tweaks to /cage

This commit is contained in:
JeromSar 2013-08-26 01:08:53 +02:00
parent 5981f7f33f
commit fd6aa7b94b
4 changed files with 45 additions and 20 deletions

View File

@ -1,5 +1,5 @@
#Sat, 24 Aug 2013 21:35:24 +0200 #Mon, 26 Aug 2013 01:01:42 +0200
program.VERSION=3.1 program.VERSION=3.1
program.BUILDNUM=482 program.BUILDNUM=490
program.BUILDDATE=08/24/2013 09\:35 PM program.BUILDDATE=08/26/2013 01\:01 AM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Sat Aug 24 21:35:24 CEST 2013 #Mon Aug 26 01:01:42 CEST 2013
build.number=483 build.number=491

View File

@ -34,13 +34,14 @@ public class Command_cage extends TFM_Command
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
Material cage_material_outer = Material.GLASS; Material outerMaterial = Material.GLASS;
Material cage_material_inner = Material.AIR; Material innerMaterial = Material.AIR;
if (args.length >= 2) if (args.length >= 2)
{ {
if (TFM_Util.isStopCommand(args[1])) if (TFM_Util.isStopCommand(args[1]))
{ {
TFM_Util.adminAction(sender.getName(), "Uncaging " + player.getName() + ".", true); TFM_Util.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
playerdata.setCaged(false); playerdata.setCaged(false);
playerdata.regenerateHistory(); playerdata.regenerateHistory();
@ -50,10 +51,13 @@ public class Command_cage extends TFM_Command
} }
else else
{ {
cage_material_outer = Material.matchMaterial(args[1]); if ("darth".equalsIgnoreCase(args[1]))
if (cage_material_outer == null)
{ {
cage_material_outer = Material.GLASS; outerMaterial = Material.SKULL;
}
else if (Material.matchMaterial(args[1]) != null)
{
outerMaterial = Material.matchMaterial(args[1]);
} }
} }
} }
@ -62,25 +66,32 @@ public class Command_cage extends TFM_Command
{ {
if (args[2].equalsIgnoreCase("water")) if (args[2].equalsIgnoreCase("water"))
{ {
cage_material_inner = Material.STATIONARY_WATER; innerMaterial = Material.STATIONARY_WATER;
} }
else if (args[2].equalsIgnoreCase("lava")) else if (args[2].equalsIgnoreCase("lava"))
{ {
cage_material_inner = Material.STATIONARY_LAVA; innerMaterial = Material.STATIONARY_LAVA;
} }
} }
Location targetPos = player.getLocation().add(0, 1, 0); Location targetPos = player.getLocation().clone().add(0, 1, 0);
playerdata.setCaged(true, targetPos, cage_material_outer, cage_material_inner); playerdata.setCaged(true, targetPos, outerMaterial, innerMaterial);
playerdata.regenerateHistory(); playerdata.regenerateHistory();
playerdata.clearHistory(); playerdata.clearHistory();
TFM_Util.buildHistory(targetPos, 2, playerdata); TFM_Util.buildHistory(targetPos, 2, playerdata);
TFM_Util.generateCube(targetPos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER)); TFM_Util.generateCube(targetPos, 2, outerMaterial);
TFM_Util.generateCube(targetPos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER)); TFM_Util.generateCube(targetPos, 1, innerMaterial);
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
TFM_Util.adminAction(sender.getName(), "Caging " + player.getName() + ".", true); if (outerMaterial != Material.SKULL)
{
TFM_Util.adminAction(sender.getName(), "Caging " + player.getName(), true);
}
else
{
TFM_Util.adminAction(sender.getName(), "Caging " + player.getName() + " in PURE_DARTH", true);
}
return true; return true;
} }

View File

@ -16,6 +16,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.*; import org.bukkit.entity.*;
@ -142,14 +143,27 @@ public class TFM_Util
public static void generateCube(Location location, int length, Material material) public static void generateCube(Location location, int length, Material material)
{ {
Block block = location.getBlock(); Block center = location.getBlock();
for (int xOffset = -length; xOffset <= length; xOffset++) for (int xOffset = -length; xOffset <= length; xOffset++)
{ {
for (int yOffset = -length; yOffset <= length; yOffset++) for (int yOffset = -length; yOffset <= length; yOffset++)
{ {
for (int zOffset = -length; zOffset <= length; zOffset++) for (int zOffset = -length; zOffset <= length; zOffset++)
{ {
block.getRelative(xOffset, yOffset, zOffset).setType(material); if (material != Material.SKULL)
{
center.getRelative(xOffset, yOffset, zOffset).setType(material);
}
else
{
final Block block = center.getRelative(xOffset, yOffset, zOffset);
block.setType(Material.SKULL);
Skull skull = (Skull) block.getState();
skull.setSkullType(SkullType.PLAYER);
skull.setOwner("DarthSalamon");
skull.update();
//skull.setRotation(block.getFace(center));
}
} }
} }
} }