This commit is contained in:
Brianna O'Keefe 2019-03-07 16:00:57 -05:00
parent 791b790247
commit 1dc3ffa34c
2 changed files with 11 additions and 9 deletions

View File

@ -116,17 +116,18 @@ public class StackingTask extends BukkitRunnable {
if (configurationSection.getInt("Mobs." + initalEntity.getType().name() + ".Max Stack Size") != -1)
maxEntityStackSize = configurationSection.getInt("Mobs." + initalEntity.getType().name() + ".Max Stack Size");
List<Entity> entityList = Methods.getSimilarEntitesAroundEntity(initalEntity).stream().filter(entity ->
!entity.hasMetadata("no-stack")
&& entity.getCustomName() == null
&& stackManager.getStack(entity) != null
&& removed.contains(entity.getUniqueId())).collect(Collectors.toList());
List<Entity> entityList = Methods.getSimilarEntitesAroundEntity(initalEntity);
for (Entity entity : entityList) {
for (Entity entity : new ArrayList<>(entityList)) {
if (removed.contains(entity.getUniqueId())) continue;
EntityStack stack = stackManager.getStack(entity);
if (stack == null && entity.getCustomName() != null) {
entityList.remove(entity);
continue;
}
//If a stack was found add 1 to this stack.
if ((stack.getAmount() + amtToStack) <= maxEntityStackSize) {
if (stack != null && (stack.getAmount() + amtToStack) <= maxEntityStackSize) {
stack.addAmount(amtToStack);
stack.updateStack();
removed.add(initalEntity.getUniqueId());
@ -134,6 +135,7 @@ public class StackingTask extends BukkitRunnable {
continue nextEntity;
}
}
if (initialStack != null) continue;

View File

@ -41,7 +41,6 @@ public class Methods {
UltimateStacker instance = UltimateStacker.getInstance();
EntityStackManager stackManager = instance.getEntityStackManager();
Entity newEntity = newEntity(killed);
killed.setMetadata("no-stack", new FixedMetadataValue(instance, true));
((LivingEntity) newEntity).getEquipment().clear();
@ -71,7 +70,8 @@ public class Methods {
if (!stackManager.isStacked(killed)) return;
killed.setCustomName(null);
killed.setCustomNameVisible(false);
killed.setCustomNameVisible(true);
killed.setCustomName(formatText("&7"));
EntityStack stack = stackManager.getStack(killed);