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;
}
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);

View File

@ -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;