@EventHandler(priority = EventPriority.HIGHEST)
 public void onExplosionPrime(ExplosionPrimeEvent event) {
   if ((event.getEntity() instanceof Fireball || event.getEntity() instanceof SmallFireball)
       && prot.getSettingBool(ProtectConfig.prevent_fireball_fire)) {
     event.setFire(false);
   }
 }
Пример #2
0
 @EventHandler(priority = EventPriority.MONITOR)
 public void onExplosionPrime(ExplosionPrimeEvent event) {
   if (event.isCancelled() || !(event.getEntity() instanceof TNTPrimed)) {
     return;
   }
   // do stuff
   CustomExplosion explosion =
       new CustomExplosion(
           event.getEntity(), event.getEntity().getLocation(), event.getRadius(), event.getFire());
   explosion.doAll();
 }
Пример #3
0
  public void onExplosionPrime(ExplosionPrimeEvent event) {
    ArrayList<Integer> ids = iCoLand.landMgr.getLandIds(event.getEntity().getLocation());
    for (Integer id : ids) {
      if (iCoLand.landMgr.getLandById(id).hasAddon("noboom")) {
        event.setCancelled(true);
      }
    }

    if (ids.size() == 0 && !Config.unclaimedLandCanBoom) {
      event.setCancelled(true);
    }
  }
Пример #4
0
  // blocks projectiles explosions
  @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
  public void onExplosionPrime(ExplosionPrimeEvent event) {
    final Entity entity = event.getEntity();

    if (entity instanceof Projectile) {
      final Projectile projectile = (Projectile) entity;
      if (projectile.getShooter() instanceof Player) {
        if (this.projectileCheck(projectile, projectile.getLocation())) {
          event.setCancelled(true);
          event.setRadius(0);
        }
      }
    }
  }
Пример #5
0
 @EventHandler(ignoreCancelled = true)
 public void onEntityPrime(ExplosionPrimeEvent event) {
   WorldSettings settings =
       plugin.getConfigManager().getWorldSettings(event.getEntity().getWorld().getName());
   boolean above = event.getEntity().getLocation().getY() >= settings.getWorldSplit();
   switch (event.getEntityType()) {
     case CREEPER:
       switch (settings.getCreeperType()) {
         case DISABLE:
           event.setCancelled(true);
           break;
         case MELEE:
           forMelee((Creeper) event.getEntity());
           event.setCancelled(true);
           break;
         case ABOVE_MELEE:
           if (above) {
             forMelee((Creeper) event.getEntity());
             event.setCancelled(true);
           }
           break;
         case ABOVE_DISABLE:
           event.setCancelled(above);
           break;
       }
       break;
     case PRIMED_TNT:
       switch (settings.getTntType()) {
         case DISABLE:
           event.setCancelled(true);
           break;
         case ABOVE_DISABLE:
           event.setCancelled(above);
           break;
       }
   }
 }
Пример #6
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onExplosionPrime(ExplosionPrimeEvent event) {
   if (event.isCancelled()) return;
   EntityType entity = event.getEntityType();
   FlagPermissions perms = Residence.getPermsByLoc(event.getEntity().getLocation());
   if (entity == EntityType.CREEPER) {
     if (!perms.has("creeper", perms.has("explode", true))) {
       event.setCancelled(true);
       event.getEntity().remove();
     }
   }
   if (entity == EntityType.PRIMED_TNT) {
     if (!perms.has("tnt", perms.has("explode", true))) {
       event.setCancelled(true);
       event.getEntity().remove();
     }
   }
   if (entity == EntityType.FIREBALL) {
     if (!perms.has("fireball", perms.has("explode", true))) {
       event.setCancelled(true);
       event.getEntity().remove();
     }
   }
 }
Пример #7
0
  /**
   * Monitor ExplosionPrime events.
   *
   * @param event The event to monitor
   */
  @EventHandler(priority = EventPriority.LOW)
  public void onExplosionPrime(ExplosionPrimeEvent event) {
    Entity entity = event.getEntity();

    if (entity instanceof TNTPrimed) {
      int id = entity.getEntityId();

      if (plugin.tntTracker.containsKey(id)) {
        Player player = plugin.tntTracker.get(id);

        if (mcPermissions.getInstance().biggerBombs(player)) {
          BlastMining.biggerBombs(player, event);
        }
      }
    }
  }
Пример #8
0
  /**
   * Event handler called when an explosive is primed.
   *
   * <p>We use it to detect impending creeper explosions. The event is fired immediately before the
   * explosion.
   */
  @EventHandler(ignoreCancelled = true)
  public void onCreeperDetonate(ExplosionPrimeEvent event) {
    if (!CONFIG.isAffectedWorld(event)) {
      return;
    }

    if (event.getEntityType() == EntityType.CREEPER) {
      event.setRadius((float) CONFIG.BLAST_RADIUS_SCALE * event.getRadius());

      Entity creeper = event.getEntity();
      launchReinforcements(creeper);

      Location origin = creeper.getLocation();
      World world = origin.getWorld();
      Firework firework = (Firework) world.spawnEntity(origin, EntityType.FIREWORK);
      if (firework != null) {
        FireworkMeta meta = firework.getFireworkMeta();
        meta.setPower(random(0, 1));
        meta.addEffect(randomFireworkFffect(true));
        firework.setFireworkMeta(meta);
      }
    }
  }
Пример #9
0
  /**
   * Handle ExplosionPrime events that involve modifying the event.
   *
   * @param event The event to modify
   */
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onExplosionPrime(ExplosionPrimeEvent event) {
    Entity entity = event.getEntity();

    if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
      return;
    }

    // We can make this assumption because we (should) be the only ones using this exact metadata
    Player player =
        plugin
            .getServer()
            .getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());

    if (Misc.isNPCEntity(player)) {
      return;
    }

    MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();

    if (miningManager.canUseBiggerBombs()) {
      event.setRadius(miningManager.biggerBombs(event.getRadius()));
    }
  }
Пример #10
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onExplosionPrime(ExplosionPrimeEvent evt) {

    Location l = evt.getEntity().getLocation();
    World w = l.getWorld();
    Chunk c = w.getChunkAt(l);

    if (evt.getEntity() instanceof Creeper) {
      if (GlobalRegionManager.getGlobalWorldSetting(w) != null) {
        if (!GlobalRegionManager.getGlobalWorldSetting(w).creeperExplodes) {
          evt.setCancelled(true);
          evt.setRadius(0);
          return;
        }
      }
    }

    ArrayList<Region> regionSet = new ArrayList<Region>();

    for (Region region : GlobalRegionManager.getRegions()) {
      for (Chunk chunk : region.getChunkGrid().getChunks()) {
        if (chunk.getWorld() == w) {
          if (areChunksEqual(chunk, c)) {
            if (!regionSet.contains(region)) {
              regionSet.add(region);
            }
          }
        }
      }
    }

    if (regionSet.isEmpty()) {
      return;
    }

    ArrayList<Region> currentRegionSet = new ArrayList<Region>();

    for (Region reg : regionSet) {
      Location rl1 = reg.getL1().toBukkitLocation(), rl2 = reg.getL2().toBukkitLocation();
      if (rl1.getX() > rl2.getX()) {
        rl2.subtract(6, 0, 0);
        rl1.add(6, 0, 0);
      } else {
        rl2.add(6, 0, 0);
        rl1.subtract(6, 0, 0);
      }
      if (rl1.getZ() > rl2.getZ()) {
        rl2.subtract(0, 0, 6);
        rl1.add(0, 0, 6);
      } else {
        rl2.add(0, 0, 6);
        rl1.subtract(0, 0, 6);
      }
      if (rl1.getY() > rl2.getY()) {
        rl2.subtract(0, 10, 0);
        rl1.add(0, 10, 0);
      } else {
        rl2.add(0, 10, 0);
        rl1.subtract(0, 10, 0);
      }
      if (extReg.isInsideCuboid(l, rl1, rl2)) {
        currentRegionSet.add(reg);
      }
    }

    if (currentRegionSet.isEmpty()) { // If player is in chunk range but not
      // inside region then cancel the
      // check.
      return;
    } else {
      for (Region r : currentRegionSet) {
        if (r.is_protection()) {
          LogRunner.addLogMessage(r, LogRunner.getPrefix(r) + (" Entity explosion was prevented."));
          evt.setCancelled(true);
          evt.setRadius(0);
          return;
        }
      }
    }
  }