Use team.getDyeColor to color wolf collars

This commit is contained in:
Spencer 2017-12-28 18:36:59 -05:00 committed by Alexander Meech
parent d47eb2367f
commit 496d515972

View File

@ -107,9 +107,12 @@ public class PerkWolfPet extends Perk
GameTeam team = Manager.GetGame().GetTeam(cur); GameTeam team = Manager.GetGame().GetTeam(cur);
if (team != null) { if (team != null)
wolf.setCollarColor(DyeColor.getByColor(team.GetColorBase())); {
} else { wolf.setCollarColor(team.getDyeColor());
}
else
{
wolf.setCollarColor(DyeColor.GREEN); wolf.setCollarColor(DyeColor.GREEN);
} }
@ -129,7 +132,12 @@ public class PerkWolfPet extends Perk
@EventHandler @EventHandler
public void cubTargetCancel(EntityTargetEvent event) public void cubTargetCancel(EntityTargetEvent event)
{ {
if (_petMap.containsKey(event.getTarget()) && _petMap.get(event.getTarget()).contains(event.getEntity()) if (!(event.getTarget() instanceof Player) || !(event.getEntity() instanceof Wolf))
{
return;
}
if (_petMap.containsKey(event.getTarget()) && _petMap.get(event.getTarget()).contains(event.getEntity()))
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -139,10 +147,11 @@ public class PerkWolfPet extends Perk
{ {
for (Wolf wolf : _petMap.get(owner)) for (Wolf wolf : _petMap.get(owner))
{ {
if (event.getEntity().getEntityId() == wolf.getEntityId()) if (event.getEntity().equals(wolf))
{ {
if (!Manager.canHurt(owner, (Player) event.getTarget())) { if (!Manager.canHurt(owner, (Player) event.getTarget())) {
event.setCancelled(true); event.setCancelled(true);
return;
} }
} }
} }