Optimizes portal entrance lookup
This commit is contained in:
@@ -532,7 +532,8 @@ portalInfoServer=Server: %server%
|
|||||||
#### \[Version 0.11.5.8] Unified Legacy Fork
|
#### \[Version 0.11.5.8] Unified Legacy Fork
|
||||||
|
|
||||||
- Cleaned up handling of invalid gate files during both migration and startup.
|
- 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.
|
- Updated various dependencies.
|
||||||
- Optimisations in the migrator as to mitigate issues associated with importing large past deployments.
|
- 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.
|
- Improved handling of some potential error states involving Floodgate and Geyser.
|
||||||
|
@@ -302,7 +302,7 @@ public class PortalHandler {
|
|||||||
if (location.getWorld() == null) {
|
if (location.getWorld() == null) {
|
||||||
return 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()));
|
location.getBlockY(), location.getBlockZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,7 +314,7 @@ public class PortalHandler {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Portal getByEntrance(@NotNull Block block) {
|
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) {
|
for (BlockLocation adjacentPosition : adjacentPositions) {
|
||||||
Portal portal = PortalRegistry.getLookupEntrances().get(adjacentPosition);
|
Portal portal = PortalRegistry.getPortalFromEntrance(adjacentPosition);
|
||||||
if (portal != null) {
|
if (portal != null) {
|
||||||
return portal;
|
return portal;
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,7 @@ import net.knarcraft.stargate.container.BlockLocation;
|
|||||||
import net.knarcraft.stargate.utility.PortalFileHelper;
|
import net.knarcraft.stargate.utility.PortalFileHelper;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
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
|
@Nullable
|
||||||
public static Map<BlockLocation, Portal> getLookupEntrances() {
|
public static Portal getPortalFromEntrance(@NotNull BlockLocation blockLocation) {
|
||||||
return new HashMap<>(lookupEntrances);
|
return lookupEntrances.get(blockLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user