Skip to content

Commit

Permalink
Fixed islands in other worlds are not detected correctly (#1426)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Oct 22, 2022
1 parent 8dd3844 commit b7e478f
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
import com.bgsoftware.superiorskyblock.SuperiorSkyblockPlugin;
import org.bukkit.Location;

import javax.annotation.Nullable;
import java.util.Objects;

public class IslandPosition {

private static final SuperiorSkyblockPlugin plugin = SuperiorSkyblockPlugin.getPlugin();

@Nullable
private final String worldName;
private final int x;
private final int z;

private IslandPosition(String worldName, int x, int z) {
private IslandPosition(@Nullable String worldName, int x, int z) {
this.worldName = worldName;
this.x = x;
this.z = z;
Expand All @@ -27,15 +29,15 @@ public static IslandPosition of(String worldName, int locX, int locZ) {
int radius = plugin.getSettings().getMaxIslandSize() * 3;
int x = (Math.abs(locX) + (radius / 2)) / radius;
int z = (Math.abs(locZ) + (radius / 2)) / radius;
return new IslandPosition(worldName, locX < 0 ? -x : x, locZ < 0 ? -z : z);
return new IslandPosition(plugin.getProviders().hasCustomWorldsSupport() ? worldName : null, locX < 0 ? -x : x, locZ < 0 ? -z : z);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IslandPosition that = (IslandPosition) o;
return x == that.x && z == that.z && worldName.equals(that.worldName);
return x == that.x && z == that.z && Objects.equals(worldName, that.worldName);
}

@Override
Expand Down

0 comments on commit b7e478f

Please sign in to comment.