Merge branch 'development'

This commit is contained in:
Brianna 2019-12-03 20:00:43 -05:00
commit 2ef1436618
7 changed files with 122 additions and 94 deletions

View File

@ -1,21 +0,0 @@
stages:
- build
variables:
name: "UltimateStacker"
path: "/builds/$CI_PROJECT_PATH"
version: "1.10.22"
build:
stage: build
image: maven:3.5.3-jdk-8
script:
- find $path/ -type f -name "*.xml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
- find $path/ -type f -name "*.yml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
- mvn clean package
- find $path/ -depth -path '*original*' -delete
- mv -v $path/target/*.jar $path
artifacts:
name: $name-$version
paths:
- "$path/*.jar"

27
pom.xml
View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>UltimateStacker</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>maven-version-number</version>
<version>1.10.23</version>
<build>
<defaultGoal>clean install</defaultGoal>
<finalName>UltimateStacker-${project.version}</finalName>
@ -16,6 +16,28 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${project.build.directory}/classes/plugin.yml</file>
<replacements>
<replacement>
<token>maven-version-number</token>
<value>${project.version}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
@ -35,6 +57,9 @@
<includes>
<include>com.songoda:SongodaCore</include>
<include>com.songoda:Lootables</include>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
</includes>
</artifactSet>
<filters>

View File

@ -342,8 +342,6 @@ public class UltimateStacker extends SongodaPlugin {
public void updateHologram(SpawnerStack stack) {
// are holograms enabled?
if(!Settings.SPAWNER_HOLOGRAMS.getBoolean() || !HologramManager.getManager().isEnabled()) return;
// verify that this is a spawner stack
if (stack.getLocation().getBlock().getType() != CompatibleMaterial.SPAWNER.getMaterial()) return;
// grab the spawner block
CreatureSpawner creatureSpawner = (CreatureSpawner) stack.getLocation().getBlock().getState();
String name = Methods.compileSpawnerName(creatureSpawner.getSpawnedType(), stack.getAmount());

View File

@ -13,6 +13,7 @@ public enum Check {
ANIMAL_OWNER(true),
SKELETON_TYPE(true),
ZOMBIE_BABY(true),
HAS_EQUIPMENT(true),
SLIME_SIZE(true),
PIG_SADDLE(true),
SHEEP_SHEARED(true),

View File

@ -146,6 +146,9 @@ public class EntityStack {
newEntity.getEquipment().setItemInHand(CompatibleMaterial.GOLDEN_SWORD.getItem());
if (Settings.CARRY_OVER_METADATA_ON_DEATH.getBoolean()) {
if (killed.hasMetadata("US_REASON"))
newEntity.setMetadata("US_REASON", killed.getMetadata("US_REASON").get(0));
if (killed.hasMetadata("ES"))
newEntity.setMetadata("ES", killed.getMetadata("ES").get(0));
@ -197,7 +200,9 @@ public class EntityStack {
if (entity == null) return;
synchronized (healthLock) {
entity.setHealth(Settings.STACK_ENTITY_HEALTH.getBoolean()
&& !this.health.isEmpty() ? this.health.removeFirst() : entity.getMaxHealth());
&& !health.isEmpty()
? (health.getFirst() > entity.getMaxHealth() ? entity.getMaxHealth() : health.removeFirst())
: entity.getMaxHealth());
}
}

View File

@ -133,7 +133,7 @@ public class Settings {
"This list is ignored if Only Stack From Spawners = true.",
"The following reasons can be added to the list:",
"\"NATURAL\", \"JOCKEY\", \"CHUNK_GEN\", \"SPAWNER\",",
"\"EGG\", \"SPAWNER_EGG\", \"LIGHTNING\", \"BUILD_SNOWMAN\",",
"\"EGG\", \"SPAWNER_EGG\", \"LIGHTNING\", \"BUILD_SNOWMAN\", \"HAS_EQUIPMENT\",",
"\"BUILD_IRONGOLEM\", \"BUILD_WITHER\", \"VILLAGE_DEFENSE\", \"VILLAGE_INVASION\",",
"\"BREEDING\", \"SLIME_SPLIT\", \"REINFORCEMENTS\", \"NETHER_PORTAL\",",
"\"DISPENSE_EGG\", \"INFECTION\", \"CURED\", \"OCELOT_BABY\",",

View File

@ -5,9 +5,7 @@ import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.entity.Check;
import com.songoda.ultimatestacker.entity.EntityStack;
import com.songoda.ultimatestacker.settings.Settings;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.entity.*;
import java.util.*;
@ -241,27 +239,27 @@ public class EntityUtils {
return newEntity;
}
public List<LivingEntity> getSimilarEntitiesAroundEntity(LivingEntity initalEntity, Location location) {
public List<LivingEntity> getSimilarEntitiesAroundEntity(LivingEntity initialEntity, Location location) {
// Create a list of all entities around the initial entity of the same type.
List<LivingEntity> entityList = getNearbyEntities(location, searchRadius, stackWholeChunk)
.stream().filter(entity -> entity.getType() == initalEntity.getType() && entity != initalEntity)
.stream().filter(entity -> entity.getType() == initialEntity.getType() && entity != initialEntity)
.collect(Collectors.toCollection(LinkedList::new));
if (stackFlyingDown && Methods.canFly(initalEntity))
entityList.removeIf(entity -> entity.getLocation().getY() > initalEntity.getLocation().getY());
if (stackFlyingDown && Methods.canFly(initialEntity))
entityList.removeIf(entity -> entity.getLocation().getY() > initialEntity.getLocation().getY());
for (String checkStr : checks) {
Check check = Check.getCheck(checkStr);
if (check == null) continue;
switch (check) {
case SPAWN_REASON: {
if (initalEntity.hasMetadata("US_REASON"))
if (initialEntity.hasMetadata("US_REASON"))
entityList.removeIf(entity -> entity.hasMetadata("US_REASON") && !entity.getMetadata("US_REASON").get(0).asString().equals("US_REASON"));
}
case AGE: {
if (!(initalEntity instanceof Ageable)) break;
if (!(initialEntity instanceof Ageable)) break;
if (((Ageable) initalEntity).isAdult()) {
if (((Ageable) initialEntity).isAdult()) {
entityList.removeIf(entity -> !((Ageable) entity).isAdult());
} else {
entityList.removeIf(entity -> ((Ageable) entity).isAdult());
@ -270,45 +268,45 @@ public class EntityUtils {
}
case NERFED: {
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) break;
entityList.removeIf(entity -> entity.hasAI() != initalEntity.hasAI());
entityList.removeIf(entity -> entity.hasAI() != initialEntity.hasAI());
}
case IS_TAMED: {
if (!(initalEntity instanceof Tameable)) break;
if (((Tameable) initalEntity).isTamed()) {
if (!(initialEntity instanceof Tameable)) break;
if (((Tameable) initialEntity).isTamed()) {
entityList.removeIf(entity -> !((Tameable) entity).isTamed());
} else {
entityList.removeIf(entity -> ((Tameable) entity).isTamed());
}
}
case ANIMAL_OWNER: {
if (!(initalEntity instanceof Tameable)) break;
if (!(initialEntity instanceof Tameable)) break;
Tameable tameable = ((Tameable) initalEntity);
Tameable tameable = ((Tameable) initialEntity);
entityList.removeIf(entity -> ((Tameable) entity).getOwner() != tameable.getOwner());
}
case PIG_SADDLE: {
if (!(initalEntity instanceof Pig)) break;
if (!(initialEntity instanceof Pig)) break;
entityList.removeIf(entity -> ((Pig) entity).hasSaddle());
break;
}
case SKELETON_TYPE: {
if (!(initalEntity instanceof Skeleton)) break;
if (!(initialEntity instanceof Skeleton)) break;
Skeleton skeleton = (Skeleton) initalEntity;
Skeleton skeleton = (Skeleton) initialEntity;
entityList.removeIf(entity -> ((Skeleton) entity).getSkeletonType() != skeleton.getSkeletonType());
break;
}
case SHEEP_COLOR: {
if (!(initalEntity instanceof Sheep)) break;
if (!(initialEntity instanceof Sheep)) break;
Sheep sheep = ((Sheep) initalEntity);
Sheep sheep = ((Sheep) initialEntity);
entityList.removeIf(entity -> ((Sheep) entity).getColor() != sheep.getColor());
break;
}
case SHEEP_SHEARED: {
if (!(initalEntity instanceof Sheep)) break;
if (!(initialEntity instanceof Sheep)) break;
Sheep sheep = ((Sheep) initalEntity);
Sheep sheep = ((Sheep) initialEntity);
if (sheep.isSheared()) {
entityList.removeIf(entity -> !((Sheep) entity).isSheared());
} else {
@ -318,9 +316,9 @@ public class EntityUtils {
}
case SNOWMAN_DERPED: {
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)
|| !(initalEntity instanceof Snowman)) break;
|| !(initialEntity instanceof Snowman)) break;
Snowman snowman = ((Snowman) initalEntity);
Snowman snowman = ((Snowman) initialEntity);
if (snowman.isDerp()) {
entityList.removeIf(entity -> !((Snowman) entity).isDerp());
} else {
@ -330,162 +328,184 @@ public class EntityUtils {
}
case LLAMA_COLOR: {
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)
|| !(initalEntity instanceof Llama)) break;
Llama llama = ((Llama) initalEntity);
|| !(initialEntity instanceof Llama)) break;
Llama llama = ((Llama) initialEntity);
entityList.removeIf(entity -> ((Llama) entity).getColor() != llama.getColor());
break;
}
case LLAMA_STRENGTH: {
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)
|| !(initalEntity instanceof Llama)) break;
Llama llama = ((Llama) initalEntity);
|| !(initialEntity instanceof Llama)) break;
Llama llama = ((Llama) initialEntity);
entityList.removeIf(entity -> ((Llama) entity).getStrength() != llama.getStrength());
break;
}
case VILLAGER_PROFESSION: {
if (!(initalEntity instanceof Villager)) break;
Villager villager = ((Villager) initalEntity);
if (!(initialEntity instanceof Villager)) break;
Villager villager = ((Villager) initialEntity);
entityList.removeIf(entity -> ((Villager) entity).getProfession() != villager.getProfession());
break;
}
case SLIME_SIZE: {
if (!(initalEntity instanceof Slime)) break;
Slime slime = ((Slime) initalEntity);
if (!(initialEntity instanceof Slime)) break;
Slime slime = ((Slime) initialEntity);
entityList.removeIf(entity -> ((Slime) entity).getSize() != slime.getSize());
break;
}
case HORSE_CARRYING_CHEST: {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (!(initalEntity instanceof ChestedHorse)) break;
if (!(initialEntity instanceof ChestedHorse)) break;
entityList.removeIf(entity -> ((ChestedHorse) entity).isCarryingChest());
} else {
if (!(initalEntity instanceof Horse)) break;
if (!(initialEntity instanceof Horse)) break;
entityList.removeIf(entity -> ((Horse) entity).isCarryingChest());
}
break;
}
case HORSE_HAS_ARMOR: {
if (!(initalEntity instanceof Horse)) break;
if (!(initialEntity instanceof Horse)) break;
entityList.removeIf(entity -> ((Horse) entity).getInventory().getArmor() != null);
break;
}
case HORSE_HAS_SADDLE: {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
&& initalEntity instanceof AbstractHorse) {
&& initialEntity instanceof AbstractHorse) {
entityList.removeIf(entity -> ((AbstractHorse) entity).getInventory().getSaddle() != null);
break;
}
if (!(initalEntity instanceof Horse)) break;
if (!(initialEntity instanceof Horse)) break;
entityList.removeIf(entity -> ((Horse) entity).getInventory().getSaddle() != null);
break;
}
case HORSE_JUMP: {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (!(initalEntity instanceof AbstractHorse)) break;
AbstractHorse horse = ((AbstractHorse) initalEntity);
if (!(initialEntity instanceof AbstractHorse)) break;
AbstractHorse horse = ((AbstractHorse) initialEntity);
entityList.removeIf(entity -> ((AbstractHorse) entity).getJumpStrength() != horse.getJumpStrength());
} else {
if (!(initalEntity instanceof Horse)) break;
Horse horse = ((Horse) initalEntity);
if (!(initialEntity instanceof Horse)) break;
Horse horse = ((Horse) initialEntity);
entityList.removeIf(entity -> ((Horse) entity).getJumpStrength() != horse.getJumpStrength());
}
break;
}
case HORSE_COLOR: {
if (!(initalEntity instanceof Horse)) break;
Horse horse = ((Horse) initalEntity);
if (!(initialEntity instanceof Horse)) break;
Horse horse = ((Horse) initialEntity);
entityList.removeIf(entity -> ((Horse) entity).getColor() != horse.getColor());
break;
}
case HORSE_STYLE: {
if (!(initalEntity instanceof Horse)) break;
Horse horse = ((Horse) initalEntity);
if (!(initialEntity instanceof Horse)) break;
Horse horse = ((Horse) initialEntity);
entityList.removeIf(entity -> ((Horse) entity).getStyle() != horse.getStyle());
break;
}
case ZOMBIE_BABY: {
if (!(initalEntity instanceof Zombie)) break;
Zombie zombie = (Zombie) initalEntity;
if (!(initialEntity instanceof Zombie)) break;
Zombie zombie = (Zombie) initialEntity;
entityList.removeIf(entity -> ((Zombie) entity).isBaby() != zombie.isBaby());
break;
}
case WOLF_COLLAR_COLOR: {
if (!(initalEntity instanceof Wolf)) break;
Wolf wolf = (Wolf) initalEntity;
if (!(initialEntity instanceof Wolf)) break;
Wolf wolf = (Wolf) initialEntity;
entityList.removeIf(entity -> ((Wolf) entity).getCollarColor() != wolf.getCollarColor());
break;
}
case OCELOT_TYPE: {
if (!(initalEntity instanceof Ocelot)) break;
Ocelot ocelot = (Ocelot) initalEntity;
if (!(initialEntity instanceof Ocelot)) break;
Ocelot ocelot = (Ocelot) initialEntity;
entityList.removeIf(entity -> ((Ocelot) entity).getCatType() != ocelot.getCatType());
}
case CAT_TYPE: {
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)
|| !(initalEntity instanceof Cat)) break;
Cat cat = (Cat) initalEntity;
|| !(initialEntity instanceof Cat)) break;
Cat cat = (Cat) initialEntity;
entityList.removeIf(entity -> ((Cat) entity).getCatType() != cat.getCatType());
break;
}
case HAS_EQUIPMENT: {
if (initialEntity.getEquipment() == null) break;
boolean imEquipped = isEquipped(initialEntity);
if (imEquipped)
entityList = new ArrayList<>();
else
entityList.removeIf(this::isEquipped);
break;
}
case RABBIT_TYPE: {
if (!(initalEntity instanceof Rabbit)) break;
Rabbit rabbit = (Rabbit) initalEntity;
if (!(initialEntity instanceof Rabbit)) break;
Rabbit rabbit = (Rabbit) initialEntity;
entityList.removeIf(entity -> ((Rabbit) entity).getRabbitType() != rabbit.getRabbitType());
break;
}
case PARROT_TYPE: {
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)
|| !(initalEntity instanceof Parrot)) break;
Parrot parrot = (Parrot) initalEntity;
|| !(initialEntity instanceof Parrot)) break;
Parrot parrot = (Parrot) initialEntity;
entityList.removeIf(entity -> ((Parrot) entity).getVariant() != parrot.getVariant());
break;
}
case PUFFERFISH_STATE: {
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|| !(initalEntity instanceof PufferFish)) break;
PufferFish pufferFish = (PufferFish) initalEntity;
|| !(initialEntity instanceof PufferFish)) break;
PufferFish pufferFish = (PufferFish) initialEntity;
entityList.removeIf(entity -> ((PufferFish) entity).getPuffState() != pufferFish.getPuffState());
break;
}
case TROPICALFISH_PATTERN: {
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|| !(initalEntity instanceof TropicalFish)) break;
TropicalFish tropicalFish = (TropicalFish) initalEntity;
|| !(initialEntity instanceof TropicalFish)) break;
TropicalFish tropicalFish = (TropicalFish) initialEntity;
entityList.removeIf(entity -> ((TropicalFish) entity).getPattern() != tropicalFish.getPattern());
break;
}
case TROPICALFISH_PATTERN_COLOR: {
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|| !(initalEntity instanceof TropicalFish)) break;
TropicalFish tropicalFish = (TropicalFish) initalEntity;
|| !(initialEntity instanceof TropicalFish)) break;
TropicalFish tropicalFish = (TropicalFish) initialEntity;
entityList.removeIf(entity -> ((TropicalFish) entity).getPatternColor() != tropicalFish.getPatternColor());
break;
}
case TROPICALFISH_BODY_COLOR: {
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|| !(initalEntity instanceof TropicalFish)) break;
TropicalFish tropicalFish = (TropicalFish) initalEntity;
|| !(initialEntity instanceof TropicalFish)) break;
TropicalFish tropicalFish = (TropicalFish) initialEntity;
entityList.removeIf(entity -> ((TropicalFish) entity).getBodyColor() != tropicalFish.getBodyColor());
break;
}
case PHANTOM_SIZE: {
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|| !(initalEntity instanceof Phantom)) break;
Phantom phantom = (Phantom) initalEntity;
|| !(initialEntity instanceof Phantom)) break;
Phantom phantom = (Phantom) initialEntity;
entityList.removeIf(entity -> ((Phantom) entity).getSize() != phantom.getSize());
break;
}
}
}
if (initalEntity.hasMetadata("breedCooldown")) {
if (initialEntity.hasMetadata("breedCooldown")) {
entityList.removeIf(entity -> !entity.hasMetadata("breedCooldown"));
}
return entityList;
}
public boolean isEquipped(LivingEntity initialEntity) {
return initialEntity.getEquipment() != null
&& (initialEntity.getEquipment().getItemInHand().getType() != Material.AIR
|| (initialEntity.getEquipment().getHelmet() != null
&& initialEntity.getEquipment().getHelmet().getType() != Material.AIR)
|| (initialEntity.getEquipment().getChestplate() != null
&& initialEntity.getEquipment().getChestplate().getType() != Material.AIR)
|| (initialEntity.getEquipment().getLeggings() != null
&& initialEntity.getEquipment().getLeggings().getType() != Material.AIR)
|| (initialEntity.getEquipment().getBoots() != null
&& initialEntity.getEquipment().getBoots().getType() != Material.AIR));
}
public void splitFromStack(LivingEntity entity) {
UltimateStacker instance = plugin;
EntityStack stack = instance.getEntityStackManager().getStack(entity);