Optimizes portal entrance lookup
This commit is contained in:
		@@ -302,7 +302,7 @@ public class PortalHandler {
 | 
			
		||||
        if (location.getWorld() == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        return PortalRegistry.getLookupEntrances().get(new BlockLocation(location.getWorld(), location.getBlockX(),
 | 
			
		||||
        return PortalRegistry.getPortalFromEntrance(new BlockLocation(location.getWorld(), location.getBlockX(),
 | 
			
		||||
                location.getBlockY(), location.getBlockZ()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -314,7 +314,7 @@ public class PortalHandler {
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Portal getByEntrance(@NotNull Block block) {
 | 
			
		||||
        return PortalRegistry.getLookupEntrances().get(new BlockLocation(block));
 | 
			
		||||
        return PortalRegistry.getPortalFromEntrance(new BlockLocation(block));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -355,7 +355,7 @@ public class PortalHandler {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (BlockLocation adjacentPosition : adjacentPositions) {
 | 
			
		||||
            Portal portal = PortalRegistry.getLookupEntrances().get(adjacentPosition);
 | 
			
		||||
            Portal portal = PortalRegistry.getPortalFromEntrance(adjacentPosition);
 | 
			
		||||
            if (portal != null) {
 | 
			
		||||
                return portal;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@ import net.knarcraft.stargate.container.BlockLocation;
 | 
			
		||||
import net.knarcraft.stargate.utility.PortalFileHelper;
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
@@ -124,13 +125,13 @@ public class PortalRegistry {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets a copy of all portal entrances available for lookup
 | 
			
		||||
     * Gets a portal from the location of a possible entrance
 | 
			
		||||
     *
 | 
			
		||||
     * @return <p>A copy of all entrances to portal mappings</p>
 | 
			
		||||
     * @return <p>A portal, or null</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static Map<BlockLocation, Portal> getLookupEntrances() {
 | 
			
		||||
        return new HashMap<>(lookupEntrances);
 | 
			
		||||
    @Nullable
 | 
			
		||||
    public static Portal getPortalFromEntrance(@NotNull BlockLocation blockLocation) {
 | 
			
		||||
        return lookupEntrances.get(blockLocation);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user