Compare commits
4 Commits
654cdbd09a
...
48bc060e5c
Author | SHA1 | Date |
---|---|---|
Ryan Fox | 48bc060e5c | |
Ryan Fox | 93f546a5ce | |
Ryan Fox | edd3cc8689 | |
Ryan Fox | 212f2db61a |
|
@ -12,8 +12,10 @@ dependencies {
|
|||
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
modCompile "org.json:json:20200518"
|
||||
modCompile "org.xerial:sqlite-jdbc:3.32.3.2"
|
||||
modImplementation "com.google.code.findbugs:jsr305:3.0.2"
|
||||
include "org.json:json:20200518"
|
||||
include "org.xerial:sqlite-jdbc:3.32.3.2"
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
|
@ -28,7 +28,7 @@ public abstract class MixinRespawnAnchorBlock extends Block {
|
|||
|
||||
@Inject(method = "explode", at = @At("HEAD"), cancellable = true)
|
||||
private void onExplode(CallbackInfo ci) {
|
||||
if (Config.getBool("disableTntExplosions") == true)
|
||||
if (Config.getBool("disableRespawnAnchorExplosions") == true)
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,10 +32,13 @@ public class Config {
|
|||
String jsonRaw = IOUtils.toString(is, "UTF-8");
|
||||
json = new JSONObject(jsonRaw);
|
||||
} else {
|
||||
LOGGER.info("Config not found, creating one");
|
||||
json = new JSONObject("{\"disableTntExplosions\":false,\"spawn\":[0,0,0,0,0,\"\"],\"members\":[]}");
|
||||
saveConfig();
|
||||
json = new JSONObject();
|
||||
}
|
||||
|
||||
setDefault("disableTntExplosions", false);
|
||||
setDefault("disableRespawnAnchorExplosions", false);
|
||||
setDefault("spawn", (new PlayerPosition()).getJSON());
|
||||
|
||||
LOGGER.info("Configuration loaded");
|
||||
}
|
||||
|
||||
|
@ -86,9 +89,19 @@ public class Config {
|
|||
saveConfig();
|
||||
}
|
||||
|
||||
public static void setDefault(String key, JSONArray data) {
|
||||
if (!json.has(key))
|
||||
json.put(key, data);
|
||||
}
|
||||
|
||||
public static void setDefault(String key, Boolean data) {
|
||||
if (!json.has(key))
|
||||
json.put(key, data);
|
||||
}
|
||||
|
||||
private static void saveConfig() {
|
||||
try (FileWriter file = new FileWriter(config)) {
|
||||
file.write(JSONObject.valueToString(json));
|
||||
file.write(json.toString(2));
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to save config file");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue