mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 13:46:46 +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;
|
Wolf wolf = (Wolf) damager;
|
||||||
|
|
||||||
if (wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
|
if (wolf.isTamed() && (wolf.getOwner() instanceof Player))
|
||||||
{
|
{
|
||||||
Player master = Taming.getOwner(wolf, pluginx);
|
Player master = (Player) wolf.getOwner();
|
||||||
if (master == null) //Can it really happen?
|
|
||||||
return;
|
|
||||||
|
|
||||||
PlayerProfile PPo = Users.getProfile(master);
|
PlayerProfile PPo = Users.getProfile(master);
|
||||||
if(mcPermissions.getInstance().taming(master))
|
if(mcPermissions.getInstance().taming(master))
|
||||||
{
|
{
|
||||||
@ -177,7 +174,7 @@ public class Combat
|
|||||||
else if(target instanceof Wolf)
|
else if(target instanceof Wolf)
|
||||||
{
|
{
|
||||||
Wolf wolf = (Wolf) target;
|
Wolf wolf = (Wolf) target;
|
||||||
if(wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
|
if(wolf.isTamed() && (wolf.getOwner() instanceof Player))
|
||||||
Taming.preventDamage(event, pluginx);
|
Taming.preventDamage(event, pluginx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,12 @@ public class Axes {
|
|||||||
|
|
||||||
if(x instanceof Wolf){
|
if(x instanceof Wolf){
|
||||||
Wolf wolf = (Wolf)x;
|
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;
|
return;
|
||||||
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(wolf, pluginx)))
|
if(Party.getInstance().inSameParty(attacker, owner))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,10 +168,14 @@ public class Axes {
|
|||||||
if(derp instanceof Wolf)
|
if(derp instanceof Wolf)
|
||||||
{
|
{
|
||||||
Wolf hurrDurr = (Wolf)derp;
|
Wolf hurrDurr = (Wolf)derp;
|
||||||
if(Taming.getOwner(hurrDurr, pluginx) == attacker)
|
if(hurrDurr.getOwner() instanceof Player)
|
||||||
continue;
|
{
|
||||||
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, pluginx)))
|
Player owner = (Player) hurrDurr.getOwner();
|
||||||
continue;
|
if(owner == attacker)
|
||||||
|
return;
|
||||||
|
if(Party.getInstance().inSameParty(attacker, owner))
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Damage nearby LivingEntities
|
//Damage nearby LivingEntities
|
||||||
|
@ -40,11 +40,12 @@ public class Swords
|
|||||||
if(x instanceof Wolf)
|
if(x instanceof Wolf)
|
||||||
{
|
{
|
||||||
Wolf wolf = (Wolf)x;
|
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;
|
return;
|
||||||
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(wolf, pluginx)))
|
if(Party.getInstance().inSameParty(attacker, owner))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,10 +98,14 @@ public class Swords
|
|||||||
if(derp instanceof Wolf)
|
if(derp instanceof Wolf)
|
||||||
{
|
{
|
||||||
Wolf hurrDurr = (Wolf)derp;
|
Wolf hurrDurr = (Wolf)derp;
|
||||||
if(Taming.getOwner(hurrDurr, pluginx) == attacker)
|
if(hurrDurr.getOwner() instanceof Player)
|
||||||
continue;
|
{
|
||||||
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, pluginx)))
|
Player owner = (Player) hurrDurr.getOwner();
|
||||||
continue;
|
if(owner == attacker)
|
||||||
|
return;
|
||||||
|
if(Party.getInstance().inSameParty(attacker, owner))
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Damage nearby LivingEntities
|
//Damage nearby LivingEntities
|
||||||
if(derp instanceof LivingEntity && targets >= 1)
|
if(derp instanceof LivingEntity && targets >= 1)
|
||||||
|
@ -16,14 +16,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
import org.bukkit.entity.AnimalTamer;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Wolf;
|
import org.bukkit.entity.Wolf;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.Combat;
|
import com.gmail.nossr50.Combat;
|
||||||
import com.gmail.nossr50.Users;
|
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)
|
public static String getOwnerName(Wolf theWolf)
|
||||||
{
|
{
|
||||||
Player owner = null;
|
Player owner = null;
|
||||||
|
|
||||||
if (theWolf.getOwner() instanceof Player)
|
if (theWolf.getOwner() instanceof Player)
|
||||||
|
{
|
||||||
owner = (Player)theWolf.getOwner();
|
owner = (Player)theWolf.getOwner();
|
||||||
if(owner != null)
|
|
||||||
return owner.getName();
|
return owner.getName();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return "Offline Master";
|
return "Offline Master";
|
||||||
}
|
}
|
||||||
@ -149,7 +115,7 @@ public class Taming
|
|||||||
DamageCause cause = event.getCause();
|
DamageCause cause = event.getCause();
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
Wolf theWolf = (Wolf)entity;
|
Wolf theWolf = (Wolf)entity;
|
||||||
Player master = getOwner(theWolf, plugin);
|
Player master = (Player)theWolf.getOwner();
|
||||||
int skillLevel = Users.getProfile(master).getSkillLevel(SkillType.TAMING);
|
int skillLevel = Users.getProfile(master).getSkillLevel(SkillType.TAMING);
|
||||||
|
|
||||||
//Environmentally Aware
|
//Environmentally Aware
|
||||||
@ -157,7 +123,7 @@ public class Taming
|
|||||||
{
|
{
|
||||||
if(event.getDamage() < theWolf.getHealth())
|
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$
|
master.sendMessage(mcLocale.getString("mcEntityListener.WolfComesBack")); //$NON-NLS-1$
|
||||||
entity.setFireTicks(0);
|
entity.setFireTicks(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user