/** * 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()); }
static void handleRightClickAir(GlowPlayer player, ItemStack holding, EquipmentSlot slot) { PlayerInteractEvent event = EventFactory.getInstance().onPlayerInteract( player, Action.RIGHT_CLICK_AIR, slot); if (event.useItemInHand() == null || event.useItemInHand() == Event.Result.DENY) { return; } if (!InventoryUtil.isEmpty(holding)) { ItemType type = ItemTable.instance().getItem(holding.getType()); if (type != null) { if (type.getContext().isAirApplicable()) { type.rightClickAir(player, holding); } } // Empties the user's inventory when the item is used up if (holding.getAmount() <= 0) { player.getInventory().setItem(slot, InventoryUtil.createEmptyStack()); } } } }
@Override public void handle(GlowSession session, PlayerSwingArmMessage message) { GlowPlayer player = session.getPlayer(); EventFactory eventFactory = EventFactory.getInstance(); Block block = player.getTargetBlock((Set<Material>) null, 6); if (block == null || block.isEmpty()) { if (eventFactory.onPlayerInteract( player, Action.LEFT_CLICK_AIR, message.getHandSlot()).useItemInHand() == Result.DENY) { return; } // todo: item interactions with air } if (!eventFactory.callEvent(new PlayerAnimationEvent(player)).isCancelled()) { // play the animation to others player.playAnimation(message.getHand() == 1 ? EntityAnimation.SWING_OFF_HAND : EntityAnimation.SWING_MAIN_HAND); } } }
if (event.useItemInHand() == Result.DENY) { return;
if (selectResult(event.useItemInHand(), !useInteractedBlock)) { ItemType type = ItemTable.instance().getItem(holding.getType()); if (holding.getType() != Material.AIR
if (!BlockPlacementHandler.selectResult(interactEvent.useItemInHand(), true)) {
/** * 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()); }
&& event.isCancelled() && event.useItemInHand() != Result.DENY) { final ItemStack stack = Bridge1_9.getUsedItem(player, event); if (stack != null && BridgeMisc.maybeElytraBoost(player, stack.getType())) {
final Result previousUseItem = event.useItemInHand(); event.setCancelled(true); event.setUseInteractedBlock(Result.DENY);
if (event.useItemInHand() == Result.ALLOW) { blockChecks = false;