Made material group api remove return if success

This commit is contained in:
alexcrea 2024-11-16 23:19:12 +01:00
parent b0f695e0ed
commit 94677b58ff
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F

View file

@ -125,7 +125,7 @@ public class MaterialGroupApi {
config.set(basePath + ItemGroupManager.MATERIAL_LIST_PATH, materialSetToStringList(materialSet)); config.set(basePath + ItemGroupManager.MATERIAL_LIST_PATH, materialSetToStringList(materialSet));
} }
if(!groupSet.isEmpty()){ if(!groupSet.isEmpty()){
config.set(basePath + ItemGroupManager.GROUP_LIST_PATH, materialGroupSEtToStringList(groupSet)); config.set(basePath + ItemGroupManager.GROUP_LIST_PATH, materialGroupSetToStringList(groupSet));
} }
} }
@ -147,7 +147,7 @@ public class MaterialGroupApi {
return materials.stream().map(material -> material.getKey().getKey().toLowerCase()).toList(); return materials.stream().map(material -> material.getKey().getKey().toLowerCase()).toList();
} }
public static List<String> materialGroupSEtToStringList(@NotNull Set<AbstractMaterialGroup> groups){ public static List<String> materialGroupSetToStringList(@NotNull Set<AbstractMaterialGroup> groups){
return groups.stream().map(AbstractMaterialGroup::getName).toList(); return groups.stream().map(AbstractMaterialGroup::getName).toList();
} }
@ -157,11 +157,12 @@ public class MaterialGroupApi {
* For that reason, it is not recommended to use this function. * For that reason, it is not recommended to use this function.
* *
* @param group The recipe to remove * @param group The recipe to remove
* @return True if successful. * @return True if the group was present.
*/ */
public static boolean removeGroup(@NotNull AbstractMaterialGroup group){ public static boolean removeGroup(@NotNull AbstractMaterialGroup group){
// Remove from registry // Remove from registry
ConfigHolder.ITEM_GROUP_HOLDER.getItemGroupsManager().groupMap.remove(group.getName()); AbstractMaterialGroup removed = ConfigHolder.ITEM_GROUP_HOLDER.getItemGroupsManager().groupMap.remove(group.getName());
if(removed == null) return false;
// Delete and save to file // Delete and save to file
ConfigHolder.ITEM_GROUP_HOLDER.delete(group.getName()); ConfigHolder.ITEM_GROUP_HOLDER.delete(group.getName());