mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-27 12:35:17 +01:00
Added option to only stack from spawners.
This commit is contained in:
parent
7fdf7bbe3d
commit
bc46241e43
@ -8,7 +8,10 @@ import com.songoda.ultimatestacker.utils.settings.Setting;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
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 org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -57,7 +60,12 @@ public class StackingTask extends BukkitRunnable {
|
|||||||
if (initalEntity.isDead()
|
if (initalEntity.isDead()
|
||||||
|| !initalEntity.isValid()
|
|| !initalEntity.isValid()
|
||||||
|| initalEntity instanceof ArmorStand
|
|| 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);
|
EntityStack initialStack = stackManager.getStack(initalEntity);
|
||||||
if (initialStack == null && initalEntity.getCustomName() != null) continue;
|
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");
|
maxEntityStackSize = configurationSection.getInt("Mobs." + initalEntity.getType().name() + ".Max Stack Size");
|
||||||
|
|
||||||
List<LivingEntity> entityList = Methods.getSimilarEntitiesAroundEntity(initalEntity);
|
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)) {
|
for (Entity entity : new ArrayList<>(entityList)) {
|
||||||
if (removed.contains(entity.getUniqueId())) continue;
|
if (removed.contains(entity.getUniqueId())) continue;
|
||||||
|
@ -81,6 +81,12 @@ public enum Setting {
|
|||||||
KEEP_POTION("Entities.Keep Potion Effects", true,
|
KEEP_POTION("Entities.Keep Potion Effects", true,
|
||||||
"Should potion effects persist to the next entity when an entity dies?"),
|
"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,
|
STACK_ITEMS("Items.Enabled", true,
|
||||||
"Should items be stacked?"),
|
"Should items be stacked?"),
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user