mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Use the delete function where a delete inteded.
This commit is contained in:
parent
5ed365b14d
commit
565bbb7e1c
8 changed files with 20 additions and 7 deletions
|
|
@ -118,7 +118,7 @@ public class ConflictAPI {
|
|||
ConfigHolder.CONFLICT_HOLDER.getConflictManager().removeConflict(conflict);
|
||||
|
||||
// Write as null and save to file
|
||||
ConfigHolder.CONFLICT_HOLDER.getConfig().set(conflict.getName(), null);
|
||||
ConfigHolder.CONFLICT_HOLDER.delete(conflict.getName());
|
||||
prepareSaveTask();
|
||||
|
||||
// Remove from gui
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class CustomAnvilRecipeApi {
|
|||
ConfigHolder.CUSTOM_RECIPE_HOLDER.getRecipeManager().cleanRemove(recipe);
|
||||
|
||||
// Write as null and save to file
|
||||
ConfigHolder.CUSTOM_RECIPE_HOLDER.getConfig().set(recipe.getName(), null);
|
||||
ConfigHolder.CUSTOM_RECIPE_HOLDER.delete(recipe.getName());
|
||||
prepareSaveTask();
|
||||
|
||||
// Remove from gui
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ public class MaterialGroupApi {
|
|||
ConfigHolder.ITEM_GROUP_HOLDER.getItemGroupsManager().groupMap.remove(group.getName());
|
||||
|
||||
// Write as null and save to file
|
||||
ConfigHolder.ITEM_GROUP_HOLDER.getConfig().set(group.getName(), null);
|
||||
ConfigHolder.ITEM_GROUP_HOLDER.delete(group.getName());
|
||||
prepareSaveTask();
|
||||
|
||||
// Remove from gui
|
||||
|
|
|
|||
|
|
@ -251,6 +251,15 @@ public abstract class ConfigHolder {
|
|||
return this.deletedListConfig.getBoolean(objectPath, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a certain object by its path. do not save the config.
|
||||
* @param objectPath The object path to delete.
|
||||
* @return True if successful.
|
||||
*/
|
||||
public boolean delete(String objectPath){
|
||||
return delete(objectPath, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a certain object by its path.
|
||||
* @param objectPath The object path to delete.
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
|
|||
cleanAndBeUnusable();
|
||||
|
||||
// Update config file storage
|
||||
ConfigHolder.CUSTOM_RECIPE_HOLDER.getConfig().set(this.anvilRecipe.toString(), null);
|
||||
ConfigHolder.CUSTOM_RECIPE_HOLDER.delete(this.anvilRecipe.toString());
|
||||
|
||||
// Save
|
||||
boolean success = true;
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
|
|||
cleanAndBeUnusable();
|
||||
|
||||
// Update config file storage
|
||||
ConfigHolder.CONFLICT_HOLDER.getConfig().set(this.enchantConflict.toString(), null);
|
||||
ConfigHolder.CONFLICT_HOLDER.delete(this.enchantConflict.toString());
|
||||
|
||||
// Save
|
||||
boolean success = true;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
|
|||
cleanAndBeUnusable();
|
||||
|
||||
// Update config file storage
|
||||
ConfigHolder.CUSTOM_RECIPE_HOLDER.getConfig().set(this.group.getName(), null);
|
||||
ConfigHolder.CUSTOM_RECIPE_HOLDER.delete(this.group.getName());
|
||||
|
||||
// Save
|
||||
boolean success = true;
|
||||
|
|
|
|||
|
|
@ -316,7 +316,11 @@ public class DoubleSettingGui extends AbstractSettingGui {
|
|||
@Override
|
||||
public boolean onSave() {
|
||||
if(isNull()){
|
||||
this.holder.config.getConfig().set(this.holder.configPath, null);
|
||||
if(this.holder.config instanceof ConfigHolder.DeletableResource deletableResource){
|
||||
deletableResource.delete(this.holder.configPath);
|
||||
}else{
|
||||
this.holder.config.getConfig().set(this.holder.configPath, null);
|
||||
}
|
||||
}else{
|
||||
this.holder.config.getConfig().set(this.holder.configPath, now.doubleValue());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue