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

64 lines
1.6 KiB
Java
Raw Normal View History

2014-08-20 03:16:28 +02:00
package nautilus.game.arcade.stats;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
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 mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game;
public class RecoveryMasterStatTracker extends StatTracker<Game>
{
private final Map<UUID, Double> _damageTaken = new HashMap<>();
public RecoveryMasterStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
2014-08-25 22:27:02 +02:00
if (getGame().GetState() != Game.GameState.Live)
return;
2014-08-20 03:16:28 +02:00
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null)
return;
_damageTaken.remove(player.getUniqueId());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCustomDamage(CustomDamageEvent event)
{
2014-08-25 22:27:02 +02:00
if (getGame().GetState() != Game.GameState.Live)
return;
2014-08-20 03:16:28 +02:00
Player damagee = event.GetDamageePlayer();
if (damagee == null)
return;
Double damage = _damageTaken.get(damagee.getUniqueId());
damage = (damage == null ? 0 : damage) + event.GetDamage();
_damageTaken.put(damagee.getUniqueId(), damage);
if (damage >= 200)
addStat(damagee, "RecoveryMaster", 1, true, false);
2014-08-20 03:16:28 +02:00
}
}