diff --git a/pom.xml b/pom.xml
index a31f5551..91e6989e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
co.kepler.fastcraftplus
fastcraftplus
- 0.3
+ 0.4
diff --git a/src/main/java/co/kepler/fastcraftplus/FastCraft.java b/src/main/java/co/kepler/fastcraftplus/FastCraft.java
index a31bfa06..420700a5 100644
--- a/src/main/java/co/kepler/fastcraftplus/FastCraft.java
+++ b/src/main/java/co/kepler/fastcraftplus/FastCraft.java
@@ -7,13 +7,12 @@
import co.kepler.fastcraftplus.craftgui.GUIFastCraft;
import co.kepler.fastcraftplus.crafting.CraftingListener;
import org.bukkit.Bukkit;
-import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.logging.Level;
-public class FastCraft extends JavaPlugin implements Listener {
+public class FastCraft extends JavaPlugin {
private static FastCraft instance;
private Config config;
@@ -74,8 +73,7 @@ public void onEnable() {
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.registerEvents(new CraftingListener(), this);
-
- GUIFastCraft.init();
+ pluginManager.registerEvents(new GUIFastCraft.GUIListener(), this);
}
@Override
diff --git a/src/main/java/co/kepler/fastcraftplus/config/Recipes.java b/src/main/java/co/kepler/fastcraftplus/config/Recipes.java
index 43b3635d..475ad77f 100644
--- a/src/main/java/co/kepler/fastcraftplus/config/Recipes.java
+++ b/src/main/java/co/kepler/fastcraftplus/config/Recipes.java
@@ -34,7 +34,7 @@ public static void loadRecipes() {
// Remove loaded recipes
for (FCRecipe fcRecipe : recipes) {
- for (Iterator iter = Bukkit.recipeIterator(); iter.hasNext();) {
+ for (Iterator iter = Bukkit.recipeIterator(); iter.hasNext(); ) {
Recipe recipe = iter.next();
if (RecipeUtil.areEqual(recipe, fcRecipe.getRecipe())) {
iter.remove();
diff --git a/src/main/java/co/kepler/fastcraftplus/craftgui/GUIButtonRecipe.java b/src/main/java/co/kepler/fastcraftplus/craftgui/GUIButtonRecipe.java
index 0b2e0a08..4435ff8b 100644
--- a/src/main/java/co/kepler/fastcraftplus/craftgui/GUIButtonRecipe.java
+++ b/src/main/java/co/kepler/fastcraftplus/craftgui/GUIButtonRecipe.java
@@ -36,9 +36,12 @@ public GUIButtonRecipe(GUIFastCraft gui, GUIRecipe recipe) {
super();
this.gui = gui;
this.recipe = recipe;
+ }
+ @Override
+ public ItemStack getItem() {
// Add the ingredients to the lore of the item
- ItemStack item = recipe.getResult().clone();
+ ItemStack item = recipe.getCraftingResult(gui).clone();
ItemMeta meta = item.getItemMeta();
LinkedList lore = new LinkedList<>();
Map ingredients = recipe.getIngredients();
@@ -58,8 +61,8 @@ public GUIButtonRecipe(GUIFastCraft gui, GUIRecipe recipe) {
meta.setLore(lore);
item.setItemMeta(meta);
- // Set the item
- setItem(item);
+ // Return the item
+ return item;
}
/**
@@ -79,7 +82,7 @@ public void setClickAction(ClickAction clickAction) {
*/
@Override
public boolean isVisible() {
- return recipe.canCraft(gui.getPlayer(), false);
+ return recipe.canCraft(gui);
}
/**
@@ -101,7 +104,9 @@ public void setVisible(boolean visible) {
@Override
public boolean onClick(Layout layout, InventoryClickEvent invEvent) {
if (ignoreClicks.contains(invEvent.getClick())) return false;
- if (!recipe.canCraft(gui.getPlayer(), true)) {
+
+ List results = new ArrayList<>();
+ if (!recipe.canCraft(gui, true, results)) {
gui.updateLayout();
return false;
}
@@ -110,14 +115,15 @@ public boolean onClick(Layout layout, InventoryClickEvent invEvent) {
case DROP:
case CONTROL_DROP:
// Drop items on the ground.
- for (ItemStack is : recipe.getResults()) {
+ for (ItemStack is : results) {
invEvent.getView().setItem(InventoryView.OUTSIDE, is);
}
break;
default:
// Add to inventory. Drop rest on ground if not enough space.
Inventory inv = gui.getPlayer().getInventory();
- for (ItemStack is : inv.addItem(recipe.getResults()).values()) {
+ ItemStack[] resultsArr = new ItemStack[results.size()];
+ for (ItemStack is : inv.addItem(results.toArray(resultsArr)).values()) {
invEvent.getView().setItem(InventoryView.OUTSIDE, is);
}
break;
diff --git a/src/main/java/co/kepler/fastcraftplus/craftgui/GUIFastCraft.java b/src/main/java/co/kepler/fastcraftplus/craftgui/GUIFastCraft.java
index 4925706b..ed1febac 100644
--- a/src/main/java/co/kepler/fastcraftplus/craftgui/GUIFastCraft.java
+++ b/src/main/java/co/kepler/fastcraftplus/craftgui/GUIFastCraft.java
@@ -2,6 +2,7 @@
import co.kepler.fastcraftplus.FastCraft;
import co.kepler.fastcraftplus.api.gui.*;
+import co.kepler.fastcraftplus.crafting.CraftingInvWrapper;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.HumanEntity;
@@ -16,9 +17,10 @@
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
+import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
-import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.*;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import java.util.HashMap;
@@ -31,12 +33,15 @@ public class GUIFastCraft extends GUI {
private static final ChatColor BUTTON_NAME_COLOR = ChatColor.GREEN;
private static final String NOT_YET_IMPLEMENTED = ChatColor.RED + "Not Yet Implemented";
- private static Map