From daee26681af2b15e28b8286fc66d0fbd34c77158 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sat, 2 May 2020 12:13:00 +0100 Subject: [PATCH] use strings for spawn reasons to be safe --- .../bukkit/listener/PaperListener.java | 48 +++++++++---------- .../bukkit/listener/PlayerEvents.java | 48 +++++++++---------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java index 671755759..0af250b01 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -157,53 +157,53 @@ public class PaperListener implements Listener { return; } CreatureSpawnEvent.SpawnReason reason = event.getReason(); - switch (reason) { - case DISPENSE_EGG: - case EGG: - case OCELOT_BABY: - case SPAWNER_EGG: + switch (reason.toString()) { + case "DISPENSE_EGG": + case "EGG": + case "OCELOT_BABY": + case "SPAWNER_EGG": if (!area.isSpawnEggs()) { event.setShouldAbortSpawn(true); event.setCancelled(true); return; } break; - case REINFORCEMENTS: - case NATURAL: - case MOUNT: - case PATROL: - case RAID: - case SHEARED: - case SHOULDER_ENTITY: - case SILVERFISH_BLOCK: - case TRAP: - case VILLAGE_DEFENSE: - case VILLAGE_INVASION: - case BEEHIVE: - case CHUNK_GEN: + case "REINFORCEMENTS": + case "NATURAL": + case "MOUNT": + case "PATROL": + case "RAID": + case "SHEARED": + case "SHOULDER_ENTITY": + case "SILVERFISH_BLOCK": + case "TRAP": + case "VILLAGE_DEFENSE": + case "VILLAGE_INVASION": + case "BEEHIVE": + case "CHUNK_GEN": if (!area.isMobSpawning()) { event.setShouldAbortSpawn(true); event.setCancelled(true); return; } - case BREEDING: + case "BREEDING": if (!area.isSpawnBreeding()) { event.setShouldAbortSpawn(true); event.setCancelled(true); return; } break; - case BUILD_IRONGOLEM: - case BUILD_SNOWMAN: - case BUILD_WITHER: - case CUSTOM: + case "BUILD_IRONGOLEM": + case "BUILD_SNOWMAN": + case "BUILD_WITHER": + case "CUSTOM": if (!area.isSpawnCustom() && event.getType() != EntityType.ARMOR_STAND) { event.setShouldAbortSpawn(true); event.setCancelled(true); return; } break; - case SPAWNER: + case "SPAWNER": if (!area.isMobSpawnerSpawning()) { event.setShouldAbortSpawn(true); event.setCancelled(true); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index d191e1c00..d1c292009 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -2024,49 +2024,49 @@ public class PlayerEvents extends PlotListener implements Listener { return; } CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason(); - switch (reason) { - case DISPENSE_EGG: - case EGG: - case OCELOT_BABY: - case SPAWNER_EGG: + switch (reason.toString()) { + case "DISPENSE_EGG": + case "EGG": + case "OCELOT_BABY": + case "SPAWNER_EGG": if (!area.isSpawnEggs()) { event.setCancelled(true); return; } break; - case REINFORCEMENTS: - case NATURAL: - case MOUNT: - case PATROL: - case RAID: - case SHEARED: - case SHOULDER_ENTITY: - case SILVERFISH_BLOCK: - case TRAP: - case VILLAGE_DEFENSE: - case VILLAGE_INVASION: - case BEEHIVE: - case CHUNK_GEN: + case "REINFORCEMENTS": + case "NATURAL": + case "MOUNT": + case "PATROL": + case "RAID": + case "SHEARED": + case "SHOULDER_ENTITY": + case "SILVERFISH_BLOCK": + case "TRAP": + case "VILLAGE_DEFENSE": + case "VILLAGE_INVASION": + case "BEEHIVE": + case "CHUNK_GEN": if (!area.isMobSpawning()) { event.setCancelled(true); return; } - case BREEDING: + case "BREEDING": if (!area.isSpawnBreeding()) { event.setCancelled(true); return; } break; - case BUILD_IRONGOLEM: - case BUILD_SNOWMAN: - case BUILD_WITHER: - case CUSTOM: + case "BUILD_IRONGOLEM": + case "BUILD_SNOWMAN": + case "BUILD_WITHER": + case "CUSTOM": if (!area.isSpawnCustom() && entity.getType() != EntityType.ARMOR_STAND) { event.setCancelled(true); return; } break; - case SPAWNER: + case "SPAWNER": if (!area.isMobSpawnerSpawning()) { event.setCancelled(true); return;