fixed damage transfer for mama pigglez kit

This commit is contained in:
Cheese 2015-04-01 17:43:46 +11:00
parent 31ddeaac50
commit 8bd883cb26
2 changed files with 31 additions and 0 deletions

View File

@ -243,6 +243,15 @@ public class CustomDamageEvent extends Event implements Cancellable
_damagerPlayer = (Player)ent;
}
public void setDamagee(LivingEntity ent)
{
_damageeEntity = ent;
_damageePlayer = null;
if (ent instanceof Player)
_damageePlayer = (Player)ent;
}
public void changeReason(String initial, String reason)
{
for (DamageChange change : _damageMod)
@ -307,4 +316,6 @@ public class CustomDamageEvent extends Event implements Cancellable
{
SetCancelled("No reason given because SOMEONE IS AN IDIOT");
}
}

View File

@ -3,14 +3,17 @@ package nautilus.game.arcade.game.games.baconbrawl.kits;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguisePig;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
@ -69,4 +72,21 @@ public class KitMamaPig extends Kit
}
}, 2);
}
@EventHandler
public void damageTransfer(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (!(event.GetDamageeEntity() instanceof Pig))
return;
Pig pig = (Pig)event.GetDamageeEntity();
if (pig.getVehicle() == null || !(pig.getPassenger() instanceof LivingEntity))
return;
event.setDamagee((LivingEntity)pig.getVehicle());
}
}