Fix renamed entities stacked back instantly

This commit is contained in:
ceze88 2024-05-29 14:14:50 +02:00
parent 02a605b3cd
commit 949f0de5d8

View File

@ -148,6 +148,10 @@ public class StackingTask extends BukkitRunnable {
if (!configurationSection.getBoolean("Mobs." + entity.getType().name() + ".Enabled")) if (!configurationSection.getBoolean("Mobs." + entity.getType().name() + ".Enabled"))
return true; return true;
//Check nametag or custom entity
if ((!stackManager.isStackedEntity(entity) && entity.getCustomName() != null) || plugin.getCustomEntityManager().getCustomEntity(entity) != null)
return true;
// Allow spawn if stack reasons are set and match, or if from a spawner // Allow spawn if stack reasons are set and match, or if from a spawner
final String spawnReason = entity.hasMetadata("US_REASON") && !entity.getMetadata("US_REASON").isEmpty() final String spawnReason = entity.hasMetadata("US_REASON") && !entity.getMetadata("US_REASON").isEmpty()
? entity.getMetadata("US_REASON").get(0).asString() : null; ? entity.getMetadata("US_REASON").get(0).asString() : null;
@ -186,12 +190,6 @@ public class StackingTask extends BukkitRunnable {
return; return;
} }
// If this entity is named or a custom entity skip it.
if (!isStack && (baseEntity.getCustomName() != null && plugin.getCustomEntityManager().getCustomEntity(baseEntity) != null)) {
processed.add(baseEntity.getUniqueId());
return;
}
// Get similar entities around our entity and make sure those entities are both compatible and stackable. // Get similar entities around our entity and make sure those entities are both compatible and stackable.
List<LivingEntity> stackableFriends = getSimilarEntitiesAroundEntity(baseEntity, location); List<LivingEntity> stackableFriends = getSimilarEntitiesAroundEntity(baseEntity, location);