From 9ac674aa9ad9870c9716f3ea2f492fe60a33a95a Mon Sep 17 00:00:00 2001 From: Brianna Date: Sat, 27 Apr 2019 15:18:10 -0400 Subject: [PATCH] Initial stacksizes can no longer go above the max stack size. --- .../java/com/songoda/ultimatestacker/tasks/StackingTask.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java b/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java index a8d6df1..5f86efd 100644 --- a/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java +++ b/src/main/java/com/songoda/ultimatestacker/tasks/StackingTask.java @@ -153,10 +153,11 @@ public class StackingTask extends BukkitRunnable { || minEntityStackAmount == 1 && entityList.size() == 0) continue; //If stack was never found make a new one. - EntityStack stack = stackManager.addStack(new EntityStack(initalEntity, entityList.size() + 1)); + EntityStack stack = stackManager.addStack(new EntityStack(initalEntity, (entityList.size() + 1) > + maxEntityStackSize ? maxEntityStackSize : entityList.size() + 1)); entityList.stream().filter(entity -> !stackManager.isStacked(entity) - && !removed.contains(entity.getUniqueId())).forEach(entity -> { + && !removed.contains(entity.getUniqueId())).limit(maxEntityStackSize).forEach(entity -> { removed.add(entity.getUniqueId()); entity.remove(); });