Skip to content

Commit

Permalink
Fixes #374
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorinwasher committed Jun 11, 2024
1 parent aa33e1e commit 7225859
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 7225859

Please sign in to comment.