From 3ae89e12a8fd51fa51c204a6588c4d24d5d79a32 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 15 Mar 2016 00:21:37 +0000 Subject: [PATCH] improve cannon UI --- .../mineplex/core/common/util/UtilCollections.java | 8 +++++++- .../game/clans/clans/siege/weapon/Cannon.java | 12 +++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java index 73fffdc52..0ffee83ad 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java @@ -228,7 +228,7 @@ public class UtilCollections return array[Random.nextInt(array.length)]; } - public static Collection toList(T[] array) + public static List toList(T[] array) { return Lists.newArrayList(array); } @@ -248,4 +248,10 @@ public class UtilCollections } } + @SafeVarargs + public static List newList(X... elements) + { + return toList(elements); + } + } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java index 3624b7c86..dffeedaef 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java @@ -20,6 +20,7 @@ import com.google.common.collect.Lists; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilCollections; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; @@ -249,6 +250,10 @@ public class Cannon extends SiegeWeapon event.setCancelled(true); } + else if (event.getSlot() != _ammunitionSlot) + { + event.setCancelled(true); + } } private void updateInventory() @@ -256,11 +261,16 @@ public class Cannon extends SiegeWeapon _inventory.setItem(0, new ItemBuilder(Material.LEVER).setTitle(C.cRed + "-1 Firepower").build()); _inventory.setItem(1, new ItemBuilder(Material.SULPHUR).setTitle(C.cWhiteB + "Firepower: " + C.cYellow + _firepower).build()); _inventory.setItem(2, new ItemBuilder(Material.LEVER).setTitle(C.cGreen + "+1 Firepower").build()); + + for (int slot : UtilCollections.newList(Integer.valueOf(3), Integer.valueOf(5), Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8))) + { + _inventory.setItem(slot, new ItemBuilder(Material.COBBLESTONE).setTitle(C.cGray + "Cannon Wall").build()); + } } protected boolean CustomInventoryValid(int slot, ItemStack item) { - return slot == 0 || slot == 1 || slot == 2; + return true; // all slots are now filled; slot == 0 || slot == 1 || slot == 2; } private void loadEntities()