Hey there folks, Got a situation going on over there. So when i’m creating the default config file in a config manager…first off all i’d like to get rid of the ("") around the nodes so on In the config it’ll say Hi = How are you?..instead of “Hi” = “blahabalj”
second…how would I go about adding Color to the configuration file? i understand how the text builder and send message work buy neither work for nodes…is there a way around this? or is there another Method I’m unaware of in this Amazing API? Thank you in advance and I hope to hear from individuals soon.
After all if I can get this block out of the way my next step is to combine several plugins i’ve already created and make them into one large one… thus the need for an organised Config system.
Aside from using legacy codes like “&”, you could use
Texts.json().from(String) to read in a raw message using this format: http://minecraft.gamepedia.com/Commands#Raw_JSON_text
ok so that deals with the color…but how do i get rid of the ""s? lol
There’s no way to consistently remove the quotations from around strings - even keys.
It’s not necessary while writing a configuration file to include them, because Configurate is fairly intelligent and can parse it. However, while the configuration is being created (by the utility), quotations will always surround a string value.
okay so maybe i didn’t reinterate the quotations are showing up in the actual configuration file…i understand that the strings reqluire them…but why are they showing up in the config?
The strings are in the config. Perhaps what you mean to ask is why quotations are put around the node keys (I am not sure if that is happening or how to solve it)?
ok so in bukkit after you type “string” what appears in the configure is STRING lol no quotes that’s what i’m trying to do is that possible?
No. As @FerusGrim stated, the utility used to create HOCON files will always surround strings with quotations. There is no way around it. HOCON and YAML (bukkit preferred config format) are not the same. My question is why is this a problem? Is it a cosmetic thing?
yup just cosmetic but if it could be fixed i’d have liked it thank you trentech and everyone
Perhaps you do not understand the reasoning behind quotations. Here’s a link to what qualifies a sequence of characters as a String value when unquoted.
oh my! that was informative
If you have any questions left, be sure to drop them here so we can help. Although if not, and your original question has been answered, would you mind marking this thread as solved (edit title, then prefix it with [SOLVED])?
thanks, i’ve been trying to figure out how to add a solved to this thread thank you
OK so none of that is working…here’s what my text is actually || now everything withing “” is for some reason coming out in the actual config with those “”…i do not want that to happen can someone give me an example on how to change that?
config.getNode(“MOTD: “).setComment(” The MOTD Message.”).setValue(" " + “Welcome to my Server.”);
config.getNode("Individuals: ", “Steven: “).setComment(” This is What Steven likes”).setValue(“Where the Hell is my TANK!?”);
config.getNode("Individuals: ", “Christopher: “).setComment(” This is What Chris Likes”).setValue(“Hmm That’s a Nice Everything you have there.”);
config.getNode("Individuals: ", "Brandon: ").setComment(“This is What Brandon thinks”).setValue(“Hello!”);
config.getNode("Individuals: ", "Nubs: ").setComment(“This is what Steven would like to say”).setValue(“Oh, my Gosh GUY!”);
Not to say that they’re necessarily unsupported (I haven’t checked), but why are you using colons?
As @FerusGrim pointed out, it is unnecessary to explicitly input colons. That may be why some of your nodes are encapsulated in quotes because the “:” character would be illegal.
At the same time, if your node is
myNode then retrieving it via
config.getNode("myNode:").<some method call> (ie: #getString(…)) would NOT yield a value as the specified node would not be the same since
myNode != (isn’t equal to)
myNode: (note the colon on the second one).
Also, don’t bother with the spaces, so instead of
"myNode: " you should be doing “myNode” just straight up. Configurate (the API you’re using to interact with HOCON formatted files) will take care of formatting and parsing in a HOCON compliant manner.
Also, if you don’t prefer to hardcode the default values and nodes, you can actually just type up a default config, put it in your JAR outside of any directories (unless that is the desired structure you want- but it will require a different way of finding the resource inside of the JAR. Also, if using maven or gradle, put it under
A default config can be named anything you want, although if only using 1 then I’d recommend just naming it
config.conf). You can then have the default
<config name>.conf file be copied from your JAR to the configuration folder. An example of doing something such as that can be found in my resource here: [Resource] HoconFile (not saying you have to use it, just something you might be able to learn off of).
If you didn’t quite understand something I mentioned, please do let me know and I can explain it in more detail, using different terms and/or using different examples with more code snippets.
EDIT 24/09/2015 @ 11:38pm EST
I would also recommend familiarizing yourself with the file format you’re attempting to use (in this case HOCON) as understanding at least some of the basics of how the file is formatted/structured will help you greatly in understanding why issues arise with your configuration.
EDIT 25/09/2015 @ 7:36pm EST
Cleaned up some typos/grammar errors. Also rephrased/elaborated/added detail to some lines to hopefully make it easier to follow.
yes I’ve never used HOCON before and So I’ve been trying to figure out a way to use it lol since I make everything my Plugins can do configurable…thank you i’ll see if that works
ok so that took the “” off off my nodes…so now how would i configure the configuration through the programming? like is there a new line command etc?
Glad to hear!
I would recommend going through the documentation here: https://docs.spongepowered.org/en/plugin/configuration/index.html
These are the related pages that will cover the basics of using Configurate to create, manage, and manipulate HOCON compliant files.
If you have any questions about the documentation linked, I’d be more than willing to help out