ACTUALLY fixed the MMOItems damage compatibility

This commit is contained in:
Aria 2019-09-19 18:56:05 +02:00
parent ba6eb65c31
commit cdc25b8417

View File

@ -15,7 +15,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
import com.codingforcookies.armorequip.ArmorEquipEvent; import com.codingforcookies.armorequip.ArmorEquipEvent;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.event.PlayerAttackEvent; import net.Indyuce.mmocore.api.event.PlayerAttackEvent;
import net.Indyuce.mmocore.api.event.PlayerCombatEvent; import net.Indyuce.mmocore.api.event.PlayerCombatEvent;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
@ -23,6 +22,7 @@ import net.Indyuce.mmocore.api.player.stats.PlayerStats;
import net.Indyuce.mmocore.api.player.stats.StatType; import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType; import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
import net.Indyuce.mmocore.gui.api.PluginInventory; import net.Indyuce.mmocore.gui.api.PluginInventory;
import net.Indyuce.mmoitems.api.AttackResult;
public class PlayerListener implements Listener { public class PlayerListener implements Listener {
@ -99,19 +99,20 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler @EventHandler
public void h(PlayerAttackEvent event) { public void h(PlayerAttackEvent event) {
double d = 1; double damage = event.getDamage();
double d = 1, s = 1;
if(Bukkit.getPluginManager().isPluginEnabled("MMOItems"))
for (DamageType type : event.getDamageInfo().getTypes())
s += (net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayer()).getStats()
.getStat(AttackResult.DamageType.valueOf(type.name()).getStat()) / 100);
if(Bukkit.getPluginManager().isPluginEnabled("MMOItems") && damage /= s;
event.getDamageInfo().getTypes().contains(DamageType.SKILL)) {
event.setDamage(event.getDamage());
return;
}
PlayerStats stats = event.getData().getStats(); PlayerStats stats = event.getData().getStats();
for (DamageType type : event.getDamageInfo().getTypes()) for (DamageType type : event.getDamageInfo().getTypes())
d += stats.getStat(type.getStat()) / 100; d += (stats.getStat(type.getStat())) / 100;
MMOCore.log("Damage: " + event.getDamage() * d); event.setDamage(damage * d);
event.setDamage(event.getDamage() * d);
} }
} }