From b2bb995d7e72de140e9588fc526dc0e00db5fdae Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Thu, 25 Nov 2021 03:54:09 +0100 Subject: [PATCH] Prevents teleportation of a leashed creature with a passenger --- README.md | 4 +++- .../stargate/portal/teleporter/Teleporter.java | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fe1feda..53d7084 100644 --- a/README.md +++ b/README.md @@ -391,11 +391,13 @@ portalInfoServer=Server: %server% #### \[Version 0.9.2.2] EpicKnarvik97 fork -- Prevents teleportation of a player holding creatures on a leash when handleLeashedCreatures is disabled to prevent +- Prevents teleportation of a player holding creatures on a leash when handleLeashedCreatures is disabled, to prevent players accidentally losing the creatures during teleportation - Fixes a potential exception when a gate's open-block or closed-block is set to a material which isn't a block - Fixes a potential exception when a portal without a sign has an invalid gate type - Prevents loading of gate files using non-blocks as part of the border +- Prevents a player smuggling another player through a restricted stargate by sitting on a creature held in a lead by + the first player #### \[Version 0.9.2.1] EpicKnarvik97 fork diff --git a/src/main/java/net/knarcraft/stargate/portal/teleporter/Teleporter.java b/src/main/java/net/knarcraft/stargate/portal/teleporter/Teleporter.java index 72e2c26..5ffd9f4 100644 --- a/src/main/java/net/knarcraft/stargate/portal/teleporter/Teleporter.java +++ b/src/main/java/net/knarcraft/stargate/portal/teleporter/Teleporter.java @@ -257,15 +257,22 @@ public abstract class Teleporter { * @return

False if the player has leashed any creatures that cannot go through the portal

*/ public static boolean noLeashedCreaturesPreventTeleportation(Player player) { + //Find any nearby leashed entities to teleport with the player + List nearbyCreatures = getLeashedCreatures(player); + + //Disallow creatures with passengers to prevent smuggling + for (Creature creature : nearbyCreatures) { + if (!creature.getPassengers().isEmpty()) { + return false; + } + } + //If it's enabled, there is no problem if (Stargate.getGateConfig().handleLeashedCreatures()) { return true; + } else { + return nearbyCreatures.isEmpty(); } - - //Find any nearby leashed entities to teleport with the player - List nearbyEntities = getLeashedCreatures(player); - - return nearbyEntities.isEmpty(); } /**