Java Code Examples for org.bukkit.event.EventPriority#LOWEST

The following examples show how to use org.bukkit.event.EventPriority#LOWEST . 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: UserListener.java    From VoxelGamesLibv2 with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onJoin(@Nonnull PlayerJoinEvent event) {
    if (!handler.hasLoggedIn(event.getPlayer().getUniqueId())) {
        // worst case: load data sync
        log.warning("Loading data for player " + event.getPlayer().getName() + "(" + event.getPlayer()
                .getUniqueId() + ") sync!");
        boolean login = handler.login(event.getPlayer().getUniqueId());
        if (!login || !handler.hasLoggedIn(event.getPlayer().getUniqueId())) {
            // something went horribly wrong
            // we don't have a locale here since the data was not loaded :/
            event.getPlayer().kickPlayer(Lang.legacyColors(Lang.string(LangKey.DATA_NOT_LOADED)));
            return;
        }
    }

    handler.join(event.getPlayer());
}
 
Example 2
Source File: EntityEventHandler.java    From GriefDefender with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onVehicleDamage(VehicleDamageEvent event) {
    GDTimings.ENTITY_DAMAGE_EVENT.startTiming();
    final Object source = event.getAttacker() != null ? event.getAttacker() : NMSUtil.getInstance().getBlockDamager();
    if (protectEntity(event, source, (Entity) event.getVehicle())) {
        event.setCancelled(true);
    }
    GDTimings.ENTITY_DAMAGE_EVENT.stopTiming();
}
 
Example 3
Source File: PlayerPickupItem.java    From AdditionsAPI with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
	if (event.isCancelled())
		return;

	ItemStack item = event.getItem().getItemStack();
	if (!AdditionsAPI.isCustomItem(item))
		return;
	CustomItemStack cStack = new CustomItemStack(item);

	Bukkit.getPluginManager().callEvent(new PlayerPickupCustomItemEvent(event, cStack));
}
 
Example 4
Source File: PlayerServerChanger.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onQuit(PlayerQuitEvent event) {
    final MetadataValue future = event.getPlayer().getMetadata(METADATA_KEY, plugin);
    if(future != null) {
        ((SettableFuture) future.value()).set(null);
    }
}
 
Example 5
Source File: PlayerEventHandler.java    From GriefDefender with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteractInventoryClick(InventoryClickEvent event) {
    final HumanEntity player = event.getWhoClicked();
    GDCauseStackManager.getInstance().pushCause(player);
    if (!GDFlags.INTERACT_INVENTORY_CLICK || event.getClickedInventory() == null || !GriefDefenderPlugin.getInstance().claimsEnabledForWorld(player.getWorld().getUID())) {
        return;
    }

    GDTimings.PLAYER_INTERACT_INVENTORY_CLICK_EVENT.startTiming();
    final Location location = player.getLocation();
    final GDClaim claim = this.dataStore.getClaimAt(location);
    final ItemStack cursorItem = event.getCursor();
    final Inventory source = event.getInventory();
    final ItemStack target = event.getCurrentItem();

    if (GriefDefenderPlugin.isTargetIdBlacklisted(Flags.INTERACT_INVENTORY_CLICK.getName(), target, player.getWorld().getUID())) {
        GDTimings.PLAYER_INTERACT_INVENTORY_CLICK_EVENT.stopTiming();
        return;
    }

    final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(player.getUniqueId());
    final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.INTERACT_INVENTORY_CLICK, source, target, user, TrustTypes.CONTAINER, true);
    if (result == Tristate.FALSE) {
        final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_INTERACT_ITEM,
                ImmutableMap.of(
                "player", claim.getOwnerDisplayName(),
                "item", ItemTypeRegistryModule.getInstance().getNMSKey(target)));
        GriefDefenderPlugin.sendClaimDenyMessage(claim, player, message);
        event.setCancelled(true);
    }
    GDTimings.PLAYER_INTERACT_INVENTORY_CLICK_EVENT.stopTiming();
}
 
Example 6
Source File: EntityEventHandler.java    From GriefDefender with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onVehicleDestroy(VehicleDestroyEvent event) {
    GDTimings.ENTITY_DAMAGE_EVENT.startTiming();
    final Object source = event.getAttacker() != null ? event.getAttacker() : NMSUtil.getInstance().getBlockDamager();
    if (protectEntity(event, source, (Entity) event.getVehicle())) {
        event.setCancelled(true);
    }
    GDTimings.ENTITY_DAMAGE_EVENT.stopTiming();
}
 
Example 7
Source File: GUI.java    From MineTinker with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onDrag(InventoryDragEvent event) {
	Window w = getWindowFromInventory(event.getInventory());

	if (w == null) {
		return;
	}

	event.setCancelled(true);
}
 
Example 8
Source File: EventFilterMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onCombust(final EntityCombustEvent event) {
  cancelUnlessInteracting(event, event.getEntity());
  if (event instanceof EntityCombustByEntityEvent) {
    cancelUnlessInteracting(event, ((EntityCombustByEntityEvent) event).getCombuster());
  }
}
 
Example 9
Source File: BlockEventHandler.java    From GriefDefender with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockFromTo(BlockFromToEvent event) {
    final Block fromBlock = event.getBlock();
    final Block toBlock = event.getToBlock();
    final World world = fromBlock.getWorld();
    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
        return;
    }

    final GDPermissionUser user = CauseContextHelper.getEventUser(fromBlock.getLocation(), PlayerTracker.Type.NOTIFIER);
    if (user == null) {
        return;
    }

    Location location = toBlock.getLocation();
    GDClaim targetClaim = this.storage.getClaimAt(location);
    if (targetClaim.isWilderness()) {
        return;
    }

    if (fromBlock.isLiquid()) {
        final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.LIQUID_FLOW, fromBlock, toBlock, user, TrustTypes.BUILDER, true);
        if (result == Tristate.FALSE) {
            event.setCancelled(true);
            return;
        }
    } else if (handleBlockBreak(event, location, targetClaim, event.getBlock(), event.getToBlock(), user, false)) {
        event.setCancelled(true);
    }
}
 
Example 10
Source File: PlayerCustomItemDamage.java    From AdditionsAPI with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void gamemodeCheck(PlayerCustomItemDamageEvent event) {
	GameMode gm = event.getPlayer().getGameMode();
	if (gm != GameMode.SURVIVAL && gm != GameMode.ADVENTURE) {
		event.setCancelled(true);
	}
	if (event.getDamage() == 0) {
		event.setCancelled(true);
	}
}
 
Example 11
Source File: PlayerPickupCustomItem.java    From AdditionsAPI with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPickupCustomItemLowest(PlayerPickupCustomItemEvent customEvent) {
	if (customEvent.isCancelled())
		return;

	CustomItem cItem = customEvent.getCustomItem();
	ItemPermissions perm = cItem.getPermissions();

	PlayerPickupItemEvent event = customEvent.getPlayerPickupItemEvent();
	if (!PermissionUtils.allowedAction(event.getPlayer(), perm.getType(), perm.getPickup()))
		event.setCancelled(true);
}
 
Example 12
Source File: SidebarMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onSpawn(ParticipantSpawnEvent event) {
    renderSidebarDebounce();
}
 
Example 13
Source File: EntityEventHandler.java    From GriefDefender with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
    if (!GDFlags.BLOCK_BREAK) {
        return;
    }

    final Block block = event.getBlock();
    if (block.isEmpty()) {
        return;
    }
    final World world = event.getBlock().getWorld();
    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
        return;
    }

    final Location location = block.getLocation();
    final GDClaim targetClaim = this.baseStorage.getClaimAt(location);

    final Entity source = event.getEntity();
    GDPermissionUser user = null;
    if (source instanceof Tameable) {
        final UUID uuid = NMSUtil.getInstance().getTameableOwnerUUID(source);
        if (uuid != null) {
            user = PermissionHolderCache.getInstance().getOrCreateUser(uuid);
        }
    }
    if (user == null && !NMSUtil.getInstance().isEntityMonster(event.getEntity())) {
        final GDEntity gdEntity = EntityTracker.getCachedEntity(event.getEntity().getEntityId());
        if (gdEntity != null) {
            user = PermissionHolderCache.getInstance().getOrCreateUser(gdEntity.getOwnerUUID());
        }
        if (user == null && source instanceof FallingBlock) {
            // always allow blocks to fall if no user found
            return;
        }
    }
    final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_BREAK, event.getEntity(), event.getBlock(), user, TrustTypes.BUILDER, true);
    if (result == Tristate.FALSE) {
        event.setCancelled(true);
        return;
    }
}
 
Example 14
Source File: EventFilterMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityTrack(final EntityTargetEvent event) {
    // Handles mobs and XP orbs
    if(event.getTarget() != null) cancelUnlessInteracting(event, event.getTarget());
}
 
Example 15
Source File: CommandEventHandler.java    From GriefDefender with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onRemoteServerCommand(RemoteServerCommandEvent event) {
   // CauseTracker.getInstance().getCauseStack().add(event.getSender());
}
 
Example 16
Source File: EventFilterMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPortalCreate(final PortalCreateEvent event) {
    cancelAlways(event, event.getWorld());
}
 
Example 17
Source File: EventFilterMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onWeatherChange(final WeatherChangeEvent event) {
    cancelAlways(event, event.getWorld());
}
 
Example 18
Source File: EventFilterMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onArmorStandInteract(final PlayerInteractAtEntityEvent event) {
    cancelUnlessInteracting(event, event.getPlayer());
}
 
Example 19
Source File: EventFilterMatchModule.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPortalCreate(final PortalCreateEvent event) {
  cancelAlways(event, event.getWorld());
}
 
Example 20
Source File: BlockListener.java    From QuickShop-Reremake with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlace(BlockPlaceEvent e) {

    final Material type = e.getBlock().getType();
    final Block placingBlock = e.getBlock();
    final Player player = e.getPlayer();

    if (type != Material.CHEST) {
        return;
    }
    Block chest = null;
    //Chest combine mechanic based checking
    if (player.isSneaking()) {
        Block blockAgainst = e.getBlockAgainst();
        if (blockAgainst.getType() == Material.CHEST && placingBlock.getFace(blockAgainst) != BlockFace.UP && placingBlock.getFace(blockAgainst) != BlockFace.DOWN && !(((Chest) blockAgainst.getState()).getInventory() instanceof DoubleChestInventory)) {
            chest = e.getBlockAgainst();
        } else {
            return;
        }
    } else {
        //Get all chest in vertical Location
        BlockFace placingChestFacing = ((Directional) (placingBlock.getState().getBlockData())).getFacing();
        for (BlockFace face : Util.getVerticalFacing()) {
            //just check the right side and left side
            if (face != placingChestFacing && face != placingChestFacing.getOppositeFace()) {
                Block nearByBlock = placingBlock.getRelative(face);
                if (nearByBlock.getType() == Material.CHEST
                        //non double chest
                        && !(((Chest) nearByBlock.getState()).getInventory() instanceof DoubleChestInventory)
                        //same facing
                        && placingChestFacing == ((Directional) nearByBlock.getState().getBlockData()).getFacing()) {
                    if (chest == null) {
                        chest = nearByBlock;
                    } else {
                        //when multiply chests competed, minecraft will always combine with right side
                        if (placingBlock.getFace(nearByBlock) == Util.getRightSide(placingChestFacing)) {
                            chest = nearByBlock;
                        }
                    }
                }
            }
        }
    }
    if (chest == null) {
        return;
    }

    Shop shop = getShopPlayer(chest.getLocation(), false);
    if (shop != null) {
        if (!QuickShop.getPermissionManager().hasPermission(player, "quickshop.create.double")) {
            e.setCancelled(true);
            MsgUtil.sendMessage(player, MsgUtil.getMessage("no-double-chests", player));

        } else if (!shop.getModerator().isModerator(player.getUniqueId())) {
            e.setCancelled(true);
            MsgUtil.sendMessage(player, MsgUtil.getMessage("not-managed-shop", player));
        }
    }
}