Entity#getEntitySpawnReason compatibility for spigot (#4305)

chore: Entity#getEntitySpawnReason compatibility for spigot
This commit is contained in:
Pierre Maurice Schwang
2024-02-02 16:46:39 +01:00
committed by GitHub
parent 966c878a72
commit 448577774a
3 changed files with 26 additions and 5 deletions

View File

@ -779,8 +779,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
Iterator<Entity> iterator = entities.iterator();
while (iterator.hasNext()) {
Entity entity = iterator.next();
final String spawnReason = entity.getEntitySpawnReason().name();
if ("CUSTOM".equals(spawnReason)) {
if (PaperLib.isPaper() && "CUSTOM".equals(entity.getEntitySpawnReason().name())) {
continue;
}
// Fallback for Spigot not having Entity#getEntitySpawnReason
if (entity.getMetadata("ps_custom_spawned").stream().anyMatch(MetadataValue::asBoolean)) {
continue;
}
switch (entity.getType().toString()) {