From 5df41b2f27af0a4612b54ca4712fb1e1a59e759e Mon Sep 17 00:00:00 2001 From: Indyuce Date: Mon, 4 Jul 2022 10:47:44 +0200 Subject: [PATCH] Fixed a comp issue with MMOCore --- pom.xml | 17 +--- .../java/net/Indyuce/mmoitems/MMOItems.java | 5 -- .../mmoitems/comp/RealDualWieldHook.java | 81 ------------------- .../comp/mmocore/MMOCoreMMOLoader.java | 4 +- .../load/MineMIBlockExperienceSource.java | 2 +- .../load/SmeltMMOItemExperienceSource.java | 2 +- .../Indyuce/mmoitems/listener/ItemUse.java | 3 +- 7 files changed, 8 insertions(+), 106 deletions(-) delete mode 100644 src/main/java/net/Indyuce/mmoitems/comp/RealDualWieldHook.java diff --git a/pom.xml b/pom.xml index 2dc2ebe7..12ec65ed 100644 --- a/pom.xml +++ b/pom.xml @@ -21,12 +21,6 @@ Lumine Releases https://mvn.lumine.io/repository/maven-releases/ - - nexus - Lumine Snapshots - https://mvn.lumine.io/repository/maven-snapshots/ - - @@ -153,14 +147,14 @@ net.Indyuce MMOCore - 1.9.1 + 1.9.3 provided io.lumine MythicLib-dist - 1.3.1 + 1.3.2 provided @@ -297,13 +291,6 @@ provided - - com.evill4mer - RealDualWield - 1.1.12 - provided - - me.arasple.mc TrHologram diff --git a/src/main/java/net/Indyuce/mmoitems/MMOItems.java b/src/main/java/net/Indyuce/mmoitems/MMOItems.java index 746806e5..8dc29f97 100644 --- a/src/main/java/net/Indyuce/mmoitems/MMOItems.java +++ b/src/main/java/net/Indyuce/mmoitems/MMOItems.java @@ -267,11 +267,6 @@ public class MMOItems extends LuminePlugin { } else Bukkit.getPluginManager().registerEvents(new NoGlowListener(), this); } - if (Bukkit.getPluginManager().getPlugin("RealDualWield") != null) { - Bukkit.getPluginManager().registerEvents(new RealDualWieldHook(), this); - getLogger().log(Level.INFO, "Hooked onto RealDualWield"); - } - if (Bukkit.getPluginManager().getPlugin("BossShopPro") != null) { getLogger().log(Level.INFO, "Hooked onto BossShopPro"); (new BukkitRunnable() { diff --git a/src/main/java/net/Indyuce/mmoitems/comp/RealDualWieldHook.java b/src/main/java/net/Indyuce/mmoitems/comp/RealDualWieldHook.java deleted file mode 100644 index 8e62cf0a..00000000 --- a/src/main/java/net/Indyuce/mmoitems/comp/RealDualWieldHook.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.Indyuce.mmoitems.comp; - -import com.evill4mer.RealDualWield.Api.PlayerDamageEntityWithOffhandEvent; -import io.lumine.mythic.lib.MythicLib; -import io.lumine.mythic.lib.api.item.NBTItem; -import io.lumine.mythic.lib.api.player.EquipmentSlot; -import io.lumine.mythic.lib.damage.DamageMetadata; -import io.lumine.mythic.lib.damage.DamageType; -import io.lumine.mythic.lib.damage.MeleeAttackMetadata; -import io.lumine.mythic.lib.player.PlayerMetadata; -import net.Indyuce.mmoitems.api.ItemAttackMetadata; -import net.Indyuce.mmoitems.api.Type; -import net.Indyuce.mmoitems.api.TypeSet; -import net.Indyuce.mmoitems.api.interaction.weapon.Weapon; -import net.Indyuce.mmoitems.api.player.PlayerData; -import org.bukkit.Material; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.Nullable; - -public class RealDualWieldHook implements Listener { - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void a(PlayerDamageEntityWithOffhandEvent event) { - - /* - * Citizens and Sentinels NPC support; damage = 0 check to ignore safety - * checks; check for entity attack - */ - if (event.getDamage() == 0 || !(event.getEntity() instanceof LivingEntity) || event.getEntity().hasMetadata("NPC") || event.getPlayer().hasMetadata("NPC")) - return; - - /* - * Must apply attack conditions before apply any effects. the event must - * be cancelled before anything is applied - */ - Player player = event.getPlayer(); - PlayerData playerData = PlayerData.get(player); - LivingEntity target = (LivingEntity) event.getEntity(); - NBTItem item = MythicLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand()); - MeleeAttackMetadata attackMeta = null; - - if (item.hasType() && Type.get(item.getType()) != Type.BLOCK) { - Weapon weapon = new Weapon(playerData, item); - - if (weapon.getMMOItem().getType().getItemSet() == TypeSet.RANGE) { - event.setCancelled(true); - return; - } - - if (!weapon.checkItemRequirements()) { - event.setCancelled(true); - return; - } - - if (!weapon.handleTargetedAttack(attackMeta = getAttack(playerData, event), target)) { - event.setCancelled(true); - return; - } - } - - // Cast on-hit abilities and add the extra damage to the damage event - new ItemAttackMetadata(attackMeta == null ? attackMeta = getAttack(playerData, event) : attackMeta).applyEffects(item, target); - - // Finally update Bukkit event - event.setDamage(attackMeta.getDamage().getDamage()); - } - - private boolean isAir(@Nullable ItemStack item) { - return item == null || item.getType() == Material.AIR; - } - - private MeleeAttackMetadata getAttack(PlayerData playerData, PlayerDamageEntityWithOffhandEvent event) { - PlayerMetadata cachedStatMap = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.OFF_HAND); - DamageType[] damageTypes = isAir(playerData.getPlayer().getInventory().getItemInOffHand()) ? new DamageType[]{DamageType.UNARMED, DamageType.PHYSICAL} : new DamageType[]{DamageType.WEAPON, DamageType.PHYSICAL}; - return new MeleeAttackMetadata(new DamageMetadata(event.getDamage(), damageTypes), cachedStatMap); - } -} diff --git a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreMMOLoader.java b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreMMOLoader.java index 49407d18..b299feec 100644 --- a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreMMOLoader.java +++ b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/MMOCoreMMOLoader.java @@ -8,9 +8,9 @@ import net.Indyuce.mmocore.api.block.BlockType; import net.Indyuce.mmocore.api.load.MMOLoader; import net.Indyuce.mmocore.api.quest.objective.Objective; import net.Indyuce.mmocore.api.quest.trigger.Trigger; -import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; +import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser; import net.Indyuce.mmocore.experience.source.type.ExperienceSource; -import net.Indyuce.mmocore.loot.droptable.condition.Condition; +import net.Indyuce.mmocore.loot.chest.condition.Condition; import net.Indyuce.mmocore.loot.droptable.dropitem.DropItem; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.block.CustomBlock; diff --git a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/MineMIBlockExperienceSource.java b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/MineMIBlockExperienceSource.java index 38a903e8..a519d42c 100644 --- a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/MineMIBlockExperienceSource.java +++ b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/MineMIBlockExperienceSource.java @@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.comp.mmocore.load; import io.lumine.mythic.lib.api.MMOLineConfig; import net.Indyuce.mmocore.api.player.PlayerData; -import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; +import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmoitems.MMOItems; diff --git a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/SmeltMMOItemExperienceSource.java b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/SmeltMMOItemExperienceSource.java index 4d16e198..2d047568 100644 --- a/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/SmeltMMOItemExperienceSource.java +++ b/src/main/java/net/Indyuce/mmoitems/comp/mmocore/load/SmeltMMOItemExperienceSource.java @@ -4,7 +4,7 @@ import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.item.NBTItem; import net.Indyuce.mmocore.api.player.PlayerData; -import net.Indyuce.mmocore.experience.provider.ExperienceDispenser; +import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import org.bukkit.Location; diff --git a/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java b/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java index 746ce06b..0a6ed366 100644 --- a/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java +++ b/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java @@ -117,7 +117,8 @@ public class ItemUse implements Listener { */ Player player = event.getPlayer(); PlayerData playerData = PlayerData.get(player); - NBTItem item = MythicLib.plugin.getVersion().getWrapper().getNBTItem(player.getInventory().getItemInMainHand()); + ItemStack weaponUsed = player.getInventory().getItem(((MeleeAttackMetadata) event.getAttack()).getHand().toBukkit()); + NBTItem item = MythicLib.plugin.getVersion().getWrapper().getNBTItem(weaponUsed); if (item.hasType() && Type.get(item.getType()) != Type.BLOCK) { Weapon weapon = new Weapon(playerData, item);