Fix slime spawner exploit

This commit is contained in:
Ineusia 2024-09-19 21:46:57 -04:00
parent 8c2848a3e7
commit 68388c0288

View File

@ -45,6 +45,8 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import java.util.Arrays;
import static com.gmail.nossr50.util.MobMetadataUtils.*; import static com.gmail.nossr50.util.MobMetadataUtils.*;
public class EntityListener implements Listener { 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) @EventHandler(priority = EventPriority.LOWEST)
public void onEntityDeathLowest(EntityDeathEvent event) { 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);
} }
/** /**