From 414cb0abd48ab87f0dbea91aec04eb0cd75131f7 Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 9 Feb 2021 19:53:18 -0600 Subject: [PATCH] custom durability bug from ticket 410 fix? --- .../mmocore/api/util/MMOCoreUtils.java | 26 +++++++++++-------- .../comp/mythicmobs/skill/MythicMobSkill.java | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java b/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java index e8cac543..8c44ba61 100644 --- a/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java +++ b/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java @@ -1,11 +1,9 @@ package net.Indyuce.mmocore.api.util; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - +import io.lumine.mythic.lib.MythicLib; +import io.lumine.mythic.lib.api.item.NBTItem; +import io.lumine.mythic.lib.version.VersionMaterial; +import net.Indyuce.mmocore.api.player.PlayerData; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -25,10 +23,11 @@ import org.bukkit.util.io.BukkitObjectInputStream; import org.bukkit.util.io.BukkitObjectOutputStream; import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; -import net.Indyuce.mmocore.api.player.PlayerData; -import io.lumine.mythic.lib.MythicLib; -import io.lumine.mythic.lib.api.item.NBTItem; -import io.lumine.mythic.lib.version.VersionMaterial; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class MMOCoreUtils { public static boolean pluginItem(ItemStack item) { @@ -211,13 +210,18 @@ public class MMOCoreUtils { */ public static void decreaseDurability(Player player, EquipmentSlot slot, int damage) { ItemStack item = player.getInventory().getItem(slot); + NBTItem nbt = NBTItem.get(item); + + if(!nbt.hasTag("MMOITEMS_MAX_DURABILITY")){ + return; + } PlayerItemDamageEvent event = new PlayerItemDamageEvent(player, item, damage); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) return; - NBTItem nbt = NBTItem.get(item); + if (!nbt.getBoolean("Unbreakable") && item.getItemMeta() instanceof Damageable) { ItemMeta meta = item.getItemMeta(); ((Damageable) meta).setDamage(((Damageable) meta).getDamage() + damage); diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/MythicMobSkill.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/MythicMobSkill.java index f3b8b12d..c93b6380 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/MythicMobSkill.java +++ b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/MythicMobSkill.java @@ -24,7 +24,7 @@ public class MythicMobSkill extends Skill { private final io.lumine.xikage.mythicmobs.skills.Skill skill; private final Map antiCheat = new HashMap<>(); - // private final BiFunction cast; + //private final BiFunction cast; public MythicMobSkill(String id, FileConfiguration config) { super(id);