!Fixed a custom durability issue in 1.12 (require latest MMOLib)

This commit is contained in:
Indyuce 2020-04-04 01:39:04 +02:00
parent 0955a073a2
commit e6e0ba341d
4 changed files with 4 additions and 12 deletions

Binary file not shown.

View File

@ -47,7 +47,7 @@ import net.Indyuce.mmoitems.listener.CustomSoundListener;
import net.Indyuce.mmoitems.listener.DisableInteractions;
import net.Indyuce.mmoitems.listener.ElementListener;
import net.Indyuce.mmoitems.listener.ItemUse;
import net.Indyuce.mmoitems.listener.NewDurabilityListener;
import net.Indyuce.mmoitems.listener.DurabilityListener;
import net.Indyuce.mmoitems.listener.PlayerListener;
import net.Indyuce.mmoitems.listener.version.Listener_v1_13;
import net.Indyuce.mmoitems.manager.AbilityManager;
@ -146,7 +146,7 @@ public class MMOItems extends JavaPlugin {
Bukkit.getPluginManager().registerEvents(new ItemUse(), this);
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
Bukkit.getPluginManager().registerEvents(new CustomSoundListener(), this);
Bukkit.getPluginManager().registerEvents(new NewDurabilityListener(), this);
Bukkit.getPluginManager().registerEvents(new DurabilityListener(), this);
Bukkit.getPluginManager().registerEvents(new DisableInteractions(), this);
Bukkit.getPluginManager().registerEvents(new GuiListener(), this);
Bukkit.getPluginManager().registerEvents(new ElementListener(), this);

View File

@ -9,8 +9,6 @@ import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -107,12 +105,6 @@ public class UnidentifiedItem extends ConfigItem {
ItemMeta meta = unidentified.getItemMeta();
meta.addItemFlags(ItemFlag.values());
meta.setUnbreakable(true);
if(meta.getAttributeModifiers() != null)
for(Attribute att : meta.getAttributeModifiers().keySet()) {
if(meta.getAttributeModifiers(att) != null)
for(AttributeModifier am : meta.getAttributeModifiers(att))
meta.removeAttributeModifier(att, am);
}
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
meta.setLore(lore);
unidentified.setItemMeta(meta);

View File

@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerItemMendEvent;
import net.Indyuce.mmoitems.api.interaction.util.DurabilityItem;
import net.mmogroup.mmolib.MMOLib;
public class NewDurabilityListener implements Listener {
public class DurabilityListener implements Listener {
@EventHandler(ignoreCancelled = true)
public void a(PlayerItemDamageEvent event) {
@ -32,7 +32,7 @@ public class NewDurabilityListener implements Listener {
}
event.setCancelled(true);
event.getItem().setItemMeta(item.toItem().getItemMeta());
MMOLib.plugin.getVersion().getWrapper().applyDurabilityData(event.getItem(), item.toItem());
}
}