config file
This commit is contained in:
@@ -9,10 +9,16 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import nmd.primal.core.common.PrimalCore;
|
||||
import nmd.primal.forgecraft.compat.ModDictionary;
|
||||
import nmd.primal.forgecraft.gui.GuiHandler;
|
||||
import nmd.primal.forgecraft.init.*;
|
||||
import nmd.primal.forgecraft.proxy.CommonProxy;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
|
||||
//import nmd.primal.forgecraft.common.init.*;
|
||||
|
||||
@@ -31,15 +37,22 @@ public class ForgeCraft
|
||||
public static SimpleNetworkWrapper NETWORK;
|
||||
@SidedProxy(clientSide = ModInfo.CLIENT_PROXY, serverSide = ModInfo.SERVER_PROXY)
|
||||
public static CommonProxy proxy;
|
||||
public static Logger LOGGER = LogManager.getLogger(ModInfo.MOD_ID);
|
||||
private static File CONFIG_FILE;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
LOGGER.info("Pre-Init");
|
||||
LOGGER.info("Debug Level: " + ModConfig.DEBUG_LEVEL);
|
||||
|
||||
CONFIG_FILE = new File(PrimalCore.getConfigDirectory(), ModInfo.MOD_ID + ".cfg");
|
||||
LOGGER.info("Loading Config File: " + CONFIG_FILE);
|
||||
ModConfig.init(CONFIG_FILE);
|
||||
|
||||
NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(ModInfo.MOD_CHANNEL);
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
|
||||
|
||||
|
||||
ModBlocks.init();
|
||||
ModBlocks.register();
|
||||
ModItems.init();
|
||||
@@ -56,6 +69,8 @@ public class ForgeCraft
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
LOGGER.info("Init");
|
||||
|
||||
//this.proxy.init(event);
|
||||
proxy.init();
|
||||
ModDictionary.registerDictionaryNames();
|
||||
@@ -67,6 +82,8 @@ public class ForgeCraft
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
LOGGER.info("Post-Init");
|
||||
|
||||
//this.proxy.postInit(event);
|
||||
}
|
||||
|
||||
|
||||
60
1.11/src/main/java/nmd/primal/forgecraft/init/ModConfig.java
Normal file
60
1.11/src/main/java/nmd/primal/forgecraft/init/ModConfig.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package nmd.primal.forgecraft.init;
|
||||
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ModConfig
|
||||
{
|
||||
// ************************************************************************ //
|
||||
// development
|
||||
// ************************************************************************ //
|
||||
public static int DEBUG_LEVEL;
|
||||
|
||||
// ************************************************************************ //
|
||||
// init config defaults
|
||||
// ************************************************************************ //
|
||||
public static void init(File configFile)
|
||||
{
|
||||
// you will be able to find the config file in .minecraft/config/ and it will be named "modname".cfg
|
||||
// here our Configuration has been instantiated, and saved under the name "config"
|
||||
Configuration config = new Configuration(configFile);
|
||||
|
||||
// loading the configuration from its file
|
||||
config.load();
|
||||
|
||||
//
|
||||
// features
|
||||
//
|
||||
//String features_title = "feature hooks";
|
||||
//ConfigCategory featuresCategory = config.getCategory(features_title);
|
||||
//featuresCategory.setComment("Hooks for controlling various aspects of the mod");
|
||||
|
||||
//
|
||||
// crafting
|
||||
//
|
||||
//String crafting_title = "crafting control";
|
||||
//ConfigCategory craftingCategory = config.getCategory(crafting_title);
|
||||
//craftingCategory.setComment("Control over Crafting");
|
||||
|
||||
//
|
||||
// dev and debugging
|
||||
//
|
||||
String debug_title = "debug settings";
|
||||
ConfigCategory settingCategory = config.getCategory(debug_title);
|
||||
settingCategory.setComment("Options useful for debugging and server operators");
|
||||
|
||||
Property dev_debug_level = config.get(debug_title, "DEBUG_LEVEL", 0);
|
||||
dev_debug_level.setComment("Debug level, by default a zero value disables debug features.");
|
||||
DEBUG_LEVEL = dev_debug_level.getInt(0);
|
||||
|
||||
// ************************************************************************ //
|
||||
// save config
|
||||
// ************************************************************************ //
|
||||
if(config.hasChanged()) {
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user