mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-03 06:37:47 +01:00
Fixed NPE's with unconventional weapons
This commit is contained in:
parent
85bce6b2a5
commit
cdc7b32edb
@ -135,6 +135,10 @@ public enum TypeSet {
|
||||
this.attackHandler = attackHandler;
|
||||
}
|
||||
|
||||
public boolean hasAttackEffect() {
|
||||
return attackHandler != null;
|
||||
}
|
||||
|
||||
public void applyAttackEffect(CachedStats playerStats, LivingEntity target, Weapon weapon, ItemAttackResult result) {
|
||||
attackHandler.apply(playerStats, target, weapon, result);
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
@ -67,7 +66,7 @@ public class Weapon extends UseItem {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemAttackResult targetedAttack(CachedStats stats, LivingEntity target, EquipmentSlot slot, ItemAttackResult result) {
|
||||
public ItemAttackResult targetedAttack(CachedStats stats, LivingEntity target, ItemAttackResult result) {
|
||||
|
||||
// cooldown
|
||||
double attackSpeed = getNBTItem().getStat(ItemStat.ATTACK_SPEED);
|
||||
@ -75,7 +74,7 @@ public class Weapon extends UseItem {
|
||||
if (!hasEnoughResources(attackSpeed, CooldownType.ATTACK, true))
|
||||
return result.setSuccessful(false);
|
||||
|
||||
if (!getNBTItem().getBoolean("MMOITEMS_DISABLE_ATTACK_PASSIVE"))
|
||||
if (!getNBTItem().getBoolean("MMOITEMS_DISABLE_ATTACK_PASSIVE") && getMMOItem().getType().getItemSet().hasAttackEffect())
|
||||
getMMOItem().getType().getItemSet().applyAttackEffect(stats, target, this, result);
|
||||
|
||||
return result;
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
|
||||
import com.evill4mer.RealDualWield.Api.PlayerDamageEntityWithOffhandEvent;
|
||||
|
||||
@ -59,7 +58,7 @@ public class RealDualWieldHook implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
weapon.targetedAttack(stats = playerData.getStats().newTemporary(), target, EquipmentSlot.HAND, result.setSuccessful(true));
|
||||
weapon.targetedAttack(stats = playerData.getStats().newTemporary(), target, result);
|
||||
if (!result.isSuccessful()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -145,7 +145,7 @@ public class ItemUse implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
weapon.targetedAttack(stats = playerData.getStats().newTemporary(), target, EquipmentSlot.HAND, result.setSuccessful(true));
|
||||
weapon.targetedAttack(stats = playerData.getStats().newTemporary(), target, result);
|
||||
if (!result.isSuccessful()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -169,7 +169,6 @@ public class ItemUse implements Listener {
|
||||
* cast on-hit abilities and add the extra damage to the damage event
|
||||
*/
|
||||
result.applyEffects(stats == null ? stats = playerData.getStats().newTemporary() : stats, item, target);
|
||||
|
||||
event.setDamage(result.getDamage());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user