org.bukkit.event.entity.ExplosionPrimeEvent Java Examples
The following examples show how to use
org.bukkit.event.entity.ExplosionPrimeEvent.
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 |
private boolean callPrimeEvent(TNTPrimed tnt, @Nullable Entity primer) { ExplosionPrimeEvent primeEvent = primer != null ? new ExplosionPrimeByEntityEvent(tnt, primer) : new ExplosionPrimeEvent(tnt); match.callEvent(primeEvent); if (primeEvent.isCancelled()) { tnt.remove(); return false; } else { return true; } }
Example #3
Source File: ControllableCreeperEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void explode(int modifier) { if (!this.world.isStatic) { boolean flag = this.world.getGameRules().getBoolean("mobGriefing"); float radius = this.isPowered() ? 6.0F : 3.0F; ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), radius, false); this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius() * modifier, event.getFire(), flag); this.die(); } } }
Example #4
Source File: ControllableCreeperEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void explode(int modifier) { if (!this.world.isStatic) { boolean flag = this.world.getGameRules().getBoolean("mobGriefing"); float radius = this.isPowered() ? 6.0F : 3.0F; ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), radius, false); this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius() * modifier, event.getFire(), flag); this.die(); } } }
Example #5
Source File: ControllableCreeperEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void explode(int modifier) { if (!this.world.isStatic) { boolean flag = this.world.getGameRules().getBoolean("mobGriefing"); float radius = this.isPowered() ? 6.0F : 3.0F; ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), radius, false); this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius() * modifier, event.getFire(), flag); this.die(); } } }
Example #6
Source File: ControllableCreeperEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void explode(int modifier) { if (!this.world.isStatic) { boolean flag = this.world.getGameRules().getBoolean("mobGriefing"); float radius = this.isPowered() ? 6.0F : 3.0F; ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), radius, false); this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius() * modifier, event.getFire(), flag); this.die(); } } }
Example #7
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 #8
Source File: Tnt.java From CardinalPGM with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onBlockPlace(BlockPlaceEvent event) { Block block = event.getBlock(); if (block.getType().equals(Material.TNT) && instantIgnite && !event.isCancelled()) { event.getBlock().setType(Material.AIR); TNTPrimed tnt = (TNTPrimed) GameHandler.getGameHandler().getMatchWorld().spawnEntity(block.getLocation().add(new Vector(0.5, 0.5, 0.5)), EntityType.PRIMED_TNT); Bukkit.getServer().getPluginManager().callEvent(new ExplosionPrimeEvent(tnt)); } }
Example #9
Source File: TntTracker.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onExplosionPrime(ExplosionPrimeEvent event) { if (event.getEntity().getType() == EntityType.PRIMED_TNT) { Location location = event.getEntity().getLocation(); if (tntPlaced.containsKey(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ())) { UUID player = tntPlaced.get(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ()); event.getEntity().setMetadata("source", new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), player)); tntPlaced.remove(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ()); } } }
Example #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
Source File: MutationModules.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onExplosionPrime(ExplosionPrimeEvent event) { event.setRadius(event.getRadius() * MULTIPLIER); }
Example #17
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 #18
Source File: LivingEntityShopListener.java From Shopkeepers with GNU General Public License v3.0 | 4 votes |
@EventHandler(ignoreCancelled = true) void onExplodePrime(ExplosionPrimeEvent event) { if (plugin.isShopkeeper(event.getEntity())) { event.setCancelled(true); } }
Example #19
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 #20
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 #21
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()); }