예제 #1
0
 @EventHandler(ignoreCancelled = true)
 public void onEntityExplode(EntityExplodeEvent event) {
   Location loc = event.getEntity().getLocation();
   WorldSettings settings =
       plugin.getConfigManager().getWorldSettings(event.getEntity().getWorld().getName());
   boolean above = loc.getY() >= settings.getWorldSplit();
   switch (event.getEntityType()) {
     case CREEPER:
       switch (settings.getCreeperType()) {
         case DESPAWN:
           event.getEntity().remove();
           break;
         case ABOVE_DESPAWN:
           event.setCancelled(above);
           break;
         default:
           event.setCancelled(true);
           loc.getWorld().createExplosion(loc, settings.getCreeperRadius());
       }
       break;
     case PRIMED_TNT:
       switch (settings.getTntType()) {
         case DESPAWN:
           event.setCancelled(true);
           break;
         case ABOVE_DESPAWN:
           event.setCancelled(above);
           break;
         default:
           event.setCancelled(true);
           loc.getWorld().createExplosion(loc, settings.getTntRadius());
       }
   }
 }
예제 #2
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;
       }
   }
 }