Fixes a bug when checking if a config key is a comment
All checks were successful
KnarCraft/KnarLib/pipeline/head This commit looks good

This commit is contained in:
2025-09-05 22:13:31 +02:00
parent 6dffb7a784
commit 368d6e9128

View File

@@ -81,6 +81,16 @@ public class StargateYamlConfiguration extends YamlConfiguration {
}
}
/**
* Checks whether the given configuration key is a comment
*
* @param key <p>The configuration key to check</p>
* @return <p>True if the configuration key is a comment</p>
*/
public static boolean isComment(@NotNull String key) {
return key.matches(".*" + START_OF_COMMENT + "[0-9]+");
}
/**
* Saves the given configuration
*
@@ -107,7 +117,7 @@ public class StargateYamlConfiguration extends YamlConfiguration {
*/
public static Set<String> getKeysWithoutComments(@NotNull ConfigurationSection configurationSection, boolean deep) {
Set<String> keys = new HashSet<>(configurationSection.getKeys(deep));
keys.removeIf(key -> key.matches(START_OF_COMMENT + "[0-9]+"));
keys.removeIf(StargateYamlConfiguration::isComment);
return keys;
}