Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheLongestShotStatTracker.java

60 lines
1.7 KiB
Java
Raw Normal View History

2014-08-23 03:54:08 +02:00
package nautilus.game.arcade.stats;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.Game;
public class TheLongestShotStatTracker extends StatTracker<Game>
{
public TheLongestShotStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (killer == null)
return;
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null)
return;
2014-08-23 22:00:15 +02:00
if (event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().equalsIgnoreCase("longshot"))
2014-08-23 03:54:08 +02:00
{
2014-08-23 22:00:15 +02:00
if (player.getLastDamageCause() instanceof EntityDamageByEntityEvent)
2014-08-23 03:54:08 +02:00
{
2014-08-23 22:00:15 +02:00
EntityDamageByEntityEvent edbee = (EntityDamageByEntityEvent) player.getLastDamageCause();
if (edbee.getDamager() instanceof Arrow)
{
Arrow arrow = (Arrow) edbee.getDamager();
2014-08-23 03:54:08 +02:00
2014-08-23 22:00:15 +02:00
if (arrow.getShooter() == killer && killer.getLocation().distanceSquared(player.getLocation()) <= 64 * 64)
getGame().AddStat(killer, "TheLongestShot", 1, false, false);
}
2014-08-23 03:54:08 +02:00
}
}
}
}