In my GitHub repository, GitHub - EliterScripts/AnnouncerPlus: AnnouncerPlus, an Announcer plugin for the Sponge plugin minecraft framework , I am having an issue that I think is in the ConfigManager class file. More specifically, I think it is an issue in the Sort method. I do believe that it is possible that I am not using the getChildrenMap incorrectly. I want to load the config file on start up, to load the messages list. That process takes the messages and puts it into an ArrayList. The sloppy draft of how I want the config to be is: http://pastebin.com/p82HizHc
I think it is possible that you are not using the other things correctly. For instance:
if (value.getNode("message").getValue().equals(Text.class) ){
This would very rarely work, and it is most definitely not what you are tryinig to do.
First of all, .equals()
means, well, equals. What you are looking for is this statement:
if (value.getNode("message").getValue() instanceof Text)) {
But, however, this is not how Configurate works. You can’t just get a Text object like that, you need a TypeToken.
value.getNode("message").getValue(TypeToken.of(Text.class))
And a final note about the config: Similar to Java, brackets []
indicate lists and braces {}
indicate objects.
This would be a mock-up of the config you are trying to create: http://pastebin.com/EQXpU9jW
However, you appear to be not using the keys for each message. Why not use a list instead of an object, and change getChildrenMap() to getChildrenList(), as in this example http://pastebin.com/hg28hJKv?
For that matter, why do you use a separate sub-object? Why not just structure it like this?
Firstly, line 116 in ConfigManager won’t run at all (just a method for using the logger to warn, with an error code; see MainPluginFile). This means that the for loop never even starts. Why?
Also, I put together the configure file structure in 5 secs, so it was a really rough sketch of how I wanted things to go.
It doesn’t run because the line above it (for( CommentedConfigurationNode value : chilMap.values() )
) didn’t find anything in chilMap.values()… probably because it’s empty!
Usually you would see if an entry exists, and then if it doesn’t create an entry, and then save the file when your done.
Otherwise, it’s looking decent @Eliter
How would creating an entry work?
EDIT: OH! You’re talking about the actual configuration. I’m talking about the actual initial processing of the configuration file.
I don’t understand.
It is… a little foggy. Did you find a solution in the IRC yesterday @Eliter, or are you still having issues?