/** * Deletes a given category. * @param category the category to delete */ public void deleteCategory(String category) { if(hasCategory(category)) { categories.remove(category); } } /** * Renames a property in a given category. * @param category the category in which the property resides * @param oldPropName the existing property name * @param newPropName the * @return true if the category and property exist, false otherwise */ public boolean renameProperty(String category, String oldPropName, String newPropName) { if (hasCategory(category)) { if (!oldPropName.equalsIgnoreCase(newPropName)) { if (getCategory(category).containsKey(oldPropName)) { get(category, newPropName, getCategory(category).get(oldPropName).getString()); getCategory(category).remove(oldPropName); return true; } else { FMLLog.warning("Mod attempted to rename a non-existant property!"); FMLLog.warning("Config \"%s\" Category: \"%s\" Source Key: \"%s\" Target Key: \"%s\"", fileName, category, oldPropName, newPropName); } } } else { FMLLog.warning("Mod attempted to rename a property from a non-existant config category!"); FMLLog.warning("Config \"%s\" Category: \"%s\" Source Key: \"%s\" Target Key: \"%s\"", fileName, category, oldPropName, newPropName); } return false; } /** * Moves a property from one category to another. The new category is created if it doesn't exist. * @param oldCategory the category the property currently resides in * @param propName the name of the property to move * @param newCategory the category the property should be moved to * @return true if the old category and property exist, false otherwise */ public boolean moveProperty(String oldCategory, String propName, String newCategory) { if (!caseSensitiveCustomCategories) { oldCategory = oldCategory.toLowerCase(Locale.ENGLISH); newCategory = newCategory.toLowerCase(Locale.ENGLISH); } if (!oldCategory.equals(newCategory)) { if(hasCategory(oldCategory)) { if (getCategory(oldCategory).containsKey(propName)) { getCategory(newCategory).put(propName, getCategory(oldCategory).get(propName)); return true; } else { FMLLog.warning("Mod attempted to move a non-existant property to another config category!"); FMLLog.warning("Config \"%s\" Source Category: \"%s\" Key: \"%s\" Target Category: \"%s\"", fileName, oldCategory, propName, newCategory); } } else { FMLLog.warning("Mod attempted to move a property from a non-existant config category!"); FMLLog.warning("Config \"%s\" Source Category: \"%s\" Key: \"%s\" Target Category: \"%s\"", fileName, oldCategory, propName, newCategory); } } return false; }