Offhand ranged check for melee hits.

This commit is contained in:
Aria 2019-10-02 01:40:26 +02:00
parent 9ba20dd408
commit dccb394775

View File

@ -118,7 +118,9 @@ public class ItemUse implements Listener {
*/
PlayerData playerData = PlayerData.get(player);
NBTItem item = MMOItems.plugin.getNMS().getNBTItem(player.getInventory().getItemInMainHand());
NBTItem offhandItem = MMOItems.plugin.getNMS().getNBTItem(player.getInventory().getItemInOffHand());
AttackResult result = new AttackResult(event.getDamage(), DamageType.WEAPON, DamageType.PHYSICAL);
if (item.hasType()) {
Weapon weapon = new Weapon(playerData, item, item.getType());
@ -138,6 +140,19 @@ public class ItemUse implements Listener {
return;
}
}
if (offhandItem.hasType()) {
Weapon weapon = new Weapon(playerData, offhandItem, offhandItem.getType());
if(weapon.getMMOItem().getType().getItemSet() == TypeSet.RANGE) {
event.setCancelled(true);
return;
}
if (!weapon.canBeUsed()) {
event.setCancelled(true);
return;
}
}
/*
* cast on-hit abilities and add the extra damage to the damage event