mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Replaced iteration with addAll()
* Iteration replaced with call Collection.addAll * Encapsulated variables
This commit is contained in:
parent
3feff223bc
commit
833ce0108a
@ -1,8 +1,6 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
|
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
@ -13,37 +11,31 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class SlimefunMachine extends SlimefunItem {
|
public class SlimefunMachine extends SlimefunItem {
|
||||||
|
|
||||||
List<ItemStack[]> recipes;
|
private List<ItemStack[]> recipes;
|
||||||
List<ItemStack> shownRecipes;
|
private List<ItemStack> shownRecipes;
|
||||||
Material trigger;
|
private Material trigger;
|
||||||
|
|
||||||
public SlimefunMachine(Category category, ItemStack item, String id, ItemStack[] recipe, ItemStack[] machineRecipes, Material trigger) {
|
public SlimefunMachine(Category category, ItemStack item, String id, ItemStack[] recipe, ItemStack[] machineRecipes, Material trigger) {
|
||||||
super(category, item, id, RecipeType.MULTIBLOCK, recipe);
|
super(category, item, id, RecipeType.MULTIBLOCK, recipe);
|
||||||
this.recipes = new ArrayList<ItemStack[]>();
|
this.recipes = new ArrayList<>();
|
||||||
this.shownRecipes = new ArrayList<ItemStack>();
|
this.shownRecipes = new ArrayList<>();
|
||||||
for (ItemStack i: machineRecipes) {
|
this.shownRecipes.addAll(Arrays.asList(machineRecipes));
|
||||||
this.shownRecipes.add(i);
|
|
||||||
}
|
|
||||||
this.trigger = trigger;
|
this.trigger = trigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SlimefunMachine(Category category, ItemStack item, String id, ItemStack[] recipe, ItemStack[] machineRecipes, Material trigger, boolean ghost) {
|
public SlimefunMachine(Category category, ItemStack item, String id, ItemStack[] recipe, ItemStack[] machineRecipes, Material trigger, boolean ghost) {
|
||||||
super(category, item, id, RecipeType.MULTIBLOCK, recipe, ghost);
|
super(category, item, id, RecipeType.MULTIBLOCK, recipe, ghost);
|
||||||
this.recipes = new ArrayList<ItemStack[]>();
|
this.recipes = new ArrayList<>();
|
||||||
this.shownRecipes = new ArrayList<ItemStack>();
|
this.shownRecipes = new ArrayList<>();
|
||||||
for (ItemStack i: machineRecipes) {
|
this.shownRecipes.addAll(Arrays.asList(machineRecipes));
|
||||||
this.shownRecipes.add(i);
|
|
||||||
}
|
|
||||||
this.trigger = trigger;
|
this.trigger = trigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SlimefunMachine(Category category, ItemStack item, String id, ItemStack[] recipe, ItemStack[] machineRecipes, Material trigger, String[] keys, Object[] values) {
|
public SlimefunMachine(Category category, ItemStack item, String id, ItemStack[] recipe, ItemStack[] machineRecipes, Material trigger, String[] keys, Object[] values) {
|
||||||
super(category, item, id, RecipeType.MULTIBLOCK, recipe, keys, values);
|
super(category, item, id, RecipeType.MULTIBLOCK, recipe, keys, values);
|
||||||
this.recipes = new ArrayList<ItemStack[]>();
|
this.recipes = new ArrayList<>();
|
||||||
this.shownRecipes = new ArrayList<ItemStack>();
|
this.shownRecipes = new ArrayList<>();
|
||||||
for (ItemStack i: machineRecipes) {
|
this.shownRecipes.addAll(Arrays.asList(machineRecipes));
|
||||||
this.shownRecipes.add(i);
|
|
||||||
}
|
|
||||||
this.trigger = trigger;
|
this.trigger = trigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,10 +67,9 @@ public class SlimefunMachine extends SlimefunItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MultiBlock toMultiBlock() {
|
public MultiBlock toMultiBlock() {
|
||||||
List<Material> mats = new ArrayList<Material>();
|
List<Material> mats = new ArrayList<>();
|
||||||
for (ItemStack i: this.getRecipe()) {
|
for (ItemStack i: this.getRecipe()) {
|
||||||
if (i == null) mats.add(null);
|
if (i == null) mats.add(null);
|
||||||
else if (i.getType() == Material.CAULDRON) mats.add(Material.CAULDRON);
|
|
||||||
else if (i.getType() == Material.FLINT_AND_STEEL) mats.add(Material.FIRE);
|
else if (i.getType() == Material.FLINT_AND_STEEL) mats.add(Material.FIRE);
|
||||||
else mats.add(i.getType());
|
else mats.add(i.getType());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user