Config base

This commit is contained in:
nelle 2023-06-25 14:09:48 -06:00
parent 22733ed3f7
commit 76884b5259

View file

@ -0,0 +1,75 @@
/*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package xyz.limepot.roses_mod.config;
import com.mojang.datafixers.util.Pair;
import xyz.limepot.roses_mod.RosesMod;
public class ModConfigs {
public static SimpleConfig CONFIG;
private static ModConfigProvider configs;
public static boolean BUSH_RECIP;
/*
//EXAMPLES
public static String TEST;
public static int SOME_INT;
public static double SOME_DOUBLE;
public static int MAX_DAMAGE_DOWSING_ROD;
*/
public static void registerConfigs() {
configs = new ModConfigProvider();
createConfigs();
CONFIG = SimpleConfig.of(RosesMod.MOD_ID + "config").provider(configs).request();
assignConfigs();
}
private static void createConfigs() {
configs.addKeyValuePair(new Pair<>("bush.crafting.recipe.feature", true), "bool");
////EXAMPLES
//configs.addKeyValuePair(new Pair<>("key.test.value1", "Just a Testing string!"), "String");
//configs.addKeyValuePair(new Pair<>("key.test.value2", 50), "int");
//configs.addKeyValuePair(new Pair<>("key.test.value3", 4142.5), "double");
//configs.addKeyValuePair(new Pair<>("dowsing.rod.max.damage", 32), "int");
}
private static void assignConfigs() {
BUSH_RECIP = Boolean.parseBoolean(CONFIG.getOrDefault("bush.crafting.recipe.feature", "false"));
////EXAMPLES
//TEST = CONFIG.getOrDefault("key.test.value1", "Nothing");
//SOME_INT = CONFIG.getOrDefault("key.test.value2", 42);
//SOME_DOUBLE = CONFIG.getOrDefault("key.test.value3", 42.0d);
//MAX_DAMAGE_DOWSING_ROD = CONFIG.getOrDefault("dowsing.rod.max.damage", 32);
System.out.println("All " + configs.getConfigsList().size() + " have been set properly");
}
}