Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type [Ljava.lang.String; Correct class is String[] #4

Open
kiriharu opened this issue Sep 22, 2021 · 0 comments
Open

Incorrect type [Ljava.lang.String; Correct class is String[] #4

kiriharu opened this issue Sep 22, 2021 · 0 comments

Comments

@kiriharu
Copy link

When I'm trying to get array from my config I'm get strange error:

Caused by: java.lang.IllegalArgumentException: Incorrect type [Ljava.lang.String; for autoMessage.messages. Correct class is String[]
	at com.oroarmor.config.Config.getValue(Config.java:135) ~[oro-config-common-3.1.0-dev.jar:?]
	at ru.kiriharu.catessentials.CatEssentials.initializeAutoMessage(CatEssentials.java:28) ~[main/:?]
	at ru.kiriharu.catessentials.CatEssentials.onInitializeServer(CatEssentials.java:40) ~[main/:?]
	at net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointUtils.invoke0(EntrypointUtils.java:47) ~[fabric-loader-0.11.7.jar:?]
	... 11 more

Code:

AutoMessageConfig class

public class AutoMessageConfig extends ConfigItemGroup {

    public AutoMessageConfig() {
        super(of(isEnabled, messages), "autoMessage");
    }

    public static final BooleanConfigItem isEnabled = new BooleanConfigItem(
            "isEnabled", true, "Enable automessage?"
    );
    public static final ArrayConfigItem<String> messages = new ArrayConfigItem<String>(
            "messages",
            new String[]{"Change default message in config"},
            "test_array"
    );
}

Code for getting value from config:

String[] messages = CONFIG.getValue("autoMessage.messages", String[].class);

Maybe I make something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant