-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Rework plugin config system #596
Conversation
...bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/config/ConfigGenerator.java
Outdated
Show resolved
Hide resolved
Hmm, the general system works perfectly, however there are issues when dealing with the lists for the config options that are used to convert commands. Converting this PR to a draft until fixed. |
I wonder if there is a general library (maybe not even Minecraft specific) for updating and loading commented YAML configurations. That could help create a more generic system that would also work for CommandAPIVelocity, and it would be probably already be well tested and reliable. |
Maybe Configurate could work, though I haven't used it before, only heard of it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to implement this system for Velocity as well before merging. With #517, the default Bukkit config will eventually need to be split Spigot/Paper for the hook-paper-reload
option. Having a system now that can deal with the shared options between Bukkit/Velocity would be nice for implementing the Spigot/Paper split later.
Additionally, it would be nice to see some automated tests for the config updating logic. With the YamlConfiguration#loadFromString
and YamlConfiguration#saveToString
methods, I imagine these tests could look something like:
String currentString;
YamlConfiguration currentConfig = YamlConfiguration.loadFromString(currentString);
YamlConfiguration updatedConfig = ConfigGenerator.generateWithNewValues(currentConfig);
String updatedString = updatedConfig.saveToString();
assertEquals(expectedString, updatedString);
Tests could include making sure new config options are added, extra config options are removed, options set by the user are carried over, comments are updated separately from values, etc.
Putting both these ideas together, writing tests could be easier if ConfigGenerator
was able to do more than just generate the default Bukkit config. Each test could pass in its own custom small set of config options, which would mean expectedString
wouldn't need to hold the whole Bukkit config.yml
every time.
...bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/config/ConfigGenerator.java
Outdated
Show resolved
Hide resolved
...bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/config/ConfigGenerator.java
Outdated
Show resolved
Hide resolved
...bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/config/ConfigGenerator.java
Outdated
Show resolved
Hide resolved
...bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/config/ConfigGenerator.java
Outdated
Show resolved
Hide resolved
7a2c6bd
to
4a36b1e
Compare
667a533
to
3444387
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't really looked too deep into how the code works, but it looks good. I just highlighted some inconsistency
commandapi-core/src/main/java/dev/jorel/commandapi/config/DefaultedConfig.java
Outdated
Show resolved
Hide resolved
.../commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/config/DefaultedBukkitConfig.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another miscellaneous thing I noticed while testing that didn't fit anywhere else. If I have a config that looks like this:
Once running the server the config gets updated to this:
This doesn't seem like a big deal since - Essentials: null
seems to be interpreted the same, but I thought I'd bring it up.
Automated tests might've caught some of the things I brought up, and perhaps more that I missed.
commandapi-core/src/main/java/dev/jorel/commandapi/config/CommentedSection.java
Outdated
Show resolved
Hide resolved
commandapi-core/src/main/java/dev/jorel/commandapi/config/ConfigGenerator.java
Outdated
Show resolved
Hide resolved
commandapi-core/src/main/java/dev/jorel/commandapi/config/ConfigGenerator.java
Outdated
Show resolved
Hide resolved
commandapi-core/src/main/java/dev/jorel/commandapi/config/ConfigGenerator.java
Outdated
Show resolved
Hide resolved
commandapi-core/src/main/java/dev/jorel/commandapi/config/ConfigGenerator.java
Outdated
Show resolved
Hide resolved
...ommandapi-bukkit-plugin-mojang-mapped/src/main/java/dev/jorel/commandapi/CommandAPIMain.java
Show resolved
Hide resolved
...-velocity-plugin/src/main/java/dev/jorel/commandapi/config/VelocityConfigurationAdapter.java
Outdated
Show resolved
Hide resolved
...-velocity-plugin/src/main/java/dev/jorel/commandapi/config/VelocityConfigurationAdapter.java
Outdated
Show resolved
Hide resolved
...-velocity-plugin/src/main/java/dev/jorel/commandapi/config/VelocityConfigurationAdapter.java
Outdated
Show resolved
Hide resolved
...-velocity-plugin/src/main/java/dev/jorel/commandapi/config/VelocityConfigurationAdapter.java
Outdated
Show resolved
Hide resolved
4bb5e0b
to
d2e5148
Compare
c7db0d5
to
677d545
Compare
This doesn't happen anymore since the included config.yml files were deleted.
This could also help with further rewriting to aid development for multiple platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality seems good, so just some comments on code logic and organization.
I still think it would be good to get some unit tests to make sure all code paths and edge cases are verified.
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-plugin-common/pom.xml
Show resolved
Hide resolved
...kkit-plugin-common/src/main/java/dev/jorel/commandapi/config/BukkitConfigurationAdapter.java
Show resolved
Hide resolved
...kkit-plugin-common/src/main/java/dev/jorel/commandapi/config/BukkitConfigurationAdapter.java
Show resolved
Hide resolved
...kkit-plugin-common/src/main/java/dev/jorel/commandapi/config/BukkitConfigurationAdapter.java
Outdated
Show resolved
Hide resolved
...kkit-plugin-common/src/main/java/dev/jorel/commandapi/config/BukkitConfigurationAdapter.java
Outdated
Show resolved
Hide resolved
...-velocity-plugin/src/main/java/dev/jorel/commandapi/config/VelocityConfigurationAdapter.java
Show resolved
Hide resolved
...-velocity-plugin/src/main/java/dev/jorel/commandapi/config/VelocityConfigurationAdapter.java
Outdated
Show resolved
Hide resolved
...-velocity-plugin/src/main/java/dev/jorel/commandapi/config/VelocityConfigurationAdapter.java
Outdated
Show resolved
Hide resolved
commandapi-plugin/src/main/java/dev/jorel/commandapi/config/ConfigGenerator.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suprise merge lol, didn't realize we needed to merge this soon.
None of these are big issues, but I would have preferred a third opinion on a few conversations: #596 (comment), #596 (comment), #596 (comment), and unit tests. When I have my own idea of how I would implement a system, its hard for me to tell if these are real concerns or just silly me problems :P.
Just an idea I had, can be merged if good and wanted, but can also be closed.
The advantage of this system is that updating the config is possible. New values can be added and user configs that already exist get the new values. Furthermore, this system would also allow removing values if they are no longer needed, if that ever happens.