fix: JSONConfig not reloading properly
This commit is contained in:
parent
fae0910759
commit
9203d8c95b
1 changed files with 10 additions and 2 deletions
|
@ -11,7 +11,6 @@ import java.util.TreeMap;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
|
@ -78,6 +77,8 @@ public class JSONConfig {
|
||||||
fw.flush();
|
fw.flush();
|
||||||
fw.close();
|
fw.close();
|
||||||
|
|
||||||
|
this.reload();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -91,7 +92,7 @@ public class JSONConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getString(final String key) {
|
private String getString(final String key) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', getRawData(key));
|
return getRawData(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getDouble(final String key) {
|
private double getDouble(final String key) {
|
||||||
|
@ -119,4 +120,11 @@ public class JSONConfig {
|
||||||
return this.json.containsKey(key) ? (JSONArray) json.get(key)
|
return this.json.containsKey(key) ? (JSONArray) json.get(key)
|
||||||
: (this.defaults.containsKey(key) ? (JSONArray) this.defaults.get(key) : new JSONArray());
|
: (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();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue