当前位置: 首页>>代码示例>>Java>>正文


Java CreatureSpawnEvent.getEntityType方法代码示例

本文整理汇总了Java中org.bukkit.event.entity.CreatureSpawnEvent.getEntityType方法的典型用法代码示例。如果您正苦于以下问题:Java CreatureSpawnEvent.getEntityType方法的具体用法?Java CreatureSpawnEvent.getEntityType怎么用?Java CreatureSpawnEvent.getEntityType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.entity.CreatureSpawnEvent的用法示例。


在下文中一共展示了CreatureSpawnEvent.getEntityType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() != SpawnReason.NATURAL) { //TODO: Should check for Custom instead of checking against natural?
        return;
    }

    EntityType type = event.getEntityType();
    World world = event.getLocation().getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.MORE_SPAWNING) && worldConfig.getStringList(Config.FEATURE_MORE_SPAWNING_MOBS).contains(type.getName().toUpperCase())) {
        for (int i = 0; i < Math.max(worldConfig.getInt(Config.FEATURE_MORE_SPAWNING_MULTIPLIER), 1); ++i) {
            for (BloodMoonEntityType bloodMoonEntity : BloodMoonEntityType.values()) {
                if (type == bloodMoonEntity.getEntityType()) {
                    bloodMoonEntity.spawnEntity(event.getLocation().add((random.nextDouble() * 3) - 1.5, (random.nextDouble() * 3) - 1.5, (random.nextDouble() * 3) - 1.5));
                    return;
                }
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:22,代码来源:MoreSpawningListener.java

示例3: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event)
{
    //Replace spawned villager if new one spawns
    if (event.getEntityType() == EntityType.VILLAGER)
    {
        final Entity villager = event.getEntity();
        if (!NMSVillagerManager.isCustomVillager(villager))
        {
            Bukkit.getScheduler().runTask(TradeCraftPlugin.instance, new Runnable() {
                @Override
                public void run() {
                    NMSVillagerManager.convert(villager);
                }
            });
        }
    }
}
 
开发者ID:CoreNetwork,项目名称:TradeCraft,代码行数:19,代码来源:TradeCraftListener.java

示例4: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onSpawn(CreatureSpawnEvent e) {
	if (e.getEntity().getWorld().getName() != "Christmas"){
		return;
	}

	if(e.getEntityType() == EntityType.GIANT ||
			e.getEntityType() == EntityType.VILLAGER ||
			e.getEntityType() == EntityType.WITCH){
		return;
	}
	
	if (e.getEntityType() == EntityType.ZOMBIE || 
			e.getEntityType() == EntityType.SKELETON) {
		setHelmet(e.getEntity());
		setChest(e.getEntity());
		setLegs(e.getEntity());
		setBoots(e.getEntity());
		setHand(e.getEntity());
	}else if (e.getEntity().getCustomName() == null){
		e.setCancelled(true);
	}
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:24,代码来源:SpawnListener.java

示例5: onEnderDragonSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
/**
 * - Prevents natural spawn of EnderDragon
 * - Prevents too many Dragons in the End world
 * - Handle custom health and take care of this new Dragon
 *
 * @param event a CreatureSpawnEvent
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEnderDragonSpawn(final CreatureSpawnEvent event) {
    if (event.getEntityType() == EntityType.ENDER_DRAGON) {
        final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(event.getLocation().getWorld().getName()));
        if (handler != null) {
            if (handler.getNumberOfAliveEnderDragons() >= handler.getConfig().getRespawnNumber()) {
                event.setCancelled(true);
            } else {
                if (event.getSpawnReason() != SpawnReason.CUSTOM && event.getSpawnReason() != SpawnReason.SPAWNER_EGG) {
                    event.setCancelled(true);
                } else {
                    if (!handler.getDragons().containsKey(event.getEntity().getUniqueId())) {
                        handler.getDragons().put(event.getEntity().getUniqueId(), new HashMap<String, Double>());
                        event.getEntity().setMaxHealth(handler.getConfig().getEdHealth());
                        event.getEntity().setHealth(event.getEntity().getMaxHealth());
                    }
                    handler.getLoadedDragons().add(event.getEntity().getUniqueId());
                }
            }
        }
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:30,代码来源:EnderDragonListener.java

示例6: 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

示例7: onArmorSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onArmorSpawn(CreatureSpawnEvent evt) {
    if (evt.getEntityType() != EntityType.ARMOR_STAND || placing == null)
        return;

    ArmorStand as = (ArmorStand) evt.getEntity();
    as.setArms(placing.isArms());
    as.setSmall(placing.isSmall());
    placing = null;
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:11,代码来源:ItemArmorStand.java

示例8: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntitySpawn(CreatureSpawnEvent e) {
	if (e.getEntityType().isAlive() && e.getEntityType() != EntityType.PLAYER
               && e.getEntityType() != EntityType.ZOMBIE && e.getEntityType() != EntityType.ENDERMAN
               && e.getEntityType() != EntityType.PIG && e.getEntityType() != EntityType.COW
               && e.getEntityType() != EntityType.SHEEP && e.getEntityType() != EntityType.HORSE
               && e.getEntityType() != EntityType.SQUID) {
	    e.setCancelled(true);
	    e.getLocation().getWorld().spawn(e.getLocation(), Zombie.class);
	}

}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:13,代码来源:MobListener.java

示例9: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent e)
{
    if (e.getEntityType() != EntityType.PLAYER && e.getEntityType() != EntityType.WITHER)
    {
        if (MWAPI.getConfig().stopEntitySpawn())
        {
            e.setCancelled(true);
        }
    }
}
 
开发者ID:WoutDev,项目名称:Mega-Walls,代码行数:12,代码来源:CreatureSpawnListener.java

示例10: CreatureSpawnBlock

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST)
public void CreatureSpawnBlock(CreatureSpawnEvent event){
	try{
		final EntityType creature = event.getEntityType();
		for(EntityType blocked : Main.moblist){
			if(blocked == creature){
				event.setCancelled(true);
			}
		}
	}catch(NullPointerException e){}
}
 
开发者ID:Kakalavala,项目名称:DragoMC-Cardinal-Dev,代码行数:12,代码来源:EntityManager.java

示例11: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent e) {
  LivingEntity en = e.getEntity();
  EntityType type = e.getEntityType();
  Location loc = en.getLocation();

  // Return without doing anything if we're in a whitelisted world, or if it's a blaze spawner
  // in the configured blaze world
  if (SpawnerGuard.config.getList("creative_worlds").contains(loc.getWorld().getName()) ||
    (SpawnerGuard.config.getString("blaze_world_name").equals(loc.getWorld().getName()) &&
     type == EntityType.BLAZE)) {
      return;
  }

  // If entity was created by a spawner
  if (e.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)) {

    // If the entity is on our invalid creature list (it isn't allowed to come from a spawner)
    if (SpawnerGuard.config.getList("invalid_creatures").contains(type.toString()) || SpawnerGuard.config.getString("blaze_world_name").equals(loc.getWorld().getName())) {
      // Cancel the spawn!
      e.setCancelled(true);
      SpawnerGuard.log.warning(type.toString() + " generation by spawner prevented near " +
          loc.getBlockX() + "," +
          loc.getBlockY() + "," +
          loc.getBlockZ() +
          " in world: " + loc.getWorld().getName());
      // Reset the spawner if that option is enabled
      if (SpawnerGuard.config.getBoolean("reset_invalid_spawners")) {
        plugin.changeBadSpawner(en.getLocation(), type);
      }
    }
  }
}
 
开发者ID:floored1585,项目名称:SpawnerGuard,代码行数:34,代码来源:SpawnerGuardListener.java

示例12: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntitySpawn(final CreatureSpawnEvent event){
	if(event.getEntityType() == EntityType.WOLF){
		// Avoid a double iteration (a "contains" and "remove" call)
		Iterator<Location> iter = getWolfSpawnLocSet().iterator();

		while(iter.hasNext()){
			if(iter.next().equals(event.getLocation())){
				event.setCancelled(false);
				iter.remove();
				return;
			}
		}
	}
}
 
开发者ID:glen3b,项目名称:BukkitLib,代码行数:16,代码来源:Utilities.java

示例13: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
	EntityType type = event.getEntityType();
	MobPermission permission = plugin.getMobPermission(type);

	if (permission == MobPermission.ENABLED) {
		// do nothing
	} else if (permission == MobPermission.DISABLED) {
		event.setCancelled(true);
	} else if (permission == MobPermission.ALLOWED_WITH_EGG) {
		if (event.getSpawnReason() != SpawnReason.SPAWNER_EGG) event.setCancelled(true);
	}
}
 
开发者ID:trew,项目名称:DisableMobs,代码行数:14,代码来源:SpawnListener.java

示例14: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
void onCreatureSpawn(CreatureSpawnEvent event) {
	if (nextSpawnLocation == null) return;
	if (event.getEntityType() == nextEntityType && event.getLocation().equals(nextSpawnLocation)) {
		event.setCancelled(false);
	} else {
		// this shouldn't normally be reached..
		Log.debug("Shopkeeper entity-spawning seems to be out of sync: spawn-force was activated for an entity of type "
				+ nextEntityType.name() + " at location " + nextSpawnLocation.toString() + ", but a (different) entity of type "
				+ event.getEntityType().name() + " was spawned at location " + event.getLocation().toString() + ".");
	}
	nextSpawnLocation = null;
	nextEntityType = null;
}
 
开发者ID:nisovin,项目名称:Shopkeepers,代码行数:15,代码来源:CreatureForceSpawnListener.java

示例15: WitherSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void WitherSpawn(CreatureSpawnEvent event){
	EntityType eType;
	try{
		eType = event.getEntityType();
	}catch(Exception e){
		eType = null;
	}
	if(eType != null){
		if(event.getEntityType() == EntityType.WITHER && plugin.isBlockWitherSpawn()){
			event.setCancelled(true);
		}
	}
}
 
开发者ID:MutinyCraft,项目名称:Wither,代码行数:15,代码来源:WitherEventHandler.java


注:本文中的org.bukkit.event.entity.CreatureSpawnEvent.getEntityType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。