コード例 #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, ignoreCancelled = true)
 public void onCreatureSpawn(CreatureSpawnEvent event) {
   ZoneManager manager = m_plugin.getZoneManager();
   if (manager.zoneExists(event.getLocation())) {
     if (!manager.getZone(event.getLocation()).canMobsSpawn()) {
       if (event.getEntity() instanceof Monster || event.getEntity() instanceof Slime) {
         event.setCancelled(true);
       }
     }
   }
 }
コード例 #3
0
ファイル: MineZListener.java プロジェクト: BlueNinjar/MyMineZ
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onCreatureSpawn(CreatureSpawnEvent event) {
   if (event.isCancelled()) return;
   Entity entity = event.getEntity();
   if (!inGameWorld(event.getEntity())) return;
   EntityType creatureType = event.getEntityType();
   if (creatureType == EntityType.ZOMBIE) {
     ZombieMaker.mineZombie((Zombie) entity);
   } else {
     event.setCancelled(true);
   }
 }
コード例 #4
0
  @Override
  public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.isCancelled()) {
      return;
    }

    GlobalConfiguration cfg = plugin.getGlobalConfiguration();
    WorldConfiguration wcfg = cfg.getWorldConfig(event.getEntity().getWorld().getName());

    // CreatureType creaType = (CreatureType) CreatureType.valueOf(event.getMobType().toString());
    CreatureType creaType = event.getCreatureType();
    String creaName = "";
    Boolean cancelEvent = false;

    if (wcfg.blockCreatureSpawn.contains(creaType)) {
      cancelEvent = true;
    }

    if (wcfg.useRegions) {
      Vector pt = toVector(event.getEntity().getLocation());
      RegionManager mgr =
          plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());

      Boolean flagValue =
          mgr.getApplicableRegions(pt)
              .getStringFlag(Flags.DENY_SPAWN, true)
              .getValue("")
              .contains(creaType.getName());
      if (flagValue != null) {
        if (flagValue) {
          cancelEvent = true;
        } else {
          cancelEvent = false;
        }
      }
    }

    if (cancelEvent) {
      event.setCancelled(true);
      return;
    }
  }
コード例 #5
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);
   }
 }
コード例 #6
0
ファイル: NDDragonListener.java プロジェクト: Juze/NoDragons
 public void onCreatureSpawn(CreatureSpawnEvent event) {
   if (event.getCreatureType() == CreatureType.DRAGON) {
     event.setCancelled(true);
   }
 }