2014-08-23 03:54:08 +02:00
|
|
|
package nautilus.game.arcade.stats;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2015-07-20 04:38:03 +02:00
|
|
|
if (!getGame().IsLive())
|
2014-08-25 22:27:02 +02:00
|
|
|
return;
|
|
|
|
|
2014-08-23 03:54:08 +02:00
|
|
|
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());
|
2015-07-20 04:38:03 +02:00
|
|
|
|
|
|
|
if (player == null || !player.isOnline())
|
2014-08-23 03:54:08 +02:00
|
|
|
return;
|
|
|
|
|
2015-07-20 16:02:50 +02:00
|
|
|
if (event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().toLowerCase().contains("longshot"))
|
2014-08-23 03:54:08 +02:00
|
|
|
{
|
2015-07-20 04:38:03 +02:00
|
|
|
if (killer.getLocation().distance(player.getLocation()) >= 64)
|
|
|
|
{
|
2014-09-19 08:46:04 +02:00
|
|
|
addStat(killer, "TheLongestShot", 1, false, false);
|
2015-07-20 04:38:03 +02:00
|
|
|
}
|
2014-08-23 03:54:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|