コード例 #1
0
 /**
  * Handles mob spawning.<br>
  * Checks if an arena allows mob spawning before letting a mob spawn inside it.
  */
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onCreatureSpawn(CreatureSpawnEvent event) {
   if (event.getSpawnReason() == SpawnReason.NATURAL) {
     Arena arena = ultimateGames.getArenaManager().getLocationArena(event.getLocation());
     if (arena != null && !arena.allowMobSpawning()) {
       event.setCancelled(true);
     }
   }
 }
コード例 #2
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onCreatureSpawn(final CreatureSpawnEvent event) {
   if (event.getEntity() instanceof Player) {
     return;
   }
   if (event.isCancelled()) {
     return;
   }
   final CreatureType creature = event.getCreatureType();
   if (creature == null) {
     return;
   }
   final String creatureName = creature.toString().toLowerCase(Locale.ENGLISH);
   if (creatureName == null || creatureName.isEmpty()) {
     return;
   }
   if (ess.getSettings().getProtectPreventSpawn(creatureName)) {
     event.setCancelled(true);
   }
 }