Optimizes portal entrance lookup

This commit is contained in:
2024-11-08 16:09:28 +01:00
parent 534ada874d
commit 966fed331f
3 changed files with 12 additions and 10 deletions

View File

@@ -523,7 +523,7 @@ portalInfoServer=Server: %server%
# Changes
#
#
#### \[Version 0.11.5.9] Unified Legacy Fork
@@ -532,7 +532,8 @@ portalInfoServer=Server: %server%
#### \[Version 0.11.5.8] Unified Legacy Fork
- Cleaned up handling of invalid gate files during both migration and startup.
- Backported the rewrite's translation system to legacy: to add new localisations, please use [this page](https://sgrewritten.org/translate).
- Backported the rewrite's translation system to legacy: to add new localisations, please
use [this page](https://sgrewritten.org/translate).
- Updated various dependencies.
- Optimisations in the migrator as to mitigate issues associated with importing large past deployments.
- Improved handling of some potential error states involving Floodgate and Geyser.

View File

@@ -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;
}

View File

@@ -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);
}
/**