mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-05 23:33: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
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user