mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Rework armor.yml to take item names instead of IDs in advance of 1.7 changes.
** YOU WILL NEED TO REDO YOUR armor.yml FILE **
This commit is contained in:
@ -121,7 +121,9 @@ public class ItemUtils {
|
||||
* @return true if the item is a helmet, false otherwise
|
||||
*/
|
||||
public static boolean isHelmet(ItemStack item) {
|
||||
switch (item.getType()) {
|
||||
Material type = item.getType();
|
||||
|
||||
switch (type) {
|
||||
case DIAMOND_HELMET:
|
||||
case GOLD_HELMET:
|
||||
case IRON_HELMET:
|
||||
@ -130,7 +132,7 @@ public class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customHelmetIDs.contains(item.getTypeId());
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customHelmets.contains(type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +143,9 @@ public class ItemUtils {
|
||||
* @return true if the item is a chestplate, false otherwise
|
||||
*/
|
||||
public static boolean isChestplate(ItemStack item) {
|
||||
switch (item.getType()) {
|
||||
Material type = item.getType();
|
||||
|
||||
switch (type) {
|
||||
case DIAMOND_CHESTPLATE:
|
||||
case GOLD_CHESTPLATE:
|
||||
case IRON_CHESTPLATE:
|
||||
@ -150,7 +154,7 @@ public class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customChestplateIDs.contains(item.getTypeId());
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customChestplates.contains(type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +165,9 @@ public class ItemUtils {
|
||||
* @return true if the item is a pair of pants, false otherwise
|
||||
*/
|
||||
public static boolean isLeggings(ItemStack item) {
|
||||
switch (item.getType()) {
|
||||
Material type = item.getType();
|
||||
|
||||
switch (type) {
|
||||
case DIAMOND_LEGGINGS:
|
||||
case GOLD_LEGGINGS:
|
||||
case IRON_LEGGINGS:
|
||||
@ -170,7 +176,7 @@ public class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customLeggingIDs.contains(item.getTypeId());
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customLeggings.contains(type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,7 +187,9 @@ public class ItemUtils {
|
||||
* @return true if the item is a pair of boots, false otherwise
|
||||
*/
|
||||
public static boolean isBoots(ItemStack item) {
|
||||
switch (item.getType()) {
|
||||
Material type = item.getType();
|
||||
|
||||
switch (type) {
|
||||
case DIAMOND_BOOTS:
|
||||
case GOLD_BOOTS:
|
||||
case IRON_BOOTS:
|
||||
@ -190,7 +198,7 @@ public class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customBootIDs.contains(item.getTypeId());
|
||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customBoots.contains(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.util;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
@ -11,7 +12,6 @@ import com.gmail.nossr50.config.mods.CustomEntityConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
|
||||
public final class ModUtils {
|
||||
@ -24,16 +24,6 @@ public final class ModUtils {
|
||||
|
||||
private ModUtils() {}
|
||||
|
||||
/**
|
||||
* Get the custom armor associated with an item.
|
||||
*
|
||||
* @param item The item to check
|
||||
* @return the armor if it exists, null otherwise
|
||||
*/
|
||||
public static CustomItem getArmorFromItemStack(ItemStack item) {
|
||||
return CustomArmorConfig.getInstance().customArmor.get(item.getTypeId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom tool associated with an item.
|
||||
*
|
||||
@ -56,7 +46,7 @@ public final class ModUtils {
|
||||
|
||||
if (CustomBlockConfig.getInstance().customItems.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||
return block;
|
||||
}
|
||||
}
|
||||
@ -92,7 +82,7 @@ public final class ModUtils {
|
||||
|
||||
if (CustomBlockConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -114,7 +104,7 @@ public final class ModUtils {
|
||||
|
||||
if (CustomBlockConfig.getInstance().customAbilityBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -136,7 +126,7 @@ public final class ModUtils {
|
||||
|
||||
if (CustomBlockConfig.getInstance().customMiningBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -158,7 +148,7 @@ public final class ModUtils {
|
||||
|
||||
if (CustomBlockConfig.getInstance().customExcavationBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -180,7 +170,7 @@ public final class ModUtils {
|
||||
|
||||
if (CustomBlockConfig.getInstance().customHerbalismBlocks.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -202,7 +192,7 @@ public final class ModUtils {
|
||||
|
||||
if (CustomBlockConfig.getInstance().customLeaves.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -224,7 +214,7 @@ public final class ModUtils {
|
||||
|
||||
if (CustomBlockConfig.getInstance().customLogs.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -246,7 +236,7 @@ public final class ModUtils {
|
||||
|
||||
if (CustomBlockConfig.getInstance().customOres.contains(item)) {
|
||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
||||
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -277,7 +267,7 @@ public final class ModUtils {
|
||||
* @return true if the item is custom armor, false otherwise
|
||||
*/
|
||||
public static boolean isCustomArmor(ItemStack item) {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customArmor.containsKey(item.getTypeId())) {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customArmor.contains(item.getType())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,7 @@ public class SkillUtils {
|
||||
*/
|
||||
public static ItemStack handleDurabilityChange(ItemStack itemStack, int durabilityModifier) {
|
||||
short finalDurability = (short) (itemStack.getDurability() + durabilityModifier);
|
||||
short maxDurability = ModUtils.isCustomTool(itemStack) ? ModUtils.getToolFromItemStack(itemStack).getDurability() : itemStack.getType().getMaxDurability();
|
||||
short maxDurability = itemStack.getType().getMaxDurability();
|
||||
boolean overMax = (finalDurability >= maxDurability);
|
||||
|
||||
itemStack.setDurability(overMax ? maxDurability : finalDurability);
|
||||
|
Reference in New Issue
Block a user