From ad8a99acda6e52e28c0d295cd2bb77fa64e0be2f Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Sat, 26 Jan 2013 04:11:52 +0100 Subject: [PATCH] Swap order for vertical layouts. --- .../garbagemule/MobArena/ArenaListener.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/com/garbagemule/MobArena/ArenaListener.java b/src/com/garbagemule/MobArena/ArenaListener.java index f8944ff..abb8224 100644 --- a/src/com/garbagemule/MobArena/ArenaListener.java +++ b/src/com/garbagemule/MobArena/ArenaListener.java @@ -837,9 +837,20 @@ public class ArenaListener if (!className.equalsIgnoreCase("random")) { if (useClassChests) { BlockFace backwards = ((org.bukkit.material.Sign) sign.getData()).getFacing().getOppositeFace(); - Block blockBelow = sign.getBlock(); + Block blockSign = sign.getBlock(); + Block blockBelow = blockSign.getRelative(BlockFace.DOWN); Block blockBehind = blockBelow.getRelative(backwards); + // If the block below this sign is a class sign, swap the order + if (blockBelow.getType() == Material.WALL_SIGN || blockBelow.getType() == Material.SIGN_POST) { + String className = ChatColor.stripColor(((Sign) blockBelow.getState()).getLine(0)).toLowerCase(); + if (arena.getClasses().containsKey(className)) { + blockSign = blockBehind; // Use blockSign as a temp while swapping + blockBehind = blockBelow; + blockBelow = blockSign; + } + } + // TODO: Make number of searches configurable // First check the pillar below the sign Block blockChest = findChestBelow(blockBelow, 6); @@ -851,6 +862,14 @@ public class ArenaListener if (blockChest != null) { InventoryHolder holder = (InventoryHolder) blockChest.getState(); ItemStack[] contents = holder.getInventory().getContents(); + // Guard against double-chests for now + if (contents.length > 36) { + ItemStack[] newContents = new ItemStack[36]; + for (int i = 0; i < 36; i++) { + newContents[i] = contents[i]; + } + contents = newContents; + } arena.assignClassGiveInv(p, className, contents); p.getInventory().setContents(contents); Messenger.tellPlayer(p, Msg.LOBBY_CLASS_PICKED, TextUtils.camelCase(className), arena.getClassLogo(className));