Java Code Examples for org.bukkit.event.block.Action#RIGHT_CLICK_AIR

The following examples show how to use org.bukkit.event.block.Action#RIGHT_CLICK_AIR . 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: TrackerListener.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onTrackerUse(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    if (!Main.isPlayerInGame(player)) {
        return;
    }

    GamePlayer gamePlayer = Main.getPlayerGameProfile(player);
    Game game = gamePlayer.getGame();
    if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (game.getStatus() == GameStatus.RUNNING && !gamePlayer.isSpectator) {
            if (event.getItem() != null) {
                ItemStack stack = event.getItem();
                String unhidden = APIUtils.unhashFromInvisibleStringStartsWith(stack, TRACKER_PREFIX);
                if (unhidden != null) {
                    event.setCancelled(true);

                    Tracker tracker = new Tracker(game, player, game.getTeamOfPlayer(player));
                    tracker.runTask();
                }
            }
        }
    }
}
 
Example 2
Source File: ArmorListener.java    From AdditionsAPI with MIT License 6 votes vote down vote up
@EventHandler(priority =  EventPriority.HIGHEST, ignoreCancelled = true)
public void playerInteractEvent(PlayerInteractEvent e){
	if(e.getAction() == Action.PHYSICAL) return;
	if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
		Player player = e.getPlayer();
		ArmorType newArmorType = ArmorType.matchType(e.getItem());
		if(newArmorType != null){
			if(newArmorType.equals(ArmorType.HELMET) && isAirOrNull(e.getPlayer().getInventory().getHelmet()) || newArmorType.equals(ArmorType.CHESTPLATE) && isAirOrNull(e.getPlayer().getInventory().getChestplate()) || newArmorType.equals(ArmorType.LEGGINGS) && isAirOrNull(e.getPlayer().getInventory().getLeggings()) || newArmorType.equals(ArmorType.BOOTS) && isAirOrNull(e.getPlayer().getInventory().getBoots())){
				ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(e.getPlayer(), EquipMethod.HOTBAR, ArmorType.matchType(e.getItem()), null, e.getItem());
				Bukkit.getServer().getPluginManager().callEvent(armorEquipEvent);
				if(armorEquipEvent.isCancelled()){
					e.setCancelled(true);
					player.updateInventory();
				}
			}
		}
	}
}
 
Example 3
Source File: FlagSpectate.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
@SuppressWarnings("deprecation")
public void onPlayerInteract(PlayerInteractEvent event) {
	SpleefPlayer player = getHeavySpleef().getSpleefPlayer(event.getPlayer());
	if (!isSpectating(player)) {
		return;
	}
	
	if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) {
		return;
	}
	
	MetadatableItemStack inHand = new MetadatableItemStack(player.getBukkitPlayer().getItemInHand());
	if (!inHand.hasItemMeta() || !inHand.getItemMeta().hasLore() || !inHand.hasMetadata(LEAVE_ITEM_KEY)) {
		return;
	}
	
	//Leave the spectate mode
	leave(player);
	player.sendMessage(getI18N().getVarString(Messages.Player.PLAYER_LEAVE_SPECTATE)
			.setVariable("game", game.getName())
			.toString());
}
 
Example 4
Source File: LobbyListener.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = false)
  public void onClick(final PlayerInteractEvent e) {
if (Util.get().isSpawnWorld(e.getPlayer().getWorld())) {
	if (SkyWarsReloaded.getCfg().protectLobby()) {
		e.setCancelled(true);
   		if (e.getPlayer().hasPermission("sw.alterlobby")) {
   			e.setCancelled(false);
   		}
	}
	
	if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
      		if (e.hasItem()) {
                  if (e.getItem().equals(SkyWarsReloaded.getIM().getItem("optionselect"))) {
                  	e.setCancelled(true);
                  	Util.get().playSound(e.getPlayer(), e.getPlayer().getLocation(), SkyWarsReloaded.getCfg().getOpenOptionsMenuSound(), 0.5F, 1);
                  	new OptionsSelectionMenu(e.getPlayer());
                  } else if (e.getItem().equals(SkyWarsReloaded.getIM().getItem("joinselect"))) {
                  	e.setCancelled(true);
                  	Util.get().playSound(e.getPlayer(), e.getPlayer().getLocation(), SkyWarsReloaded.getCfg().getOpenJoinMenuSound(), 1, 1);
                  	e.getPlayer().openInventory(joinMenu);
                  } 
      		}
      	}
}
  }
 
Example 5
Source File: CustomItemListener.java    From NBTEditor with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
private void playerInteract(PlayerInteractEvent event) {
	Action action = event.getAction();
	if (action != Action.PHYSICAL) {
		if (action == Action.RIGHT_CLICK_BLOCK && _interationMaterials.contains(event.getClickedBlock().getType())) {
			return;
		}
		CustomItem customItem = CustomItemManager.getCustomItem(event.getItem());
		if (customItem != null) {
			if (verifyCustomItem(customItem, event.getPlayer(), false)) {
				if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
					customItem.onRightClick(event, new PlayerDetails(event));
				} else if (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) {
					customItem.onLeftClick(event, new PlayerDetails(event));
				}
			} else {
				event.setCancelled(true);
			}
		}
	}
}
 
Example 6
Source File: AntiGriefListener.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void checkDefuse(final PlayerInteractEvent event) {
  ItemStack hand = event.getPlayer().getItemInHand();
  if (hand == null || hand.getType() != DEFUSE_ITEM) return;

  MatchPlayer clicker = this.mm.getPlayer(event.getPlayer());
  if (clicker != null
      && clicker.isObserving()
      && clicker.getBukkit().hasPermission(Permissions.DEFUSE)) {
    if (event.getAction() == Action.RIGHT_CLICK_AIR) {
      this.obsTntDefuse(clicker, event.getPlayer().getLocation());
    } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
      this.obsTntDefuse(clicker, event.getClickedBlock().getLocation());
    }
  }
}
 
Example 7
Source File: TeamCommand.java    From AnnihilationPro with MIT License 5 votes vote down vote up
@EventHandler(priority=EventPriority.HIGH)
public void voteGUIcheck(PlayerInteractEvent event)
{
	if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)
	{
		final Player player = event.getPlayer();
		if(KitUtils.itemHasName(player.getItemInHand(), CustomItem.TEAMMAP.getName()))
		{
			if(menu != null)
				menu.open(player);
			event.setCancelled(true);
		}
	}
}
 
Example 8
Source File: AutoPotion.java    From AACAdditionPro with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onInteract(final PlayerInteractEvent event)
{
    final User user = UserManager.getUser(event.getPlayer().getUniqueId());

    // Not bypassed
    if (User.isUserInvalid(user, this.getModuleType())) {
        return;
    }

    // Timeout
    if (user.getTimestampMap().recentlyUpdated(TimestampKey.AUTOPOTION_TIMEOUT, timeout)) {
        event.setCancelled(true);
        return;
    }

    // Is the action a right-click that can throw a potion
    if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) &&
        // The item is a throwable potion
        event.getItem() != null &&
        event.getMaterial() == Material.SPLASH_POTION &&
        // The last sudden movement was not long ago
        user.getTimestampMap().recentlyUpdated(TimestampKey.AUTOPOTION_DETECTION, timeOffset))
    {
        user.getDataMap().setValue(DataKey.AUTOPOTION_ALREADY_THROWN, true);
        // Here the timestamp is used to contain the data of the last splash
        user.getTimestampMap().updateTimeStamp(TimestampKey.AUTOPOTION_DETECTION);
    }
}
 
Example 9
Source File: BonusGoodieManager.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void OnPlayerInteractEvent(PlayerInteractEvent event) {
	
	ItemStack item = event.getPlayer().getItemInHand();
	BonusGoodie goodie = CivGlobal.getBonusGoodie(item);
	if (goodie == null) {
		return;
	}

	if (event.getClickedBlock() == null) {
		event.setCancelled(true);
		return;
	}
	
	BlockCoord bcoord = new BlockCoord(event.getClickedBlock());		
	ItemFrameStorage clickedFrame = ItemFrameStorage.attachedBlockMap.get(bcoord);
	
	if (clickedFrame != null) {
		if (clickedFrame.getItemFrame() != null) {
			if (clickedFrame.getItemFrame().getAttachedFace().getOppositeFace() ==
					event.getBlockFace()) {
				onPlayerProtectedFrameInteract(event.getPlayer(), clickedFrame,	goodie, event);
				event.setCancelled(true);
			}
		}
		return;
	}
	
	if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {				
		CivMessage.sendError(event.getPlayer(), "Cannot use bonus goodie as a normal item.");
		event.setCancelled(true);
		return;
	}
}
 
Example 10
Source File: MapBuilder.java    From AnnihilationPro with MIT License 5 votes vote down vote up
@EventHandler(priority=EventPriority.HIGH)
public void nexusHelperCheck(PlayerInteractEvent event)
{
	if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK
			|| event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
	{
		final Player player = event.getPlayer();
		TeamBlock t = null;
		if(KitUtils.itemHasName(player.getItemInHand(), TeamBlock.Red.getName()))
			t = TeamBlock.Red;
		else if(KitUtils.itemHasName(player.getItemInHand(), TeamBlock.Blue.getName()))
			t = TeamBlock.Blue;
		else if(KitUtils.itemHasName(player.getItemInHand(), TeamBlock.Green.getName()))
			t = TeamBlock.Green;
		else if(KitUtils.itemHasName(player.getItemInHand(), TeamBlock.Yellow.getName()))
			t = TeamBlock.Yellow;
		if(t != null)
		{
			//They made a click with a team block
			event.setCancelled(true);
			List<MetadataValue> vals = player.getMetadata("TeamHandler");
			if(vals != null && vals.size() == 1)
			{
				Object obj = vals.get(0).value();
				if(obj != null && obj instanceof TeamBlockHandler)
				{
					((TeamBlockHandler)obj).onBlockClick(player, t.Team, event.getAction(), event.getClickedBlock(),event.getBlockFace());
				}
			}
		}
	}
}
 
Example 11
Source File: ThirstManager.java    From Survival-Games with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerDrinkWater(PlayerInteractEvent e) {
	if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
		if (e.getPlayer().getItemInHand() == new ItemStack(Material.POTION)) {
			e.getPlayer().getInventory().removeItem(new ItemStack(Material.POTION, 1));
			addThirst(e.getPlayer(), 5);
			e.getPlayer().sendMessage(ChatColor.GREEN + "You drank water.");
		}
	}
}
 
Example 12
Source File: ItemsListener.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onRightClickItem(PlayerInteractEvent event){
	if (
			event.getAction() != Action.RIGHT_CLICK_AIR &&
			event.getAction() != Action.RIGHT_CLICK_BLOCK
	){
		return;
	}

	Player player = event.getPlayer();
	GameManager gm = GameManager.getGameManager();
	UhcPlayer uhcPlayer = gm.getPlayersManager().getUhcPlayer(player);
	ItemStack hand = player.getItemInHand();

	if (GameItem.isGameItem(hand)){
		event.setCancelled(true);
		GameItem gameItem = GameItem.getGameItem(hand);
		handleGameItemInteract(gameItem, player, uhcPlayer, hand);
		return;
	}

	if ( (gm.getGameState().equals(GameState.PLAYING) || gm.getGameState().equals(GameState.DEATHMATCH))
			&& UhcItems.isRegenHeadItem(hand)
			&& uhcPlayer.getState().equals(PlayerState.PLAYING)
			&& (event.getAction() == Action.RIGHT_CLICK_AIR
			|| event.getAction() == Action.RIGHT_CLICK_BLOCK)
	) {
		event.setCancelled(true);
		uhcPlayer.getTeam().regenTeam(gm.getConfiguration().getEnableDoubleRegenHead());
		player.getInventory().remove(hand);
	}
}
 
Example 13
Source File: ThrowableFireballListener.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onFireballThrow(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    if (!Main.isPlayerInGame(player)) {
        return;
    }

    if (event.getItem() != null) {
        ItemStack stack = event.getItem();
        String unhash = APIUtils.unhashFromInvisibleStringStartsWith(stack, THROWABLE_FIREBALL_PREFIX);
        if (unhash != null && (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)) {
            String[] properties = unhash.split(":");
            double damage = Double.parseDouble(properties[2]);
            float explosion = (float) Double.parseDouble(properties[2]);

            Fireball fireball = player.launchProjectile(Fireball.class);
            fireball.setIsIncendiary(false);
            fireball.setYield(explosion);
            Main.registerGameEntity(fireball, Main.getPlayerGameProfile(player).getGame());

            event.setCancelled(true);

            if (stack.getAmount() > 1) {
                stack.setAmount(stack.getAmount() - 1);
            } else {
                player.getInventory().remove(stack);
            }

            player.updateInventory();
        }
    }
}
 
Example 14
Source File: TeamBlock.java    From AnnihilationPro with MIT License 5 votes vote down vote up
public TeamBlock addLine(Action action, ChatColor color1, String message)
{
	String str = "";
	if(action == Action.LEFT_CLICK_BLOCK || action == Action.LEFT_CLICK_AIR)
		str = color1+"Left click to ";
	else if(action == Action.RIGHT_CLICK_BLOCK || action == Action.RIGHT_CLICK_AIR)
		str = color1+"Right click to ";
	str += message;
	lore.add(str);
	return this;
}
 
Example 15
Source File: CancellableChunkEvents.java    From ClaimChunk with MIT License 5 votes vote down vote up
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
    if (e != null
        && e.getClickedBlock() != null
        && e.getAction() != Action.LEFT_CLICK_BLOCK
        && e.getAction() != Action.LEFT_CLICK_AIR
        && e.getAction() != Action.RIGHT_CLICK_AIR) {
        ChunkEventHelper.handleInteractionEvent(e.getPlayer(), e.getClickedBlock().getChunk(), e);
    }
}
 
Example 16
Source File: TNTSheepListener.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onTNTSheepUsed(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    if (!Main.isPlayerInGame(player)) {
        return;
    }

    GamePlayer gamePlayer = Main.getPlayerGameProfile(player);
    Game game = gamePlayer.getGame();

    if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (game.getStatus() == GameStatus.RUNNING && !gamePlayer.isSpectator && event.getItem() != null) {
            ItemStack stack = event.getItem();
            String unhidden = APIUtils.unhashFromInvisibleStringStartsWith(stack, TNT_SHEEP_PREFIX);

            if (unhidden != null) {
                event.setCancelled(true);

                double speed = Double.parseDouble(unhidden.split(":")[2]);
                double follow = Double.parseDouble(unhidden.split(":")[3]);
                double maxTargetDistance = Double.parseDouble(unhidden.split(":")[4]);
                int explosionTime = Integer.parseInt(unhidden.split(":")[5]);
                Location startLocation;

                if (event.getClickedBlock() == null) {
                    startLocation = player.getLocation();
                } else {
                    startLocation = event.getClickedBlock().getRelative(BlockFace.UP).getLocation();
                }
                TNTSheep sheep = new TNTSheep(game, player, game.getTeamOfPlayer(player),
                        startLocation, stack, speed, follow, maxTargetDistance, explosionTime);

                sheep.spawn();
            }

        }
    }
}
 
Example 17
Source File: SlimefunItemTest.java    From Slimefun4 with GNU General Public License v3.0 4 votes vote down vote up
default void simulateRightClick(Player player, T item) {
    PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_AIR, item.getItem().clone(), null, null, EquipmentSlot.HAND);
    PlayerRightClickEvent event = new PlayerRightClickEvent(e);
    item.callItemHandler(ItemUseHandler.class, handler -> handler.onRightClick(event));
}
 
Example 18
Source File: BlockListener.java    From MineTinker with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onClick(PlayerInteractEvent event) {
	Player player = event.getPlayer();

	ItemStack norm = null;
	if (event.getHand() == EquipmentSlot.HAND) {
		norm = player.getInventory().getItemInMainHand();
	} else if (event.getHand() == EquipmentSlot.OFF_HAND) {
		norm = player.getInventory().getItemInOffHand();
	}

	if (norm == null) return;

	if (event.getAction() == Action.RIGHT_CLICK_AIR) {
		if (modManager.isModifierItem(norm)) {
			event.setCancelled(true);
		}
	} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
		Block block = event.getClickedBlock();

		if (block == null) {
			return;
		}
		if (!player.isSneaking()) {
			Material type = block.getType();

			if (type == Material.ANVIL || type == Material.CRAFTING_TABLE
					|| type == Material.CHEST || type == Material.ENDER_CHEST
					|| type == Material.DROPPER || type == Material.HOPPER
					|| type == Material.DISPENSER || type == Material.TRAPPED_CHEST
					|| type == Material.FURNACE || type == Material.ENCHANTING_TABLE) {

				return;
			}
		}

		if (modManager.isModifierItem(norm)) {
			event.setCancelled(true);
			return;
		}

		if (block.getType() == Material.getMaterial(MineTinker.getPlugin().getConfig().getString("BlockToEnchantModifiers", Material.BOOKSHELF.name()))) {
			ItemStack item = player.getInventory().getItemInMainHand();

			for (Modifier m : modManager.getAllMods()) {
				if (m.getModItem().getType().equals(item.getType())) {
					if (!m.isEnchantable()) continue;
					m.enchantItem(player);
					event.setCancelled(true);
					break;
				}
			}
		}
	}
}
 
Example 19
Source File: BukkitImageListener.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.useItemInHand() == Event.Result.DENY) return;

    Player player = event.getPlayer();
    FawePlayer<Object> fp = FawePlayer.wrap(player);
    if (fp.getMeta("CFISettings") == null) return;
    try {
        if (event.getHand() == EquipmentSlot.OFF_HAND) return;
    } catch (NoSuchFieldError | NoSuchMethodError ignored) {}

    List<Block> target = player.getLastTwoTargetBlocks((Set<Material>) null, 100);
    if (target.isEmpty()) return;

    Block targetBlock = target.get(0);
    World world = player.getWorld();
    mutable.setWorld(world);
    mutable.setX(targetBlock.getX() + 0.5);
    mutable.setY(targetBlock.getY() + 0.5);
    mutable.setZ(targetBlock.getZ() + 0.5);
    Collection<Entity> entities = world.getNearbyEntities(mutable, 0.46875, 0, 0.46875);

    if (!entities.isEmpty()) {
        Action action = event.getAction();
        boolean primary = action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK;

        double minDist = Integer.MAX_VALUE;
        ItemFrame minItemFrame = null;

        for (Entity entity : entities) {
            if (entity instanceof ItemFrame) {
                ItemFrame itemFrame = (ItemFrame) entity;
                Location loc = itemFrame.getLocation();
                double dx = loc.getX() - mutable.getX();
                double dy = loc.getY() - mutable.getY();
                double dz = loc.getZ() - mutable.getZ();
                double dist = dx * dx + dy * dy + dz * dz;
                if (dist < minDist) {
                    minItemFrame = itemFrame;
                    minDist = dist;
                }
            }
        }
        if (minItemFrame != null) {
            handleInteract(event, minItemFrame, primary);
            if (event.isCancelled()) return;
        }
    }
}
 
Example 20
Source File: PlayerEventHandler.java    From GriefDefender with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteractBlockSecondary(PlayerInteractEvent event) {
    final Block clickedBlock = event.getClickedBlock();
    if (clickedBlock == null) {
        return;
    }

    final String id = GDPermissionManager.getInstance().getPermissionIdentifier(clickedBlock);
    final GDBlockType gdBlock = BlockTypeRegistryModule.getInstance().getById(id).orElse(null);
    if (gdBlock == null || (!gdBlock.isInteractable() && event.getAction() != Action.PHYSICAL)) {
        return;
    }
    if (NMSUtil.getInstance().isBlockStairs(clickedBlock) && event.getAction() != Action.PHYSICAL) {
        return;
    }

    final Player player = event.getPlayer();
    GDCauseStackManager.getInstance().pushCause(player);
    final GDPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
    if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) {
        onPlayerInteractBlockPrimary(event, player);
        return;
    }

    final Location location = clickedBlock.getLocation();
    GDClaim claim = this.dataStore.getClaimAt(location);
    final Sign sign = SignUtil.getSign(location);
    // check sign
    if (SignUtil.isSellSign(sign)) {
        EconomyUtil.getInstance().buyClaimConsumerConfirmation(player, claim, sign);
        return;
    }
    if (SignUtil.isRentSign(claim, sign)) {
        EconomyUtil.getInstance().rentClaimConsumerConfirmation(player, claim, sign);
        return;
    }

    final BlockState state = clickedBlock.getState();
    final ItemStack itemInHand = event.getItem();
    final boolean hasInventory = NMSUtil.getInstance().isTileInventory(location) || clickedBlock.getType() == Material.ENDER_CHEST;
    if (hasInventory) {
        onInventoryOpen(event, state.getLocation(), state, player);
        return;
    }

    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(player.getWorld().getUID())) {
        return;
    }
    if (GriefDefenderPlugin.isTargetIdBlacklisted(Flags.INTERACT_BLOCK_SECONDARY.getName(), event.getClickedBlock(), player.getWorld().getUID())) {
        return;
    }

    GDTimings.PLAYER_INTERACT_BLOCK_SECONDARY_EVENT.startTiming();
    final Object source = player;

    final TrustType trustType = NMSUtil.getInstance().isTileInventory(location) || clickedBlock.getType() == Material.ENDER_CHEST ? TrustTypes.CONTAINER : TrustTypes.ACCESSOR;
    if (GDFlags.INTERACT_BLOCK_SECONDARY && playerData != null) {
        Flag flag = Flags.INTERACT_BLOCK_SECONDARY;
        if (event.getAction() == Action.PHYSICAL) {
            flag = Flags.COLLIDE_BLOCK;
        }
        Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, flag, source, clickedBlock, player, trustType, true);
        if (result == Tristate.FALSE) {
            // if player is holding an item, check if it can be placed
            if (GDFlags.BLOCK_PLACE && itemInHand != null && itemInHand.getType().isBlock()) {
                if (GriefDefenderPlugin.isTargetIdBlacklisted(Flags.BLOCK_PLACE.getName(), itemInHand, player.getWorld().getUID())) {
                    GDTimings.PLAYER_INTERACT_BLOCK_SECONDARY_EVENT.stopTiming();
                    return;
                }
                if (GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.BLOCK_PLACE, source, itemInHand, player, TrustTypes.BUILDER, true) == Tristate.TRUE) {
                    GDTimings.PLAYER_INTERACT_BLOCK_SECONDARY_EVENT.stopTiming();
                    return;
                }
            }
            // Don't send a deny message if the player is in claim mode or is holding an investigation tool
            if (lastInteractItemCancelled != true) {
                if (!playerData.claimMode && (GriefDefenderPlugin.getInstance().investigationTool == null || !NMSUtil.getInstance().hasItemInOneHand(player, GriefDefenderPlugin.getInstance().investigationTool))) {
                    if (event.getAction() == Action.PHYSICAL) {
                        if (player.getWorld().getTime() % 100 == 0L) {
                            this.sendInteractBlockDenyMessage(itemInHand, clickedBlock, claim, player, playerData);
                        }
                    } else {
                        if (gdBlock != null && gdBlock.isInteractable()) {
                            this.sendInteractBlockDenyMessage(itemInHand, clickedBlock, claim, player, playerData);
                        }
                    }
                }
            }

            event.setUseInteractedBlock(Result.DENY);
            GDTimings.PLAYER_INTERACT_BLOCK_SECONDARY_EVENT.stopTiming();
            return;
        }
    }

    GDTimings.PLAYER_INTERACT_BLOCK_SECONDARY_EVENT.stopTiming();
}