Fixed an attack speed issue with MythicLib

This commit is contained in:
Indyuce 2021-06-26 19:20:30 +02:00
parent e2239d341f
commit 2fd09206dd
2 changed files with 19 additions and 21 deletions

17
pom.xml
View File

@ -95,6 +95,14 @@
<dependencies>
<!-- Spigot API -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.Indyuce.mmoitems.lib</groupId>
<artifactId>GoogleGSON</artifactId>
@ -179,14 +187,7 @@
<scope>provided</scope>
</dependency>
<!-- Spigot API -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Local dependencies -->
<dependency>
<groupId>com.github.Eniripsa96</groupId>
<artifactId>SkillAPI</artifactId>

View File

@ -65,13 +65,6 @@ public class PlayerStats {
*/
StatInstance.ModifierPacket packet = getInstance(stat).newPacket();
/**
* Some stats including Atk Damage and Speed have stat offsets, when equipping
* at least one item which grants this stat the final value must be lowered
* by a flat amount
*/
boolean isHoldingWeapon = false;
/**
* The index of the mmoitem stat modifier being added
*/
@ -80,21 +73,25 @@ public class PlayerStats {
for (EquippedPlayerItem item : playerData.getInventory().getEquipped()) {
double value = item.getItem().getNBT().getStat(stat.getId());
if (value != 0) {
Type type = item.getItem().getType();
ModifierSource source = type == null ? ModifierSource.OTHER : type.getItemSet().getModifierSource();
/**
* Apply main hand weapon stat offset ie 4 for attack speed and 1 for attack damage.
*/
if (item.getSlot() == EquipmentSlot.MAIN_HAND && stat instanceof AttributeStat)
value -= ((AttributeStat) stat).getOffset();
packet.addModifier("MMOItem-" + index++, new StatModifier(value, ModifierType.FLAT, item.getSlot(), source));
if (!isHoldingWeapon && item.getSlot().isHand())
isHoldingWeapon = true;
}
}
if (isHoldingWeapon && stat instanceof AttributeStat)
packet.addModifier("MMOItemOffset", new StatModifier(-((AttributeStat) stat).getOffset()));
/**
* Finally run a stat update
* Finally run a stat update after all modifiers
* have been gathered by MythicLib
*/
packet.runUpdate();
}