use of org.bukkit.inventory.Inventory in project EliteMobs by MagmaGuy.
the class EliteMenu method onInventoryClose.
public static boolean onInventoryClose(InventoryCloseEvent event, Map<Player, Inventory> inventories) {
Player player = (Player) event.getPlayer();
Inventory inventory = inventories.get(player);
if (inventory == null)
return false;
inventories.remove(player);
return event.getView().getTopInventory().equals(inventory);
}
use of org.bukkit.inventory.Inventory in project EliteMobs by MagmaGuy.
the class Explosion method fullBlockRestore.
private void fullBlockRestore(BlockState blockState, boolean isShutdown) {
for (Entity entity : blockState.getWorld().getNearbyEntities(new BoundingBox(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getX() + 1, blockState.getY() + 1, blockState.getZ() + 1))) entity.teleport(entity.getLocation().clone().add(new Vector(0, 1, 0)));
blockState.setBlockData(blockState.getBlockData());
if (blockState instanceof Container) {
Inventory container = null;
switch(blockState.getType()) {
case LECTERN:
container = ((Lectern) blockState).getInventory();
break;
case JUKEBOX:
// ((Jukebox) blockState).setRecord(this.items.get(0));
blockState.update(true, false);
break;
default:
container = ((Container) blockState).getInventory();
}
if (container != null)
container.setContents(((Container) blockState).getInventory().getContents());
}
blockState.update(true);
if (!isShutdown)
detonatedBlocks.remove(blockState);
}
use of org.bukkit.inventory.Inventory in project Glowstone by GlowstoneMC.
the class InventoryUtilTest method testRandomItem.
@Test
public void testRandomItem() {
Random random = new Random();
Inventory inventory = new GlowInventory(null, InventoryType.CHEST);
assertThat(-1, is(InventoryUtil.getRandomSlot(random, inventory, true)));
assertThat(InventoryUtil.getRandomSlot(random, inventory, false), OrderingComparison.greaterThanOrEqualTo(0));
inventory.setItem(0, new ItemStack(Material.APPLE));
assertThat(0, is(InventoryUtil.getRandomSlot(random, inventory, true)));
inventory.setItem(1, new ItemStack(Material.CARROT));
assertThat(InventoryUtil.getRandomSlot(random, inventory, true), OrderingComparison.greaterThanOrEqualTo(0));
}
use of org.bukkit.inventory.Inventory in project HawkEye by oliverwoodings.
the class ContainerEntry method rebuild.
@Override
public boolean rebuild(Block block) {
if (!(block instanceof InventoryHolder))
return false;
Inventory inv = ((InventoryHolder) block.getState()).getInventory();
List<HashMap<String, Integer>> ops = InventoryUtil.interpretDifferenceString(data);
// Handle the additions
if (ops.size() > 0) {
for (ItemStack stack : InventoryUtil.uncompressInventory(ops.get(0))) inv.addItem(stack);
}
// Handle subtractions
if (ops.size() > 1) {
for (ItemStack stack : InventoryUtil.uncompressInventory(ops.get(1))) inv.removeItem(stack);
}
return true;
}
use of org.bukkit.inventory.Inventory in project Denizen-For-Bukkit by DenizenScript.
the class DenizenNPCHelper method onInventoryClick.
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Inventory inventory = event.getInventory();
if (inventory.getHolder() instanceof NPCTag) {
NPCTag npc = (NPCTag) inventory.getHolder();
npc.getInventory().setContents(inventory.getContents());
Equipment equipment = npc.getEquipmentTrait();
for (int i = 0; i < 5; i++) {
equipment.set(i, inventory.getItem(i));
}
}
}
Aggregations