Skip to content

Commit cdb44d4

Browse files
authored
fix: re-add default spawn option and disclude armour stands (#4240)
- Fixes #4238
1 parent eb63e43 commit cdb44d4

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ public void creatureSpawnEvent(CreatureSpawnEvent event) {
143143
if (area == null) {
144144
return;
145145
}
146+
// Armour-stands are handled elsewhere and should not be handled by area-wide entity-spawn options
147+
if (entity.getType() == EntityType.ARMOR_STAND) {
148+
return;
149+
}
146150
CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason();
147151
switch (reason.toString()) {
148152
case "DISPENSE_EGG", "EGG", "OCELOT_BABY", "SPAWNER_EGG" -> {
@@ -153,7 +157,7 @@ public void creatureSpawnEvent(CreatureSpawnEvent event) {
153157
}
154158
case "REINFORCEMENTS", "NATURAL", "MOUNT", "PATROL", "RAID", "SHEARED", "SILVERFISH_BLOCK", "ENDER_PEARL",
155159
"TRAP", "VILLAGE_DEFENSE", "VILLAGE_INVASION", "BEEHIVE", "CHUNK_GEN", "NETHER_PORTAL",
156-
"DUPLICATION", "FROZEN", "SPELL" -> {
160+
"DUPLICATION", "FROZEN", "SPELL", "DEFAULT" -> {
157161
if (!area.isMobSpawning()) {
158162
event.setCancelled(true);
159163
return;
@@ -166,7 +170,7 @@ public void creatureSpawnEvent(CreatureSpawnEvent event) {
166170
}
167171
}
168172
case "BUILD_IRONGOLEM", "BUILD_SNOWMAN", "BUILD_WITHER", "CUSTOM" -> {
169-
if (!area.isSpawnCustom() && entity.getType() != EntityType.ARMOR_STAND) {
173+
if (!area.isSpawnCustom()) {
170174
event.setCancelled(true);
171175
return;
172176
}

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void onEntityPathfind(SlimePathfindEvent event) {
124124
}
125125
Slime slime = event.getEntity();
126126

127-
Block b = slime.getTargetBlock(4);
127+
Block b = slime.getTargetBlockExact(4);
128128
if (b == null) {
129129
return;
130130
}
@@ -166,12 +166,16 @@ public void onPreCreatureSpawnEvent(PreCreatureSpawnEvent event) {
166166
}
167167
Location location = BukkitUtil.adapt(event.getSpawnLocation());
168168
PlotArea area = location.getPlotArea();
169-
if (!location.isPlotArea()) {
169+
if (area == null) {
170+
return;
171+
}
172+
// Armour-stands are handled elsewhere and should not be handled by area-wide entity-spawn options
173+
if (event.getType() == EntityType.ARMOR_STAND) {
170174
return;
171175
}
172-
//If entities are spawning... the chunk should be loaded?
176+
// If entities are spawning... the chunk should be loaded?
173177
Entity[] entities = event.getSpawnLocation().getChunk().getEntities();
174-
if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
178+
if (entities.length >= Settings.Chunk_Processor.MAX_ENTITIES) {
175179
event.setShouldAbortSpawn(true);
176180
event.setCancelled(true);
177181
return;
@@ -200,7 +204,7 @@ public void onPreCreatureSpawnEvent(PreCreatureSpawnEvent event) {
200204
}
201205
}
202206
case "BUILD_IRONGOLEM", "BUILD_SNOWMAN", "BUILD_WITHER", "CUSTOM" -> {
203-
if (!area.isSpawnCustom() && event.getType() != EntityType.ARMOR_STAND) {
207+
if (!area.isSpawnCustom()) {
204208
event.setShouldAbortSpawn(true);
205209
event.setCancelled(true);
206210
return;

0 commit comments

Comments
 (0)