This commit is contained in:
Sarah 2015-08-10 14:01:12 +02:00
commit aea081c292

View File

@ -3,16 +3,20 @@ package mineplex.hub.modules;
import java.util.ArrayList;
import java.util.HashSet;
import org.bukkit.EntityEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
@ -350,6 +354,12 @@ public class SoccerManager extends MiniPlugin
if (_ball != null && _ball.equals(ent))
continue;
if (ent instanceof Bat)
{
ent.remove();
continue;
}
if (inPlayerArena(ent))
{
Location bounce = UtilAlg.getMidpoint(_cornerFieldPlayerA, _cornerFieldPlayerB);
@ -491,4 +501,30 @@ public class SoccerManager extends MiniPlugin
{
_active.remove(event.getPlayer());
}
@EventHandler(priority = EventPriority.HIGHEST)
public void allowDamage(EntityDamageByEntityEvent event)
{
if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player))
return;
Player damager = (Player)event.getDamager();
Player damagee = (Player)event.getEntity();
if (!_active.contains(damager) || !_active.contains(damagee))
return;
if (getTeamColor(damager) == null || getTeamColor(damagee) == null)
return;
if (getTeamColor(damager) == getTeamColor(damagee))
return;
if (Recharge.Instance.use(damagee, "Football Damage", 800, false, false))
{
UtilAction.velocity(damagee, UtilAlg.getTrajectory2d(damager, damagee), 0.6, false, 0, 0.3, 1, true);
damagee.playEffect(EntityEffect.HURT);
}
}
}