Consider the summon command as plugin spawning
This commit is contained in:
parent
44d0735412
commit
4a26e306b6
|
@ -603,7 +603,7 @@ public class WorldGuardEntityListener extends AbstractListener {
|
|||
WorldConfiguration wcfg = getWorldConfig(event.getEntity().getWorld());
|
||||
|
||||
// allow spawning of creatures from plugins
|
||||
if (!wcfg.blockPluginSpawning && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
|
||||
if (!wcfg.blockPluginSpawning && Entities.isPluginSpawning(event.getSpawnReason())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.bukkit.entity.TNTPrimed;
|
|||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
|
@ -230,4 +231,18 @@ public final class Entities {
|
|||
public static boolean isAoECloud(EntityType type) {
|
||||
return type == EntityType.AREA_EFFECT_CLOUD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the spawn reason should be considered as a "plugin spawning".
|
||||
* This is true for custom creations or the summon command.
|
||||
*
|
||||
* @param spawnReason the reason
|
||||
* @return true if considerd plugin spawning
|
||||
*/
|
||||
public static boolean isPluginSpawning(CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
return switch (spawnReason) {
|
||||
case CUSTOM, COMMAND -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue