From 9ed67a0f812556892413361eebf0176d7045cd6c Mon Sep 17 00:00:00 2001 From: Ethan Date: Tue, 11 Aug 2020 07:13:37 -0400 Subject: [PATCH] Fixed custom blocks throwing errors when used as a weapon. --- .../Indyuce/mmoitems/listener/ItemUse.java | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java b/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java index 1c23b8a0..e7caa871 100644 --- a/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java +++ b/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java @@ -1,7 +1,23 @@ package net.Indyuce.mmoitems.listener; -import java.text.DecimalFormat; - +import net.Indyuce.mmoitems.MMOItems; +import net.Indyuce.mmoitems.MMOUtils; +import net.Indyuce.mmoitems.api.ItemAttackResult; +import net.Indyuce.mmoitems.api.Type; +import net.Indyuce.mmoitems.api.TypeSet; +import net.Indyuce.mmoitems.api.interaction.*; +import net.Indyuce.mmoitems.api.interaction.weapon.Gauntlet; +import net.Indyuce.mmoitems.api.interaction.weapon.Weapon; +import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.Staff; +import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon; +import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon.WeaponType; +import net.Indyuce.mmoitems.api.player.PlayerData; +import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats; +import net.Indyuce.mmoitems.api.util.message.Message; +import net.Indyuce.mmoitems.stat.type.ItemStat; +import net.mmogroup.mmolib.MMOLib; +import net.mmogroup.mmolib.api.DamageType; +import net.mmogroup.mmolib.api.item.NBTItem; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; @@ -23,28 +39,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.inventory.EquipmentSlot; -import net.Indyuce.mmoitems.MMOItems; -import net.Indyuce.mmoitems.MMOUtils; -import net.Indyuce.mmoitems.api.ItemAttackResult; -import net.Indyuce.mmoitems.api.Type; -import net.Indyuce.mmoitems.api.TypeSet; -import net.Indyuce.mmoitems.api.interaction.Consumable; -import net.Indyuce.mmoitems.api.interaction.GemStone; -import net.Indyuce.mmoitems.api.interaction.ItemSkin; -import net.Indyuce.mmoitems.api.interaction.Tool; -import net.Indyuce.mmoitems.api.interaction.UseItem; -import net.Indyuce.mmoitems.api.interaction.weapon.Gauntlet; -import net.Indyuce.mmoitems.api.interaction.weapon.Weapon; -import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.Staff; -import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon; -import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon.WeaponType; -import net.Indyuce.mmoitems.api.player.PlayerData; -import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats; -import net.Indyuce.mmoitems.api.util.message.Message; -import net.Indyuce.mmoitems.stat.type.ItemStat; -import net.mmogroup.mmolib.MMOLib; -import net.mmogroup.mmolib.api.DamageType; -import net.mmogroup.mmolib.api.item.NBTItem; +import java.text.DecimalFormat; public class ItemUse implements Listener { private static final DecimalFormat digit = new DecimalFormat("0.#"); @@ -133,6 +128,8 @@ public class ItemUse implements Listener { ItemAttackResult result = new ItemAttackResult(event.getDamage(), DamageType.WEAPON, DamageType.PHYSICAL); if (item.hasType()) { + if (item.getType() == Type.BLOCK) + return; Weapon weapon = new Weapon(playerData, item, item.getType()); if (weapon.getMMOItem().getType().getItemSet() == TypeSet.RANGE) { @@ -152,6 +149,8 @@ public class ItemUse implements Listener { } } if (offhandItem.hasType()) { + if (item.getType() == Type.BLOCK) + return; Weapon weapon = new Weapon(playerData, offhandItem, offhandItem.getType()); if (weapon.getMMOItem().getType().getItemSet() == TypeSet.RANGE) {