mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Custom armor can now be repaired.
This commit is contained in:
@@ -2,10 +2,14 @@ package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.mods.LoadCustomArmor;
|
||||
import com.gmail.nossr50.config.mods.LoadCustomTools;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
|
||||
public class ModChecks {
|
||||
private static LoadCustomTools toolInstance = LoadCustomTools.getInstance();
|
||||
private static LoadCustomArmor armorInstance = LoadCustomArmor.getInstance();
|
||||
|
||||
/**
|
||||
* Check if this custom tool can use abilities.
|
||||
@@ -14,25 +18,59 @@ public class ModChecks {
|
||||
* @return true if the tool can use abilities, false otherwise
|
||||
*/
|
||||
public static boolean toolAbilityEnabled(ItemStack item) {
|
||||
for (CustomTool tool : LoadCustomTools.getInstance().customTools) {
|
||||
if (tool.getItemID() == item.getTypeId()) {
|
||||
return tool.isAbilityEnabled();
|
||||
int id = item.getTypeId();
|
||||
|
||||
if (!toolInstance.customIDs.contains(id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (CustomItem tool : toolInstance.customItems) {
|
||||
if (tool.getItemID() == id) {
|
||||
return ((CustomTool) tool).isAbilityEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom armor associated with an item.
|
||||
*
|
||||
* @param item The item to check
|
||||
* @return the ay if it exists, null otherwise
|
||||
*/
|
||||
public static CustomItem getArmorFromItemStack(ItemStack item) {
|
||||
int id = item.getTypeId();
|
||||
|
||||
if (!armorInstance.customIDs.contains(id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (CustomItem armor : armorInstance.customItems) {
|
||||
if (armor.getItemID() == id) {
|
||||
return armor;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom tool associated with an item.
|
||||
*
|
||||
* @param item The item to check
|
||||
* @return the tool if it exists, null otherwise
|
||||
* @return the armor if it exists, null otherwise
|
||||
*/
|
||||
public static CustomTool getToolFromItemStack(ItemStack item) {
|
||||
for (CustomTool tool : LoadCustomTools.getInstance().customTools) {
|
||||
if (tool.getItemID() == item.getTypeId()) {
|
||||
return tool;
|
||||
int id = item.getTypeId();
|
||||
|
||||
if (!toolInstance.customIDs.contains(id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (CustomItem tool : toolInstance.customItems) {
|
||||
if (tool.getItemID() == id) {
|
||||
return (CustomTool) tool;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user