File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 4444import org .bukkit .entity .Tameable ;
4545import org .bukkit .entity .Vehicle ;
4646import org .bukkit .entity .minecart .ExplosiveMinecart ;
47+ import org .bukkit .event .entity .CreatureSpawnEvent ;
4748import org .bukkit .inventory .InventoryHolder ;
4849import 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}
You can’t perform that action at this time.
0 commit comments