diff --git a/build.gradle b/build.gradle
index 40fd19a..3f60835 100644
--- a/build.gradle
+++ b/build.gradle
@@ -92,6 +92,7 @@ publishing {
mavenJava(MavenPublication) {
groupId = findProperty('maven_group')
artifactId = findProperty('lib_name')
+
version = findProperty('wrapper_version')
from components.java
diff --git a/src/main/java/io/github/emcw/entities/Location.java b/src/main/java/io/github/emcw/entities/Location.java
index 6bd4c5f..16513b7 100644
--- a/src/main/java/io/github/emcw/entities/Location.java
+++ b/src/main/java/io/github/emcw/entities/Location.java
@@ -11,12 +11,9 @@
import static io.github.emcw.utils.GsonUtil.*;
public class Location implements ISerializable {
- @Getter
- final Integer x;
- @Getter
- final Integer z;
- @Getter
- Integer y;
+ @Getter final Integer x;
+ @Getter final Integer z;
+ @Getter Integer y;
/**
*
A location in 3D space.
diff --git a/src/main/java/io/github/emcw/entities/Player.java b/src/main/java/io/github/emcw/entities/Player.java
index 887a5d1..fbaf10a 100644
--- a/src/main/java/io/github/emcw/entities/Player.java
+++ b/src/main/java/io/github/emcw/entities/Player.java
@@ -78,20 +78,34 @@ public Resident asResident(String mapName) throws MissingEntryException {
return new Resident(asTree(res), this);
}
+ /**
+ * If this player has set a nickname.
+ * @return true/false if {@link #nickname} is same as their account {@link #name}.
+ */
public boolean hasCustomNickname() {
return nickname != null && !Objects.equals(nickname, name);
}
- public boolean aboveGround() {
+ /**
+ * If this player is visible on the Dynmap.
+ * @return true/false if {@link #world} is "earth" and player is not under a block.
+ */
+ public boolean visible() {
return Objects.equals(world, "earth");
}
- public boolean underground() {
- return locationIsDefault() && !aboveGround();
+ /**
+ * Essentially the opposite of {@link #visible}.
+ * NOTE:
+ * This returns true for players under a tree, in the nether etc.
+ * @return true/false if {@link #world} is NOT "earth" and {@link #location} is 0, 64, 0.
+ */
+ public boolean hidden() {
+ return locationIsDefault() && !visible();
}
/**
- *
Whether this player is located at the default Dynmap location.
+ * Whether this player is located at the default Dynmap location.
* @return true/false if {@link #location} is 0, 64, 0
*/
public boolean locationIsDefault() {
@@ -99,7 +113,7 @@ public boolean locationIsDefault() {
}
/**
- * Check if this player is also a resident on the map this instance was retrieved from.
+ * Check if this player is also a resident on the map this instance was retrieved from.
*/
public boolean isResident() {
return isResident != null && isResident;
diff --git a/src/main/java/io/github/emcw/entities/Resident.java b/src/main/java/io/github/emcw/entities/Resident.java
index fa8d369..6273406 100644
--- a/src/main/java/io/github/emcw/entities/Resident.java
+++ b/src/main/java/io/github/emcw/entities/Resident.java
@@ -13,7 +13,6 @@
import static io.github.emcw.utils.GsonUtil.keyAsStr;
-@SuppressWarnings("unused")
public class Resident extends Player implements ISerializable {
@Getter private String town, nation, rank;
@@ -46,6 +45,7 @@ public boolean hasAuthority() {
return Objects.equals(rank, "Mayor") || Objects.equals(rank, "Leader");
}
+ @SuppressWarnings("SameParameterValue")
protected static List fromArr(@NotNull JsonArray arr, String key) {
return StreamSupport.stream(arr.spliterator(), true).map(curRes -> {
JsonObject obj = new JsonObject();
diff --git a/src/main/java/io/github/emcw/interfaces/ILocatable.java b/src/main/java/io/github/emcw/interfaces/ILocatable.java
index 9b7d9b2..e5d208c 100644
--- a/src/main/java/io/github/emcw/interfaces/ILocatable.java
+++ b/src/main/java/io/github/emcw/interfaces/ILocatable.java
@@ -51,7 +51,7 @@ private boolean checkNearby(T val) {
Location loc = null;
if (val instanceof Player player) {
- if (!player.aboveGround()) return false;
+ if (!player.visible()) return false;
loc = player.getLocation();
}
else if (val instanceof Town town) loc = town.getLocation();
diff --git a/src/main/java/io/github/emcw/map/Nations.java b/src/main/java/io/github/emcw/map/Nations.java
index 1e3c227..029c8f6 100644
--- a/src/main/java/io/github/emcw/map/Nations.java
+++ b/src/main/java/io/github/emcw/map/Nations.java
@@ -3,7 +3,6 @@
import com.github.benmanes.caffeine.cache.Cache;
import io.github.emcw.caching.BaseCache;
import io.github.emcw.caching.CacheOptions;
-import io.github.emcw.caching.CacheStrategy;
import io.github.emcw.core.EMCMap;
import io.github.emcw.entities.Nation;
import io.github.emcw.exceptions.MissingEntryException;
diff --git a/src/main/java/io/github/emcw/map/Players.java b/src/main/java/io/github/emcw/map/Players.java
index 99b1257..9aa20e1 100644
--- a/src/main/java/io/github/emcw/map/Players.java
+++ b/src/main/java/io/github/emcw/map/Players.java
@@ -4,7 +4,6 @@
import com.google.gson.JsonObject;
import io.github.emcw.caching.BaseCache;
import io.github.emcw.caching.CacheOptions;
-import io.github.emcw.caching.CacheStrategy;
import io.github.emcw.core.EMCMap;
import io.github.emcw.entities.Location;
import io.github.emcw.exceptions.MissingEntryException;
diff --git a/src/main/java/io/github/emcw/map/Residents.java b/src/main/java/io/github/emcw/map/Residents.java
index 915a5c1..fbacaaf 100644
--- a/src/main/java/io/github/emcw/map/Residents.java
+++ b/src/main/java/io/github/emcw/map/Residents.java
@@ -3,7 +3,6 @@
import com.github.benmanes.caffeine.cache.Cache;
import io.github.emcw.caching.BaseCache;
import io.github.emcw.caching.CacheOptions;
-import io.github.emcw.caching.CacheStrategy;
import io.github.emcw.core.EMCMap;
import io.github.emcw.entities.Resident;
import io.github.emcw.exceptions.MissingEntryException;
diff --git a/src/main/java/io/github/emcw/map/Towns.java b/src/main/java/io/github/emcw/map/Towns.java
index 624dbba..9d3f9ae 100644
--- a/src/main/java/io/github/emcw/map/Towns.java
+++ b/src/main/java/io/github/emcw/map/Towns.java
@@ -3,7 +3,6 @@
import com.github.benmanes.caffeine.cache.Cache;
import io.github.emcw.caching.BaseCache;
import io.github.emcw.caching.CacheOptions;
-import io.github.emcw.caching.CacheStrategy;
import io.github.emcw.core.EMCMap;
import io.github.emcw.entities.Town;
import io.github.emcw.exceptions.MissingEntryException;
diff --git a/src/main/java/io/github/emcw/utils/DataParser.java b/src/main/java/io/github/emcw/utils/DataParser.java
index e440ff9..8f521cd 100644
--- a/src/main/java/io/github/emcw/utils/DataParser.java
+++ b/src/main/java/io/github/emcw/utils/DataParser.java
@@ -10,6 +10,7 @@
import io.github.emcw.entities.Resident;
import io.github.emcw.entities.Town;
+import io.github.emcw.utils.http.DynmapAPI;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.Contract;
@@ -61,7 +62,7 @@ public static void parseMapData(String map) {
}
public static void parseMapData(String map, Boolean parseTowns, Boolean parseNations, Boolean parseResidents) {
- JsonObject mapData = API.mapData(map);
+ JsonObject mapData = DynmapAPI.mapData(map);
if (mapData.size() < 1) return;
if (parseTowns) rawTowns.invalidateAll();
@@ -218,7 +219,7 @@ private static void parseResidents(String[] members, String town, String nation,
}
public static void parsePlayerData(String map) {
- JsonArray pData = API.playerData(map).getAsJsonArray("players");
+ JsonArray pData = DynmapAPI.playerData(map).getAsJsonArray("players");
if (pData.size() < 1) return;
rawPlayers.invalidateAll();
diff --git a/src/main/java/io/github/emcw/utils/API.java b/src/main/java/io/github/emcw/utils/http/DynmapAPI.java
similarity index 95%
rename from src/main/java/io/github/emcw/utils/API.java
rename to src/main/java/io/github/emcw/utils/http/DynmapAPI.java
index df5a148..c96f742 100644
--- a/src/main/java/io/github/emcw/utils/API.java
+++ b/src/main/java/io/github/emcw/utils/http/DynmapAPI.java
@@ -1,4 +1,4 @@
-package io.github.emcw.utils;
+package io.github.emcw.utils.http;
import com.google.gson.JsonObject;
import org.jetbrains.annotations.Contract;
@@ -11,8 +11,8 @@
* Note:
*
This class is used internally to obtain fresh data, you should never need to use it directly.
*/
-public final class API {
- private API() {}
+public final class DynmapAPI {
+ private DynmapAPI() {}
@Contract("_, _ -> new")
private static @NotNull CompletableFuture get(String map, String key) {
diff --git a/src/main/java/io/github/emcw/utils/http/OfficialAPI.java b/src/main/java/io/github/emcw/utils/http/OfficialAPI.java
new file mode 100644
index 0000000..917918e
--- /dev/null
+++ b/src/main/java/io/github/emcw/utils/http/OfficialAPI.java
@@ -0,0 +1,7 @@
+package io.github.emcw.utils.http;
+
+public class OfficialAPI {
+ public OfficialAPI() { }
+
+ static String Domain = "https://api.earthmc.net/v2/aurora/";
+}
\ No newline at end of file
diff --git a/src/main/java/io/github/emcw/utils/Request.java b/src/main/java/io/github/emcw/utils/http/Request.java
similarity index 90%
rename from src/main/java/io/github/emcw/utils/Request.java
rename to src/main/java/io/github/emcw/utils/http/Request.java
index 86f1818..8955fd2 100644
--- a/src/main/java/io/github/emcw/utils/Request.java
+++ b/src/main/java/io/github/emcw/utils/http/Request.java
@@ -1,4 +1,4 @@
-package io.github.emcw.utils;
+package io.github.emcw.utils.http;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
@@ -30,6 +30,7 @@ public class Request {
static final String epUrl = "https://raw.githubusercontent.com/EarthMC-Toolkit/EarthMC-NPM/main/src/endpoints.json";
static final Cache endpoints = Caffeine.newBuilder().build();
+ @SuppressWarnings("SameReturnValue")
static Cache getEndpoints() {
if (endpoints.asMap().isEmpty()) {
JsonObject eps = updateEndpoints();
@@ -43,14 +44,10 @@ static Cache getEndpoints() {
}
static @Nullable JsonObject updateEndpoints() {
- try { return send(epUrl); }
- catch (APIException e) {
- System.out.println(e.getMessage());
- return null;
- }
+ return send(epUrl);
}
- public static T send(String url) throws APIException {
+ public static T send(String url) {
return (T) JsonParser.parseString(fetch(url));
}