From 9203d8c95b08cb40137f98e032f49bc374344f1e Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 17 May 2020 19:15:57 +0200 Subject: [PATCH] fix: JSONConfig not reloading properly --- .../java/de/cliffbreak/varo/uitls/JSONConfig.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/varo/src/main/java/de/cliffbreak/varo/uitls/JSONConfig.java b/varo/src/main/java/de/cliffbreak/varo/uitls/JSONConfig.java index a067544..f8789ec 100644 --- a/varo/src/main/java/de/cliffbreak/varo/uitls/JSONConfig.java +++ b/varo/src/main/java/de/cliffbreak/varo/uitls/JSONConfig.java @@ -11,7 +11,6 @@ import java.util.TreeMap; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import org.bukkit.ChatColor; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -78,6 +77,8 @@ public class JSONConfig { fw.flush(); fw.close(); + this.reload(); + return true; } catch (final Exception ex) { ex.printStackTrace(); @@ -91,7 +92,7 @@ public class JSONConfig { } private String getString(final String key) { - return ChatColor.translateAlternateColorCodes('&', getRawData(key)); + return getRawData(key); } private double getDouble(final String key) { @@ -119,4 +120,11 @@ public class JSONConfig { return this.json.containsKey(key) ? (JSONArray) json.get(key) : (this.defaults.containsKey(key) ? (JSONArray) this.defaults.get(key) : new JSONArray()); } + + @SuppressWarnings("unchecked") + public void updatePlayerName(final int teamKey, final int playerKey, final String name) { + ((JSONObject) ((JSONArray) ((JSONObject) ((JSONArray) this.json.get("teams")).get(teamKey)).get("players")) + .get(playerKey)).put("name", name); + this.save(); + } } \ No newline at end of file