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


Java SpawnReason.CUSTOM属性代码示例

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


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

示例1: onSpawn

@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,代码行数:21,代码来源:mobs.java

示例2: onEnderDragonSpawn

/**
 * - 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,代码行数:29,代码来源:EnderDragonListener.java

示例3: onCreatureSpawn

@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() != SpawnReason.CUSTOM) {
        event.getEntity().setHealth(0);
        event.getEntity().remove();
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:7,代码来源:EnvironmentManager.java

示例4: onEntitySpawn

@EventHandler
public void onEntitySpawn(CreatureSpawnEvent event) {
	if (event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.EGG)
		return;
	
	event.setCancelled(true);
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:7,代码来源:Events.java

示例5: onMonsterSpawn

@EventHandler(priority = EventPriority.NORMAL)
public void onMonsterSpawn(CreatureSpawnEvent event) {
	
	if (event.getSpawnReason() != SpawnReason.CUSTOM && _activated && event.getEntity() instanceof Monster) {
		
		double modifier = calculateGlobalModifier(event.getLocation());

		if (modifier > 0.0) {
			
			// boost le health
			Damageable entityDamage = event.getEntity();
			double maxHealth = entityDamage.getMaxHealth() + (int)(modifier * entityDamage.getMaxHealth());
			try {
				EntityReflection.setEntityPropertyValue(event.getEntity(), EntityReflection.HEALTH, maxHealth);
				ScenarioService.getInstance().updateDamageModifier(event.getEntity(), modifier);
			}
			catch (Exception ex) {
				_logger.info("exception on Frontier!");
			}
			
			// ajuste les rare drops, rien en diamant dans le premier palier
			if (LocationUtil.getDistanceBetween(event.getLocation(), event.getLocation().getWorld().getSpawnLocation()) <= _divider) {
				RareDropsMultiplierData.getInstance().addEntityRareDropsMultiplier(event.getEntity().getEntityId(), new RareDropsMultipliers(0.25, 0.25, 0.00));
			}
			else {
				RareDropsMultiplierData.getInstance().addEntityRareDropsMultiplier(event.getEntity().getEntityId(), new RareDropsMultipliers(modifier, modifier, modifier));
			}
		}
	}
}
 
开发者ID:Allov,项目名称:world-of-icerealm,代码行数:30,代码来源:Frontier.java

示例6: onMobSpawn

@EventHandler
public void onMobSpawn(CreatureSpawnEvent e){
	if(e.getSpawnReason() == SpawnReason.CUSTOM)
		return;
	
	e.setCancelled(true);
}
 
开发者ID:devBuzzy,项目名称:Dexoria-Hub,代码行数:7,代码来源:Protection.java

示例7: onEntitySpawn

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event) {
    if (!enabled || event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.DEFAULT) return;
    
    MagicWorld magicWorld = controller.getWorld(event.getLocation().getWorld().getName());
    if (magicWorld == null) return;
    
    LivingEntity entity = event.getEntity();
    Plugin plugin = controller.getPlugin();
    LivingEntity replace =  magicWorld.processEntitySpawn(plugin, entity);
    if (replace != null && replace != entity) {
    	entity.setHealth(0);
        event.setCancelled(true);
	}
}
 
开发者ID:elBukkit,项目名称:MagicWorlds,代码行数:15,代码来源:EntitySpawnListener.java

示例8: EntitySnapshot

public EntitySnapshot(World pWorld,Entity pEntity,SpawnReason pReason){
    this.mWorld=pWorld;
    this.mEntity=pEntity;
    this.mReason=pReason==null?SpawnReason.CUSTOM:pReason;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:5,代码来源:EntitySnapshot.java

示例9: onEntitySpawn

@EventHandler
public void onEntitySpawn(CreatureSpawnEvent event) {
	event.setCancelled(false);
	if (event.getSpawnReason() != SpawnReason.EGG && event.getSpawnReason() != SpawnReason.CUSTOM)
		event.setCancelled(true);
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:6,代码来源:GeneralEvents.java

示例10: onCreatureSpawn

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent e) {
	if (!cm.spawnLimitEnabled) {
		return;
	}
	// 如果开启了TPS阀值,当TPS大于阀值,就不限制
	if (cm.spawnLimitTpsThreshold > 0 && cm.spawnLimitTpsThreshold <= 20 &&
		NeverLag.getTpsWatcher().getAverageTPS() >= cm.spawnLimitTpsThreshold) {
		return;
	}
	// 实体有自定义名字的不限制,兼容MM怪物等插件
	LivingEntity creature = e.getEntity();
	if (creature.getCustomName() != null) {
		return;
	}
	// 不限制插件、刷怪蛋、刷怪笼刷出的实体和凋零、铁傀儡、雪人
	if (creature.getType() != EntityType.IRON_GOLEM && creature.getType() != EntityType.SNOWMAN && creature.getType() != EntityType.WITHER
		&& e.getSpawnReason() != SpawnReason.SPAWNER_EGG && e.getSpawnReason() != SpawnReason.SPAWNER
		&& e.getSpawnReason() != SpawnReason.CUSTOM) {
		if (creature instanceof Animals) {
			if (this.getMobCount() >= cm.spawnLimitAnimalThreshold) {
				e.setCancelled(true);
			}
		} else if (creature instanceof Monster) {
			if (this.getMobCount() >= cm.spawnLimitMonsterThreshold) {
				e.setCancelled(true);
			}
		}
	}
	// 刷怪笼不按照总数量限制,而是按照区块内实体数量
	if (SpawnReason.SPAWNER == e.getSpawnReason()) {
		int count = 0;
		for (Entity entity : e.getLocation().getChunk().getEntities()) {
			if (creature instanceof Monster && entity instanceof Monster) {
				count++;
			} else if (creature instanceof Animals && entity instanceof Animals) {
				count++;
			} else if (entity instanceof Monster) {
				count++;
			}
			if (count > cm.maxSpawnEntityPerChunk) {
				e.setCancelled(true);
				break;
			}
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:47,代码来源:MobLimtier.java

示例11: addEntity

public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
    if (entity == null) return false;
    // CraftBukkit end

    int i = MathHelper.floor(entity.locX / 16.0D);
    int j = MathHelper.floor(entity.locZ / 16.0D);
    boolean flag = entity.attachedToPlayer;

    if (entity instanceof EntityHuman) {
        flag = true;
    }

    // CraftBukkit start
    org.bukkit.event.Cancellable event = null;
    if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
        boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
        boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;

        if (spawnReason != SpawnReason.CUSTOM) {
            if (isAnimal && !allowAnimals || isMonster && !allowMonsters)  {
                entity.dead = true;
                return false;
            }
        }

        event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
    } else if (entity instanceof EntityItem) {
        event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
    } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
        // Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
        event = CraftEventFactory.callProjectileLaunchEvent(entity);
    }

    if (event != null && (event.isCancelled() || entity.dead)) {
        entity.dead = true;
        return false;
    }
    // CraftBukkit end

    if (!flag && !this.isChunkLoaded(i, j)) {
        entity.dead = true; // CraftBukkit
        return false;
    } else {
        if (entity instanceof EntityHuman) {
            EntityHuman entityhuman = (EntityHuman) entity;

            this.players.add(entityhuman);
            this.everyoneSleeping();
            this.b(entity);
        }

        this.getChunkAt(i, j).a(entity);
        this.entityList.add(entity);
        this.a(entity);
        return true;
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:57,代码来源:World.java

示例12: addEntity

public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
    if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous entity add!"); // Spigot
    if (entity == null) return false;
    // CraftBukkit end

    int i = MathHelper.floor(entity.locX / 16.0D);
    int j = MathHelper.floor(entity.locZ / 16.0D);
    boolean flag = entity.p;

    if (entity instanceof EntityHuman) {
        flag = true;
    }

    // CraftBukkit start
    org.bukkit.event.Cancellable event = null;
    if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
        boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
        boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;

        if (spawnReason != SpawnReason.CUSTOM) {
            if (isAnimal && !allowAnimals || isMonster && !allowMonsters)  {
                entity.dead = true;
                return false;
            }
        }

        event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
    } else if (entity instanceof EntityItem) {
        event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
    } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
        // Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
        event = CraftEventFactory.callProjectileLaunchEvent(entity);
    }
    // Spigot start
    else if (entity instanceof EntityExperienceOrb) {
        EntityExperienceOrb xp = (EntityExperienceOrb) entity;
        double radius = spigotConfig.expMerge;
        if (radius > 0) {
            List<Entity> entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius));
            for (Entity e : entities) {
                if (e instanceof EntityExperienceOrb) {
                    EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
                    if (!loopItem.dead) {
                        xp.value += loopItem.value;
                        loopItem.die();
                    }
                }
            }
        }
    } // Spigot end

    if (event != null && (event.isCancelled() || entity.dead)) {
        entity.dead = true;
        return false;
    }
    // CraftBukkit end

    if (!flag && !this.isChunkLoaded(i, j)) {
        entity.dead = true; // CraftBukkit
        return false;
    } else {
        if (entity instanceof EntityHuman) {
            EntityHuman entityhuman = (EntityHuman) entity;

            this.players.add(entityhuman);
            this.everyoneSleeping();
        }

        this.getChunkAt(i, j).a(entity);
        this.entityList.add(entity);
        this.a(entity);
        return true;
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:74,代码来源:World.java

示例13: addEntity

public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
    org.spigotmc.AsyncCatcher.catchOp( "entity add"); // Spigot
    if (entity == null) return false;
    // CraftBukkit end

    int i = MathHelper.floor(entity.locX / 16.0D);
    int j = MathHelper.floor(entity.locZ / 16.0D);
    boolean flag = entity.attachedToPlayer;

    if (entity instanceof EntityHuman) {
        flag = true;
    }

    // CraftBukkit start
    org.bukkit.event.Cancellable event = null;
    if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
        boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
        boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;

        if (spawnReason != SpawnReason.CUSTOM) {
            if (isAnimal && !allowAnimals || isMonster && !allowMonsters)  {
                entity.dead = true;
                return false;
            }
        }

        event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
    } else if (entity instanceof EntityItem) {
        event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
    } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
        // Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
        event = CraftEventFactory.callProjectileLaunchEvent(entity);
    }
    // Spigot start
    else if (entity instanceof EntityExperienceOrb) {
        EntityExperienceOrb xp = (EntityExperienceOrb) entity;
        double radius = spigotConfig.expMerge;
        if (radius > 0) {
            List<Entity> entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius));
            for (Entity e : entities) {
                if (e instanceof EntityExperienceOrb) {
                    EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
                    if (!loopItem.dead) {
                        xp.value += loopItem.value;
                        loopItem.die();
                    }
                }
            }
        }
    } // Spigot end

    if (event != null && (event.isCancelled() || entity.dead)) {
        entity.dead = true;
        return false;
    }
    // CraftBukkit end

    if (!flag && !this.isChunkLoaded(i, j)) {
        entity.dead = true; // CraftBukkit
        return false;
    } else {
        if (entity instanceof EntityHuman) {
            EntityHuman entityhuman = (EntityHuman) entity;

            this.players.add(entityhuman);
            this.everyoneSleeping();
            this.b(entity);
        }

        this.getChunkAt(i, j).a(entity);
        this.entityList.add(entity);
        this.a(entity);
        return true;
    }
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:75,代码来源:World.java

示例14: onEntitySpawn

@EventHandler
	public void onEntitySpawn(CreatureSpawnEvent event) {
		if (event.isCancelled())
			return;
		
		// Don't mess with other Plugins or Spawn Eggs
		// REMEMBER: Our own Mod throws CUSTOM spawn events when we cancel the old spawn 
		//           and schedule a new one in this handler
		if ((SpawnReason.CUSTOM == event.getSpawnReason()) ||
			(SpawnReason.DISPENSE_EGG == event.getSpawnReason()))
			return;
		
		if (SpawnReason.BREEDING == event.getSpawnReason()) {
			event.getEntity().setMetadata("domesticated", new FixedMetadataValue(p, "true"));
			// BetterPassives used to assign a CustomName here on passives
			// TODO: Do over-crowding checks
		}
		
		// If a hostile tried to spawn, change it to a locally acceptable hostile
		if (event.getEntity() instanceof Monster) {
			// If this is not one of the Monsters(Hostile) that is allowed here, change it to one that is
		}
		
		if (PlanetSettings.getInstance().isAllowed(event)) {
			PlanetSettings.getInstance().applyPlanetChanges(event.getEntity());
		} else {
			event.setCancelled(true);
		}
		
//		} else if (event.getSpawnReason() != SpawnReason.CUSTOM) {
//			if (!event.isCancelled()) {
//				List<EntityType> types = p.getAcceptableHostileTypes(event.getEntity().getWorld());
//				if (types == null) {
//					event.setCancelled(true);
//					return;
//				}
//				if (types.size() == 0) {
//					event.setCancelled(true);
//					return;
//				}
//				if (types.contains(event.getEntity().getType()) && !event.getEntity().getWorld().getName().equalsIgnoreCase("Ceharram")){
//					hostileQueue.add(event.getEntity());
//					if(hostileQueue.size() > MAX_HOSTILES){
//						hostileQueue.remove().remove();
//					}
//					return;
//				}
//					
//
//				Collections.shuffle(types);
//				EntityType type = types.get(0);
//				Entity e = event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), type);
//				String n = e.getWorld().getName().toLowerCase();
//				if (e.getType() == EntityType.SKELETON && n.equals("inaris")) {
//					Skeleton s = (Skeleton) e;
//					s.setSkeletonType(SkeletonType.WITHER);
//				} else if (e.getType() == EntityType.CREEPER && n.equals("acualis")) {
//					Creeper c = (Creeper) e;
//					c.setPowered(true);
//					permaVanish(c);
//				} else if (e.getType() == EntityType.SKELETON && n.equals("krystallos")) {
//					createRobot((Skeleton) e);
//				} else if (e.getType() == EntityType.ZOMBIE && n.equals("emera")) {
//					createSpiritBlock((Zombie) e);
//				}
//				event.setCancelled(true);
//				hostileQueue.add(e);
//				if(hostileQueue.size() > MAX_HOSTILES){
//					hostileQueue.remove().remove();
//				}
//			}
//		}
	}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:73,代码来源:EntityListener.java

示例15: addEntity

public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
    org.spigotmc.AsyncCatcher.catchOp( "entity add"); // Spigot
    if (entity == null) return false;
    // CraftBukkit end
    int i = MathHelper.floor(entity.locX / 16.0D);
    int j = MathHelper.floor(entity.locZ / 16.0D);
    boolean flag = entity.attachedToPlayer;

    if (entity instanceof EntityHuman) {
        flag = true;
    }

    // CraftBukkit start
    org.bukkit.event.Cancellable event = null;
    if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
        boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
        boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;

        if (spawnReason != SpawnReason.CUSTOM) {
            if (isAnimal && !allowAnimals || isMonster && !allowMonsters) {
                entity.dead = true;
                return false;
            }
        }

        event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
    } else if (entity instanceof EntityItem) {
        event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
    } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
        // Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
        event = CraftEventFactory.callProjectileLaunchEvent(entity);
    }
    // Spigot start
    else if (entity instanceof EntityExperienceOrb) {
        EntityExperienceOrb xp = (EntityExperienceOrb) entity;
        double radius = spigotConfig.expMerge;
        if (radius > 0) {
            List<Entity> entities = this.getEntities(entity, entity.getBoundingBox().grow(radius, radius, radius));
            for (Entity e : entities) {
                if (e instanceof EntityExperienceOrb) {
                    EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
                    if (!loopItem.dead) {
                        xp.value += loopItem.value;
                        loopItem.die();
                    }
                }
            }
        }
    } // Spigot end

    if (event != null && (event.isCancelled() || entity.dead)) {
        entity.dead = true;
        return false;
    }
    // CraftBukkit end


    if (!flag && !this.isChunkLoaded(i, j, false)) {
        return false;
    } else {
        if (entity instanceof EntityHuman) {
            EntityHuman entityhuman = (EntityHuman) entity;

            this.players.add(entityhuman);
            this.everyoneSleeping();
        }

        this.getChunkAt(i, j).a(entity);
        this.entityList.add(entity);
        this.b(entity);
        return true;
    }
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:73,代码来源:World.java


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