下面列出了org.bukkit.event.entity.CreatureSpawnEvent#SpawnReason ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public boolean makeWaiting(Entity entity, CreatureSpawnEvent.SpawnReason reason){
if(!sm.getCustomConfig().getBoolean("wait-to-stack.enabled")){
return false;
}
if(!sm.getCustomConfig().getStringList("wait-to-stack.entity-types")
.contains(entity.getType().toString())){
return false;
}
if(!sm.getCustomConfig().getStringList("wait-to-stack.spawn-reasons")
.contains(reason.toString())){
return false;
}
int waitingTime = sm.getCustomConfig().getInt("wait-to-stack.wait-time");
StackTools.addWaiting(entity, waitingTime);
return true;
}
public EntitySpawnQuery(
@Nullable Event event, Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
super(event, entity);
this.spawnReason = checkNotNull(spawnReason);
}
@Override
public CreatureSpawnEvent.SpawnReason getSpawnReason() {
return spawnReason;
}
public PreCreatureSpawnEvent(Location location, EntityType type, CreatureSpawnEvent.SpawnReason reason) {
this.location = Preconditions.checkNotNull(location, "Location may not be null").clone();
this.type = Preconditions.checkNotNull(type, "Type may not be null");
this.reason = Preconditions.checkNotNull(reason, "Reason may not be null");
}
/**
* @return Reason this creature is spawning (ie, NATURAL vs SPAWNER)
*/
public CreatureSpawnEvent.SpawnReason getReason() {
return reason;
}
@Override
public CreatureSpawnEvent.SpawnReason getSpawnReason() {
return spawnReason;
}
public TimedBossMobEntity(EntityType entityType, Location location, int eliteMobLevel, String name, CreatureSpawnEvent.SpawnReason spawnReason) {
super(entityType, location, eliteMobLevel, name, spawnReason);
super.setHasFarAwayUnload(false);
super.getLivingEntity().setRemoveWhenFarAway(false);
BossMobDeathCountdown.startDeathCountdown(super.getLivingEntity());
}
public ActionBossMobEntity(EntityType entityType, Location location, int eliteMobLevel, String name, CreatureSpawnEvent.SpawnReason spawnReason) {
super(entityType, location, eliteMobLevel, name, spawnReason);
}
public ActionBossMobEntity(EntityType entityType, Location location, int eliteMobsLevel, String name, HashSet<ElitePower> elitePowers, CreatureSpawnEvent.SpawnReason spawnReason) {
super(entityType, location, eliteMobsLevel, name, elitePowers, spawnReason);
}
public ReinforcementMobEntity(EntityType entityType, Location location, int eliteMobLevel, String name, CreatureSpawnEvent.SpawnReason spawnReason) {
super(entityType, location, (int) Math.ceil(eliteMobLevel / 2), name, spawnReason);
super.setHasSpecialLoot(false);
}
/**
* This is the generic constructor used in most instances of natural elite mob generation
*
* @param livingEntity Minecraft entity associated to this elite mob
* @param eliteMobLevel Level of the mob, can be modified during runtime. Dynamically assigned.
*/
public EliteMobEntity(LivingEntity livingEntity, int eliteMobLevel, CreatureSpawnEvent.SpawnReason spawnReason) {
/*
Register living entity to keep track of which entity this object is tied to
*/
this.eliteMob = livingEntity;
/*
Register level, this is variable as per stacking rules
*/
setEliteMobLevel(eliteMobLevel);
eliteMobTier = MobTierFinder.findMobTier(eliteMobLevel);
/*
Sets the spawn reason
*/
setSpawnReason(spawnReason);
/*
Start tracking the entity
*/
if (!EntityTracker.registerEliteMob(this)) return;
/*
Get correct instance of plugin data, necessary for settings names and health among other things
*/
EliteMobProperties eliteMobProperties = EliteMobProperties.getPluginData(livingEntity);
/*
Handle name, variable as per stacking rules
*/
setCustomName(eliteMobProperties);
/*
Handle health, max is variable as per stacking rules
Currently #setHealth() resets the health back to maximum
*/
setMaxHealth(eliteMobProperties);
setHealth();
/*
Set the armor
*/
setArmor();
/*
Register whether or not the elite mob is natural
*/
this.isNaturalEntity = EntityTracker.isNaturalEntity(livingEntity);
/*
Set the power list
*/
randomizePowers(eliteMobProperties);
eliteMob.setCanPickupItems(false);
}
public CreatureSpawnEvent.SpawnReason getReason() {
return reason;
}
/**
* Spawning method for boss mobs.
* Assumes custom powers and custom names.
*
* @param entityType type of mob that this entity is slated to become
* @param location location at which the elite mob will spawn
* @param eliteMobLevel boss mob level, should be automatically generated based on the highest player tier online
* @param name the name for this boss mob, overrides the usual elite mob name format
* @see BossMobEntity
*/
public EliteMobEntity(EntityType entityType, Location location, int eliteMobLevel, String name, CreatureSpawnEvent.SpawnReason spawnReason) {
/*
Register living entity to keep track of which entity this object is tied to
*/
this.eliteMob = spawnBossMobLivingEntity(entityType, location);
/*
Register level, this is variable as per stacking rules
*/
setEliteMobLevel(eliteMobLevel);
eliteMobTier = MobTierFinder.findMobTier(eliteMobLevel);
/*
Sets the spawn reason
*/
setSpawnReason(spawnReason);
/*
Start tracking the entity
*/
if (!EntityTracker.registerEliteMob(this)) return;
/*
Get correct instance of plugin data, necessary for settings names and health among other things
*/
EliteMobProperties eliteMobProperties = EliteMobProperties.getPluginData(entityType);
/*
Handle name, variable as per stacking rules
*/
setCustomName(name);
/*
Handle health, max is variable as per stacking rules
Currently #setHealth() resets the health back to maximum
*/
setMaxHealth(eliteMobProperties);
setHealth();
/*
Register whether or not the elite mob is natural
*/
this.isNaturalEntity = EntityTracker.isNaturalEntity(this.eliteMob);
/*
These have custom powers
*/
this.hasCustomPowers = true;
/*
Start tracking the entity
*/
// EntityTracker.registerEliteMob(this);
eliteMob.setCanPickupItems(false);
this.setHasStacking(false);
this.setHasCustomArmor(true);
}
/**
* This manages Elite Mob that are spawned naturally. It takes a mob that spawns normally in the world, randomizes
* its chance to become an Elite Mob, scans the area around it for players, finds what combat tier those players,
* finds if there are additional players, increases the tier of the Elite Mob accordingly and adds sets it as a new
* Elite Mob
*
* @param entity Entity to check for Elite Mob conversion
* @param spawnReason Reason for the mob spawning
*/
public static void naturalMobProcessor(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
int eliteMobLevel = getNaturalMobLevel(entity.getLocation());
if (eliteMobLevel < 0) return;
EliteMobEntity eliteMobEntity = new EliteMobEntity((LivingEntity) entity, eliteMobLevel, spawnReason);
if (spawnReason.equals(CreatureSpawnEvent.SpawnReason.SPAWNER))
eliteMobEntity.setHasSpecialLoot(false);
}
/**
* Gets the spawn reason for the LivingEntity. Used for the API.
*
* @return Spawn reason for the LivingEntity.
*/
public CreatureSpawnEvent.SpawnReason getSpawnReason() {
return this.spawnReason;
}
/**
* Cancelling this event will prevent the Elite Mob from being constructed.
*
* @param entity Entity associated to the Elite Mob
* @param eliteMobEntity EliteMobEntity being formed
* @param spawnReason Reason for the Entity's spawn
*/
public EliteMobSpawnEvent(Entity entity, EliteMobEntity eliteMobEntity, CreatureSpawnEvent.SpawnReason spawnReason) {
this.entity = entity;
this.eliteMobEntity = eliteMobEntity;
this.spawnReason = spawnReason;
}
/**
* Sets the spawn reason for the Living Entity. Used for the API.
*
* @param spawnReason Spawn reason for the Living Entity.
*/
public void setSpawnReason(CreatureSpawnEvent.SpawnReason spawnReason) {
this.spawnReason = spawnReason;
}
CreatureSpawnEvent.SpawnReason getSpawnReason();
CreatureSpawnEvent.SpawnReason getSpawnReason();
boolean makeWaiting(Entity entity, CreatureSpawnEvent.SpawnReason reason);