Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed locations of invalid worlds stay with null world if put in maps
- Loading branch information
1 parent
e756657
commit da7d0da
Showing
4 changed files
with
53 additions
and
16 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/main/java/com/bgsoftware/superiorskyblock/core/LocationKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.bgsoftware.superiorskyblock.core; | ||
|
||
import org.bukkit.Location; | ||
|
||
import java.util.Objects; | ||
|
||
public class LocationKey { | ||
|
||
private final String worldName; | ||
private final double x; | ||
private final double y; | ||
private final double z; | ||
|
||
public LocationKey(Location location) { | ||
this(LazyWorldLocation.getWorldName(location), location.getX(), location.getY(), location.getZ()); | ||
} | ||
|
||
public LocationKey(LazyWorldLocation location) { | ||
this(location.getWorldName(), location.getX(), location.getY(), location.getZ()); | ||
} | ||
|
||
private LocationKey(String worldName, double x, double y, double z) { | ||
this.worldName = worldName; | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
LocationKey that = (LocationKey) o; | ||
return Double.compare(that.x, x) == 0 && Double.compare(that.y, y) == 0 && Double.compare(that.z, z) == 0 && worldName.equals(that.worldName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(worldName, x, y, z); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters