/** * Gets the cancellation state of this event. Set to true if you want to * prevent buckets from placing water and so forth * * @return boolean cancellation state */ public boolean isCancelled() { return useInteractedBlock() == Result.DENY; }
/** * Sets the cancellation state of this event. A canceled event will not be * executed in the server, but will still pass to other plugins * <p> * Canceling this event will prevent use of food (player won't lose the * food item), prevent bows/snowballs/eggs from firing, etc. (player won't * lose the ammo) * * @param cancel true if you wish to cancel this event */ public void setCancelled(boolean cancel) { setUseInteractedBlock(cancel ? Result.DENY : useInteractedBlock() == Result.DENY ? Result.DEFAULT : useInteractedBlock()); setUseItemInHand(cancel ? Result.DENY : useItemInHand() == Result.DENY ? Result.DEFAULT : useItemInHand()); }
boolean useInteractedBlock = event.useInteractedBlock() != Result.DENY; if (useInteractedBlock && (!player.isSneaking() || bothHandsEmpty(player))) { BlockType blockType = ItemTable.instance().getBlock(clicked.getType());
/** * Gets the cancellation state of this event. Set to true if you want to * prevent buckets from placing water and so forth * * @return boolean cancellation state */ public boolean isCancelled() { return useInteractedBlock() == Result.DENY; }
/** * Adjust to the results of a BlockInteractEvent - only the results, the * coordinates and action is not updated. * * @param event */ public void setPlayerInteractEventResolution(final PlayerInteractEvent event) { if (event.isCancelled()) { // TODO: resetPassedChecks() ? lastIsCancelled = true; lastAllowUseItem = event.useItemInHand() == Result.ALLOW; lastAllowUseBlock = event.useInteractedBlock() == Result.ALLOW; subsequentCancel ++; } else { lastIsCancelled = false; lastAllowUseItem = event.useItemInHand() != Result.DENY; lastAllowUseBlock = event.useInteractedBlock() != Result.DENY; subsequentCancel = 0; } }
/** * Sets the cancellation state of this event. A canceled event will not be * executed in the server, but will still pass to other plugins * <p> * Canceling this event will prevent use of food (player won't lose the * food item), prevent bows/snowballs/eggs from firing, etc. (player won't * lose the ammo) * * @param cancel true if you wish to cancel this event */ public void setCancelled(boolean cancel) { setUseInteractedBlock(cancel ? Result.DENY : useInteractedBlock() == Result.DENY ? Result.DEFAULT : useInteractedBlock()); setUseItemInHand(cancel ? Result.DENY : useItemInHand() == Result.DENY ? Result.DEFAULT : useItemInHand()); }
private void onRightClickBlock(final PlayerInteractEvent event) { final Result result = event.useInteractedBlock(); if ((result == Result.ALLOW || result == Result.DEFAULT && !event.isCancelled())) { final Block block = event.getClickedBlock(); if (block != null) { final Material type = block.getType(); // TODO: Dirt/Grass (/Podzol+-spelling) -> flag. Add, if a hoe is used. if ((BlockProperties.getBlockFlags(type) | BlockProperties.F_VARIABLE_USE) != 0L) { addBlockWithAttachedPotential(block, BlockProperties.F_VARIABLE_USE); } } } }
private void checkBoatsAnywhere(final Player player, final PlayerInteractEvent event, final BlockPlaceConfig cc, final IPlayerData pData) { // Check boats-anywhere. final Block block = event.getClickedBlock(); final Material mat = block.getType(); // TODO: allow lava ? if (BlockProperties.isWater(mat)) { return; } // TODO: Shouldn't this be the opposite face? final BlockFace blockFace = event.getBlockFace(); final Block relBlock = block.getRelative(blockFace); final Material relMat = relBlock.getType(); // TODO: Placing inside of water, but not "against" ? if (BlockProperties.isWater(relMat)) { return; } // TODO: Add a check type for exemption? if (!pData.hasPermission(Permissions.BLOCKPLACE_BOATSANYWHERE, player)) { final Result previousUseBlock = event.useInteractedBlock(); event.setCancelled(true); event.setUseItemInHand(Result.DENY); event.setUseInteractedBlock(previousUseBlock == Result.DEFAULT ? Result.ALLOW : previousUseBlock); counters.addPrimaryThread(idBoatsAnywhere, 1); } }
if (event.isCancelled() && event.useInteractedBlock() != Result.ALLOW) { if (event.useItemInHand() == Result.ALLOW) { blockChecks = false;