Minor fixes

This commit is contained in:
Cameron Reed 2023-02-10 10:19:22 -07:00
parent 231c0e3b8f
commit d2ef12f718
3 changed files with 22 additions and 9 deletions

View File

@ -6,7 +6,7 @@ minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.13
# Mod Properties
mod_version=1.0.0
mod_version=1.0.1
maven_group=cmods
archives_base_name=cmods
# Dependencies

View File

@ -0,0 +1,17 @@
package cmods.cmods.api;
import org.jetbrains.annotations.Nullable;
public class PropertyUtils {
public static boolean getBooleanProperty(@Nullable java.util.Properties properties, String key, Boolean default_value) {
if (properties == null)
return default_value;
return Boolean.parseBoolean(properties.getProperty(key, default_value.toString()));
}
public static int getIntegerProperty(@Nullable java.util.Properties properties, String key, Integer default_value) {
if (properties == null)
return default_value;
return Integer.parseInt(properties.getProperty(key, default_value.toString()));
}
}

View File

@ -11,6 +11,8 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Properties;
import static cmods.cmods.api.PropertyUtils.getBooleanProperty;
public final class CmodsOptions {
private static CmodsOptions instance = null;
@ -82,12 +84,6 @@ public final class CmodsOptions {
}
}
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()));
}
public static class UIOptions {
private final String PREFIX = "ui.";
@ -100,8 +96,8 @@ public final class CmodsOptions {
void load(@Nullable Properties properties) {
enabled.value = getBooleanProperty(properties, PREFIX + "enabled", true);
show_coordinates.value = getBooleanProperty(properties, PREFIX + "show_coordinates", true);
enabled.value = getBooleanProperty(properties, PREFIX + "enabled", enabled.value);
show_coordinates.value = getBooleanProperty(properties, PREFIX + "show_coordinates", show_coordinates.value);
}
void save(Properties properties) {