mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-01 11:11:21 +01:00
!Moved damage modifiers to MMOLib
This commit is contained in:
parent
38328fbbf8
commit
245356b517
@ -15,9 +15,6 @@ import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@ -63,10 +60,6 @@ public class MMOUtils {
|
||||
return bar.substring(0, (int) (ratio * n)) + ChatColor.WHITE + bar.substring((int) (ratio * n));
|
||||
}
|
||||
|
||||
public static boolean isUndead(Entity entity) {
|
||||
return entity instanceof Zombie || entity instanceof Skeleton || entity instanceof Wither;
|
||||
}
|
||||
|
||||
public static void giveOrDrop(Player player, ItemStack item) {
|
||||
for (ItemStack drop : player.getInventory().addItem(item).values())
|
||||
player.getWorld().dropItem(player.getLocation(), drop);
|
||||
|
@ -61,7 +61,7 @@ public class Contamination extends Ability {
|
||||
loc.getWorld().playSound(loc, VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 2, 1);
|
||||
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
|
||||
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) <= 25)
|
||||
MMOLib.plugin.getDamage().damage(stats.getPlayer(), (LivingEntity) entity, new ItemAttackResult(dps, DamageType.SKILL, DamageType.MAGICAL).applySkillEffects(stats, (LivingEntity) entity), false);
|
||||
MMOLib.plugin.getDamage().damage(stats.getPlayer(), (LivingEntity) entity, new ItemAttackResult(dps, DamageType.SKILL, DamageType.MAGICAL), false);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(MMOItems.plugin, 0, 1);
|
||||
|
@ -52,7 +52,7 @@ public class Death_Mark extends Ability {
|
||||
target.getWorld().spawnParticle(Particle.SPELL_MOB, target.getLocation(), 4, .2, 0, .2, 0);
|
||||
|
||||
if (ti % 20 == 0)
|
||||
MMOLib.plugin.getDamage().damage(stats.getPlayer(), target, new ItemAttackResult(dps, DamageType.SKILL, DamageType.MAGICAL).applySkillEffects(stats, target), false);
|
||||
MMOLib.plugin.getDamage().damage(stats.getPlayer(), target, new ItemAttackResult(dps, DamageType.SKILL, DamageType.MAGICAL), false);
|
||||
}
|
||||
}.runTaskTimer(MMOItems.plugin, 0, 1);
|
||||
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_BLAZE_HURT, 1, 2);
|
||||
|
@ -7,10 +7,8 @@ import java.util.Random;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability.CastingMode;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
@ -73,21 +71,7 @@ public class ItemAttackResult extends AttackResult {
|
||||
if (hasType(DamageType.WEAPON)) {
|
||||
applyElementalEffects(stats, item, target);
|
||||
applyOnHitEffects(stats, target);
|
||||
} else if (hasType(DamageType.SKILL))
|
||||
applySkillEffects(stats, target);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemAttackResult applySkillEffects(CachedStats stats, LivingEntity target) {
|
||||
|
||||
for (DamageType type : DamageType.values())
|
||||
if (hasType(type))
|
||||
addRelativeDamage(stats.getStat((ItemStat) type.getMMOItemsStat()) / 100);
|
||||
|
||||
addRelativeDamage(stats.getStat(target instanceof Player ? ItemStat.PVP_DAMAGE : ItemStat.PVE_DAMAGE) / 100);
|
||||
if (MMOUtils.isUndead(target))
|
||||
addRelativeDamage(stats.getStat(ItemStat.UNDEAD_DAMAGE) / 100);
|
||||
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -97,7 +81,7 @@ public class ItemAttackResult extends AttackResult {
|
||||
}
|
||||
|
||||
/*
|
||||
* vanilla melee weapons have no NBTTitems so this method only provides for
|
||||
* vanilla melee weapons have no NBT tags so this method only provides for
|
||||
* non-weapon specific effects like critical strikes and extra stat damage
|
||||
*/
|
||||
public ItemAttackResult applyOnHitEffects(CachedStats stats, LivingEntity target) {
|
||||
@ -105,15 +89,6 @@ public class ItemAttackResult extends AttackResult {
|
||||
// abilities
|
||||
stats.getPlayerData().castAbilities(stats, target, this, CastingMode.ON_HIT);
|
||||
|
||||
// extra damage
|
||||
for (DamageType type : DamageType.values())
|
||||
if (hasType(type))
|
||||
addRelativeDamage(stats.getStat((ItemStat) type.getMMOItemsStat()) / 100);
|
||||
|
||||
addRelativeDamage(stats.getStat(target instanceof Player ? ItemStat.PVP_DAMAGE : ItemStat.PVE_DAMAGE) / 100);
|
||||
if (MMOUtils.isUndead(target))
|
||||
addRelativeDamage(stats.getStat(ItemStat.UNDEAD_DAMAGE) / 100);
|
||||
|
||||
// critical strikes
|
||||
if (random.nextDouble() <= stats.getStat(ItemStat.CRITICAL_STRIKE_CHANCE) / 100) {
|
||||
multiplyDamage(MMOItems.plugin.getConfig().getDouble("crit-coefficient") + stats.getStat(ItemStat.CRITICAL_STRIKE_POWER) / 100);
|
||||
|
@ -172,10 +172,10 @@ public class CraftingStatus {
|
||||
//
|
||||
// public
|
||||
// public class InstantCraftingInfo extends CraftingInfo {
|
||||
// private final PlayerData data;
|
||||
// private final PlayerDataManager data;
|
||||
// private boolean timedOut;
|
||||
//
|
||||
// public InstantCraftingInfo(PlayerData data, Recipe recipe) {
|
||||
// public InstantCraftingInfo(PlayerDataManager data, Recipe recipe) {
|
||||
// super(recipe);
|
||||
// this.data = data;
|
||||
// }
|
||||
|
@ -10,19 +10,18 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.item.MMOItem;
|
||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.mmogroup.mmolib.api.player.MMOData;
|
||||
import net.mmogroup.mmolib.api.stat.StatInstance;
|
||||
import net.mmogroup.mmolib.api.stat.StatMap;
|
||||
|
||||
public class PlayerStats {
|
||||
private final PlayerData playerData;
|
||||
|
||||
private final StatMap map;
|
||||
|
||||
public PlayerStats(PlayerData playerData) {
|
||||
this.playerData = playerData;
|
||||
|
||||
map = StatMap.get(playerData.getPlayer());
|
||||
map.getPlayerData().setMMOItems(playerData);
|
||||
|
||||
map = MMOData.get(playerData.getPlayer()).setMMOItems(playerData).getStatMap();
|
||||
}
|
||||
|
||||
public PlayerData getPlayerData() {
|
||||
@ -46,7 +45,7 @@ public class PlayerStats {
|
||||
t += item.getNBTItem().getStat(stat.getId());
|
||||
|
||||
if (t != 0)
|
||||
getInstance(stat).addModifier("item", t + (stat instanceof AttributeStat ? -((AttributeStat) stat).getOffset() : 0 ));
|
||||
getInstance(stat).addModifier("item", t + (stat instanceof AttributeStat ? -((AttributeStat) stat).getOffset() : 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,30 +57,10 @@ public class PlayerStats {
|
||||
return map.getInstance(stat.getId());
|
||||
}
|
||||
|
||||
// public void updateAttributeModifiers() {
|
||||
// for (AttributeStat stat : MMOItems.plugin.getStats().getAttributeStats()) {
|
||||
// AttributeInstance ins = playerData.getPlayer().getAttribute(stat.getAttribute());
|
||||
// removeAttributeModifiers(ins);
|
||||
//
|
||||
// double value = getStat(stat);
|
||||
// if (value != 0)
|
||||
// ins.addModifier(new AttributeModifier(UUID.randomUUID(), "mmoitems." + stat.getId(), value - stat.getOffset(), Operation.ADD_NUMBER));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void removeAttributeModifiers(AttributeInstance ins) {
|
||||
// for (Iterator<AttributeModifier> iterator = ins.getModifiers().iterator(); iterator.hasNext();) {
|
||||
// AttributeModifier attribute = iterator.next();
|
||||
// if (attribute.getName().startsWith("mmoitems."))
|
||||
// ins.removeModifier(attribute);
|
||||
// }
|
||||
// }
|
||||
|
||||
public CachedStats newTemporary() {
|
||||
return new CachedStats();
|
||||
}
|
||||
|
||||
|
||||
public class CachedStats {
|
||||
|
||||
/*
|
||||
@ -90,7 +69,7 @@ public class PlayerStats {
|
||||
* not to add a safe check in every ability loop.
|
||||
*/
|
||||
private final Player player;
|
||||
|
||||
|
||||
private final Map<String, Double> stats = new HashMap<>();
|
||||
|
||||
public CachedStats() {
|
||||
@ -111,7 +90,6 @@ public class PlayerStats {
|
||||
return stats.containsKey(stat.getId()) ? stats.get(stat.getId()) : 0;
|
||||
}
|
||||
|
||||
|
||||
public void setStat(ItemStat stat, double value) {
|
||||
stats.put(stat.getId(), value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user