private void onPlayerInteract(final PlayerInteractEvent event) { // Check preconditions. final org.bukkit.event.block.Action action = event.getAction(); if (action == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) { onRightClickBlock(event); } else if (!event.isCancelled()) { if (action == org.bukkit.event.block.Action.PHYSICAL) { onInteractPhysical(event); } } }
private void genericDebug(final Player player, final Block block, final BlockFace face, final PlayerInteractEvent event, final String tag, final int previousLastTick, final BlockInteractData data, final BlockInteractConfig cc) { final StringBuilder builder = new StringBuilder(512); // Rate limit. if (data.getLastTick() == previousLastTick && data.subsequentCancel > 0) { data.rateLimitSkip ++; return; } // Debug log. builder.append("Interact cancel: " + event.isCancelled()); builder.append(" ("); builder.append(tag); if (block == null) { builder.append(") block: null"); } else { builder.append(") block: "); builder.append(block.getWorld().getName() + "/" + LocUtil.simpleFormat(block)); builder.append(" type: " + block.getType()); builder.append(" data: " + BlockProperties.getData(block)); builder.append(" face: " + face); } if (data.rateLimitSkip > 0) { builder.append(" skipped(rate-limit: " + data.rateLimitSkip); data.rateLimitSkip = 0; } debug(player, builder.toString()); }
/** * 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; } }
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); } } } }
/** * Called when a player steps on a pressure plate or tramples crops. * * @param event Thrown event */ private void handlePhysicalInteract(PlayerInteractEvent event) { if (event.isCancelled()) return; Player player = event.getPlayer(); Block block = event.getClickedBlock(); //not actually clicked but whatever //int type = block.getTypeId(); World world = player.getWorld(); ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world)); if (block.getType() == Material.FARMLAND && wcfg.disablePlayerCropTrampling) { event.setCancelled(true); return; } }
if (event.isCancelled()) { return;
return; if ((tardis.isIso_on() && !uuid.equals(tardis.getUuid()) && event.isCancelled() && !player.hasPermission("tardis.skeletonkey")) || plugin.getTrackerKeeper().getJohnSmith().containsKey(uuid)) { TARDISMessage.send(player, "ISO_HANDS_OFF"); return;
if ((tardis.isIso_on() && !uuid.equals(ownerUUID) && event.isCancelled() && !player.hasPermission("tardis.skeletonkey")) || plugin.getTrackerKeeper().getJohnSmith().containsKey(uuid)) {
return; if ((tardis.isIso_on() && !player.getUniqueId().equals(ownerUUID) && !event.isCancelled()) || plugin.getTrackerKeeper().getJohnSmith().containsKey(player.getUniqueId())) { TARDISMessage.send(player, "ISO_HANDS_OFF"); return;
&& event.isCancelled() && event.useItemInHand() != Result.DENY) { final ItemStack stack = Bridge1_9.getUsedItem(player, event); if (stack != null && BridgeMisc.maybeElytraBoost(player, stack.getType())) {
final BlockInteractData data, final BlockInteractConfig cc, final IPlayerData pData) { final boolean debug = pData.isDebugActive(CheckType.BLOCKINTERACT); if (event.isCancelled()) {
if (event.isCancelled()) {
if(e.isCancelled()) return;
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){ Block cblock = event.getClickedBlock(); if(cblock.getState() instanceof Chest && !event.isCancelled()){ for(Minigame minigame : mdata.getAllMinigames().values()){ if(minigame.getType() == MinigameType.GLOBAL &&
if ((e.isCancelled() || !externalPluginsAllowed) && !p.hasPermission(Permissions.CREATE_PROTECTED)) { p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_CREATE_PROTECTED)); ClickType.removePlayerClickType(p);
if (event.isCancelled()) { return;
if(cblock.getState() instanceof Sign && !event.isCancelled()){ Sign sign = (Sign) cblock.getState(); if(sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE + "[Minigame]")){
if (event.isCancelled()) { playDenyEffect(event.getPlayer(), clicked.getLocation().add(0.5, 1, 0.5));
if (event.isCancelled() && event.useInteractedBlock() != Result.ALLOW) { if (event.useItemInHand() == Result.ALLOW) { blockChecks = false;