Jump to content

[SOLVED] [1.10.2] Questions about the new config system


Choonster

Recommended Posts

Is calling

ConfigManager.load

the correct way to save the config and inject the new values when

ConfigChangedEvent.OnConfigChangedEvent

is fired?

 

Is there any way to get a list of

ConfigCategory

or

IConfigElement

from the new config system for use with

GuiConfig

?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Hey choonster ^^

 

If you want to save something to your config when config changed event gets fired, you should compare the event modid with yours and in the if statement call the methods from your config class!

 

And if you want a list with your config categories, you could do something like this (if you meant that):

ArrayList<ConfigCategory> list=new ArrayList<ConfigCategory>();
for(String str:config.getCategoryNames())
	list.add(config.getCategory(str));

 

Maybe that should also work with your config elements!

 

Hope that helps ;D

Link to comment
Share on other sites

I'm asking about the config system added in this commit, which automatically creates the

Configuration

object and doesn't give you direct access to it.

 

This means you can't simply call

Configuration#get

for each property when changes have been made in the config GUI and you can't call

Configuration#getCategoryNames

to get a list of category names.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Why do you load your config this way now and no more as before?

You should have the ability to update values with properties!

Or do I misunderstand what?

Please tell me exactly what you need, because I misunderstand many things!

 

I updated to the new config system to test it out.

 

The new system automatically creates the

Configuration

instance when you annotate a class with

@Config

. Each public static field of this class is a property (if it's a primitive, primitive wrapper,

String

,

Map

or

Enum

) or sub-category (if it's a custom class that directly extends

Object

).

 

You can annotate these fields with the sub-annotations of

@Config

to set the language key, comment or numeric range of the property.

 

ConfigManager

creates the properties and categories for you, you don't call any methods of

Configuration

yourself.

 

The difficulty is that

GuiConfig

still expects you to have access to the

Configuration

instance so you can create the

IConfigElement

s from the properties and categories; but

ConfigManager

doesn't give you this access without resorting to reflection.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.