Skip to content

Commit

Permalink
Potential optimization for detection of spawn area (#1317)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Sep 2, 2022
1 parent d0c8170 commit 7cf4027
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -76,6 +76,7 @@ public class SpawnIsland implements Island {
private final PriorityQueue<SuperiorPlayer> playersInside = new PriorityQueue<>(SortingComparators.PLAYER_NAMES_COMPARATOR);

private final Location center;
private final World spawnWorld;
private final int islandSize;
private final Location minLocation;
private final Location maxLocation;
Expand Down Expand Up @@ -103,7 +104,7 @@ public SpawnIsland(SuperiorSkyblockPlugin plugin) {
if (center.getWorld() == null)
plugin.getProviders().runWorldsListeners(spawnLocation.split(", ")[0]);

if (center.getWorld() == null) {
if ((this.spawnWorld = center.getWorld()) == null) {
new ManagerLoadException("The spawn location is in invalid world.", ManagerLoadException.ErrorLevel.SERVER_SHUTDOWN).printStackTrace();
Bukkit.shutdown();
return;
Expand Down Expand Up @@ -460,8 +461,7 @@ public void resetChunks(boolean onlyProtected, Runnable onFinish) {

@Override
public boolean isInside(Location location) {
World spawnWorld = center.getWorld();
return location.getWorld().equals(spawnWorld) &&
return location.getWorld().equals(this.spawnWorld) &&
this.islandArea.intercepts(location.getBlockX(), location.getBlockZ());
}

Expand All @@ -477,7 +477,7 @@ public boolean isInsideRange(Location location, int extraRadius) {

@Override
public boolean isInsideRange(Chunk chunk) {
if (!chunk.getWorld().equals(getCenter(plugin.getSettings().getWorlds().getDefaultWorld()).getWorld()))
if (!chunk.getWorld().equals(this.spawnWorld))
return false;

Location min = getMinimum();
Expand Down

0 comments on commit 7cf4027

Please sign in to comment.