@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void creatureSpawnEvent(EntitySpawnEvent event) {
   Entity entity = event.getEntity();
   Location location = BukkitUtil.getLocation(entity.getLocation());
   PlotArea area = location.getPlotArea();
   if (area == null) {
     return;
   }
   Plot plot = area.getOwnedPlotAbs(location);
   if (plot == null) {
     return;
   }
   if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
     event.setCancelled(true);
   }
   switch (entity.getType()) {
     case ENDER_CRYSTAL:
       if (plot == null) {
         if (!area.MOB_SPAWNING) {
           event.setCancelled(true);
         }
         return;
       }
       if (PlayerEvents.checkEntity(entity, plot)) {
         event.setCancelled(true);
       }
   }
 }
Exemplo n.º 2
0
  @EventHandler
  public void onMobSpawn(EntitySpawnEvent event) {
    EntityUtil entity = (EntityUtil) event.getEntity();
    if (entity instanceof Player) {

    } else {
      if (entity.checkInVillage()) {
        event.setCancelled(true);
      }
    }
  }