mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 20:39:10 +00:00
feat(config): 修改配置项默认值
This commit is contained in:
@@ -17,7 +17,7 @@ import java.nio.file.Path;
|
||||
|
||||
public class ModConfig {
|
||||
private static final Path CONFIG_PATH = FabricLoader.getInstance().getConfigDir().resolve("craft-engine-fabric-mod/config.yml");
|
||||
public static boolean enableNetwork = true;
|
||||
public static boolean enableNetwork = false;
|
||||
public static boolean enableCancelBlockUpdate = false;
|
||||
|
||||
public static Screen getConfigScreen(Screen parent) {
|
||||
@@ -33,7 +33,7 @@ public class ModConfig {
|
||||
Text.translatable("option.craftengine.enable_network")
|
||||
.formatted(Formatting.WHITE),
|
||||
enableNetwork)
|
||||
.setDefaultValue(true)
|
||||
.setDefaultValue(false)
|
||||
.setSaveConsumer(newValue -> enableNetwork = newValue)
|
||||
.setTooltip(
|
||||
Text.translatable("tooltip.craftengine.enable_network")
|
||||
|
||||
@@ -53,7 +53,7 @@ public class CraftEngineFabricMod implements ModInitializer {
|
||||
@SuppressWarnings("unchecked")
|
||||
private void loadConfig() {
|
||||
if (!Files.exists(CONFIG_PATH)) {
|
||||
ModConfig.enableNetwork = true;
|
||||
ModConfig.enableNetwork = false;
|
||||
ModConfig.enableCancelBlockUpdate = false;
|
||||
return;
|
||||
}
|
||||
@@ -61,11 +61,11 @@ public class CraftEngineFabricMod implements ModInitializer {
|
||||
Yaml yaml = new Yaml();
|
||||
var config = yaml.loadAs(inputStream, java.util.Map.class);
|
||||
if (config == null) {
|
||||
ModConfig.enableNetwork = true;
|
||||
ModConfig.enableNetwork = false;
|
||||
ModConfig.enableCancelBlockUpdate = false;
|
||||
return;
|
||||
}
|
||||
ModConfig.enableNetwork = (Boolean) config.getOrDefault("enable-network", true);
|
||||
ModConfig.enableNetwork = (Boolean) config.getOrDefault("enable-network", false);
|
||||
ModConfig.enableCancelBlockUpdate = (Boolean) config.getOrDefault("enable-cancel-block-update", false);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user