org.bukkit.block.Container Java Examples
The following examples show how to use
org.bukkit.block.Container.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DispenserShear.java From StackMob-3 with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onDispenserShear(BlockShearEntityEvent event) { if(!StackTools.hasSizeMoreThanOne(event.getEntity())) { return; } if(event.getEntity() instanceof Sheep) { Sheep sheep = (Sheep) event.getEntity(); if(sm.getLogic().doSheepShearAll(sheep, event.getTool())){ ItemStack is = ItemTools.damageItem(event.getTool(), StackTools.getSize(event.getEntity())); sm.getServer().getScheduler().runTask(sm, () -> { Container dispenser = (Container) event.getBlock().getState(); int itemId = dispenser.getInventory().first(event.getTool()); dispenser.getInventory().setItem(itemId, is); }); return; } sm.getLogic().doSheepShearSingle(sheep); } else { throw new UnsupportedOperationException("This is not implemented!"); } }
Example #2
Source File: DropTransferModule.java From Modern-LWC with MIT License | 5 votes |
@Override public void onProtectionInteract(LWCProtectionInteractEvent event) { LWC lwc = event.getLWC(); Protection protection = event.getProtection(); Set<String> actions = event.getActions(); boolean canAccess = event.canAccess(); Player bPlayer = event.getPlayer(); LWCPlayer player = lwc.wrapPlayer(bPlayer); if (!actions.contains("dropTransferSelect")) { return; } if (!canAccess) { lwc.sendLocale(player, "protection.interact.dropxfer.noaccess"); } else { if (event.getEvent().getClickedBlock() instanceof Container) { lwc.sendLocale(player, "protection.interact.dropxfer.notchest"); player.removeAllActions(); event.setResult(Result.CANCEL); return; } Mode mode = new Mode(); mode.setName("dropTransfer"); mode.setData(protection.getId() + ""); mode.setPlayer(bPlayer); player.enableMode(mode); mode = new Mode(); mode.setName("+dropTransfer"); mode.setPlayer(bPlayer); player.enableMode(mode); lwc.sendLocale(player, "protection.interact.dropxfer.finalize"); } player.removeAllActions(); // ignore the persist mode }
Example #3
Source File: ContainerAdapter.java From DungeonsXL with GNU General Public License v3.0 | 5 votes |
public static boolean isValidContainer(Block block) { if (Version.isAtLeast(Version.MC1_12_1)) { return block.getState() instanceof Container; } else { return block.getState() instanceof Chest; } }
Example #4
Source File: ContainerAdapter.java From DungeonsXL with GNU General Public License v3.0 | 5 votes |
public static boolean isValidContainer(Inventory inventory) { if (Version.isAtLeast(Version.MC1_12_1)) { return inventory.getHolder() instanceof Container; } else { return inventory.getHolder() instanceof Chest; } }
Example #5
Source File: ContainerAdapter.java From DungeonsXL with GNU General Public License v3.0 | 5 votes |
public static Block getHolderBlock(InventoryHolder holder) { if (Version.isAtLeast(Version.MC1_12_1)) { return ((Container) holder).getBlock(); } else { return ((Chest) holder).getBlock(); } }
Example #6
Source File: ContainerAdapter.java From DungeonsXL with GNU General Public License v3.0 | 5 votes |
public static Inventory getBlockInventory(Block block) { if (Version.isAtLeast(Version.MC1_12_1)) { return ((Container) block.getState()).getInventory(); } else { return ((Chest) block.getState()).getInventory(); } }