No longer stacking named entities.

This commit is contained in:
Brianna 2019-07-29 22:00:14 -04:00
parent b606d33c44
commit 40c95c6936

View File

@ -212,14 +212,19 @@ public class StackingTask extends BukkitRunnable {
|| minEntityStackSize > maxEntityStackSize) return;
// If a stack was never found create a new one.
EntityStack newStack = stackManager.addStack(new EntityStack(livingEntity, (stackableFriends.size() + 1) >
maxEntityStackSize ? maxEntityStackSize : stackableFriends.size() + 1));
EntityStack newStack = stackManager.addStack(new EntityStack(livingEntity,
Math.min((stackableFriends.size() + 1), maxEntityStackSize)));
// Loop through the unstacked and unprocessed stackable friends while not creating
// a stack larger than the maximum.
stackableFriends.stream().filter(entity -> !stackManager.isStacked(entity)
&& !this.processed.contains(entity.getUniqueId())).limit(maxEntityStackSize).forEach(entity -> {
// Make sure we're not naming some poor kids pet.
if (entity.getCustomName() != null) {
processed.add(livingEntity.getUniqueId());
return;
}
// Fix the entities health.
fixHealth(livingEntity, entity);
newStack.addHealth(entity.getHealth());
@ -262,7 +267,6 @@ public class StackingTask extends BukkitRunnable {
}
private void fixHealth(LivingEntity entity, LivingEntity initialEntity) {
if (!Setting.STACK_ENTITY_HEALTH.getBoolean() && Setting.CARRY_OVER_LOWEST_HEALTH.getBoolean() && initialEntity.getHealth() < entity.getHealth())
entity.setHealth(initialEntity.getHealth());