From 7225859672a381e514e3ec6dfae4a657d574e293 Mon Sep 17 00:00:00 2001 From: Thorinwasher Date: Tue, 11 Jun 2024 13:41:07 +0200 Subject: [PATCH] Fixes #374 --- .../stargate/network/portal/StargatePortal.java | 7 +++++-- .../org/sgrewritten/stargate/util/EconomyHelper.java | 9 +++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/sgrewritten/stargate/network/portal/StargatePortal.java b/src/main/java/org/sgrewritten/stargate/network/portal/StargatePortal.java index fd88d031..d874f5c9 100644 --- a/src/main/java/org/sgrewritten/stargate/network/portal/StargatePortal.java +++ b/src/main/java/org/sgrewritten/stargate/network/portal/StargatePortal.java @@ -47,6 +47,7 @@ import org.sgrewritten.stargate.property.StargateConstant; import org.sgrewritten.stargate.thread.task.StargateGlobalTask; import org.sgrewritten.stargate.thread.task.StargateRegionTask; +import org.sgrewritten.stargate.util.EconomyHelper; import org.sgrewritten.stargate.util.NameHelper; import org.sgrewritten.stargate.util.portal.PortalHelper; @@ -268,8 +269,10 @@ public void teleportHere(Entity target, RealPortal origin) { entranceFace = entranceFace.getOppositeFace(); } - boolean shouldCharge = !(this.hasFlag(StargateFlag.FREE) || origin.hasFlag(StargateFlag.FREE)) - && target instanceof Player && !target.hasPermission(BypassPermission.COST_USE.getPermissionString()); + boolean shouldCharge = false; + if(target instanceof Player player){ + shouldCharge = EconomyHelper.shouldChargePlayer(player, origin, BypassPermission.COST_USE); + } useCost = shouldCharge ? ConfigurationHelper.getInteger(ConfigurationOption.USE_COST) : 0; } diff --git a/src/main/java/org/sgrewritten/stargate/util/EconomyHelper.java b/src/main/java/org/sgrewritten/stargate/util/EconomyHelper.java index 0ae3b61f..76d2aa1c 100644 --- a/src/main/java/org/sgrewritten/stargate/util/EconomyHelper.java +++ b/src/main/java/org/sgrewritten/stargate/util/EconomyHelper.java @@ -3,8 +3,9 @@ import org.bukkit.entity.Player; import org.sgrewritten.stargate.api.config.ConfigurationOption; import org.sgrewritten.stargate.api.network.portal.Portal; -import org.sgrewritten.stargate.api.network.portal.flag.StargateFlag; import org.sgrewritten.stargate.api.network.portal.RealPortal; +import org.sgrewritten.stargate.api.network.portal.flag.PortalFlag; +import org.sgrewritten.stargate.api.network.portal.flag.StargateFlag; import org.sgrewritten.stargate.api.permission.BypassPermission; import org.sgrewritten.stargate.config.ConfigurationHelper; @@ -34,9 +35,9 @@ public static boolean shouldChargePlayer(Player player, Portal portal, BypassPer if (destination == null) { return false; } - return ConfigurationHelper.getBoolean(ConfigurationOption.CHARGE_FREE_DESTINATION) || - !portal.hasFlag(StargateFlag.FIXED) || - !destination.hasFlag(StargateFlag.FREE); + return (ConfigurationHelper.getBoolean(ConfigurationOption.CHARGE_FREE_DESTINATION) || + !destination.hasFlag(PortalFlag.FREE)) && + !portal.hasFlag(PortalFlag.FREE); } return false; }