config: Add forRemoval option

This commit is contained in:
Oliver
2025-07-19 18:54:35 +02:00
parent 54bdda5990
commit a744e6e354
3 changed files with 17 additions and 0 deletions

View File

@@ -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)) {

View File

@@ -3,6 +3,7 @@ package com.fancyinnovations.config;
public record ConfigField<T>(
String path,
String description,
boolean forRemoval,
T defaultValue,
Class<T> type
) {