From c9d95b69af16e262ba74da992becd7c80bc4175a Mon Sep 17 00:00:00 2001 From: alexcrea <42614139+alexcrea@users.noreply.github.com> Date: Sun, 27 Apr 2025 20:00:41 +0200 Subject: [PATCH] write correctly group on the api --- .../alexcrea/cuanvil/api/MaterialGroupApi.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/MaterialGroupApi.java b/src/main/java/xyz/alexcrea/cuanvil/api/MaterialGroupApi.java index 250f797..48dd500 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/MaterialGroupApi.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/MaterialGroupApi.java @@ -105,7 +105,9 @@ public class MaterialGroupApi { if (group instanceof IncludeGroup includeGroup) { changed = writeKnownGroup("include", includeGroup); } else if (group instanceof ExcludeGroup excludeGroup) { - changed = writeKnownGroup("exclude", excludeGroup); + throw new UnsupportedOperationException("exclude group is temporarily disable for the time being. sorry"); + // This code do not do what is intended ? idk why do it exist + //changed = writeKnownGroup("exclude", excludeGroup); } else { changed = writeUnknownGroup(group); } @@ -124,13 +126,24 @@ public class MaterialGroupApi { Set materialSet = group.getNonGroupInheritedMaterials(); Set groupSet = group.getGroups(); + boolean empty = true; if (!materialSet.isEmpty()) { config.set(basePath + ItemGroupManager.MATERIAL_LIST_PATH, materialSetToStringList(materialSet)); + empty = false; + } else { + config.set(basePath + ItemGroupManager.MATERIAL_LIST_PATH, null); } if (!groupSet.isEmpty()) { config.set(basePath + ItemGroupManager.GROUP_LIST_PATH, materialGroupSetToStringList(groupSet)); + empty = false; + } else { + config.set(basePath + ItemGroupManager.GROUP_LIST_PATH, null); + } + + if (empty) { + config.set(basePath + ItemGroupManager.GROUP_TYPE_PATH, null); + return false; } - if (!config.isConfigurationSection(group.getName())) return false; config.set(basePath + ItemGroupManager.GROUP_TYPE_PATH, groupType); return true;