Fixed a comp issue with MMOCore

This commit is contained in:
Indyuce 2022-07-04 10:47:44 +02:00
parent eff20fcda6
commit 5df41b2f27
7 changed files with 8 additions and 106 deletions

17
pom.xml
View File

@ -21,12 +21,6 @@
<name>Lumine Releases</name> <name>Lumine Releases</name>
<url>https://mvn.lumine.io/repository/maven-releases/</url> <url>https://mvn.lumine.io/repository/maven-releases/</url>
</repository> </repository>
<snapshotRepository>
<id>nexus</id>
<name>Lumine Snapshots</name>
<url>https://mvn.lumine.io/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement> </distributionManagement>
<build> <build>
@ -153,14 +147,14 @@
<dependency> <dependency>
<groupId>net.Indyuce</groupId> <groupId>net.Indyuce</groupId>
<artifactId>MMOCore</artifactId> <artifactId>MMOCore</artifactId>
<version>1.9.1</version> <version>1.9.3</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.lumine</groupId> <groupId>io.lumine</groupId>
<artifactId>MythicLib-dist</artifactId> <artifactId>MythicLib-dist</artifactId>
<version>1.3.1</version> <version>1.3.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@ -297,13 +291,6 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.evill4mer</groupId>
<artifactId>RealDualWield</artifactId>
<version>1.1.12</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>me.arasple.mc</groupId> <groupId>me.arasple.mc</groupId>
<artifactId>TrHologram</artifactId> <artifactId>TrHologram</artifactId>

View File

@ -267,11 +267,6 @@ public class MMOItems extends LuminePlugin {
} else Bukkit.getPluginManager().registerEvents(new NoGlowListener(), this); } 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) { if (Bukkit.getPluginManager().getPlugin("BossShopPro") != null) {
getLogger().log(Level.INFO, "Hooked onto BossShopPro"); getLogger().log(Level.INFO, "Hooked onto BossShopPro");
(new BukkitRunnable() { (new BukkitRunnable() {

View File

@ -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);
}
}

View File

@ -8,9 +8,9 @@ import net.Indyuce.mmocore.api.block.BlockType;
import net.Indyuce.mmocore.api.load.MMOLoader; import net.Indyuce.mmocore.api.load.MMOLoader;
import net.Indyuce.mmocore.api.quest.objective.Objective; import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.api.quest.trigger.Trigger; 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.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.mmocore.loot.droptable.dropitem.DropItem;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.block.CustomBlock; import net.Indyuce.mmoitems.api.block.CustomBlock;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.comp.mmocore.load;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData; 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.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;

View File

@ -4,7 +4,7 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmocore.api.player.PlayerData; 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.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -117,7 +117,8 @@ public class ItemUse implements Listener {
*/ */
Player player = event.getPlayer(); Player player = event.getPlayer();
PlayerData playerData = PlayerData.get(player); 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) { if (item.hasType() && Type.get(item.getType()) != Type.BLOCK) {
Weapon weapon = new Weapon(playerData, item); Weapon weapon = new Weapon(playerData, item);