mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 05:28:59 +00:00
Try to find Items with Vault
Makes adding Ingredients a lot easier, as Vault has a great database of item names. Will match things like "green dye", or even "stained glass pane green"
This commit is contained in:
@@ -53,6 +53,11 @@
|
||||
</snapshots>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/artifactory/repo/</url>
|
||||
@@ -90,6 +95,13 @@
|
||||
<version>1.8-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user