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


Java CreatureSpawnEvent.getSpawnReason方法代碼示例

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


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

示例1: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SLIME_SPLIT) { // allow slimes to always split
        return;
    }

    switch (event.getSpawnReason()) {
    case NATURAL:
        if (event.getLocation().getChunk().getEntities().length > MAX_NATURAL_CHUNK_ENTITIES) {
            event.setCancelled(true);
        }
        break;
    case CHUNK_GEN:
        if (event.getLocation().getChunk().getEntities().length > MAX_CHUNK_GENERATED_ENTITIES) {
            event.setCancelled(true);
        }
        break;
    default:
        break;
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:22,代碼來源:EntityLimitListener.java

示例2: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onSpawn(@Nonnull CreatureSpawnEvent event) {
    if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM ||
            event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG) {
        return;
    }
    if (!denySpawn) {
        return;
    }
    if (!event.getLocation().getWorld().getName().equals(worldName)) {
        return;
    }

    if (blacklist.length != 0) {
        if (Arrays.stream(blacklist).anyMatch(m -> m.equals(event.getEntityType()))) {
            event.setCancelled(true);
        }
    } else if (whitelist.length != 0) {
        if (Arrays.stream(whitelist).noneMatch(m -> m.equals(event.getEntityType()))) {
            event.setCancelled(true);
        }
    } else {
        event.setCancelled(true);
    }
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:26,代碼來源:MobFeature.java

示例3: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySpawnerEggs") == true) {
  if (event.getSpawnReason() == SpawnReason.SPAWNER_EGG) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySpawners") == true) {
  if (event.getSpawnReason() == SpawnReason.SPAWNER) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySummonCommand") == true) {
  if (event.getSpawnReason() == SpawnReason.DEFAULT) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
  if (event.getSpawnReason() == SpawnReason.CUSTOM) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
}
 
開發者ID:AnonymousDr,項目名稱:ADR,代碼行數:22,代碼來源:mobs.java

示例4: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SPAWNER) {
        if (DefaultConfig.isAntiFarmingSpawner()) {
            spawnedEntities.add(event.getEntity().getUniqueId());

            return;
        }
    }

    if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG) {
        if (DefaultConfig.isAntiFarmingSpawnerEgg()) {
            spawnedEntities.add(event.getEntity().getUniqueId());

            return;
        }
    }
}
 
開發者ID:diecode,項目名稱:KillerMoney,代碼行數:19,代碼來源:AntiFarmingHandler.java

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

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

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

示例8: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event)
{
	//these rules apply only to creative worlds
	if(!GriefPrevention.instance.creativeRulesApply(event.getLocation())) return;
	
	//chicken eggs and breeding could potentially make a mess in the wilderness, once griefers get involved
	SpawnReason reason = event.getSpawnReason();
	if(reason != SpawnReason.SPAWNER_EGG && reason != SpawnReason.BUILD_IRONGOLEM && reason != SpawnReason.BUILD_SNOWMAN)
	{
		event.setCancelled(true);
		return;
	}

	//otherwise, just apply the limit on total entities per claim (and no spawning in the wilderness!)
	Claim claim = this.dataStore.getClaimAt(event.getLocation(), false, null);
	if(claim == null || claim.allowMoreEntities() != null)
	{
		event.setCancelled(true);
		return;
	}
}
 
開發者ID:john01dav,項目名稱:GriefPreventionPlus,代碼行數:23,代碼來源:EntityEventHandler.java

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

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

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

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

示例13: onMobSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onMobSpawn(CreatureSpawnEvent evt) {
    switch (evt.getSpawnReason()) {
        case NATURAL:
        case JOCKEY:
        case CHUNK_GEN:
        case SPAWNER:
        case BUILD_WITHER:
        case VILLAGE_DEFENSE:
        case VILLAGE_INVASION:
        case REINFORCEMENTS:
        case NETHER_PORTAL:
            if (Statics.ARENA_WORLD_NAME.equals(evt.getLocation().getWorld().getName())) {
                evt.setCancelled(true);
            }
            break;
        default:
            break;
    }
}
 
開發者ID:SkyWars,項目名稱:SkyWars,代碼行數:21,代碼來源:MobSpawnDisable.java

示例14: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() != SpawnReason.CUSTOM) {
        event.getEntity().setHealth(0);
        event.getEntity().remove();
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:8,代碼來源:EnvironmentManager.java

示例15: onSlimeSplit

import org.bukkit.event.entity.CreatureSpawnEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSlimeSplit(CreatureSpawnEvent event) {
    switch(event.getSpawnReason()) {
        case SLIME_SPLIT:
            Slime parent = splitter.get();
            if(parent != null) {
                MobInfo info = resolveEntity(parent);
                if(info != null) {
                    entities().trackEntity(event.getEntity(), info);
                }
            }
            break;
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:15,代碼來源:OwnedMobTracker.java


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