Java Code Examples for org.bukkit.event.block.BlockIgniteEvent#getIgnitingEntity()
The following examples show how to use
org.bukkit.event.block.BlockIgniteEvent#getIgnitingEntity() .
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: BlockEventHandler.java From GriefDefender with MIT License | 6 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onBlockIgnite(BlockIgniteEvent event) { if (!GDFlags.BLOCK_MODIFY) { return; } final World world = event.getBlock().getWorld(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) { return; } if (event.getPlayer() != null) { GDCauseStackManager.getInstance().pushCause(event.getPlayer()); } final Object source = event.getIgnitingBlock() != null ? event.getIgnitingBlock() : event.getIgnitingEntity(); CommonBlockEventHandler.getInstance().handleBlockModify(event, source, event.getBlock().getState()); }
Example 2
Source File: BlockTransformEvent.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
/** * Get whether the {@link Block} was probably transformed by a player. * * @return Whether the event is considered "manual." */ public final boolean isManual() { final Event event = getCause(); if (event instanceof BlockPlaceEvent || event instanceof BlockBreakEvent || event instanceof PlayerBucketEmptyEvent || event instanceof PlayerBucketFillEvent) return true; if (event instanceof BlockIgniteEvent) { BlockIgniteEvent igniteEvent = (BlockIgniteEvent) event; if (igniteEvent.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && igniteEvent.getIgnitingEntity() != null) { return true; } } if (event instanceof ExplosionPrimeByEntityEvent && ((ExplosionPrimeByEntityEvent) event).getPrimer() instanceof Player) { return true; } return false; }
Example 3
Source File: BlockTransformListener.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@EventWrapper public void onBlockIgnite(final BlockIgniteEvent event) { // Flint & steel generates a BlockPlaceEvent if (event.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) return; BlockState oldState = event.getBlock().getState(); BlockState newState = BlockStates.cloneWithMaterial(event.getBlock(), Material.FIRE); ParticipantState igniter = null; if (event.getIgnitingEntity() != null) { // The player themselves using flint & steel, or any of // several types of owned entity starting or spreading a fire. igniter = Trackers.getOwner(event.getIgnitingEntity()); } else if (event.getIgnitingBlock() != null) { // Fire, lava, or flint & steel in a dispenser igniter = Trackers.getOwner(event.getIgnitingBlock()); } callEvent(event, oldState, newState, igniter); }
Example 4
Source File: BlockTransformEvent.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
/** * Return true if the block transformation was performed "by hand". * * Handled: * - place * - mine * - bucket fill/empty * - flint & steel fire/tnt * * Not handled: * - bonemeal * - probably lots of other things */ public boolean isManual() { final Event event = getCause(); if(Types.instanceOfAny( event, BlockPlaceEvent.class, BlockBreakEvent.class, PlayerBucketEmptyEvent.class, PlayerBucketFillEvent.class )) return true; if(event instanceof BlockIgniteEvent) { BlockIgniteEvent igniteEvent = (BlockIgniteEvent) event; if(igniteEvent.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && igniteEvent.getIgnitingEntity() != null) { return true; } } if(event instanceof ExplosionPrimeByEntityEvent && ((ExplosionPrimeByEntityEvent) event).getPrimer() instanceof Player) { return true; } return false; }
Example 5
Source File: BlockTransformListener.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@EventWrapper public void onBlockIgnite(final BlockIgniteEvent event) { // Flint & steel generates a BlockPlaceEvent if(event.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) return; BlockState oldState = event.getBlock().getState(); BlockState newState = BlockStateUtils.cloneWithMaterial(event.getBlock(), Material.FIRE); ParticipantState igniter = null; if(event.getIgnitingEntity() != null) { // The player themselves using flint & steel, or any of // several types of owned entity starting or spreading a fire. igniter = entityResolver.getOwner(event.getIgnitingEntity()); } else if(event.getIgnitingBlock() != null) { // Fire, lava, or flint & steel in a dispenser igniter = blockResolver.getOwner(event.getIgnitingBlock()); } callEvent(event, oldState, newState, igniter); }
Example 6
Source File: SentinelEventHandler.java From Sentinel with MIT License | 6 votes |
@EventHandler public void onBlockIgnites(BlockIgniteEvent event) { if (event.isCancelled()) { return; } if (!SentinelPlugin.instance.preventExplosionBlockDamage) { return; } if (event.getIgnitingEntity() instanceof Projectile) { ProjectileSource source = ((Projectile) event.getIgnitingEntity()).getShooter(); if (source instanceof Entity) { SentinelTrait sourceSentinel = SentinelUtilities.tryGetSentinel((Entity) source); if (sourceSentinel != null) { event.setCancelled(true); } } } }
Example 7
Source File: BukkitPlotListener.java From PlotMe-Core with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockIgnite(BlockIgniteEvent event) { if (event.getIgnitingEntity() == null) { return; } Location location = BukkitUtil.adapt(event.getBlock().getLocation()); PlotMapInfo pmi = manager.getMap(location); if (pmi != null) { if (pmi.isDisableIgnition()) { event.setCancelled(true); } else { Plot plot = manager.getPlot(location); if (plot == null) { event.setCancelled(true); } else { if (plot.getOwnerId().equals(event.getPlayer().getUniqueId())) { return; } Optional<Plot.AccessLevel> member = plot.isMember(event.getIgnitingEntity().getUniqueId()); if (member.isPresent()) { if (member.get().equals(Plot.AccessLevel.TRUSTED) && !api.getServerBridge().getOfflinePlayer(plot.getOwnerId()).isOnline()) { event.setCancelled(true); } else if (api.isPlotLocked(plot.getId())) { event.setCancelled(true); } } else { event.setCancelled(true); } } } } }
Example 8
Source File: BlockListener.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
@EventHandler(ignoreCancelled = true) public void onIgnite(BlockIgniteEvent ignite) { if (ignite.getIgnitingBlock() == null && ignite.getIgnitingEntity() == null) { return; } Game game = null; if (ignite.getIgnitingBlock() == null) { if (ignite.getIgnitingEntity() instanceof Player) { game = BedwarsRel.getInstance().getGameManager() .getGameOfPlayer((Player) ignite.getIgnitingEntity()); } else { game = BedwarsRel.getInstance().getGameManager() .getGameByLocation(ignite.getIgnitingEntity().getLocation()); } } else { game = BedwarsRel.getInstance().getGameManager() .getGameByLocation(ignite.getIgnitingBlock().getLocation()); } if (game == null) { return; } if (game.getState() == GameState.STOPPED) { return; } if (ignite.getCause() == IgniteCause.ENDER_CRYSTAL || ignite.getCause() == IgniteCause.LIGHTNING || ignite.getCause() == IgniteCause.SPREAD) { ignite.setCancelled(true); return; } if (ignite.getIgnitingEntity() == null) { ignite.setCancelled(true); return; } if (game.getState() == GameState.WAITING) { return; } if (!game.getRegion().isPlacedBlock(ignite.getIgnitingBlock()) && ignite.getIgnitingBlock() != null) { game.getRegion().addPlacedBlock(ignite.getIgnitingBlock(), ignite.getIgnitingBlock().getState()); } }