Skip to content

Commit

Permalink
Fix config
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeRNG committed Jun 12, 2023
1 parent 18c317c commit 891a7f5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/main/java/dev/dfonline/codeclient/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public static void writeFile(String fileName, String content) throws IOException

public static String readFile(String fileName, Charset charset) throws IOException {
return Files.readString(Path().resolve(fileName), charset);
}

public static boolean exists(String fileName) {
return Files.exists(Path().resolve(fileName));
}

/**
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/dev/dfonline/codeclient/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import dev.dfonline.codeclient.FileManager;
import dev.dfonline.codeclient.hypercube.actiondump.ActionDump;
import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.controller.*;
import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
import dev.isxander.yacl3.gui.controllers.cycling.EnumController;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

Expand Down Expand Up @@ -66,6 +70,9 @@ public static Config getConfig() {
catch (Exception exception) {
CodeClient.LOGGER.info("Config didn't load: " + exception);
instance = new Config();
if(FileManager.exists("options.json")) {
instance.save();
}
}
}
return instance;
Expand Down Expand Up @@ -105,7 +112,7 @@ public YetAnotherConfigLib getLibConfig() {
opt -> FileCharSet = opt
)
.flag(minecraftClient -> ActionDump.clear())
.controller(EnumControllerBuilder::create)
.controller(nodeOption -> () -> new EnumController<>(nodeOption, CharSetOption.class))
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Auto Fly"))
Expand Down Expand Up @@ -154,7 +161,7 @@ public YetAnotherConfigLib getLibConfig() {
.controller(opt -> IntegerSliderControllerBuilder.create(opt)
.range(0, 30)
.step(1))
// .build())
.build())
// .option(Option.createBuilder(boolean.class)
// .name(Text.literal("Air Control"))
// .description(OptionDescription.createBuilder()
Expand All @@ -166,7 +173,7 @@ public YetAnotherConfigLib getLibConfig() {
// opt -> AirControl = opt
// )
// .controller(TickBoxController::new)
.build())
// .build())
.build())
.group(OptionGroup.createBuilder()
.name(Text.literal("Interaction"))
Expand Down Expand Up @@ -224,6 +231,7 @@ public YetAnotherConfigLib getLibConfig() {
.controller(opt -> FloatSliderControllerBuilder.create(opt)
.range(5f, 10f)
.step(0.1f))
.available(false)
.build())
.option(Option.createBuilder(LayerInteractionMode.class)
.name(Text.literal("Layer Interaction"))
Expand All @@ -236,7 +244,7 @@ public YetAnotherConfigLib getLibConfig() {
() -> CodeLayerInteractionMode,
opt -> CodeLayerInteractionMode = opt
)
.controller(EnumControllerBuilder::create)
.controller(nodeOption -> () -> new EnumController<>(nodeOption, LayerInteractionMode.class))
.build())
.build())
.option(Option.createBuilder(boolean.class)
Expand Down Expand Up @@ -290,7 +298,7 @@ public YetAnotherConfigLib getLibConfig() {
() -> AutoNode,
opt -> AutoNode = opt
)
.controller(EnumControllerBuilder::create)
.controller(nodeOption -> () -> new EnumController<>(nodeOption, Node.class))
// .available(AutoJoin)
.build())
.option(Option.createBuilder(boolean.class)
Expand Down

0 comments on commit 891a7f5

Please sign in to comment.