diff --git a/src/main/java/com/gmail/nossr50/Combat.java b/src/main/java/com/gmail/nossr50/Combat.java index afc6d1540..9d56e4b14 100644 --- a/src/main/java/com/gmail/nossr50/Combat.java +++ b/src/main/java/com/gmail/nossr50/Combat.java @@ -134,12 +134,9 @@ public class Combat { Wolf wolf = (Wolf) damager; - if (wolf.isTamed() && Taming.ownerOnline(wolf, pluginx)) + if (wolf.isTamed() && (wolf.getOwner() instanceof Player)) { - Player master = Taming.getOwner(wolf, pluginx); - if (master == null) //Can it really happen? - return; - + Player master = (Player) wolf.getOwner(); PlayerProfile PPo = Users.getProfile(master); if(mcPermissions.getInstance().taming(master)) { @@ -177,7 +174,7 @@ public class Combat else if(target instanceof Wolf) { Wolf wolf = (Wolf) target; - if(wolf.isTamed() && Taming.ownerOnline(wolf, pluginx)) + if(wolf.isTamed() && (wolf.getOwner() instanceof Player)) Taming.preventDamage(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 c06f3763d..f7fa5a051 100644 --- a/src/main/java/com/gmail/nossr50/skills/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/Axes.java @@ -53,11 +53,12 @@ public class Axes { if(x instanceof Wolf){ Wolf wolf = (Wolf)x; - if(Taming.getOwner(wolf, pluginx) != null) + if(wolf.getOwner() instanceof Player) { - if(Taming.getOwner(wolf, pluginx) == attacker) + Player owner = (Player) wolf.getOwner(); + if(owner == attacker) return; - if(Party.getInstance().inSameParty(attacker, Taming.getOwner(wolf, pluginx))) + if(Party.getInstance().inSameParty(attacker, owner)) return; } } @@ -167,10 +168,14 @@ public class Axes { if(derp instanceof Wolf) { Wolf hurrDurr = (Wolf)derp; - if(Taming.getOwner(hurrDurr, pluginx) == attacker) - continue; - if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, pluginx))) - continue; + if(hurrDurr.getOwner() instanceof Player) + { + Player owner = (Player) hurrDurr.getOwner(); + if(owner == attacker) + return; + if(Party.getInstance().inSameParty(attacker, owner)) + return; + } } //Damage nearby LivingEntities diff --git a/src/main/java/com/gmail/nossr50/skills/Swords.java b/src/main/java/com/gmail/nossr50/skills/Swords.java index 61bf1ca12..4ac96bae9 100644 --- a/src/main/java/com/gmail/nossr50/skills/Swords.java +++ b/src/main/java/com/gmail/nossr50/skills/Swords.java @@ -40,11 +40,12 @@ public class Swords if(x instanceof Wolf) { Wolf wolf = (Wolf)x; - if(Taming.getOwner(wolf, pluginx) != null) + if(wolf.getOwner() instanceof Player) { - if(Taming.getOwner(wolf, pluginx) == attacker) + Player owner = (Player) wolf.getOwner(); + if(owner == attacker) return; - if(Party.getInstance().inSameParty(attacker, Taming.getOwner(wolf, pluginx))) + if(Party.getInstance().inSameParty(attacker, owner)) return; } } @@ -97,10 +98,14 @@ public class Swords if(derp instanceof Wolf) { Wolf hurrDurr = (Wolf)derp; - if(Taming.getOwner(hurrDurr, pluginx) == attacker) - continue; - if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, pluginx))) - continue; + if(hurrDurr.getOwner() instanceof Player) + { + Player owner = (Player) hurrDurr.getOwner(); + if(owner == attacker) + return; + if(Party.getInstance().inSameParty(attacker, owner)) + return; + } } //Damage nearby LivingEntities if(derp instanceof LivingEntity && targets >= 1) diff --git a/src/main/java/com/gmail/nossr50/skills/Taming.java b/src/main/java/com/gmail/nossr50/skills/Taming.java index b7c7c6f4b..c5758b60e 100644 --- a/src/main/java/com/gmail/nossr50/skills/Taming.java +++ b/src/main/java/com/gmail/nossr50/skills/Taming.java @@ -16,14 +16,12 @@ */ package com.gmail.nossr50.skills; -import org.bukkit.entity.AnimalTamer; 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.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.plugin.Plugin; import com.gmail.nossr50.Combat; import com.gmail.nossr50.Users; @@ -99,47 +97,15 @@ public class Taming } } - public static boolean ownerOnline(Wolf theWolf, Plugin pluginx) - { - for(Player x : pluginx.getServer().getOnlinePlayers()) - { - if(x instanceof AnimalTamer) - { - AnimalTamer tamer = (AnimalTamer)x; - if(theWolf.getOwner() == tamer) - return true; - } - } - return false; - } - - public static Player getOwner(Entity wolf, Plugin pluginx) - { - if(wolf instanceof Wolf) - { - Wolf theWolf = (Wolf)wolf; - for(Player x : pluginx.getServer().getOnlinePlayers()) - { - if(x instanceof AnimalTamer && x.isOnline()) - { - AnimalTamer tamer = (AnimalTamer)x; - if(theWolf.getOwner() == tamer) - return x; - } - } - return null; - } - return null; - } - public static String getOwnerName(Wolf theWolf) { Player owner = null; if (theWolf.getOwner() instanceof Player) + { owner = (Player)theWolf.getOwner(); - if(owner != null) return owner.getName(); + } else return "Offline Master"; } @@ -149,7 +115,7 @@ public class Taming DamageCause cause = event.getCause(); Entity entity = event.getEntity(); Wolf theWolf = (Wolf)entity; - Player master = getOwner(theWolf, plugin); + Player master = (Player)theWolf.getOwner(); int skillLevel = Users.getProfile(master).getSkillLevel(SkillType.TAMING); //Environmentally Aware @@ -157,7 +123,7 @@ public class Taming { if(event.getDamage() < theWolf.getHealth()) { - entity.teleport(Taming.getOwner(theWolf, plugin).getLocation()); + entity.teleport(master.getLocation()); master.sendMessage(mcLocale.getString("mcEntityListener.WolfComesBack")); //$NON-NLS-1$ entity.setFireTicks(0); }