mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-20 09:11:21 +01:00
Fixed an issue with weapons taking away attributes
This commit is contained in:
parent
c19f612928
commit
cc7d4e8f20
@ -96,9 +96,9 @@ public class ItemStats {
|
|||||||
UNBREAKABLE = new Unbreakable(),
|
UNBREAKABLE = new Unbreakable(),
|
||||||
TIER = new ItemTierStat(),
|
TIER = new ItemTierStat(),
|
||||||
SET = new ItemSetStat(),
|
SET = new ItemSetStat(),
|
||||||
ARMOR = new Armor(),
|
ARMOR = new DoubleStat("ARMOR", VersionMaterial.GOLDEN_CHESTPLATE.toMaterial(), "Armor", new String[] { "The armor given to the holder." }),
|
||||||
ARMOR_TOUGHNESS = new ArmorToughness(),
|
ARMOR_TOUGHNESS = new DoubleStat("ARMOR_TOUGHNESS", Material.DIAMOND_CHESTPLATE, "Armor Toughness", new String[] { "Armor toughness reduces damage taken." }),
|
||||||
MAX_HEALTH = new MaxHealth(),
|
MAX_HEALTH = new DoubleStat("MAX_HEALTH", Material.GOLDEN_APPLE, "Max Health", new String[] { "The amount of health your", "item gives to the holder." }),
|
||||||
UNSTACKABLE = new Unstackable(),
|
UNSTACKABLE = new Unstackable(),
|
||||||
MAX_MANA = new DoubleStat("MAX_MANA", VersionMaterial.LAPIS_LAZULI.toMaterial(), "Max Mana", new String[]{"Adds mana to your max mana bar."}),
|
MAX_MANA = new DoubleStat("MAX_MANA", VersionMaterial.LAPIS_LAZULI.toMaterial(), "Max Mana", new String[]{"Adds mana to your max mana bar."}),
|
||||||
KNOCKBACK_RESISTANCE = new KnockbackResistance(),
|
KNOCKBACK_RESISTANCE = new KnockbackResistance(),
|
||||||
|
@ -10,7 +10,7 @@ import io.lumine.mythic.lib.player.modifier.ModifierType;
|
|||||||
import net.Indyuce.mmoitems.MMOItems;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
import net.Indyuce.mmoitems.api.Type;
|
import net.Indyuce.mmoitems.api.Type;
|
||||||
import net.Indyuce.mmoitems.api.player.inventory.EquippedPlayerItem;
|
import net.Indyuce.mmoitems.api.player.inventory.EquippedPlayerItem;
|
||||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
import net.Indyuce.mmoitems.stat.type.AttackWeaponStat;
|
||||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||||
|
|
||||||
public class PlayerStats {
|
public class PlayerStats {
|
||||||
@ -75,8 +75,8 @@ public class PlayerStats {
|
|||||||
ModifierSource source = type == null ? ModifierSource.OTHER : type.getItemSet().getModifierSource();
|
ModifierSource source = type == null ? ModifierSource.OTHER : type.getItemSet().getModifierSource();
|
||||||
|
|
||||||
// Apply main hand weapon stat offset
|
// Apply main hand weapon stat offset
|
||||||
if (item.getSlot() == EquipmentSlot.MAIN_HAND && stat instanceof AttributeStat)
|
if (item.getSlot() == EquipmentSlot.MAIN_HAND && stat instanceof AttackWeaponStat)
|
||||||
value -= ((AttributeStat) stat).getOffset(playerData);
|
value -= ((AttackWeaponStat) stat).getOffset(playerData);
|
||||||
|
|
||||||
packet.addModifier(new StatModifier("MMOItem-" + index++, stat.getId(), value, ModifierType.FLAT, item.getSlot(), source));
|
packet.addModifier(new StatModifier("MMOItem-" + index++, stat.getId(), value, ModifierType.FLAT, item.getSlot(), source));
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,15 @@
|
|||||||
package net.Indyuce.mmoitems.manager;
|
package net.Indyuce.mmoitems.manager;
|
||||||
|
|
||||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||||
import io.lumine.mythic.lib.damage.DamageMetadata;
|
|
||||||
import io.lumine.mythic.lib.damage.DamageType;
|
|
||||||
import io.lumine.mythic.lib.player.PlayerMetadata;
|
import io.lumine.mythic.lib.player.PlayerMetadata;
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
import net.Indyuce.mmoitems.api.ElementalAttack;
|
import net.Indyuce.mmoitems.api.ElementalAttack;
|
||||||
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
|
|
||||||
import net.Indyuce.mmoitems.api.event.MMOItemsProjectileFireEvent;
|
|
||||||
import net.Indyuce.mmoitems.api.interaction.projectile.ArrowParticles;
|
import net.Indyuce.mmoitems.api.interaction.projectile.ArrowParticles;
|
||||||
import net.Indyuce.mmoitems.api.interaction.projectile.EntityData;
|
import net.Indyuce.mmoitems.api.interaction.projectile.EntityData;
|
||||||
import net.Indyuce.mmoitems.api.interaction.projectile.ProjectileData;
|
import net.Indyuce.mmoitems.api.interaction.projectile.ProjectileData;
|
||||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -146,9 +138,7 @@ public class EntityManager implements Listener {
|
|||||||
event.setDamage(damage);
|
event.setDamage(damage);
|
||||||
|
|
||||||
// Remove projectile if it has no piercing anymore
|
// Remove projectile if it has no piercing anymore
|
||||||
if (projectile instanceof AbstractArrow) {
|
if (!(projectile instanceof AbstractArrow) && ((AbstractArrow) projectile).getPierceLevel() <= 1)
|
||||||
|
|
||||||
if (((AbstractArrow) projectile).getPierceLevel() > 1) { return; } }
|
|
||||||
unregisterCustomProjectile(projectile);
|
unregisterCustomProjectile(projectile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ public class StatManager {
|
|||||||
* individually to understand better
|
* individually to understand better
|
||||||
*/
|
*/
|
||||||
private final Set<DoubleStat> numeric = new HashSet<>();
|
private final Set<DoubleStat> numeric = new HashSet<>();
|
||||||
private final Set<AttributeStat> attributeBased = new HashSet<>();
|
|
||||||
private final Set<ItemRestriction> itemRestriction = new HashSet<>();
|
private final Set<ItemRestriction> itemRestriction = new HashSet<>();
|
||||||
private final Set<ConsumableItemInteraction> consumableActions = new HashSet<>();
|
private final Set<ConsumableItemInteraction> consumableActions = new HashSet<>();
|
||||||
private final Set<PlayerConsumable> playerConsumables = new HashSet<>();
|
private final Set<PlayerConsumable> playerConsumables = new HashSet<>();
|
||||||
@ -42,14 +41,6 @@ public class StatManager {
|
|||||||
return stats.values();
|
return stats.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection of all stats which are based on vanilla player
|
|
||||||
* attributes like movement speed, attack damage, max health..
|
|
||||||
*/
|
|
||||||
public Set<AttributeStat> getAttributeStats() {
|
|
||||||
return attributeBased;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection of all numeric stats like atk damage, crit strike
|
* @return Collection of all numeric stats like atk damage, crit strike
|
||||||
* chance, max mana... which can be applied on a gem stone. This is
|
* chance, max mana... which can be applied on a gem stone. This is
|
||||||
@ -122,9 +113,6 @@ public class StatManager {
|
|||||||
if (stat instanceof DoubleStat && !(stat instanceof GemStoneStat) && stat.isCompatible(Type.GEM_STONE))
|
if (stat instanceof DoubleStat && !(stat instanceof GemStoneStat) && stat.isCompatible(Type.GEM_STONE))
|
||||||
numeric.add((DoubleStat) stat);
|
numeric.add((DoubleStat) stat);
|
||||||
|
|
||||||
if (stat instanceof AttributeStat)
|
|
||||||
attributeBased.add((AttributeStat) stat);
|
|
||||||
|
|
||||||
if (stat instanceof ItemRestriction)
|
if (stat instanceof ItemRestriction)
|
||||||
itemRestriction.add((ItemRestriction) stat);
|
itemRestriction.add((ItemRestriction) stat);
|
||||||
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
package net.Indyuce.mmoitems.stat;
|
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
|
||||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
|
||||||
import org.bukkit.attribute.Attribute;
|
|
||||||
|
|
||||||
public class Armor extends AttributeStat {
|
|
||||||
public Armor() {
|
|
||||||
super("ARMOR", VersionMaterial.GOLDEN_CHESTPLATE.toMaterial(), "Armor", new String[] { "The armor given to the holder." },
|
|
||||||
Attribute.GENERIC_ARMOR);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package net.Indyuce.mmoitems.stat;
|
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.attribute.Attribute;
|
|
||||||
|
|
||||||
public class ArmorToughness extends AttributeStat {
|
|
||||||
public ArmorToughness() {
|
|
||||||
super("ARMOR_TOUGHNESS", Material.DIAMOND_CHESTPLATE, "Armor Toughness",
|
|
||||||
new String[] { "Armor toughness reduces damage taken." }, Attribute.GENERIC_ARMOR_TOUGHNESS);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,10 @@
|
|||||||
package net.Indyuce.mmoitems.stat;
|
package net.Indyuce.mmoitems.stat;
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
import net.Indyuce.mmoitems.stat.type.AttackWeaponStat;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
|
|
||||||
public class AttackDamage extends AttributeStat {
|
public class AttackDamage extends AttackWeaponStat {
|
||||||
public AttackDamage() {
|
public AttackDamage() {
|
||||||
super("ATTACK_DAMAGE", Material.IRON_SWORD, "Attack Damage", new String[] { "The amount of damage", "your weapon deals." },
|
super("ATTACK_DAMAGE", Material.IRON_SWORD, "Attack Damage", new String[] { "The amount of damage", "your weapon deals." },
|
||||||
Attribute.GENERIC_ATTACK_DAMAGE);
|
Attribute.GENERIC_ATTACK_DAMAGE);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package net.Indyuce.mmoitems.stat;
|
package net.Indyuce.mmoitems.stat;
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
import net.Indyuce.mmoitems.stat.type.AttackWeaponStat;
|
||||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
|
|
||||||
public class AttackSpeed extends AttributeStat {
|
public class AttackSpeed extends AttackWeaponStat {
|
||||||
public AttackSpeed() {
|
public AttackSpeed() {
|
||||||
super("ATTACK_SPEED", VersionMaterial.LIGHT_GRAY_DYE.toMaterial(), "Attack Speed",
|
super("ATTACK_SPEED", VersionMaterial.LIGHT_GRAY_DYE.toMaterial(), "Attack Speed",
|
||||||
new String[] { "The speed at which your weapon strikes.", "In attacks/sec." }, Attribute.GENERIC_ATTACK_SPEED);
|
new String[] { "The speed at which your weapon strikes.", "In attacks/sec." }, Attribute.GENERIC_ATTACK_SPEED);
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
package net.Indyuce.mmoitems.stat;
|
package net.Indyuce.mmoitems.stat;
|
||||||
|
|
||||||
|
import net.Indyuce.mmoitems.stat.type.DoubleStat;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.attribute.Attribute;
|
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
public class KnockbackResistance extends DoubleStat {
|
||||||
|
|
||||||
public class KnockbackResistance extends AttributeStat {
|
|
||||||
public KnockbackResistance() {
|
public KnockbackResistance() {
|
||||||
super("KNOCKBACK_RESISTANCE", Material.CHAINMAIL_CHESTPLATE, "Knockback Resistance", new String[] {
|
super("KNOCKBACK_RESISTANCE", Material.CHAINMAIL_CHESTPLATE, "Knockback Resistance", new String[] {
|
||||||
"The chance of your item to block the", "knockback from explosions, creepers...", "1.0 corresponds to 100%, 0.7 to 70%..." },
|
"The chance of your item to block the", "knockback from explosions, creepers...", "1.0 corresponds to 100%, 0.7 to 70%..." });
|
||||||
Attribute.GENERIC_KNOCKBACK_RESISTANCE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package net.Indyuce.mmoitems.stat;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.attribute.Attribute;
|
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
|
||||||
|
|
||||||
public class MaxHealth extends AttributeStat {
|
|
||||||
public MaxHealth() {
|
|
||||||
super("MAX_HEALTH", Material.GOLDEN_APPLE, "Max Health",
|
|
||||||
new String[] { "The amount of health your", "item gives to the holder." }, Attribute.GENERIC_MAX_HEALTH);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +1,11 @@
|
|||||||
package net.Indyuce.mmoitems.stat;
|
package net.Indyuce.mmoitems.stat;
|
||||||
|
|
||||||
|
import net.Indyuce.mmoitems.stat.type.DoubleStat;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.attribute.Attribute;
|
|
||||||
|
|
||||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
public class MovementSpeed extends DoubleStat {
|
||||||
|
|
||||||
public class MovementSpeed extends AttributeStat {
|
|
||||||
public MovementSpeed() {
|
public MovementSpeed() {
|
||||||
super("MOVEMENT_SPEED", Material.LEATHER_BOOTS, "Movement Speed",
|
super("MOVEMENT_SPEED", Material.LEATHER_BOOTS, "Movement Speed", new String[] { "Movement Speed increase walk speed.", "Default MC walk speed: 0.1" });
|
||||||
new String[] { "Movement Speed increase walk speed.", "Default MC walk speed: 0.1" }, Attribute.GENERIC_MOVEMENT_SPEED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,16 +5,15 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute stats are also collected when registered in the StatManager because
|
* Since MMOItems 6.7 attribute stats are now fully handled by MythicLib.
|
||||||
* their corresponding player vanilla attributes must be updated when the player
|
|
||||||
* stat value changes.
|
|
||||||
*
|
*
|
||||||
* @author cympe
|
* @author jules
|
||||||
|
* @see {@link #getOffset(PlayerData)} for class use case
|
||||||
*/
|
*/
|
||||||
public abstract class AttributeStat extends DoubleStat {
|
public abstract class AttackWeaponStat extends DoubleStat {
|
||||||
private final Attribute attribute;
|
private final Attribute attribute;
|
||||||
|
|
||||||
public AttributeStat(String id, Material mat, String name, String[] lore, Attribute attribute) {
|
public AttackWeaponStat(String id, Material mat, String name, String[] lore, Attribute attribute) {
|
||||||
super(id, mat, name, lore, new String[]{"!consumable", "!block", "!miscellaneous", "all"});
|
super(id, mat, name, lore, new String[]{"!consumable", "!block", "!miscellaneous", "all"});
|
||||||
|
|
||||||
this.attribute = attribute;
|
this.attribute = attribute;
|
||||||
@ -40,7 +39,7 @@ public abstract class AttributeStat extends DoubleStat {
|
|||||||
* This generated issues when MMOCore changed the player's base attribute
|
* This generated issues when MMOCore changed the player's base attribute
|
||||||
* value to non default values.
|
* value to non default values.
|
||||||
*
|
*
|
||||||
* @return Offset that need
|
* @return Offset that needs to be substract from the apparent stat value
|
||||||
*/
|
*/
|
||||||
public double getOffset(PlayerData playerData) {
|
public double getOffset(PlayerData playerData) {
|
||||||
return playerData.getPlayer().getAttribute(attribute).getBaseValue();
|
return playerData.getPlayer().getAttribute(attribute).getBaseValue();
|
Loading…
Reference in New Issue
Block a user