Why we were making this so complicated, I'll never know.

This commit is contained in:
GJ
2013-09-18 14:55:17 -04:00
parent a8e23e08ee
commit 14eb473355
2 changed files with 7 additions and 85 deletions

View File

@ -2,8 +2,6 @@ package com.gmail.nossr50.skills.repair;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
@ -53,65 +51,6 @@ public class Repair {
return "";
}
/**
* Search the inventory for an item and return the index.
*
* @param inventory PlayerInventory to scan
* @param itemId Item id to look for
* @return index location where the item was found, or -1 if not found
*/
protected static int findInInventory(PlayerInventory inventory, int itemId) {
int location = inventory.first(itemId);
// VALIDATE
if (inventory.getItem(location).getTypeId() == itemId) {
return location;
}
return -1;
}
/**
* Search the inventory for an item and return the index.
*
* @param inventory PlayerInventory to scan
* @param itemId Item id to look for
* @param metadata Metadata to look for
* @return index location where the item was found, or -1 if not found
*/
protected static int findInInventory(PlayerInventory inventory, int itemId, byte metadata) {
int location = -1;
ItemStack[] contents = inventory.getContents();
for (int i = 0; i < contents.length; i++) {
ItemStack item = contents[i];
if (item == null) {
continue;
}
if (item.getData().equals(new MaterialData(itemId, metadata))) {
return i;
}
}
return location;
}
/**
* Decrease the amount of items in this slot by one
*
* @param inventory PlayerInventory to work in
* @param index Item index to decrement
*/
protected static void removeOneFrom(PlayerInventory inventory, int index) {
ItemStack item = inventory.getItem(index).clone();
item.setAmount(1);
inventory.removeItem(item);
}
protected static Material getSalvagedItem(ItemStack inHand) {
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
return Material.DIAMOND;