org.bukkit.event.block.BlockCanBuildEvent Java Examples
The following examples show how to use
org.bukkit.event.block.BlockCanBuildEvent.
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: DisplayBugFixListener.java From QuickShop-Reremake with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void canBuild(BlockCanBuildEvent e) { if (!plugin.isDisplay() || DisplayItem.getNowUsing() != DisplayType.ARMORSTAND || e.isBuildable()) { return; } final Collection<Entity> entities = e.getBlock().getWorld().getNearbyEntities(e.getBlock().getLocation(), 1.0, 1, 1.0); for (final Entity entity : entities) { if (!(entity instanceof ArmorStand) || !DisplayItem.checkIsGuardItemStack(((ArmorStand) entity).getItemInHand())) { continue; } e.setBuildable(true); Util.debugLog( "Re-set the allowed build flag here because it found the cause of the display-item blocking it before."); return; } }
Example #2
Source File: EffCancelEvent.java From Skript with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("null") @Override public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) { if (isDelayed == Kleenean.TRUE) { Skript.error("Can't cancel an event anymore after it has already passed", ErrorQuality.SEMANTIC_ERROR); return false; } cancel = matchedPattern == 0; final Class<? extends Event>[] es = ScriptLoader.getCurrentEvents(); if (es == null) return false; for (final Class<? extends Event> e : es) { if (Cancellable.class.isAssignableFrom(e) || BlockCanBuildEvent.class.isAssignableFrom(e)) return true; // TODO warning if some event(s) cannot be cancelled even though some can (needs a way to be suppressed) } if (ScriptLoader.isCurrentEvent(PlayerLoginEvent.class)) Skript.error("A connect event cannot be cancelled, but the player may be kicked ('kick player by reason of \"...\"')", ErrorQuality.SEMANTIC_ERROR); else Skript.error(Utils.A(ScriptLoader.getCurrentEventName()) + " event cannot be cancelled", ErrorQuality.SEMANTIC_ERROR); return false; }
Example #3
Source File: EffCancelEvent.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public void execute(final Event e) { if (e instanceof Cancellable) ((Cancellable) e).setCancelled(cancel); if (e instanceof PlayerInteractEvent) { EvtClick.interactTracker.eventModified((Cancellable) e); ((PlayerInteractEvent) e).setUseItemInHand(cancel ? Result.DENY : Result.DEFAULT); ((PlayerInteractEvent) e).setUseInteractedBlock(cancel ? Result.DENY : Result.DEFAULT); } else if (e instanceof BlockCanBuildEvent) { ((BlockCanBuildEvent) e).setBuildable(!cancel); } else if (e instanceof PlayerDropItemEvent) { PlayerUtils.updateInventory(((PlayerDropItemEvent) e).getPlayer()); } }