當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。