Java Code Examples for org.bukkit.event.entity.ExplosionPrimeEvent#getEntity()
The following examples show how to use
org.bukkit.event.entity.ExplosionPrimeEvent#getEntity() .
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: GriefEvents.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onCreeperExplode(ExplosionPrimeEvent event) { if (!creeperEnabled || !plugin.getWorldManager().isSkyWorld(event.getEntity().getWorld())) { return; } if (event.getEntity() instanceof Creeper && !isValidTarget(((Creeper)event.getEntity()).getTarget())) { event.setCancelled(true); } else if (event.getEntity() instanceof TNTPrimed) { TNTPrimed tntPrimed = (TNTPrimed) event.getEntity(); if (tntPrimed.getSource() instanceof Player && !isValidTarget(tntPrimed.getSource())) { event.setCancelled(true); } } }
Example 2
Source File: TNTMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void setCustomProperties(ExplosionPrimeEvent event) { if (event.getEntity() instanceof TNTPrimed) { TNTPrimed tnt = (TNTPrimed) event.getEntity(); if (this.properties.fuse != null) { tnt.setFuseTicks(this.getFuseTicks()); } if (this.properties.power != null) { tnt.setYield(this.properties.power); // Note: not related to EntityExplodeEvent.yield } } }
Example 3
Source File: BlockTransformListener.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPrimeTNT(ExplosionPrimeEvent event) { if (event.getEntity() instanceof TNTPrimed) { Block block = event.getEntity().getLocation().getBlock(); if (block.getType() == Material.TNT) { ParticipantState player; if (event instanceof ExplosionPrimeByEntityEvent) { player = Trackers.getOwner(((ExplosionPrimeByEntityEvent) event).getPrimer()); } else { player = null; } callEvent(event, block.getState(), BlockStates.toAir(block), player); } } }
Example 4
Source File: TNTTracker.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPrime(ExplosionPrimeEvent event) { if (event.getEntity() instanceof TNTPrimed) { // Some TNT was activated, try to figure out why TNTPrimed tnt = (TNTPrimed) event.getEntity(); TNTInfo info = null; if (event instanceof ExplosionPrimeByEntityEvent) { Entity primer = ((ExplosionPrimeByEntityEvent) event).getPrimer(); if (primer instanceof TNTPrimed) { // Primed by another owned explosive, propagate the damage info (e.g. origin location) info = resolveEntity(primer); } else { ParticipantState owner = entities().getOwner(primer); if (owner != null) { // Primed by some other type of owned entity e.g. flaming arrow, pet creeper, etc. info = new TNTInfo(owner, tnt.getLocation()); } } } if (info == null) { ParticipantState placer = blocks().getOwner(tnt.getLocation().getBlock()); if (placer != null) { // If no primer was resolved for the event, give the TNT entity to the block placer, if // any info = new TNTInfo(placer, tnt.getLocation()); } } if (info != null) { entities().trackEntity(tnt, info); } } }
Example 5
Source File: TNTMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void setCustomProperties(ExplosionPrimeEvent event) { if(event.getEntity() instanceof TNTPrimed) { TNTPrimed tnt = (TNTPrimed) event.getEntity(); if(this.properties.fuse != null) { tnt.setFuseTicks(this.getFuseTicks()); } if(this.properties.power != null) { tnt.setYield(this.properties.power); // Note: not related to EntityExplodeEvent.yield } } }
Example 6
Source File: BlockTransformListener.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventWrapper public void onPrimeTNT(ExplosionPrimeEvent event) { if(event.getEntity() instanceof TNTPrimed && !(event instanceof InstantTNTPlaceEvent)) { Block block = event.getEntity().getLocation().getBlock(); if(block.getType() == Material.TNT) { ParticipantState player; if(event instanceof ExplosionPrimeByEntityEvent) { player = entityResolver.getOwner(((ExplosionPrimeByEntityEvent) event).getPrimer()); } else { player = null; } callEvent(event, block.getState(), BlockStateUtils.toAir(block), player); } } }
Example 7
Source File: TNTTracker.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPrime(ExplosionPrimeEvent event) { if(event.getEntity() instanceof TNTPrimed) { // Some TNT was activated, try to figure out why TNTPrimed tnt = (TNTPrimed) event.getEntity(); TNTInfo info = null; if(event instanceof ExplosionPrimeByEntityEvent) { Entity primer = ((ExplosionPrimeByEntityEvent) event).getPrimer(); if(primer instanceof TNTPrimed) { // Primed by another owned explosive, propagate the damage info (e.g. origin location) info = resolveEntity(primer); } else { ParticipantState owner = entities().getOwner(primer); if(owner != null) { // Primed by some other type of owned entity e.g. flaming arrow, pet creeper, etc. info = new TNTInfo(owner, tnt.getLocation()); } } } if(info == null) { ParticipantState placer = blocks().getOwner(tnt.getLocation().getBlock()); if(placer != null) { // If no primer was resolved for the event, give the TNT entity to the block placer, if any info = new TNTInfo(placer, tnt.getLocation()); } } if(info != null) { entities().trackEntity(tnt, info); } } }
Example 8
Source File: Tnt.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onExplosionPrime(ExplosionPrimeEvent event) { if (event.getEntity() instanceof TNTPrimed) { TNTPrimed tnt = (TNTPrimed) event.getEntity(); if (fuse != 4) { tnt.setFuseTicks(fuse); } if (power != 4.0) { tnt.setYield((float) power); } } }
Example 9
Source File: EntityEventHandler.java From GriefDefender with MIT License | 4 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onExplosionPrimeEvent(ExplosionPrimeEvent event) { final World world = event.getEntity().getLocation().getWorld(); final Entity source = event.getEntity(); if (!GDFlags.EXPLOSION_BLOCK && !GDFlags.EXPLOSION_ENTITY) { return; } if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) { return; } if (source instanceof Creeper || source instanceof EnderCrystal) { return; } GDCauseStackManager.getInstance().pushCause(source); GDTimings.ENTITY_EXPLOSION_PRE_EVENT.startTiming(); final GDEntity gdEntity = EntityTracker.getCachedEntity(source.getEntityId()); GDPermissionUser user = null; if (gdEntity != null) { user = PermissionHolderCache.getInstance().getOrCreateUser(gdEntity.getOwnerUUID()); } final Location location = event.getEntity().getLocation(); final GDClaim radiusClaim = NMSUtil.getInstance().createClaimFromCenter(location, event.getRadius()); final GDClaimManager claimManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(location.getWorld().getUID()); final Set<Claim> surroundingClaims = claimManager.findOverlappingClaims(radiusClaim); if (surroundingClaims.size() == 0) { GDTimings.ENTITY_EXPLOSION_PRE_EVENT.stopTiming(); return; } for (Claim claim : surroundingClaims) { // Use any location for permission check final Vector3i pos = claim.getLesserBoundaryCorner(); Location targetLocation = new Location(location.getWorld(), pos.getX(), pos.getY(), pos.getZ()); Tristate blockResult = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.EXPLOSION_BLOCK, source, targetLocation, user, true); if (blockResult == Tristate.FALSE) { // Check explosion entity if (GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.EXPLOSION_ENTITY, source, targetLocation, user, true) == Tristate.FALSE) { event.setCancelled(true); break; } } } GDTimings.ENTITY_EXPLOSION_PRE_EVENT.stopTiming(); }
Example 10
Source File: FlyingMobEvents.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Deal with pre-explosions */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void WitherExplode(final ExplosionPrimeEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } // Only cover withers in the island world if (!IslandGuard.inWorld(e.getEntity()) || e.getEntity() == null) { return; } // The wither or wither skulls can both blow up if (e.getEntityType() == EntityType.WITHER) { //plugin.getLogger().info("DEBUG: Wither"); // Check the location if (mobSpawnInfo.containsKey(e.getEntity())) { // We know about this wither if (DEBUG) { plugin.getLogger().info("DEBUG: We know about this wither"); } if (!mobSpawnInfo.get(e.getEntity()).inIslandSpace(e.getEntity().getLocation())) { // Cancel the explosion if (DEBUG) { plugin.getLogger().info("DEBUG: cancelling wither pre-explosion"); } e.setCancelled(true); } } // Testing only e.setCancelled(true); } if (e.getEntityType() == EntityType.WITHER_SKULL) { //plugin.getLogger().info("DEBUG: Wither skull"); // Get shooter Projectile projectile = (Projectile)e.getEntity(); if (projectile.getShooter() instanceof Wither) { //plugin.getLogger().info("DEBUG: shooter is wither"); Wither wither = (Wither)projectile.getShooter(); // Check the location if (mobSpawnInfo.containsKey(wither)) { // We know about this wither if (DEBUG) { plugin.getLogger().info("DEBUG: We know about this wither"); } if (!mobSpawnInfo.get(wither).inIslandSpace(e.getEntity().getLocation())) { // Cancel the explosion if (DEBUG) { plugin.getLogger().info("DEBUG: cancel wither skull explosion"); } e.setCancelled(true); } } } } }
Example 11
Source File: CombatSystem.java From EliteMobs with GNU General Public License v3.0 | 3 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onEliteCreeperDetonation(ExplosionPrimeEvent event) { if (event.isCancelled()) return; if (!(event.getEntity() instanceof Creeper && EntityTracker.isEliteMob(event.getEntity()))) return; /* This is necessary because the propagate the same duration as they have, which is nearly infinite */ for (PotionEffect potionEffect : ((Creeper) event.getEntity()).getActivePotionEffects()) ((Creeper) event.getEntity()).removePotionEffect(potionEffect.getType()); EliteMobEntity eliteMobEntity = EntityTracker.getEliteMobEntity(event.getEntity()); int mobLevel = eliteMobEntity.getLevel() < 1 ? 1 : eliteMobEntity.getLevel(); float newExplosionRange = (float) (event.getRadius() + Math.ceil(0.01 * mobLevel * event.getRadius() * ConfigValues.mobCombatSettingsConfig.getDouble(MobCombatSettingsConfig.ELITE_CREEPER_EXPLOSION_MULTIPLIER))); if (newExplosionRange > 20) newExplosionRange = 20; event.setRadius(newExplosionRange); }
Example 12
Source File: AttackFireball.java From EliteMobs with GNU General Public License v3.0 | 3 votes |
@EventHandler public void explosionEvent(ExplosionPrimeEvent event) { if (!(event.getEntity() instanceof Fireball)) return; if (!fireballs.contains(event.getEntity())) return; event.setCancelled(true); event.getEntity().getLocation().getWorld().createExplosion(event.getEntity().getLocation(), 3F, true); fireballs.remove(event.getEntity()); }