Java Code Examples for org.bukkit.event.entity.CreatureSpawnEvent#SpawnReason

The following examples show how to use org.bukkit.event.entity.CreatureSpawnEvent#SpawnReason . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StackLogic.java    From StackMob-3 with GNU General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example 2
Source File: EntitySpawnQuery.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
public EntitySpawnQuery(
    @Nullable Event event, Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
  super(event, entity);
  this.spawnReason = checkNotNull(spawnReason);
}
 
Example 3
Source File: EliteMobEntity.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
/**
     * 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);

    }
 
Example 4
Source File: SpawnFilterParser.java    From CardinalPGM with MIT License 4 votes vote down vote up
public CreatureSpawnEvent.SpawnReason getReason() {
    return reason;
}
 
Example 5
Source File: EliteMobEntity.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);

}
 
Example 6
Source File: ReinforcementMobEntity.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
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);
}
 
Example 7
Source File: ActionBossMobEntity.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
public ActionBossMobEntity(EntityType entityType, Location location, int eliteMobsLevel, String name, HashSet<ElitePower> elitePowers, CreatureSpawnEvent.SpawnReason spawnReason) {
    super(entityType, location, eliteMobsLevel, name, elitePowers, spawnReason);
}
 
Example 8
Source File: ActionBossMobEntity.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
public ActionBossMobEntity(EntityType entityType, Location location, int eliteMobLevel, String name, CreatureSpawnEvent.SpawnReason spawnReason) {
    super(entityType, location, eliteMobLevel, name, spawnReason);
}
 
Example 9
Source File: TimedBossMobEntity.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
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());
}
 
Example 10
Source File: EntitySpawnQuery.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public CreatureSpawnEvent.SpawnReason getSpawnReason() {
    return spawnReason;
}
 
Example 11
Source File: PreCreatureSpawnEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @return Reason this creature is spawning (ie, NATURAL vs SPAWNER)
 */
public CreatureSpawnEvent.SpawnReason getReason() {
    return reason;
}
 
Example 12
Source File: PreCreatureSpawnEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
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");
}
 
Example 13
Source File: EntitySpawnQuery.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public CreatureSpawnEvent.SpawnReason getSpawnReason() {
  return spawnReason;
}
 
Example 14
Source File: NaturalEliteMobSpawnEventHandler.java    From EliteMobs with GNU General Public License v3.0 3 votes vote down vote up
/**
 * 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);

}
 
Example 15
Source File: EliteMobSpawnEvent.java    From EliteMobs with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 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;
}
 
Example 16
Source File: EliteMobEntity.java    From EliteMobs with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the spawn reason for the LivingEntity. Used for the API.
 *
 * @return Spawn reason for the LivingEntity.
 */
public CreatureSpawnEvent.SpawnReason getSpawnReason() {
    return this.spawnReason;
}
 
Example 17
Source File: EliteMobEntity.java    From EliteMobs with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 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;
}
 
Example 18
Source File: IStackLogic.java    From StackMob-3 with GNU General Public License v3.0 votes vote down vote up
boolean makeWaiting(Entity entity, CreatureSpawnEvent.SpawnReason reason); 
Example 19
Source File: IEntitySpawnQuery.java    From ProjectAres with GNU Affero General Public License v3.0 votes vote down vote up
CreatureSpawnEvent.SpawnReason getSpawnReason(); 
Example 20
Source File: EntitySpawnQuery.java    From PGM with GNU Affero General Public License v3.0 votes vote down vote up
CreatureSpawnEvent.SpawnReason getSpawnReason();