mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-29 13:45:24 +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 {
|
public class ModuleAutoCrafting implements Module {
|
||||||
|
|
||||||
|
private final Map<Material, Recipe> cachedRecipes = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "AutoCrafting";
|
return "AutoCrafting";
|
||||||
@ -47,14 +49,21 @@ public class ModuleAutoCrafting implements Module {
|
|||||||
public List<Material> getBlockedItems(Hopper hopper) {
|
public List<Material> getBlockedItems(Hopper hopper) {
|
||||||
List<Material> materials = new ArrayList<>();
|
List<Material> materials = new ArrayList<>();
|
||||||
if (hopper.getAutoCrafting() != null) {
|
if (hopper.getAutoCrafting() != null) {
|
||||||
for (Recipe recipe : Bukkit.getServer().getRecipesFor(new ItemStack(hopper.getAutoCrafting()))) {
|
|
||||||
|
Material material = hopper.getAutoCrafting();
|
||||||
|
|
||||||
|
if (!cachedRecipes.containsKey(material)) {
|
||||||
|
for (Recipe recipe : Bukkit.getServer().getRecipesFor(new ItemStack(material))) {
|
||||||
if (!(recipe instanceof ShapedRecipe)) continue;
|
if (!(recipe instanceof ShapedRecipe)) continue;
|
||||||
for (ItemStack itemStack : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
cachedRecipes.put(material, recipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ItemStack itemStack : ((ShapedRecipe) cachedRecipes.get(material)).getIngredientMap().values()) {
|
||||||
if (itemStack == null) continue;
|
if (itemStack == null) continue;
|
||||||
materials.add(itemStack.getType());
|
materials.add(itemStack.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return materials;
|
return materials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ public abstract class Storage {
|
|||||||
public Storage(EpicHoppersPlugin instance) {
|
public Storage(EpicHoppersPlugin instance) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
this.dataFile = new ConfigWrapper(instance, "", "data.yml");
|
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.getConfig().options().copyDefaults(true);
|
||||||
this.dataFile.saveConfig();
|
this.dataFile.saveConfig();
|
||||||
}
|
}
|
||||||
|
@ -194,6 +194,7 @@ public class SettingsManager implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Setting {
|
public enum Setting {
|
||||||
o1("Upgrading-enabled", "Main.Allow hopper Upgrading", true),
|
o1("Upgrading-enabled", "Main.Allow hopper Upgrading", true),
|
||||||
o2("Upgrade-with-eco", "Main.Upgrade With Economy", true),
|
o2("Upgrade-with-eco", "Main.Upgrade With Economy", true),
|
||||||
|
Loading…
Reference in New Issue
Block a user