Fix Gson compatibility errors & clean comments

This commit is contained in:
2026-09-20 17:35:48 -05:00
parent 6196d75d2e
commit c512fc189a
4 changed files with 24 additions and 25 deletions
+2 -2
View File
@@ -4,7 +4,7 @@
<groupId>dev.bailey</groupId>
<artifactId>ETPlaceholders</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<packaging>jar</packaging>
<name>ETPlaceholders</name>
@@ -43,7 +43,7 @@
</dependencies>
<build>
<finalName>et_placeholders1.0.1</finalName>
<finalName>et_placeholders1.0.2</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -49,22 +49,20 @@ public class DataManager {
}
private String getApiUrl() {
String url = plugin.getConfig().getString("api-url", "https://api.eaglertiers.com/api");
if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
return url;
return "https://api.eaglertiers.com/api";
}
private HttpURLConnection createConnection(String endpoint) throws Exception {
String urlStr = getApiUrl() + endpoint;
String key = plugin.getConfig().getString("api-key", "");
if (key != null && !key.trim().isEmpty()) {
if (urlStr.contains("?")) {
urlStr += "&key=" + key;
} else {
urlStr += "?key=" + key;
}
if (key == null || key.trim().isEmpty()) {
throw new IllegalArgumentException("API key is missing in config.yml! ETPlaceholders requires an API key to function.");
}
String urlStr = getApiUrl() + endpoint;
if (urlStr.contains("?")) {
urlStr += "&key=" + key;
} else {
urlStr += "?key=" + key;
}
URL url = new URL(urlStr);
@@ -73,10 +71,7 @@ public class DataManager {
conn.setRequestProperty("Accept", "application/json");
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
if (key != null && !key.trim().isEmpty()) {
conn.setRequestProperty("X-API-Key", key);
}
conn.setRequestProperty("X-API-Key", key);
return conn;
}
@@ -104,7 +99,7 @@ public class DataManager {
String tier = plugin.getConfig().getString("not-found-text", "Unranked");
if (pObj.has("tiers") && !pObj.get("tiers").isJsonNull()) {
JsonObject tiersObj = pObj.getAsJsonObject("tiers");
JsonObject tiersObj = pObj.get("tiers").getAsJsonObject();
if (tiersObj.has(mode) && !tiersObj.get(mode).isJsonNull()) {
tier = tiersObj.get(mode).getAsString();
}
@@ -116,6 +111,10 @@ public class DataManager {
}
}
}
} catch (IllegalArgumentException e) {
plugin.getLogger().warning(e.getMessage());
stopTasks();
break;
} catch (Exception e) {
plugin.getLogger().warning("Failed to fetch leaderboard for " + mode + ": " + e.getMessage());
}
@@ -134,7 +133,7 @@ public class DataManager {
Map<String, String> pTiers = new ConcurrentHashMap<>();
if (json.has("tiers") && !json.get("tiers").isJsonNull()) {
JsonObject tiersObj = json.getAsJsonObject("tiers");
JsonObject tiersObj = json.get("tiers").getAsJsonObject();
for (Map.Entry<String, JsonElement> entry : tiersObj.entrySet()) {
if (!entry.getValue().isJsonNull()) {
pTiers.put(entry.getKey().toLowerCase(), entry.getValue().getAsString());
@@ -150,6 +149,8 @@ public class DataManager {
}
}
}
} catch (IllegalArgumentException e) {
plugin.getLogger().warning(e.getMessage());
} catch (Exception e) {
}
});
+2 -4
View File
@@ -1,11 +1,9 @@
# ET Placeholders Configuration
# Available Gamemodes: overall, vanilla, mace, axe, sword, smp, diamondsmp, uhc, pot, nethop, cart
# The base URL of the EaglerTiers API
api-url: "https://api.eaglertiers.com/api"
# Your API key. While public read requests don't require an API key, it is highly recommended to provide one to avoid rate limits.
api-key: ""
# To get an api key, open a ticket on the discord https://discord.eaglertiers.com You need a key for this
api-key: ""
# How often (in minutes) to refresh cached player and leaderboard data.
# Do not set this too low or you may hit the API rate limit (120 req/min).
+1 -1
View File
@@ -1,5 +1,5 @@
name: ETPlaceholders
version: 1.0.1
version: 1.0.2
main: dev.bailey.etplaceholders.ETPlaceholdersPlugin
api-version: "1.13"
softdepend: [PlaceholderAPI]