25.8 C
New York
Friday, August 22, 2025

java – Having hassle making a ModGUIConfig with a customized class


I am engaged on a mod for 1.7.10 Forge that wants a posh config for the consumer to arrange, however solely the “basic” class reveals up (from Configuration.CATEGORY_GENERAL). That is how stuff’s being registered:

public class ModGUIConfig extends GuiConfig {
    public ModGUIConfig(GuiScreen guiScreen) {

        tremendous(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 ultimate String CATEGORY_FARMING = "Farming";

    personal static void loadConfiguration() {
      crop_workers = configuration.getInt("Farm Employees",
              CATEGORY_FARMING, 1, 1, 2048,
              "What number of staff ought to are likely to your crops. Must be stored low to protect recreation efficiency. " +
                      "[default: 1, min: 1, max: 2048]");

      seed_supplier = configuration.getString("Seed Provider", CATEGORY_FARMING, "greenthumb",
              "Which seed provider to attach get seeds from"
      );

      storage_barn = configuration.getString("Storage Barn", CATEGORY_FARMING,
              "MacDonalds",
              "Your crop storage barn");

      serverFeatures = configuration.getBoolean("Server Options", Configuration.CATEGORY_GENERAL, false,
              "Whether or not or not you need the server-side options of this mod, corresponding to:" +
                      "n Permitting gamers to commerce crops in-game" +
                      "n Permitting servers to execute instructions in trade for crops" +
                      "n Permitting servers to execute a command each time crops are harvested on the farm that the server is related to");

      commandOnHarvest = configuration.getString("Command on farm harvest", Configuration.CATEGORY_GENERAL, "",
              "Command to execute when crops are efficiently harvested on the farm that the SERVER is related to" +
                      "n This command will execute ANY TIME crops are harvested from the farm, which means that this could go off continuously when you're utilizing a                       in style provider");

      if(configuration.hasChanged()){
            configuration.save();
      }
  }
  
  public static Record getConfigElements() {
        loadConfiguration();
        ArrayList iConfigElements = new ArrayList();

        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 constructed, however the “Farming” class is empty, having no choices in it
​

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles