improve cannon UI

This commit is contained in:
Ben 2016-03-15 00:21:37 +00:00
parent c556d7b3c3
commit 3ae89e12a8
2 changed files with 18 additions and 2 deletions

View File

@ -228,7 +228,7 @@ public class UtilCollections
return array[Random.nextInt(array.length)]; return array[Random.nextInt(array.length)];
} }
public static <T> Collection<? extends T> toList(T[] array) public static <T> List<? extends T> toList(T[] array)
{ {
return Lists.newArrayList(array); return Lists.newArrayList(array);
} }
@ -248,4 +248,10 @@ public class UtilCollections
} }
} }
@SafeVarargs
public static <X> List<? extends X> newList(X... elements)
{
return toList(elements);
}
} }

View File

@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilCollections;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
@ -249,6 +250,10 @@ public class Cannon extends SiegeWeapon
event.setCancelled(true); event.setCancelled(true);
} }
else if (event.getSlot() != _ammunitionSlot)
{
event.setCancelled(true);
}
} }
private void updateInventory() 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(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(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()); _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) 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() private void loadEntities()