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


Java CreatureSpawnEvent.getEntity方法代码示例

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


在下文中一共展示了CreatureSpawnEvent.getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event)
{
    LivingEntity entity = event.getEntity();
    if(!this.isMonster(entity)) return;
    
    SpawnReason reason = event.getSpawnReason();
    if(reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG)
    {
        entity.setMetadata(this.ALLOW_TARGET_TAG, new FixedMetadataValue(GPFlags.instance, new Boolean(true)));
        return;
    }
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getLocation(), null);
    if(flag == null) return;
    
    event.setCancelled(true);
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:19,代码来源:FlagDef_NoMonsterSpawns.java

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

示例3: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    LivingEntity entity = event.getEntity();
    World world = entity.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.TARGET_DISTANCE)) {
        if (worldConfig.getStringList(Config.FEATURE_TARGET_DISTANCE_MOBS).contains(entity.getType().name())) {
            try {
                //((CraftLivingEntity)entity).setfol
                BloodMoonEntityLiving bloodMoonEntity = BloodMoonEntityLiving.getBloodMoonEntity(((CraftLivingEntity) entity).getHandle());
                bloodMoonEntity.setFollowRangeMultiplier(worldConfig.getDouble(Config.FEATURE_TARGET_DISTANCE_MULTIPLIER));
            } catch (IllegalArgumentException e) {
                // This means the entity is not supported *shrug*
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:19,代码来源:TargetDistanceListener.java

示例4: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    LivingEntity entity = event.getEntity();
    World world = entity.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.MOVEMENT_SPEED)) {
        if (worldConfig.getStringList(Config.FEATURE_MOVEMENT_SPEED_MOBS).contains(entity.getType().name())) {
            try {
                BloodMoonEntityLiving bloodMoonEntity = BloodMoonEntityLiving.getBloodMoonEntity(((CraftLivingEntity) entity).getHandle());
                //EntityInsentient sam = (EntityInsentient)((CraftLivingEntity) entity).getHandle();
                //System.err.println(bloodMoonEntity.toString() + "le mob");
                double multiplier = worldConfig.getDouble((this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_MOVEMENT_SPEED_FAST_CHANCE)) ? Config.FEATURE_MOVEMENT_SPEED_FAST_MULTIPLIER : Config.FEATURE_MOVEMENT_SPEED_MULTIPLIER);
                bloodMoonEntity.setSpeedMultiplier(multiplier);
            } catch (IllegalArgumentException e) {
                // This means the entity is not supported *shrug*
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:21,代码来源:MovementSpeedListener.java

示例5: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event) {
    LivingEntity entity = event.getEntity();
    Chunk chunk = entity.getLocation().getChunk();
    if (chunk == lastChunk) {
        event.getEntity().remove();
        event.setCancelled(true);
        return;
    }
    if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) {
        return;
    }
    Entity[] entities = chunk.getEntities();
    if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
        event.getEntity().remove();
        event.setCancelled(true);
        lastChunk = chunk;
    }
    else {
        lastChunk = null;
    }
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:23,代码来源:ChunkListener.java

示例6: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
	LivingEntity e = event.getEntity();
	WorldSettings set = plugin.getWorlds().get(event.getEntity().getWorld().getName());
	if (set == null) {
		return;
	}
	if (!set.getEntities().contains(e.getType())) {
		return;
	}
	if (!set.shouldExist(e)) {
		event.setCancelled(true);
	} else if (rand.nextDouble() > set.getRatio(e.getType())) {
		event.setCancelled(true);
	} else {
		AttributeInstance maxHealth = e.getAttribute(Attribute.GENERIC_MAX_HEALTH);
		maxHealth.setBaseValue(maxHealth.getBaseValue() * set.getHealth(e.getType()));
		e.setHealth(e.getMaxHealth());
	}
}
 
开发者ID:Co0sh,项目名称:Hordes,代码行数:21,代码来源:Blocker.java

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

示例8: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event) {
    LivingEntity entity = event.getEntity();
    Chunk chunk = entity.getLocation().getChunk();
    if (chunk == this.lastChunk) {
        event.getEntity().remove();
        event.setCancelled(true);
        return;
    }
    if (!PS.get().hasPlotArea(chunk.getWorld().getName())) {
        return;
    }
    Entity[] entities = chunk.getEntities();
    if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
        event.getEntity().remove();
        event.setCancelled(true);
        this.lastChunk = chunk;
    } else {
        this.lastChunk = null;
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:22,代码来源:ChunkListener.java

示例9: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
/**
 * Monitor CreatureSpawn events.
 *
 * @param event The event to watch
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    switch (event.getSpawnReason()) {
        case SPAWNER:
        case SPAWNER_EGG:
            LivingEntity entity = event.getEntity();
            Entity passenger = entity.getPassenger();

            entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);

            if (passenger != null) {
                passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
            }
            return;

        default:
            return;
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:25,代码来源:EntityListener.java

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

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

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

示例13: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
	if(event.isCancelled())
		return;
	LivingEntity c = event.getEntity();
	if(c instanceof Zombie)
	{
		Zombie a = (Zombie) c;
		
		if(a.isBaby())
		{
			a.setBaby(false);
			//a.remove();
		}
			
	}
	
    // Some code here
}
 
开发者ID:nheir,项目名称:killBaby,代码行数:20,代码来源:KillBaby.java

示例14: onCreatureSpawnEventLowest

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onCreatureSpawnEventLowest(CreatureSpawnEvent event) {
  if (!(event.getEntity() instanceof Monster) || event.isCancelled()) {
    return;
  }
  if (!mythicDrops.getConfigSettings().getEnabledWorlds().contains(event.getEntity().getWorld()
      .getName())) {
    return;
  }
  if (mythicDrops.getConfigSettings().isGiveAllMobsNames()) {
    nameMobs(event.getEntity());
  }
  if (mythicDrops.getConfigSettings().isBlankMobSpawnEnabled()) {
    event.getEntity().getEquipment().clear();
    if (event.getEntity() instanceof Skeleton && !mythicDrops.getConfigSettings()
        .isSkeletonsSpawnWithoutBows()) {
      event.getEntity().getEquipment().setItemInMainHand(new ItemStack(Material.BOW, 1));
    }
  }
  event.getEntity()
      .setCanPickupItems(mythicDrops.getConfigSettings().isMobsPickupEquipment());
}
 
开发者ID:Nunnery,项目名称:MythicDrops,代码行数:23,代码来源:ItemSpawningListener.java

示例15: onMobSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入方法依赖的package包/类
/**
 * Prevents mobs spawning at spawn or in an island
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onMobSpawn(final CreatureSpawnEvent e) {
    if (DEBUG2) {
        plugin.getLogger().info("on Mob spawn" + e.getEventName());
    }
    // if grid is not loaded yet, return.
    if (plugin.getIslands() == null) {
        return;
    }
    // If not in the right world, return
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    // Deal with natural spawning
    if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime) {
        if (!actionAllowed(e.getLocation(), SettingsFlag.MONSTER_SPAWN)) {
            if (DEBUG2)
                plugin.getLogger().info("Natural monster spawn cancelled.");
            // Mobs not allowed to spawn
            e.setCancelled(true);
            return;
        }
    }
    if (e.getEntity() instanceof Animals) {
        if (!actionAllowed(e.getLocation(), SettingsFlag.ANIMAL_SPAWN)) {
            // Animals are not allowed to spawn
            if (DEBUG2)
                plugin.getLogger().info("Natural animal spawn cancelled.");
            e.setCancelled(true);
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:38,代码来源:IslandGuard.java


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