mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
config: Add forRemoval option
This commit is contained in:
@@ -71,6 +71,15 @@ public class Config {
|
||||
String path = entry.getKey();
|
||||
ConfigField<?> field = entry.getValue();
|
||||
|
||||
if (field.forRemoval()) {
|
||||
if (yaml.isSet(path)) {
|
||||
logger.debug("Removing path '" + path + "' from config");
|
||||
yaml.set(path, null);
|
||||
dirty = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (yaml.isSet(path)) {
|
||||
Object value = yaml.get(path);
|
||||
if (field.type().isInstance(value)) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.fancyinnovations.config;
|
||||
public record ConfigField<T>(
|
||||
String path,
|
||||
String description,
|
||||
boolean forRemoval,
|
||||
T defaultValue,
|
||||
Class<T> type
|
||||
) {
|
||||
|
||||
@@ -26,12 +26,14 @@ public final class FHConfiguration implements HologramConfiguration {
|
||||
MUTE_VERSION_NOTIFICATION_PATH,
|
||||
"Whether version notifications are muted.",
|
||||
false,
|
||||
false,
|
||||
Boolean.class
|
||||
));
|
||||
|
||||
config.addField(new ConfigField<>(
|
||||
ENABLE_AUTOSAVE_PATH,
|
||||
"Whether autosave is enabled.",
|
||||
false,
|
||||
true,
|
||||
Boolean.class
|
||||
));
|
||||
@@ -39,6 +41,7 @@ public final class FHConfiguration implements HologramConfiguration {
|
||||
config.addField(new ConfigField<>(
|
||||
AUTOSAVE_INTERVAL_PATH,
|
||||
"The interval at which autosave is performed in minutes.",
|
||||
false,
|
||||
15,
|
||||
Integer.class
|
||||
));
|
||||
@@ -46,6 +49,7 @@ public final class FHConfiguration implements HologramConfiguration {
|
||||
config.addField(new ConfigField<>(
|
||||
SAVE_ON_CHANGED_PATH,
|
||||
"Whether the plugin should save holograms when they are changed.",
|
||||
false,
|
||||
true,
|
||||
Boolean.class
|
||||
));
|
||||
@@ -53,6 +57,7 @@ public final class FHConfiguration implements HologramConfiguration {
|
||||
config.addField(new ConfigField<>(
|
||||
VISIBILITY_DISTANCE_PATH,
|
||||
"The default visibility distance for holograms.",
|
||||
false,
|
||||
20,
|
||||
Integer.class
|
||||
));
|
||||
@@ -60,6 +65,7 @@ public final class FHConfiguration implements HologramConfiguration {
|
||||
config.addField(new ConfigField<>(
|
||||
REGISTER_COMMANDS_PATH,
|
||||
"Whether the plugin should register its commands.",
|
||||
false,
|
||||
true,
|
||||
Boolean.class
|
||||
));
|
||||
@@ -67,6 +73,7 @@ public final class FHConfiguration implements HologramConfiguration {
|
||||
config.addField(new ConfigField<>(
|
||||
LOG_LEVEL_PATH,
|
||||
"The log level for the plugin (DEBUG, INFO, WARN, ERROR).",
|
||||
false,
|
||||
"INFO",
|
||||
String.class
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user