From 729469e0308bffa0a24014f844ee06971d462d05 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 1 May 2020 10:54:19 +0100 Subject: [PATCH] Add config options for all paper events. --- .../bukkit/listener/PaperListener.java | 18 +++++++++++++----- .../core/configuration/Settings.java | 6 ++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java index 7ecd26436..671755759 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -141,6 +141,9 @@ public class PaperListener implements Listener { } @EventHandler public void onPreCreatureSpawnEvent(PreCreatureSpawnEvent event) { + if (!Settings.Paper_Components.CREATURE_SPAWN) { + return; + } Location location = BukkitUtil.getLocation(event.getSpawnLocation()); PlotArea area = location.getPlotArea(); if (!location.isPlotArea()) { @@ -245,11 +248,13 @@ public class PaperListener implements Listener { } @EventHandler public void onPreSpawnerSpawnEvent(PreSpawnerSpawnEvent event) { - Location location = BukkitUtil.getLocation(event.getSpawnerLocation()); - PlotArea area = location.getPlotArea(); - if (area != null && !area.isMobSpawnerSpawning()) { - event.setCancelled(true); - event.setShouldAbortSpawn(true); + if (Settings.Paper_Components.SPAWNER_SPAWN) { + Location location = BukkitUtil.getLocation(event.getSpawnerLocation()); + PlotArea area = location.getPlotArea(); + if (area != null && !area.isMobSpawnerSpawning()) { + event.setCancelled(true); + event.setShouldAbortSpawn(true); + } } } @@ -260,6 +265,9 @@ public class PaperListener implements Listener { * @param event Paper's PlayerLaunchProjectileEvent */ @EventHandler public void onProjectileLaunch(PlayerLaunchProjectileEvent event) { + if (!Settings.Paper_Components.PLAYER_PROJECTILE) { + return; + } Projectile entity = event.getProjectile(); if (!(entity instanceof ThrownPotion)) { return; diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index 5d7672445..3b1fe6b22 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -364,6 +364,12 @@ public class Settings extends Config { @Comment( "Cancel entity spawns when the chunk is loaded if the PlotArea's mob spawning is off") public static boolean CANCEL_CHUNK_SPAWN = true; + @Comment("Use paper's PlayerLaunchProjectileEvent to cancel projectiles") + public static boolean PLAYER_PROJECTILE = true; + @Comment("Cancel entity spawns from spawners before they happen (performance buff)") + public static boolean SPAWNER_SPAWN = true; + @Comment("Cancel entity spawns from tick spawn rates before they happen (performance buff)") + public static boolean CREATURE_SPAWN = true; }