Jump to content

[1.12.2] Custom classes in config array


jasonhaxstuff

Recommended Posts

It might be best if I show you my logical thinking when creating the configuration class for my mod.

 

@Config(modid = Notifs.MODID, name = "Notifications")
public class NotifsConfig {
    @Config.Name("Blacklist")
    @Config.Comment("A list of phrases to blacklist.")
    public static String[] blacklist = {};

    @Config.Name("Urls")
    @Config.Comment("The list of URLs to send phrases to.")
    public static Url[] URLs = {};

    class Url {
        @Config.Name("Urls")
        @Config.Comment("The URL(s).")
        public String[] URLs = {};

        @Config.Name("Phrases")
        @Config.Comment("The list of phrases to send notifications for.")
        public String[] Phrases = {};
    }
}

 

For some reason, whenever I click on the "URLs" button in the configurator, there is no option to add new objects or anything.

Is there any way that I could circumvent this?

Edited by jasonhaxstuff
Link to comment
Share on other sites

I have come up with a janky solution to my problem. I won't mark this as solved as I would really prefer to use what I had in my previous post.

 

@Config(modid = MODID, name = "notifications")
public class NotifsConfig {
    @Config.Name("URLs")
    @Config.Comment("The list of phrases to send notifications for (separate with commas).")
    public static URLs = {};

    @Config.Name("Phrases")
    @Config.Comment("The list of phrases to send notifications for (separate with commas).")
    public static Phrases = {};
    
    @Config.Name("Blacklist")
    @Config.Comment("A list of phrases to blacklist from sending to the URLs (separate with commas).")
    public static Blacklist = {};

}

 

Basically, I use the index of the current URL(s) that I'm checking to link them to the items at those same indexes in the Phrases and Blacklist arrays. To make them 2D arrays, I just split them with (escapable) commas.

Edited by jasonhaxstuff
This forum has some odd formatting
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.