diff --git a/pom.xml b/pom.xml index d41e523..d4ce54f 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,11 @@ + + vault-repo + http://nexus.theyeticave.net/content/repositories/pub_releases + + sk89q-repo http://maven.sk89q.com/artifactory/repo/ @@ -90,6 +95,13 @@ 1.8-R0.1-SNAPSHOT + + net.milkbowl.vault + VaultAPI + 1.5 + provided + + com.sk89q worldguard diff --git a/resources/plugin.yml b/resources/plugin.yml index 276ea28..bb0bf5f 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -2,7 +2,7 @@ name: Brewery version: 1.3.2 main: com.dre.brewery.P authors: [Milan Albrecht, Frank Baumann] -softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention] +softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault] commands: brewery: description: Command for Administration diff --git a/src/com/dre/brewery/BRecipe.java b/src/com/dre/brewery/BRecipe.java index 0aaf6b0..6d1f8bf 100644 --- a/src/com/dre/brewery/BRecipe.java +++ b/src/com/dre/brewery/BRecipe.java @@ -51,11 +51,26 @@ public class BRecipe { matParts = ingredParts[0].split("\\."); } Material mat = Material.matchMaterial(matParts[0]); - if (mat != null) { - ItemStack stack = new ItemStack(mat, P.p.parseInt(ingredParts[1]), (short) -1); - if (matParts.length == 2) { - stack.setDurability((short) P.p.parseInt(matParts[1])); + short durability = -1; + if (matParts.length == 2) { + durability = (short) P.p.parseInt(matParts[1]); + } + if (mat == null && P.p.hasVault) { + try { + net.milkbowl.vault.item.ItemInfo vaultItem = net.milkbowl.vault.item.Items.itemByString(matParts[0]); + if (vaultItem != null) { + mat = vaultItem.getType(); + if (durability == -1 && vaultItem.getSubTypeId() != 0) { + durability = vaultItem.getSubTypeId(); + } + } + } catch (Exception e) { + P.p.errorLog("Could not check vault for Item Name"); + e.printStackTrace(); } + } + if (mat != null) { + ItemStack stack = new ItemStack(mat, P.p.parseInt(ingredParts[1]), durability); this.ingredients.add(stack); } else { P.p.errorLog("Unknown Material: " + ingredParts[0]); diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java index a0f0385..e1d95fd 100644 --- a/src/com/dre/brewery/P.java +++ b/src/com/dre/brewery/P.java @@ -49,6 +49,7 @@ public class P extends JavaPlugin { public boolean useLWC; //LWC public boolean useLB; //LogBlock public boolean useGP; //GriefPrevention + public boolean hasVault; // Listeners public BlockListener blockListener; @@ -243,6 +244,7 @@ public class P extends JavaPlugin { useLWC = config.getBoolean("useLWC", true) && getServer().getPluginManager().isPluginEnabled("LWC"); useGP = config.getBoolean("useGriefPrevention", true) && getServer().getPluginManager().isPluginEnabled("GriefPrevention"); useLB = config.getBoolean("useLogBlock", false) && getServer().getPluginManager().isPluginEnabled("LogBlock"); + hasVault = getServer().getPluginManager().isPluginEnabled("Vault"); // various Settings DataSave.autosave = config.getInt("autosave", 3); @@ -282,6 +284,17 @@ public class P extends JavaPlugin { if (configSection != null) { for (String ingredient : configSection.getKeys(false)) { Material mat = Material.matchMaterial(ingredient); + if (mat == null && hasVault) { + try { + net.milkbowl.vault.item.ItemInfo vaultItem = net.milkbowl.vault.item.Items.itemByString(ingredient); + if (vaultItem != null) { + mat = vaultItem.getType(); + } + } catch (Exception e) { + P.p.errorLog("Could not check vault for Item Name"); + e.printStackTrace(); + } + } if (mat != null) { BIngredients.cookedNames.put(mat, (configSection.getString(ingredient, null))); BIngredients.possibleIngredients.add(mat); @@ -299,6 +312,17 @@ public class P extends JavaPlugin { if (drainSplit.length > 1) { Material mat = Material.matchMaterial(drainSplit[0]); int strength = p.parseInt(drainSplit[1]); + if (mat == null && hasVault && strength > 0) { + try { + net.milkbowl.vault.item.ItemInfo vaultItem = net.milkbowl.vault.item.Items.itemByString(drainSplit[0]); + if (vaultItem != null) { + mat = vaultItem.getType(); + } + } catch (Exception e) { + P.p.errorLog("Could not check vault for Item Name"); + e.printStackTrace(); + } + } if (mat != null && strength > 0) { BPlayer.drainItems.put(mat, strength); }