From 449c927c6ca6781073d864972e26027f56ae83ff Mon Sep 17 00:00:00 2001 From: darbyjack Date: Wed, 25 Mar 2020 23:04:00 -0500 Subject: [PATCH] Add user-friendly message when host can't connect to ecloud --- .../placeholderapi/configuration/PlaceholderAPIConfig.java | 4 ++++ .../expansion/cloud/ExpansionCloudManager.java | 7 ++++++- src/main/resources/config.yml | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/clip/placeholderapi/configuration/PlaceholderAPIConfig.java b/src/main/java/me/clip/placeholderapi/configuration/PlaceholderAPIConfig.java index 8c66bce..cf76252 100644 --- a/src/main/java/me/clip/placeholderapi/configuration/PlaceholderAPIConfig.java +++ b/src/main/java/me/clip/placeholderapi/configuration/PlaceholderAPIConfig.java @@ -47,6 +47,10 @@ public class PlaceholderAPIConfig { return plugin.getConfig().getBoolean("cloud_enabled"); } + public boolean isDebugMode() { + return plugin.getConfig().getBoolean("debug", false); + } + public void setCloudEnabled(boolean b) { plugin.getConfig().set("cloud_enabled", b); plugin.reloadConfig(); diff --git a/src/main/java/me/clip/placeholderapi/expansion/cloud/ExpansionCloudManager.java b/src/main/java/me/clip/placeholderapi/expansion/cloud/ExpansionCloudManager.java index 2612776..d8c2af3 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/cloud/ExpansionCloudManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/cloud/ExpansionCloudManager.java @@ -169,7 +169,12 @@ public class ExpansionCloudManager { try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(API_URL).openStream()))) { data.putAll(GSON.fromJson(reader, new TypeToken>() {}.getType())); } catch (Exception ex) { - ex.printStackTrace(); + if (plugin.getPlaceholderAPIConfig().isDebugMode()) { + ex.printStackTrace(); + } + else { + plugin.getLogger().warning("Unable to fetch expansions!\nThere was an error with the server host connecting to the PlaceholderAPI eCloud (https://api.extendedclip.com/v2/)"); + } } final List unsorted = new ArrayList<>(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4af49f5..59e8953 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -15,3 +15,4 @@ boolean: 'true': 'yes' 'false': 'no' date_format: MM/dd/yy HH:mm:ss +debug: false