#Adding functionality or options to config.yml

1 messages · Page 1 of 1 (latest)

grave thistle
#

Imagine you are a server owner running HelloWorld v1.0 and in v1.0 there are some comments in it's config.yml file explaining how the plugin operates, as well as a configurable option that allows you to change the Hello message.

Now, imagine that the plugin developer for HelloWorld releases a version v1.1, this new version has a second line in its config.yml file that allows HelloWorld to give a player a specified block to a player that uses the command.

My question is, if the server owner only replaces the jar file for v1.0 with the jar for v1.1, then their config never changes and they don't have the option to specify the given block, SO, how, without having the server owner delete their config file, can you add more options to an existing config file?

The only options I have come across involve either a server owner losing their current configurations if they have changed anything from the default values, OR, losing all comments inside the file, I'm looking to see if anyone has a solution that will not necessitate either of those things.

earnest crest
#

You would need to write your own system for keeping the comments

#

The yaml spec does not include comments and they will be removed

dense crag
#

check if that certain new key in ur config exists

#

and if it is not then make it

grave thistle
#

@dense crag so basically during startup onEnable would have to run a method to check for each param in the config and if it cant find it, it just adds a specified string? this sounds like a good solution and i could totally do it, only thing i am concerned about it losing comments "##" inside of the document, would a method like this cause that?

dense crag
#

uhh

#

OH I KNOW HOW

#

make something like this

grave thistle
#

and if not what method(s) would you use for looking for the params, and adding them in if they dont exist?

dense crag
#

in ur config

#

Note: "this is my comment"

#

so make it as a key and value thing

#

this is what i would do if i cant find any other solution

grave thistle
#

Yeah i mean i COULD do that, what i dont understand are there are plugins out there eg: essentials that regularly change their configs and they change when you update their jar by themselves as opposed to having to delete them manually and let them regenerate

#

and the comments inside are not lost

#

so i feel like there is a way to accomplish it because others already have just need to find someone that knows 😒

dense crag
#

you couldve done the minimal amount of research and get it done, but instead you chose to act rude