Added ConfigEntry#needsRestart()

It prints a comment in the config telling that the server must be restarted in order to take the changes into account.
This commit is contained in:
Florian CUNY 2020-02-17 19:37:53 +01:00
parent f620601caa
commit 5cd2287d3a
2 changed files with 11 additions and 0 deletions

View File

@ -30,4 +30,11 @@ public @interface ConfigEntry {
* @since 1.5.3
*/
String video() default "";
/**
* Sets whether this config entry requires restarting the server in order to take changes into account.
* @return {@code true} if this config entry requires restarting the server in order to take changes into account, {@code false} otherwise.
* @since 1.12.0
*/
boolean needsRestart() default false;
}

View File

@ -518,6 +518,10 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
if (configEntry.needsReset()) {
setComment("/!\\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds.", config, yamlComments, parent);
}
// Tell if the configEntry needs the server to be restarted.
if (configEntry.needsRestart()) {
setComment("/!\\ In order to apply the changes made to this option, you must restart your server. Reloading BentoBox or the server won't work.", config, yamlComments, parent);
}
}
private void setComment(@NonNull String comment, @NonNull YamlConfiguration config, @NonNull Map<String, String> yamlComments, @NonNull String parent) {