I'm working on a mod for 1.7.10 Forge that needs a complex config for the user to set up, but only the "general" category shows up (from Configuration.CATEGORY_GENERAL
). This is how stuff's being registered:
public class ModGUIConfig extends GuiConfig {
public ModGUIConfig(GuiScreen guiScreen) {
super(guiScreen,
ConfigurationHandler.getConfigElements(),
Reference.MOD_ID,
true,
true,
GuiConfig.getAbridgedConfigPath(ConfigurationHandler.getConfiguration().toString()));
}
}
public class ConfigurationHandler {
public static void init(String configDir) {
if(configDir != null) {
File path = new File(configDir + "/" + Reference.MOD_ID + ".cfg");
configuration = new Configuration(path);
loadConfiguration();
}else{
configDir = "/config";
}
}
public static int crop_workers = 1;
public static String seed_supplier = "greenthumb";
public static String storage_barn = "MacDonalds";
public static boolean serverFeatures = false;
public static String commandOnHarvest = "";
public static final String CATEGORY_FARMING = "Farming";
private static void loadConfiguration() {
crop_workers = configuration.getInt("Farm Workers",
CATEGORY_FARMING, 1, 1, 2048,
"How many workers should tend to your crops. Should be kept low to preserve game performance. " +
"[default: 1, min: 1, max: 2048]");
seed_supplier = configuration.getString("Seed Supplier", CATEGORY_FARMING, "greenthumb",
"Which seed supplier to connect get seeds from"
);
storage_barn = configuration.getString("Storage Barn", CATEGORY_FARMING,
"MacDonalds",
"Your crop storage barn");
serverFeatures = configuration.getBoolean("Server Features", Configuration.CATEGORY_GENERAL, false,
"Whether or not you want the server-side features of this mod, such as:" +
"\n Allowing players to trade crops in-game" +
"\n Allowing servers to execute commands in exchange for crops" +
"\n Allowing servers to execute a command every time crops are harvested on the farm that the server is connected to");
commandOnHarvest = configuration.getString("Command on farm harvest", Configuration.CATEGORY_GENERAL, "",
"Command to execute when crops are successfully harvested on the farm that the SERVER is connected to" +
"\n This command will execute ANY TIME crops are harvested from the farm, meaning that this can go off constantly if you're using a popular supplier");
if(configuration.hasChanged()){
configuration.save();
}
}
public static List<IConfigElement> getConfigElements() {
loadConfiguration();
ArrayList<IConfigElement> iConfigElements = new ArrayList<IConfigElement>();
iConfigElements.add(new ConfigElement(ConfigurationHandler.getConfiguration().getCategory(ConfigurationHandler.CATEGORY_FARMING)));
iConfigElements.add(new ConfigElement(ConfigurationHandler.getConfiguration().getCategory(Configuration.CATEGORY_GENERAL)));
//System.out.println(""+iConfigElements.toString());
return iConfigElements;
}
}
The GUI is built, but the "Farming" category is empty, having no options in it
1 Answer 1
Turns out that category names must be lowercase, the issue was fixed by changing:
public static final String CATEGORY_FARMING = "Farming";
to:
public static final String CATEGORY_FARMING = "farming";