Skip to content

Commit 4a26e30

Browse files
committed
Consider the summon command as plugin spawning
1 parent 44d0735 commit 4a26e30

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardEntityListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
603603
WorldConfiguration wcfg = getWorldConfig(event.getEntity().getWorld());
604604

605605
// allow spawning of creatures from plugins
606-
if (!wcfg.blockPluginSpawning && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
606+
if (!wcfg.blockPluginSpawning && Entities.isPluginSpawning(event.getSpawnReason())) {
607607
return;
608608
}
609609

worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Entities.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.bukkit.entity.Tameable;
4545
import org.bukkit.entity.Vehicle;
4646
import org.bukkit.entity.minecart.ExplosiveMinecart;
47+
import org.bukkit.event.entity.CreatureSpawnEvent;
4748
import org.bukkit.inventory.InventoryHolder;
4849
import org.bukkit.projectiles.ProjectileSource;
4950

@@ -230,4 +231,18 @@ public static boolean isPotionArrow(Entity entity) {
230231
public static boolean isAoECloud(EntityType type) {
231232
return type == EntityType.AREA_EFFECT_CLOUD;
232233
}
234+
235+
/**
236+
* Check whether the spawn reason should be considered as a "plugin spawning".
237+
* This is true for custom creations or the summon command.
238+
*
239+
* @param spawnReason the reason
240+
* @return true if considerd plugin spawning
241+
*/
242+
public static boolean isPluginSpawning(CreatureSpawnEvent.SpawnReason spawnReason) {
243+
return switch (spawnReason) {
244+
case CUSTOM, COMMAND -> true;
245+
default -> false;
246+
};
247+
}
233248
}

0 commit comments

Comments
 (0)