From 68388c0288231fcb36e1ddeec8f79e04eccd9864 Mon Sep 17 00:00:00 2001 From: Ineusia Date: Thu, 19 Sep 2024 21:46:57 -0400 Subject: [PATCH] Fix slime spawner exploit --- .../gmail/nossr50/listeners/EntityListener.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 72ee68df5..961d6ee60 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -45,6 +45,8 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.projectiles.ProjectileSource; +import java.util.Arrays; + import static com.gmail.nossr50.util.MobMetadataUtils.*; public class EntityListener implements Listener { @@ -72,6 +74,11 @@ public class EntityListener implements Listener { } } } + + // Clear the original slime/magma cubes metadata - it's dead. + if (Arrays.asList(EntityType.SLIME, EntityType.MAGMA_CUBE).contains(livingEntity.getType())) { + mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(livingEntity); + } } } @@ -652,7 +659,14 @@ public class EntityListener implements Listener { */ @EventHandler(priority = EventPriority.LOWEST) public void onEntityDeathLowest(EntityDeathEvent event) { - mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(event.getEntity()); + LivingEntity entity = event.getEntity(); + + // Clear metadata for Slimes/Magma Cubes after transformation events take place, otherwise small spawned slimes will not have any tags + if (Arrays.asList(EntityType.SLIME, EntityType.MAGMA_CUBE).contains(entity.getType())) { + return; + } + + mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(entity); } /**