-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
Reload configuration #370
Comments
Gonna work on this.
|
@SlimeDog Clarification question: is this a request for bentobox reload to reload the BentoBox plugin config, or try to reload all the addon configs as well? @Poslovitch The latter could be very difficult because addons load their configs independently and may not actually use the BentoBox config system, e.g., they just use the Bukkit config. I've tried to look at doing this before and I thought of adding an interface to the Addon class called "reload" that would be called by BentoBox when this command is executed so each addon can decide how to react. Some may not be able to do any reloading, some may. What do you think? If this request is just to have BentoBox reload a config itself, then this may be simpler. In regards to splitting config handling from the YAML database - what is your thinking there? We do already have a separate Config class that abstracts the underlying loading and saving. The reasons it uses the YAML database code is to avoid code duplication (YAML is YAML) and to enable comment preservation when saving configs. I'm open to better ways, but I'd like to understand why code reuse is not a good approach in this case. |
I would start with BentoBox/config.yml. That is the main one that is going to be changed for testing. |
I'll implement that optional reload method for Addons, so that they can handle their reload themselves. @tastybento Regarding splitting config handling from the YAML database... Well, code re-use is good, but the YAML saving/loading gets mixed up with config specific features which make the code harder to read. Maybe splitting the YAML methods in a few more methods so that we can override them at some point would be a more viable solution than code duplication... If I've got enough time today, I'll submit a PR so you can have a look at it. |
Related to #370. It is currently unused. Added Javadoc to #onEnable(), #onDisable(), #onLoad(), #onReload().
@Poslovitch Okay. |
Okay, I thought about it a bit and I wondered that we were saving the updated config when disabling BentoBox. What if we were actually doing that when enabling BentoBox? Basically, we'd save it just after loading it. And, thanks to how the database api works, the config would be updated. This way, we actually wouldn't have to save it when disabling BentoBox, therefore making the config actually editable when the server's running. @tastybento May I ask your opinion on my idea above? And do you confirm that "reloading" the config consists in loading the config when running the reload command? |
@Poslovitch Yes, what you say sounds correct. |
By the way, this is also good practice for addons, i.e., save the config immediately after loading it and do not save it again onDisable unless there's some reason for doing so. |
100% yes. |
I'll push the commit soon, I'm not a 100 % sure it's the correct handling. @tastybento Could you have a look? |
I could switch the default from en-US to ja-JP then back to en-US again. It looks like it worked fine. Committing! @tastybento Feel free to revert the commit and/or to fix it if it is causing critical bugs. From what I've tested, it's working fine, but we all know these good ol' bugs are pretty good at playing hide and seek. |
@Poslovitch Looks good! |
BentoBox 0.16.0 and previous
Please consider supporting /bentobox reload for configuration file. This would also require that configuration not be rewritten on shutdown. It would make configuration testing a lot easier.
The text was updated successfully, but these errors were encountered: