mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-09-28 22:57:29 +02:00
Consider the summon command as plugin spawning
This commit is contained in:
parent
44d0735412
commit
4a26e306b6
@ -603,7 +603,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
|||||||
WorldConfiguration wcfg = getWorldConfig(event.getEntity().getWorld());
|
WorldConfiguration wcfg = getWorldConfig(event.getEntity().getWorld());
|
||||||
|
|
||||||
// allow spawning of creatures from plugins
|
// allow spawning of creatures from plugins
|
||||||
if (!wcfg.blockPluginSpawning && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
|
if (!wcfg.blockPluginSpawning && Entities.isPluginSpawning(event.getSpawnReason())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.entity.Vehicle;
|
import org.bukkit.entity.Vehicle;
|
||||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
@ -230,4 +231,18 @@ public static boolean isPotionArrow(Entity entity) {
|
|||||||
public static boolean isAoECloud(EntityType type) {
|
public static boolean isAoECloud(EntityType type) {
|
||||||
return type == EntityType.AREA_EFFECT_CLOUD;
|
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
Block a user