Added team kill and death achievement trackers
This commit is contained in:
parent
4ce537a3a7
commit
9acc7d8496
@ -8,6 +8,9 @@ import nautilus.game.arcade.*;
|
||||
import nautilus.game.arcade.events.*;
|
||||
import nautilus.game.arcade.game.GameTeam.*;
|
||||
import nautilus.game.arcade.kit.*;
|
||||
import nautilus.game.arcade.stats.TeamGameDeathsStatTracker;
|
||||
import nautilus.game.arcade.stats.TeamGameKillsStatTracker;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.event.player.*;
|
||||
@ -27,6 +30,11 @@ public abstract class TeamGame extends Game
|
||||
public TeamGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
|
||||
{
|
||||
super(manager, gameType, kits, gameDesc);
|
||||
|
||||
registerStatTrackers(
|
||||
new TeamGameDeathsStatTracker(this),
|
||||
new TeamGameKillsStatTracker(this)
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -0,0 +1,41 @@
|
||||
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;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
|
||||
public class TeamGameDeathsStatTracker extends StatTracker<TeamGame>
|
||||
{
|
||||
public TeamGameDeathsStatTracker(TeamGame game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onCombatDeath(CombatDeathEvent event)
|
||||
{
|
||||
if (getGame().GetState() != Game.GameState.Live)
|
||||
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;
|
||||
|
||||
GameTeam team = getGame().GetTeam(player);
|
||||
|
||||
if (team != null && team.GetName() != null)
|
||||
getGame().AddStat(player, team.GetName() + " Deaths", 1, false, false);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
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;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
|
||||
public class TeamGameKillsStatTracker extends StatTracker<TeamGame>
|
||||
{
|
||||
public TeamGameKillsStatTracker(TeamGame game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onCombatDeath(CombatDeathEvent event)
|
||||
{
|
||||
if (getGame().GetState() != Game.GameState.Live)
|
||||
return;
|
||||
|
||||
if (event.GetLog().GetKiller() == null)
|
||||
return;
|
||||
|
||||
if (!event.GetLog().GetKiller().IsPlayer())
|
||||
return;
|
||||
|
||||
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
GameTeam team = getGame().GetTeam(player);
|
||||
|
||||
if (team != null && team.GetName() != null)
|
||||
getGame().AddStat(player, team.GetName() + " Kills", 1, false, false);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user