Minor fixes
This commit is contained in:
parent
231c0e3b8f
commit
d2ef12f718
@ -6,7 +6,7 @@ minecraft_version=1.19.3
|
|||||||
yarn_mappings=1.19.3+build.5
|
yarn_mappings=1.19.3+build.5
|
||||||
loader_version=0.14.13
|
loader_version=0.14.13
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.0.0
|
mod_version=1.0.1
|
||||||
maven_group=cmods
|
maven_group=cmods
|
||||||
archives_base_name=cmods
|
archives_base_name=cmods
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
17
src/main/java/cmods/cmods/api/PropertyUtils.java
Normal file
17
src/main/java/cmods/cmods/api/PropertyUtils.java
Normal 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()));
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,8 @@ import java.nio.file.Path;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static cmods.cmods.api.PropertyUtils.getBooleanProperty;
|
||||||
|
|
||||||
public final class CmodsOptions {
|
public final class CmodsOptions {
|
||||||
private static CmodsOptions instance = null;
|
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 {
|
public static class UIOptions {
|
||||||
private final String PREFIX = "ui.";
|
private final String PREFIX = "ui.";
|
||||||
@ -100,8 +96,8 @@ public final class CmodsOptions {
|
|||||||
|
|
||||||
|
|
||||||
void load(@Nullable Properties properties) {
|
void load(@Nullable Properties properties) {
|
||||||
enabled.value = getBooleanProperty(properties, PREFIX + "enabled", true);
|
enabled.value = getBooleanProperty(properties, PREFIX + "enabled", enabled.value);
|
||||||
show_coordinates.value = getBooleanProperty(properties, PREFIX + "show_coordinates", true);
|
show_coordinates.value = getBooleanProperty(properties, PREFIX + "show_coordinates", show_coordinates.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void save(Properties properties) {
|
void save(Properties properties) {
|
||||||
|
Loading…
Reference in New Issue
Block a user