From aff00829062a5efd522e7b8c0c1b561f5f6ff9f3 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Mon, 1 Nov 2021 18:44:10 +0100 Subject: [PATCH] Adds a config option to disable leashed creatures from teleporting with a player --- .../stargate/config/StargateGateConfig.java | 12 +++++++++++- .../net/knarcraft/stargate/portal/Teleporter.java | 5 +++++ src/main/resources/config.yml | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/knarcraft/stargate/config/StargateGateConfig.java b/src/main/java/net/knarcraft/stargate/config/StargateGateConfig.java index 917f91b..f8da09e 100644 --- a/src/main/java/net/knarcraft/stargate/config/StargateGateConfig.java +++ b/src/main/java/net/knarcraft/stargate/config/StargateGateConfig.java @@ -13,6 +13,7 @@ public final class StargateGateConfig { private int maxGatesEachNetwork = 0; private boolean rememberDestination = false; private boolean handleVehicles = true; + private boolean handleLeashedCreatures = true; private boolean sortNetworkDestinations = false; private boolean protectEntrance = false; private boolean enableBungee = true; @@ -76,6 +77,15 @@ public final class StargateGateConfig { return handleVehicles; } + /** + * Gets whether leashed creatures should be teleported with a teleporting player + * + * @return

Whether leashed creatures should be handled

+ */ + public boolean handleLeashedCreatures() { + return handleLeashedCreatures; + } + /** * Gets whether the list of destinations within a network should be sorted * @@ -142,6 +152,7 @@ public final class StargateGateConfig { //Functionality handleVehicles = newConfig.getBoolean("gates.functionality.handleVehicles"); + handleLeashedCreatures = newConfig.getBoolean("gates.functionality.handleLeashedCreatures"); enableBungee = newConfig.getBoolean("gates.functionality.enableBungee"); //Integrity @@ -173,5 +184,4 @@ public final class StargateGateConfig { Stargate.logWarning("You have specified an invalid color in your config.yml. Defaulting to BLACK and WHITE"); PortalSignDrawer.setColors(ChatColor.BLACK, ChatColor.WHITE); } - } diff --git a/src/main/java/net/knarcraft/stargate/portal/Teleporter.java b/src/main/java/net/knarcraft/stargate/portal/Teleporter.java index 2160e74..1cf8364 100644 --- a/src/main/java/net/knarcraft/stargate/portal/Teleporter.java +++ b/src/main/java/net/knarcraft/stargate/portal/Teleporter.java @@ -256,6 +256,11 @@ public abstract class Teleporter { * @param origin

The portal the player is teleporting from

*/ protected void teleportLeashedCreatures(Player player, Portal origin) { + //If this feature is disabled, just return + if (!Stargate.getGateConfig().handleLeashedCreatures()) { + return; + } + //Find any nearby leashed entities to teleport with the player List nearbyEntities = getLeashedCreatures(player); //Teleport all creatures leashed by the player to the portal the player is to exit from diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index eac074b..c67aa5a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -9,6 +9,7 @@ # language - The language file to load for messages # rememberDestination - Whether to remember the cursor location between uses # handleVehicles - Whether to allow vehicles through gates +# handleLeashedCreatures - Whether to allow creatures lead by a player to teleport with the player # sortNetworkDestinations - Whether to sort network lists alphabetically # protectEntrance - Whether to protect gate entrance material (More resource intensive. Only enable if using destroyable open/closed material) # mainSignColor - The color used for drawing signs (Default: BLACK). @@ -49,6 +50,7 @@ gates: functionality: enableBungee: false handleVehicles: true + handleLeashedCreatures: true economy: useEconomy: false createCost: 0