Added option to only stack from spawners.

This commit is contained in:
Brianna 2019-06-15 05:05:53 -04:00
parent 7fdf7bbe3d
commit bc46241e43
2 changed files with 22 additions and 3 deletions

View File

@ -8,7 +8,10 @@ import com.songoda.ultimatestacker.utils.settings.Setting;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.*;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
@ -57,7 +60,12 @@ public class StackingTask extends BukkitRunnable {
if (initalEntity.isDead()
|| !initalEntity.isValid()
|| initalEntity instanceof ArmorStand
|| initalEntity.hasMetadata("inLove")) continue;
|| initalEntity.hasMetadata("inLove")
|| Setting.ONLY_STACK_FROM_SPAWNERS.getBoolean()
&& !(initalEntity.hasMetadata("US_REASON")
&& initalEntity.getMetadata("US_REASON").get(0).asString().equals("SPAWNER")))
continue;
EntityStack initialStack = stackManager.getStack(initalEntity);
if (initialStack == null && initalEntity.getCustomName() != null) continue;
@ -73,7 +81,12 @@ public class StackingTask extends BukkitRunnable {
maxEntityStackSize = configurationSection.getInt("Mobs." + initalEntity.getType().name() + ".Max Stack Size");
List<LivingEntity> entityList = Methods.getSimilarEntitiesAroundEntity(initalEntity);
entityList.removeIf(entity -> entity.hasMetadata("inLove") || entity.hasMetadata("breedCooldown"));
entityList.removeIf(entity -> entity.hasMetadata("inLove")
|| entity.hasMetadata("breedCooldown")
|| Setting.ONLY_STACK_FROM_SPAWNERS.getBoolean()
&& !(initalEntity.hasMetadata("US_REASON")
&& initalEntity.getMetadata("US_REASON").get(0).asString().equals("SPAWNER")));
for (Entity entity : new ArrayList<>(entityList)) {
if (removed.contains(entity.getUniqueId())) continue;

View File

@ -81,6 +81,12 @@ public enum Setting {
KEEP_POTION("Entities.Keep Potion Effects", true,
"Should potion effects persist to the next entity when an entity dies?"),
ONLY_STACK_FROM_SPAWNERS("Entities.Only Stack From Spawners", false,
"Should entities only be stacked if they originate from a spawner?",
"It should be noted that the identifier that tells the plugin",
"if the entity originated from a spawner or not is wiped on",
"server restart."),
STACK_ITEMS("Items.Enabled", true,
"Should items be stacked?"),