mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-16 10:45:01 +00:00
ModTweaker2 Rework
- Revised base classes for IUndoableAction - Reordered lots of code, so stuck actions should be less frequent - Added wildcard support to many "remove" methods - Started working on exist & duplicate checks
This commit is contained in:
1 parent
f5034b04d8
commit
da33cc6fab
112 files changed
+4596
-3522
No files matched your search
@@ -1,8 +1,10 @@
|
||||
package modtweaker2.mods.tconstruct.handlers;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
@@ -11,28 +13,37 @@ import tconstruct.library.modifier.ItemModifier;
|
||||
|
||||
@ZenClass("mods.tconstruct.Modifiers")
|
||||
public class Modifiers {
|
||||
|
||||
protected static final String name = "TConstruct Modifier";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void remove(String mod) {
|
||||
MineTweakerAPI.apply(new Remove(mod));
|
||||
List<ItemModifier> recipes = new LinkedList<ItemModifier>();
|
||||
|
||||
for (ItemModifier recipe : TConstructHelper.modifiers) {
|
||||
if (recipe.key.equals(mod)) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Modifiers.name, mod));
|
||||
}
|
||||
}
|
||||
|
||||
//Searches through the modifiers and removes the first valid entry
|
||||
private static class Remove extends BaseListRemoval {
|
||||
private final String check;
|
||||
|
||||
public Remove(String check) {
|
||||
super("Modifier", TConstructHelper.modifiers);
|
||||
this.check = check;
|
||||
private static class Remove extends BaseListRemoval<ItemModifier>{
|
||||
public Remove(List<ItemModifier> recipes) {
|
||||
super(Modifiers.name, TConstructHelper.modifiers, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (ItemModifier m : (List<ItemModifier>) list) {
|
||||
if (m.key.equals(check)) {
|
||||
recipes. add(m);
|
||||
}
|
||||
}
|
||||
super.apply();
|
||||
protected String getRecipeInfo(ItemModifier recipe) {
|
||||
return recipe.key;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user