Sets the always on option to true for bungee portals and removes some unnecessary checks

This commit is contained in:
Kristian Knarvik 2021-11-05 21:40:06 +01:00
parent 80ff241d4b
commit 0297d62d6d
6 changed files with 13 additions and 13 deletions

View File

@ -2,12 +2,12 @@ package net.knarcraft.stargate.portal;
import net.knarcraft.stargate.container.BlockLocation; import net.knarcraft.stargate.container.BlockLocation;
import net.knarcraft.stargate.container.RelativeBlockVector; import net.knarcraft.stargate.container.RelativeBlockVector;
import net.knarcraft.stargate.portal.property.gate.Gate;
import net.knarcraft.stargate.portal.property.PortalLocation; import net.knarcraft.stargate.portal.property.PortalLocation;
import net.knarcraft.stargate.portal.property.PortalOption; import net.knarcraft.stargate.portal.property.PortalOption;
import net.knarcraft.stargate.portal.property.PortalOptions; import net.knarcraft.stargate.portal.property.PortalOptions;
import net.knarcraft.stargate.portal.property.PortalOwner; import net.knarcraft.stargate.portal.property.PortalOwner;
import net.knarcraft.stargate.portal.property.PortalStructure; import net.knarcraft.stargate.portal.property.PortalStructure;
import net.knarcraft.stargate.portal.property.gate.Gate;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -3,13 +3,14 @@ package net.knarcraft.stargate.portal;
import net.knarcraft.stargate.Stargate; import net.knarcraft.stargate.Stargate;
import net.knarcraft.stargate.container.BlockLocation; import net.knarcraft.stargate.container.BlockLocation;
import net.knarcraft.stargate.container.RelativeBlockVector; import net.knarcraft.stargate.container.RelativeBlockVector;
import net.knarcraft.stargate.portal.property.gate.Gate;
import net.knarcraft.stargate.portal.property.gate.GateHandler;
import net.knarcraft.stargate.portal.property.PortalLocation; import net.knarcraft.stargate.portal.property.PortalLocation;
import net.knarcraft.stargate.portal.property.PortalOption; import net.knarcraft.stargate.portal.property.PortalOption;
import net.knarcraft.stargate.portal.property.PortalStructure; import net.knarcraft.stargate.portal.property.PortalStructure;
import net.knarcraft.stargate.portal.property.gate.Gate;
import net.knarcraft.stargate.portal.property.gate.GateHandler;
import net.knarcraft.stargate.utility.PermissionHelper; import net.knarcraft.stargate.utility.PermissionHelper;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -142,12 +143,12 @@ public class PortalHandler {
* Tries to find a gate matching the portal the user is trying to create * Tries to find a gate matching the portal the user is trying to create
* *
* @param portalLocation <p>The location data for the new portal</p> * @param portalLocation <p>The location data for the new portal</p>
* @param player <p>The player trying to create the new portal</p> * @param world <p>The world the player is located in</p>
* @return <p>The matching gate type, or null if no such gate could be found</p> * @return <p>The matching gate type, or null if no such gate could be found</p>
*/ */
static Gate findMatchingGate(PortalLocation portalLocation, Player player) { static Gate findMatchingGate(PortalLocation portalLocation, World world) {
Block signParent = portalLocation.getSignLocation().getParent(); Block signParent = portalLocation.getSignLocation().getParent();
BlockLocation parent = new BlockLocation(player.getWorld(), signParent.getX(), signParent.getY(), BlockLocation parent = new BlockLocation(world, signParent.getX(), signParent.getY(),
signParent.getZ()); signParent.getZ());
//Get all gates with the used type of control blocks //Get all gates with the used type of control blocks

View File

@ -28,9 +28,9 @@ public class PortalOptions {
Stargate.debug("Portal", "Can not create a non-fixed always-on gate. Setting AlwaysOn = false"); Stargate.debug("Portal", "Can not create a non-fixed always-on gate. Setting AlwaysOn = false");
} }
if (this.isRandom() && !this.isAlwaysOn()) { if ((this.isRandom() || this.isBungee()) && !this.isAlwaysOn()) {
this.options.put(PortalOption.ALWAYS_ON, true); this.options.put(PortalOption.ALWAYS_ON, true);
Stargate.debug("Portal", "Gate marked as random, set to always-on"); Stargate.debug("Portal", "Gate marked as random or bungee, set to always-on");
} }
} }

View File

@ -30,8 +30,7 @@ public class StarGateThread implements Runnable {
for (Portal portal : openPortalsQueue) { for (Portal portal : openPortalsQueue) {
//Skip always open and non-open gates //Skip always open and non-open gates
if (portal.getOptions().isAlwaysOn() || portal.getOptions().isRandom() || portal.getOptions().isBungee() || if (portal.getOptions().isAlwaysOn() || !portal.isOpen()) {
!portal.isOpen()) {
continue; continue;
} }
if (time > portal.getTriggeredTime() + Stargate.getGateConfig().getOpenTime()) { if (time > portal.getTriggeredTime() + Stargate.getGateConfig().getOpenTime()) {

View File

@ -27,7 +27,7 @@ public final class PermissionHelper {
Portal destination = portal.getPortalActivator().getDestination(); Portal destination = portal.getPortalActivator().getDestination();
//For an always open portal, no action is necessary //For an always open portal, no action is necessary
if (portal.getOptions().isAlwaysOn() || portal.getOptions().isRandom() || portal.getOptions().isBungee()) { if (portal.getOptions().isAlwaysOn()) {
return; return;
} }