diff --git a/pom.xml b/pom.xml
index f3c3737..b63c682 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
dev.bailey
ETPlaceholders
- 1.0.1
+ 1.0.2
jar
ETPlaceholders
@@ -43,7 +43,7 @@
- et_placeholders1.0.1
+ et_placeholders1.0.2
org.apache.maven.plugins
diff --git a/src/main/java/dev/bailey/etplaceholders/DataManager.java b/src/main/java/dev/bailey/etplaceholders/DataManager.java
index f63ae14..1db6b19 100644
--- a/src/main/java/dev/bailey/etplaceholders/DataManager.java
+++ b/src/main/java/dev/bailey/etplaceholders/DataManager.java
@@ -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 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 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) {
}
});
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index b27f73d..5fde669 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -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).
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index f3eccad..eda6d22 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -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]