From 39a5b5b96542694ba5317bc6038aa6fc10e8bb5d Mon Sep 17 00:00:00 2001 From: Jules Date: Tue, 22 Mar 2022 19:45:50 +0100 Subject: [PATCH 1/2] Fixed NPC death error log --- pom.xml | 2 +- .../java/net/Indyuce/mmoitems/listener/PlayerListener.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e359e726..04071b7d 100644 --- a/pom.xml +++ b/pom.xml @@ -160,7 +160,7 @@ io.lumine MythicLib-dist - 1.4 + 1.3.1 provided diff --git a/src/main/java/net/Indyuce/mmoitems/listener/PlayerListener.java b/src/main/java/net/Indyuce/mmoitems/listener/PlayerListener.java index 45ed6b9d..b1acdd0b 100644 --- a/src/main/java/net/Indyuce/mmoitems/listener/PlayerListener.java +++ b/src/main/java/net/Indyuce/mmoitems/listener/PlayerListener.java @@ -63,6 +63,9 @@ public class PlayerListener implements Listener { // No if (event instanceof Cancellable) { if (((Cancellable) event).isCancelled()) { return; } } + // Supports NPCs + if (!PlayerData.has(event.getEntity())) return; + // Get Player PlayerData data = PlayerData.get(event.getEntity()); From 3fe9014c29f0f4d87853586f36e2702819f9431b Mon Sep 17 00:00:00 2001 From: Jules Date: Tue, 22 Mar 2022 20:00:35 +0100 Subject: [PATCH 2/2] Changed the way attacks are cancelled when casting skills thru MMOCore --- .../net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java | 8 -------- src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java | 5 ++--- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java index f64799d3..43c0dc25 100644 --- a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java +++ b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreHook.java @@ -10,7 +10,6 @@ import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; import net.Indyuce.mmocore.api.player.stats.StatType; import net.Indyuce.mmocore.experience.Profession; import net.Indyuce.mmoitems.MMOItems; -import net.Indyuce.mmoitems.api.event.item.UntargetedWeaponUseEvent; import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.comp.mmocore.stat.Required_Attribute; import net.Indyuce.mmoitems.comp.mmocore.stat.Required_Profession; @@ -63,13 +62,6 @@ public class MMOCoreHook implements RPGHandler, Listener { net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate(); } - @EventHandler(ignoreCancelled = true) - public void stopAttacksWhenCasting(UntargetedWeaponUseEvent event) { - PlayerData playerData = PlayerData.get(event.getPlayerData().getUniqueId()); - if (playerData.isCasting()) - event.setCancelled(true); - } - /** * Removing this as it is causing issues when players log on for the first time. * Right after MMOCore loads the player data, MMOItems player data is not loaded yet diff --git a/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java b/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java index adfb649e..0161bc06 100644 --- a/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java +++ b/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java @@ -95,11 +95,10 @@ public class ItemUse implements Listener { useItem.executeCommands(); } + // Target free weapon attack if (useItem instanceof UntargetedWeapon) { - UntargetedWeapon weapon = (UntargetedWeapon) useItem; - if ((event.getAction().name().contains("RIGHT_CLICK") && weapon.getWeaponType() == UntargetedWeaponType.RIGHT_CLICK) - || (event.getAction().name().contains("LEFT_CLICK") && weapon.getWeaponType() == UntargetedWeaponType.LEFT_CLICK)) + if (weapon.getWeaponType().corresponds(event.getAction())) weapon.handleTargetFreeAttack(EquipmentSlot.fromBukkit(event.getHand())); } }