Fix clan-mates and allies being able to force despawn mounts

This commit is contained in:
AlexTheCoder 2017-07-14 06:31:03 -04:00
parent 953ad66aca
commit 460cc29c04

View File

@ -396,7 +396,7 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
}
@EventHandler(priority = EventPriority.LOWEST)
public void handleHorseHits(CustomDamageEvent event)
public void redirectHorseDamage(CustomDamageEvent event)
{
if (event.GetDamageeEntity() == null || !(event.GetDamageeEntity() instanceof Horse))
{
@ -413,14 +413,16 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
mount.despawn(false);
return;
}
event.setDamagee(mount.getOwner());
if (event.GetCause() != DamageCause.FALL)
if (mount.getEntity().getPassenger() == null)
{
mount.handleHit();
event.SetCancelled("Killing riderless mount");
mount.despawn(true);
return;
}
event.setDamagee(mount.getOwner());
}
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void handleRiderHits(CustomDamageEvent event)
{
if (event.GetDamageePlayer() == null || event.GetDamageePlayer().getVehicle() == null || !(event.GetDamageePlayer().getVehicle() instanceof Horse))