use strings for spawn reasons to be safe

This commit is contained in:
dordsor21 2020-05-02 12:13:00 +01:00
parent 729469e030
commit daee26681a
2 changed files with 48 additions and 48 deletions

View File

@ -157,53 +157,53 @@ public class PaperListener implements Listener {
return; return;
} }
CreatureSpawnEvent.SpawnReason reason = event.getReason(); CreatureSpawnEvent.SpawnReason reason = event.getReason();
switch (reason) { switch (reason.toString()) {
case DISPENSE_EGG: case "DISPENSE_EGG":
case EGG: case "EGG":
case OCELOT_BABY: case "OCELOT_BABY":
case SPAWNER_EGG: case "SPAWNER_EGG":
if (!area.isSpawnEggs()) { if (!area.isSpawnEggs()) {
event.setShouldAbortSpawn(true); event.setShouldAbortSpawn(true);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
break; break;
case REINFORCEMENTS: case "REINFORCEMENTS":
case NATURAL: case "NATURAL":
case MOUNT: case "MOUNT":
case PATROL: case "PATROL":
case RAID: case "RAID":
case SHEARED: case "SHEARED":
case SHOULDER_ENTITY: case "SHOULDER_ENTITY":
case SILVERFISH_BLOCK: case "SILVERFISH_BLOCK":
case TRAP: case "TRAP":
case VILLAGE_DEFENSE: case "VILLAGE_DEFENSE":
case VILLAGE_INVASION: case "VILLAGE_INVASION":
case BEEHIVE: case "BEEHIVE":
case CHUNK_GEN: case "CHUNK_GEN":
if (!area.isMobSpawning()) { if (!area.isMobSpawning()) {
event.setShouldAbortSpawn(true); event.setShouldAbortSpawn(true);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
case BREEDING: case "BREEDING":
if (!area.isSpawnBreeding()) { if (!area.isSpawnBreeding()) {
event.setShouldAbortSpawn(true); event.setShouldAbortSpawn(true);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
break; break;
case BUILD_IRONGOLEM: case "BUILD_IRONGOLEM":
case BUILD_SNOWMAN: case "BUILD_SNOWMAN":
case BUILD_WITHER: case "BUILD_WITHER":
case CUSTOM: case "CUSTOM":
if (!area.isSpawnCustom() && event.getType() != EntityType.ARMOR_STAND) { if (!area.isSpawnCustom() && event.getType() != EntityType.ARMOR_STAND) {
event.setShouldAbortSpawn(true); event.setShouldAbortSpawn(true);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
break; break;
case SPAWNER: case "SPAWNER":
if (!area.isMobSpawnerSpawning()) { if (!area.isMobSpawnerSpawning()) {
event.setShouldAbortSpawn(true); event.setShouldAbortSpawn(true);
event.setCancelled(true); event.setCancelled(true);

View File

@ -2024,49 +2024,49 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason(); CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason();
switch (reason) { switch (reason.toString()) {
case DISPENSE_EGG: case "DISPENSE_EGG":
case EGG: case "EGG":
case OCELOT_BABY: case "OCELOT_BABY":
case SPAWNER_EGG: case "SPAWNER_EGG":
if (!area.isSpawnEggs()) { if (!area.isSpawnEggs()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
break; break;
case REINFORCEMENTS: case "REINFORCEMENTS":
case NATURAL: case "NATURAL":
case MOUNT: case "MOUNT":
case PATROL: case "PATROL":
case RAID: case "RAID":
case SHEARED: case "SHEARED":
case SHOULDER_ENTITY: case "SHOULDER_ENTITY":
case SILVERFISH_BLOCK: case "SILVERFISH_BLOCK":
case TRAP: case "TRAP":
case VILLAGE_DEFENSE: case "VILLAGE_DEFENSE":
case VILLAGE_INVASION: case "VILLAGE_INVASION":
case BEEHIVE: case "BEEHIVE":
case CHUNK_GEN: case "CHUNK_GEN":
if (!area.isMobSpawning()) { if (!area.isMobSpawning()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
case BREEDING: case "BREEDING":
if (!area.isSpawnBreeding()) { if (!area.isSpawnBreeding()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
break; break;
case BUILD_IRONGOLEM: case "BUILD_IRONGOLEM":
case BUILD_SNOWMAN: case "BUILD_SNOWMAN":
case BUILD_WITHER: case "BUILD_WITHER":
case CUSTOM: case "CUSTOM":
if (!area.isSpawnCustom() && entity.getType() != EntityType.ARMOR_STAND) { if (!area.isSpawnCustom() && entity.getType() != EntityType.ARMOR_STAND) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
break; break;
case SPAWNER: case "SPAWNER":
if (!area.isMobSpawnerSpawning()) { if (!area.isMobSpawnerSpawning()) {
event.setCancelled(true); event.setCancelled(true);
return; return;