From a44bd6dadfb8638dd6804ff5a4a8b47e515701ef Mon Sep 17 00:00:00 2001 From: LexManos Date: Thu, 4 Apr 2013 18:09:01 -0700 Subject: [PATCH] Add function to remove categories from a configuration, indavidual properties can be removed using ConfigCategory.remove() Closes #462 --- .../minecraftforge/common/ConfigCategory.java | 10 ++++++++++ .../minecraftforge/common/Configuration.java | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/common/net/minecraftforge/common/ConfigCategory.java b/common/net/minecraftforge/common/ConfigCategory.java index 5af16b2a9a..7656bdd64b 100644 --- a/common/net/minecraftforge/common/ConfigCategory.java +++ b/common/net/minecraftforge/common/ConfigCategory.java @@ -256,4 +256,14 @@ public class ConfigCategory implements Map return ImmutableSet.copyOf(properties.entrySet()); } + public Set getChildren(){ return ImmutableSet.copyOf(children); } + + public void removeChild(ConfigCategory child) + { + if (children.contains(child)) + { + children.remove(child); + changed = true; + } + } } \ No newline at end of file diff --git a/common/net/minecraftforge/common/Configuration.java b/common/net/minecraftforge/common/Configuration.java index fc6237cf6b..588d057ff4 100644 --- a/common/net/minecraftforge/common/Configuration.java +++ b/common/net/minecraftforge/common/Configuration.java @@ -771,6 +771,24 @@ public class Configuration return ret; } + public void removeCategory(ConfigCategory category) + { + for (ConfigCategory child : category.getChildren()) + { + removeCategory(child); + } + + if (categories.containsKey(category.getQualifiedName())) + { + categories.remove(category.getQualifiedName()); + if (category.parent != null) + { + category.parent.removeChild(category); + } + changed = true; + } + } + public void addCustomCategoryComment(String category, String comment) { if (!caseSensitiveCustomCategories)