mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-13 02:54:43 +02:00
Why we were making this so complicated, I'll never know.
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user