mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-25 19:56:20 +01:00
Removed data loading message.
Cached AutoCrafting data;
This commit is contained in:
parent
bed3c0016b
commit
1bd79b3505
@ -18,6 +18,8 @@ import java.util.Map;
|
||||
|
||||
public class ModuleAutoCrafting implements Module {
|
||||
|
||||
private final Map<Material, Recipe> cachedRecipes = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "AutoCrafting";
|
||||
@ -47,13 +49,20 @@ public class ModuleAutoCrafting implements Module {
|
||||
public List<Material> getBlockedItems(Hopper hopper) {
|
||||
List<Material> materials = new ArrayList<>();
|
||||
if (hopper.getAutoCrafting() != null) {
|
||||
for (Recipe recipe : Bukkit.getServer().getRecipesFor(new ItemStack(hopper.getAutoCrafting()))) {
|
||||
if (!(recipe instanceof ShapedRecipe)) continue;
|
||||
for (ItemStack itemStack : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
||||
if (itemStack == null) continue;
|
||||
materials.add(itemStack.getType());
|
||||
|
||||
Material material = hopper.getAutoCrafting();
|
||||
|
||||
if (!cachedRecipes.containsKey(material)) {
|
||||
for (Recipe recipe : Bukkit.getServer().getRecipesFor(new ItemStack(material))) {
|
||||
if (!(recipe instanceof ShapedRecipe)) continue;
|
||||
cachedRecipes.put(material, recipe);
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack itemStack : ((ShapedRecipe) cachedRecipes.get(material)).getIngredientMap().values()) {
|
||||
if (itemStack == null) continue;
|
||||
materials.add(itemStack.getType());
|
||||
}
|
||||
}
|
||||
return materials;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public abstract class Storage {
|
||||
public Storage(EpicHoppersPlugin instance) {
|
||||
this.instance = instance;
|
||||
this.dataFile = new ConfigWrapper(instance, "", "data.yml");
|
||||
this.dataFile.createNewFile("Loading Data File", "EpicHoppers Data File");
|
||||
this.dataFile.createNewFile(null, "EpicHoppers Data File");
|
||||
this.dataFile.getConfig().options().copyDefaults(true);
|
||||
this.dataFile.saveConfig();
|
||||
}
|
||||
|
@ -194,6 +194,7 @@ public class SettingsManager implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum Setting {
|
||||
o1("Upgrading-enabled", "Main.Allow hopper Upgrading", true),
|
||||
o2("Upgrade-with-eco", "Main.Upgrade With Economy", true),
|
||||
|
Loading…
Reference in New Issue
Block a user