use of org.bukkit.entity.Arrow in project Minigames by AddstarMC.
the class Events method entityDamageEntity.
@EventHandler(priority = EventPriority.LOWEST)
private void entityDamageEntity(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player && event.getDamager() instanceof Snowball) {
MinigamePlayer ply = pdata.getMinigamePlayer((Player) event.getEntity());
if (ply == null)
return;
Snowball sb = (Snowball) event.getDamager();
if (ply.isInMinigame() && ply.getMinigame().hasPaintBallMode()) {
if (sb.getShooter() instanceof Player) {
MinigamePlayer shooter = pdata.getMinigamePlayer((Player) sb.getShooter());
Minigame mgm = ply.getMinigame();
if (shooter == null)
return;
if (shooter.isInMinigame() && shooter.getMinigame().equals(ply.getMinigame())) {
if (!shooter.canPvP()) {
event.setCancelled(true);
return;
}
Team plyTeam = ply.getTeam();
Team atcTeam = shooter.getTeam();
if (!mgm.isTeamGame() || plyTeam != atcTeam) {
int damage = mgm.getPaintBallDamage();
event.setDamage(damage);
}
}
}
}
} else if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
MinigamePlayer ply = pdata.getMinigamePlayer((Player) event.getDamager());
if (ply == null)
return;
if (ply.isInMinigame() && !ply.canPvP())
event.setCancelled(true);
else if (ply.isInMinigame() && ply.getMinigame().getState() == MinigameState.ENDED && GameOverModule.getMinigameModule(ply.getMinigame()).isHumiliationMode() && GameOverModule.getMinigameModule(ply.getMinigame()).getLosers().contains(ply)) {
event.setCancelled(true);
}
} else if (event.getEntity() instanceof Player && event.getDamager() instanceof Arrow) {
Arrow arrow = (Arrow) event.getDamager();
if (arrow.getShooter() instanceof Player) {
Player ply = (Player) arrow.getShooter();
MinigamePlayer mgpl = pdata.getMinigamePlayer(ply);
if (mgpl == null)
return;
if (mgpl.isInMinigame() && !mgpl.canPvP())
event.setCancelled(true);
}
}
}