mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Updates to Taming
This commit is contained in:
parent
5a8b9fc344
commit
f9b9dddbc8
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user