1.16.5 Test if InventoryOpenEvent is a vehicle?

Discussion in 'Spigot Plugin Development' started by ShiftingKill, Jun 25, 2020.

  1. So I'm trying to make sure people can't store certain items with certain lore into a WorldGuard region, and have all bases covered except for vehicles like StorageMinecarts/mules from going in with those items. Instead of having a massive fire with VehicleMoveEvents, I now think I'm going to disallow InventoryOpenEvent on all vehicles, if the player has these items in their inventory. I want to make sure they can't open Inventories that are instanceof Vehicle. Any red flags with this performance wise? Code actually works.

    Code (Text):
    @EventHandler
    public void openVehicleInventoryPreventRaidLoot (InventoryOpenEvent e) {
        if (e.getInventory().getHolder() instanceof Vehicle) {

        }
    }