當前位置: 首頁>>代碼示例>>Java>>正文


Java CreatureSpawnEvent.getLocation方法代碼示例

本文整理匯總了Java中org.bukkit.event.entity.CreatureSpawnEvent.getLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java CreatureSpawnEvent.getLocation方法的具體用法?Java CreatureSpawnEvent.getLocation怎麽用?Java CreatureSpawnEvent.getLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.entity.CreatureSpawnEvent的用法示例。


在下文中一共展示了CreatureSpawnEvent.getLocation方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event)
{
    if(!(event.getEntity() instanceof LivingEntity)) return;
    
    if(event.getLocation() == null) return;
    
    EntityType type = event.getEntityType();
    if(type == EntityType.PLAYER) return;
    if(type == EntityType.ARMOR_STAND) return;
    
    SpawnReason reason = event.getSpawnReason();
    if(reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG) return;
    
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getLocation(), null);
    if(flag == null) return;
    
    event.setCancelled(true);
}
 
開發者ID:BigScary,項目名稱:GriefPreventionFlags,代碼行數:21,代碼來源:FlagDef_NoMobSpawns.java

示例2: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event == null || event.isCancelled() || event.getLocation() == null || !plugin.isSkyWorld(event.getLocation().getWorld())) {
        return; // Bail out, we don't care
    }
    if (!event.isCancelled() && ADMIN_INITIATED.contains(event.getSpawnReason())) {
        return; // Allow it, the above method would have blocked it if it should be blocked.
    }
    checkLimits(event, event.getEntity().getType(), event.getLocation());
    if (!event.isCancelled() && event.getEntity() instanceof Squid) {
        Location loc = event.getLocation();
        int z = loc.getBlockZ();
        int x = loc.getBlockX();
        if (loc.getWorld().getBiome(x, z) == Biome.DEEP_OCEAN && LocationUtil.findRoofBlock(loc).getType() == Material.PRISMARINE) {
            loc.getWorld().spawnEntity(loc, EntityType.GUARDIAN);
            event.setCancelled(true);
        }
    }
    if (!event.isCancelled() && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.BUILD_WITHER && event.getEntity() instanceof Wither) {
        IslandInfo islandInfo = plugin.getIslandInfo(event.getLocation());
        if (islandInfo != null && islandInfo.getLeader() != null) {
            event.getEntity().setCustomName(I18nUtil.tr("{0}''s Wither", islandInfo.getLeader()));
            event.getEntity().setMetadata("fromIsland", new FixedMetadataValue(plugin, islandInfo.getName()));
        }
    }
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:27,代碼來源:SpawnEvents.java

示例3: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onSpawn(CreatureSpawnEvent event)
{
    Entity ent = event.getEntity();
    Location loc = event.getLocation();
    
    ZoneWorld world = plugin.getWorld(loc.getWorld());
    
    Zone zone = world.findZone(loc);
    
    if(zone == null)return;
    
    if(!zone.hasFlag(Flag.HOSTILES)){
        if(types.contains(ent.getType())){
            event.setCancelled(true);
            return;
        }
    }
}
 
開發者ID:sabersamus,項目名稱:Bytecraft,代碼行數:20,代碼來源:ZoneListener.java

示例4: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event)
{
    Entity entity = event.getEntity();

    Location location = event.getLocation();
    Point pos = new Point(location.getBlockX(), location.getBlockZ());

    ZoneWorld world = plugin.getWorld(entity.getWorld());
    Zone zone = world.findZone(pos);

    if (zone == null || zone.hasHostiles()) {
        return;
    }

    if (!allowedMobs.contains(event.getEntityType()) &&
        event.getSpawnReason() == SpawnReason.NATURAL) {

        event.setCancelled(true);
    }
}
 
開發者ID:EmilHernvall,項目名稱:tregmine,代碼行數:22,代碼來源:ZoneEntityListener.java

示例5: onChickenSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onChickenSpawn(CreatureSpawnEvent e)
{
	if(e.getEntityType() == EntityType.CHICKEN)
	{
		if(e.getSpawnReason() == SpawnReason.BREEDING)
		{
			e.setCancelled(true);
			Random rand = new Random();
			Location loc = e.getLocation();
			loc.getWorld().dropItem(loc, new ItemStack(Material.EGG, rand.nextInt(4) + 1));
        	loc.getWorld().playSound(loc, Sound.ENTITY_CHICKEN_EGG, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
		}
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:16,代碼來源:ChickenSpawn.java

示例6: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntitySpawn(CreatureSpawnEvent ese) {
  if (BedwarsRel.getInstance().getGameManager() == null) {
    return;
  }

  if (ese.getLocation() == null) {
    return;
  }

  if (ese.getLocation().getWorld() == null) {
    return;
  }

  Game game = BedwarsRel.getInstance().getGameManager().getGameByLocation(ese.getLocation());
  if (game == null) {
    return;
  }

  if (game.getState() == GameState.STOPPED) {
    return;
  }

  if (ese.getEntityType().equals(EntityType.CREEPER)
      || ese.getEntityType().equals(EntityType.CAVE_SPIDER)
      || ese.getEntityType().equals(EntityType.SPIDER)
      || ese.getEntityType().equals(EntityType.ZOMBIE)
      || ese.getEntityType().equals(EntityType.SKELETON)
      || ese.getEntityType().equals(EntityType.SILVERFISH)) {
    ese.setCancelled(true);
  }
}
 
開發者ID:BedwarsRel,項目名稱:BedwarsRel,代碼行數:33,代碼來源:EntityListener.java

示例7: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
  public void onCreatureSpawn(CreatureSpawnEvent event) {
RedProtect.get().logger.debug("RPGlobalListener - Is CreatureSpawnEvent event! Cancelled? " + event.isCancelled());
  	if (event.isCancelled()) {
          return;
      }
      Entity e = event.getEntity();
      if (e == null) {
          return;
      }
      
      Location l = event.getLocation();
      Region r = RedProtect.get().rm.getTopRegion(l);
      if (r != null){
      	return;
      }
      
      if (e instanceof Wither && event.getSpawnReason().equals(SpawnReason.BUILD_WITHER) && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-wither")){ 
          event.setCancelled(true);
          return;
      }        
      if (e instanceof Monster && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-monsters")) {        	
          if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CHUNK_GEN)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.DEFAULT)) {
          	event.setCancelled(true);
              return;
          }
      }
      if ((e instanceof Animals || e instanceof Villager || e instanceof Golem) && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-passives")) {        	
          if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CHUNK_GEN)
                  		|| event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.DEFAULT)) {
          	event.setCancelled(true);
	}
      }
  }
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:40,代碼來源:RPGlobalListener.java

示例8: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onCreatureSpawn(CreatureSpawnEvent event)
{
    if (!event.isCancelled())
    {
        Location loc = event.getLocation();
        if (event.getEntity() instanceof Monster)
        {
            if (Math.abs(loc.getBlockX()) < CoreData.getSpawnSize() && Math.abs(loc.getBlockZ()) < CoreData.getSpawnSize())
            {
                event.setCancelled(true);
            }
        }
    }
}
 
開發者ID:Vanillacraft,項目名稱:vanillacraft,代碼行數:16,代碼來源:MobControl.java

示例9: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getEntity() instanceof Monster) {
        int range = Floodlight.INTERDICTION_RANGE * Floodlight.INTERDICTION_RANGE;
        for (Floodlight light : lights) {
            Location loc = event.getLocation();
            if (loc.getWorld().equals(light.getLocation().getWorld()) && loc.distanceSquared(light.getLocation()) < range) {
                Debugger.getInstance().debug(2, light + " prevents spawn of " + event.getEntity().getType());
                event.setCancelled(true);
            }
        }
    }
}
 
開發者ID:desht,項目名稱:sensibletoolbox,代碼行數:14,代碼來源:FloodlightListener.java

示例10: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onSpawn(CreatureSpawnEvent e) {
	if(e.getEntity() instanceof Monster) {
		if(pl.getManagers().getWorldGuardManager().isInRegion(e.getLocation())) {
			if(!pl.getManagers().getWorldGuardManager().isFlagAllowed(pl.getManagers().getWorldGuardManager().getMonsterFlag(), e.getLocation())) {
				Location loc = e.getLocation();
				loc.setY(-10);
				e.getEntity().teleport(loc);
			}
		}
	}
}
 
開發者ID:xEssentials,項目名稱:xEssentials-deprecated-bukkit,代碼行數:13,代碼來源:WorldGuardMonsterEvent.java

示例11: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler (ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
	Location loc = event.getLocation();
	if (Util.getQuadtree(loc).contains(loc))
		event.setCancelled(true);
}
 
開發者ID:catageek,項目名稱:BCProtect,代碼行數:7,代碼來源:MobListener.java


注:本文中的org.bukkit.event.entity.CreatureSpawnEvent.getLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。