Skip to content

Commit

Permalink
Consider the summon command as plugin spawning
Browse files Browse the repository at this point in the history
  • Loading branch information
Joo200 committed May 31, 2023
1 parent 44d0735 commit 4a26e30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Expand Up @@ -603,7 +603,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
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;
}

Expand Down
Expand Up @@ -44,6 +44,7 @@
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;

Expand Down Expand Up @@ -230,4 +231,18 @@ public static boolean isPotionArrow(Entity entity) {
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;
};
}
}

0 comments on commit 4a26e30

Please sign in to comment.