fix: JSONConfig not reloading properly

This commit is contained in:
Simon Giesel 2020-05-17 19:15:57 +02:00
parent fae0910759
commit 9203d8c95b

View file

@ -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();
}
}