diff --git a/src/main/java/com/gmail/nossr50/Combat.java b/src/main/java/com/gmail/nossr50/Combat.java index bccff85b0..081250f5d 100644 --- a/src/main/java/com/gmail/nossr50/Combat.java +++ b/src/main/java/com/gmail/nossr50/Combat.java @@ -82,6 +82,10 @@ public class Combat Axes.axeCriticalCheck(attacker, event, pluginx); //Critical hit + //Impact + if(event.getEntity() instanceof LivingEntity) + Axes.impact(attacker, (LivingEntity)event.getEntity()); + if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSkullSplitterMode()) Axes.applyAoeDamage(attacker, event, pluginx); diff --git a/src/main/java/com/gmail/nossr50/skills/Axes.java b/src/main/java/com/gmail/nossr50/skills/Axes.java index 656538dea..d284048f7 100644 --- a/src/main/java/com/gmail/nossr50/skills/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/Axes.java @@ -17,11 +17,13 @@ package com.gmail.nossr50.skills; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Wolf; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import com.gmail.nossr50.Combat; @@ -80,6 +82,53 @@ public class Axes { } } + public static void impact(Player attacker, LivingEntity target) + { + boolean didImpact = false; + + if(target instanceof Player) + { + Player targetPlayer = (Player) target; + int emptySlots = 0; + + for(ItemStack x : targetPlayer.getInventory().getArmorContents()) + { + System.out.println("[mcMMO] DEBUG: "+x.getType().toString()); + if(x.getType() == Material.AIR) + { + emptySlots++; + } else { + x.setDurability((short) (x.getDurability()+30)); //Damage armor piece + } + } + + if(emptySlots == 4) + { + targetPlayer.sendMessage("**HIT BY IMPACT**"); + didImpact = applyImpact(target); + } + } else { + //Since mobs are technically unarmored this will always trigger + didImpact = applyImpact(target); + } + + if(didImpact) + { + attacker.sendMessage("STRUCK WITH GREAT FORCE!"); + } + } + + public static boolean applyImpact(LivingEntity target) + { + if(Math.random() * 100 > 75) + { + target.teleport(target.getLocation()); + target.damage(2); + return true; + } + return false; + } + public static void applyAoeDamage(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx) { int targets = 0;