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


Java CreatureSpawnEvent类代码示例

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


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

示例1: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入依赖的package包/类
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
	if (ConfigOptimize.NoCrowdedEntityenable) {
		Chunk chunk = event.getEntity().getLocation().getChunk();
		Entity[] entities = chunk.getEntities();

		for (Entity e : entities) {
			EntityType type = e.getType();
			int count = 0;
			if (ConfigOptimize.NoCrowdedEntityTypeList.contains("*")
					|| ConfigOptimize.NoCrowdedEntityTypeList.contains(type.name())) {
				count++;
				if (count > ConfigOptimize.NoCrowdedEntityPerChunkLimit && e.getType() != EntityType.PLAYER) {
					e.remove();
				}
			}
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:20,代码来源:NoCrowdEntity.java

示例2: mobSpawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入依赖的package包/类
/**
 * Track where the mob was created. This will determine its allowable movement zone.
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void mobSpawn(CreatureSpawnEvent e) {
    // Only cover withers in the island world
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    if (!e.getEntityType().equals(EntityType.WITHER) && !e.getEntityType().equals(EntityType.BLAZE) && !e.getEntityType().equals(EntityType.GHAST)) {
        return;
    }
    if (DEBUG) {
        plugin.getLogger().info("Flying mobs " + e.getEventName());
    }
    // Store where this mob originated
    Island island = plugin.getIslands().getIslandAt(e.getLocation());
    if (island != null) {
        if (DEBUG) {
            plugin.getLogger().info("DEBUG: Mob spawned on known island - id = " + e.getEntity().getUniqueId());
        }
        mobSpawnInfo.put(e.getEntity(),island);
    } // Else do nothing - maybe an Op spawned it? If so, on their head be it!
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:26,代码来源:FlyingMobEvents.java

示例3: NametagEntity

import org.bukkit.event.entity.CreatureSpawnEvent; //导入依赖的package包/类
public NametagEntity(final Player player)
{
    super(((CraftWorld)player.getWorld()).getHandle());
    final Location location = player.getLocation();
    this.setInvisible(true);
    this.setPosition(location.getX(), location.getY(), location.getZ());
    try {
        final Field invulnerable = Entity.class.getDeclaredField("invulnerable");
        invulnerable.setAccessible(true);
        invulnerable.setBoolean(this, true);
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    this.world.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
    this.persistent = true;
    this.hideTag(player);
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:19,代码来源:NametagEntity.java

示例4: Graou

import org.bukkit.event.entity.CreatureSpawnEvent; //导入依赖的package包/类
Graou(Hub hub, Location catLocation, Location door, Location treasureLocations, Location openingLocations)
{
    super(hub);

    this.holograms = new HashMap<>();

    WorldServer world = ((CraftWorld) catLocation.getWorld()).getHandle();

    this.graouEntity = new EntityGraou(world);
    this.graouEntity.setPosition(catLocation.getX(), catLocation.getY(), catLocation.getZ());
    world.addEntity(this.graouEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
    catLocation.getChunk().load(true);

    hub.getServer().getScheduler().runTaskLater(hub, () -> this.graouEntity.postInit(catLocation.getYaw(), catLocation.getPitch()), 20L);

    this.catLocation = catLocation;
    this.door = door;
    this.treasureLocations = treasureLocations;
    this.openingLocations = openingLocations;
    this.animationTask = null;
    this.playerUsing = null;
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:23,代码来源:Graou.java

示例5: Meow

import org.bukkit.event.entity.CreatureSpawnEvent; //导入依赖的package包/类
Meow(Hub hub, Location location)
{
    super(hub);

    this.holograms = new HashMap<>();

    WorldServer world = ((CraftWorld) location.getWorld()).getHandle();

    this.meowEntity = new EntityMeow(world);
    this.meowEntity.setPosition(location.getX(), location.getY(), location.getZ());
    world.addEntity(this.meowEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
    location.getChunk().load(true);

    hub.getServer().getScheduler().runTaskLater(hub, () -> this.meowEntity.postInit(location.getYaw(), location.getPitch()), 20L);

    this.random = new Random();
    this.thankYouTask = null;
    this.lock = false;
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:20,代码来源:Meow.java

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

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

示例8: spawn

import org.bukkit.event.entity.CreatureSpawnEvent; //导入依赖的package包/类
@Override
public boolean spawn(EntityType type, Location location) {
    World nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
    RideAbleEntityType rideAbleEntityType = RideAbleEntityType.valueOf(type);
    if (rideAbleEntityType == null) {
        return false;
    }
    Entity entity;
    try {
        entity = (Entity) rideAbleEntityType.getCustomClass().getConstructors()[0].newInstance(nmsWorld);
    } catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
        return false;
    }

    entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw());
    return nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
}
 
开发者ID:MiniDigger,项目名称:RideThaMobv3,代码行数:18,代码来源:NMSHandler_1_9_R1.java

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

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

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

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

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

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

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


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