Config and minor improvements

This commit is contained in:
Andrew-71 2023-08-24 13:56:29 +03:00
parent ca2c5aa93e
commit a166e94656
6 changed files with 114 additions and 3 deletions

View file

@ -0,0 +1,55 @@
package su.a71.new_soviet;
import java.io.*;
public class Config {
private boolean invert_lamps = false;
public static Config INSTANCE;
public Config() {
INSTANCE = this;
}
public boolean shouldInvertLamps() {
return invert_lamps;
}
private static void generateDefault() {
File file = new File("config/new_soviet.json");
if(!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
INSTANCE = new Config();
try {
FileWriter writer = new FileWriter(file);
writer.write(NewSoviet.GSON.toJson(INSTANCE));
writer.close();
} catch (Exception e) {
INSTANCE = new Config();
}
}
public static void load() {
// Generate config if it doesn't exist
File file = new File("config/new_soviet.json");
if(!file.exists()) {
generateDefault();
}
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuilder sb = new StringBuilder();
String s;
while((s = reader.readLine()) != null)
sb.append(s);
reader.close();
INSTANCE = NewSoviet.GSON.fromJson(sb.toString(), Config.class);
} catch(Exception e) {
INSTANCE = new Config();
}
}
}

View file

@ -26,6 +26,8 @@ public class NewSoviet implements ModInitializer {
@Override
public void onInitialize() {
Config.load();
NSE_Blocks.init();
NSE_Items.init();
NSE_Custom.init();

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

View file

@ -204,5 +204,6 @@
"block.new_soviet.brown_wallpaper": "Brown Wallpaper Block",
"block.new_soviet.beige_wallpaper": "Beige Wallpaper Block",
"block.new_soviet.purple_goo": "Purple Goo",
"subtitles.new_soviet.switch_press": "Switch clicks"
"subtitles.new_soviet.switch_press": "Switch clicks",
"subtitles.new_soviet.electric_hit": "Electric sparks"
}

View file

@ -12,7 +12,7 @@
"homepage": "https://nse.a71.su/",
"sources": "https://git.a71.su/Ethyl/New-Soviet-Era"
},
"license": "All rights reserved",
"license": "Mixed: All rights reserved assets & MIT code",
"icon": "assets/new_soviet/icon.png",
"environment": "*",
"entrypoints": {
@ -31,5 +31,14 @@
"minecraft": "~1.20.1",
"java": ">=17",
"fabric-api": "*"
},
"custom": {
"modmenu": {
"links": {
"modmenu.discord": "https://discord.gg/D46vGJeCfj"
},
"update_checker": true
}
}
}