当前位置: 首页>>代码示例>>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;未经允许,请勿转载。