Minor fixes

This commit is contained in:
Cameron Reed 2023-02-10 10:29:10 -07:00
parent 0d56349c53
commit 93884ec751
4 changed files with 8 additions and 32 deletions

View File

@ -26,7 +26,7 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation files("libs/cmods-1.0.0-dev.jar")
modImplementation files("libs/cmods-1.0.1-dev.jar")
modCompileOnly "com.terraformersmc:modmenu:4.1.1"
}

View File

@ -6,7 +6,7 @@ minecraft_version=1.19.3
yarn_mappings=1.19.3+build.2
loader_version=0.14.13
# Mod Properties
mod_version=2.0.0
mod_version=2.0.1
maven_group=cmods
archives_base_name=haxxor
# Dependencies

View File

@ -2,24 +2,20 @@ package cmods.haxxor.client.options;
import cmods.cmods.api.ModuleOptions;
import cmods.cmods.client.options.BooleanOption;
import cmods.cmods.client.options.CmodsOptions;
import cmods.cmods.client.options.IntegerOption;
import cmods.haxxor.client.AutoFarmer;
import net.fabricmc.loader.api.FabricLoader;
import org.jetbrains.annotations.Nullable;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Properties;
import static cmods.cmods.api.PropertyUtils.getBooleanProperty;
import static cmods.cmods.api.PropertyUtils.getIntegerProperty;
public final class HaxxorOptions extends ModuleOptions {
private static HaxxorOptions instance = null;
private static final String MODULE_PREFIX = "haxxor.";
private final Path properties_file = FabricLoader.getInstance().getConfigDir().resolve("Haxxor.properties");
public final AutoFarmerOptions autoFarmer;
public final UIOptions uiOptions;
@ -30,7 +26,6 @@ public final class HaxxorOptions extends ModuleOptions {
public static HaxxorOptions getInstance() {
if (instance == null) {
instance = new HaxxorOptions();
CmodsOptions.addOptions(instance);
}
return instance;
@ -57,27 +52,8 @@ public final class HaxxorOptions extends ModuleOptions {
// Top level properties
properties.setProperty("cancel_fall_damage", cancelFallDamage.value.toString());
try {
properties.store(new FileWriter(properties_file.toFile()), "Haxxor Properties");
} catch (IOException e) {
System.out.println("[Haxxor]: Failed to save properties");
}
}
private static boolean getBooleanProperty(@Nullable Properties properties, String key, Boolean default_value) {
if (properties == null)
return default_value;
return Boolean.parseBoolean(properties.getProperty(key, default_value.toString()));
}
private static int getIntegerProperty(@Nullable Properties properties, String key, Integer default_value) {
if (properties == null)
return default_value;
return Integer.parseInt(properties.getProperty(key, default_value.toString()));
}
public static class AutoFarmerOptions {
private final String PREFIX = MODULE_PREFIX + "auto_farmer.";
@ -155,8 +131,8 @@ public final class HaxxorOptions extends ModuleOptions {
private void load(@Nullable Properties properties) {
show_auto_farmer.value = getBooleanProperty(properties, PREFIX + "show_auto_farmer", true);
show_fly_hack.value = getBooleanProperty(properties, PREFIX + "show_fly_hack", true);
show_auto_farmer.value = getBooleanProperty(properties, PREFIX + "show_auto_farmer", show_auto_farmer.value);
show_fly_hack.value = getBooleanProperty(properties, PREFIX + "show_fly_hack", show_fly_hack.value);
}
private void save(Properties properties) {

View File

@ -24,6 +24,6 @@
"fabricloader": ">=0.14.11",
"fabric": "*",
"minecraft": "1.19.3",
"cmods": "1.0.0"
"cmods": "1.0.1"
}
}