Ensure achievements are tracked

This commit is contained in:
Sam 2018-01-10 14:14:10 +00:00 committed by Alexander Meech
parent f11f95a3d7
commit ba2eeca97d
7 changed files with 66 additions and 140 deletions

View File

@ -1,41 +0,0 @@
package nautilus.game.arcade.game.games.skywars.events;
import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerKillZombieEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private final Player _who;
private final Zombie _zombie;
public PlayerKillZombieEvent(Player who, Zombie zombie)
{
this._who = who;
this._zombie = zombie;
}
public Player getWho()
{
return _who;
}
public Zombie getZombie() {
return _zombie;
}
}

View File

@ -1,35 +0,0 @@
package nautilus.game.arcade.game.games.skywars.events;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class TNTPickupEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private static Player _who;
public TNTPickupEvent(Player who)
{
super(who);
_who = who;
}
public Player getWho()
{
return _who;
}
}

View File

@ -170,6 +170,7 @@ public class ZombieGuardianModule extends Module
return;
}
Zombie zombie = (Zombie) entity;
ChestLootModule lootModule = getGame().getModule(ChestLootModule.class);
ItemStack randomItem = lootModule.getRandomItem("Middle");
@ -179,5 +180,10 @@ public class ZombieGuardianModule extends Module
{
event.getDrops().add(randomItem);
}
if (zombie.getKiller() != null)
{
getGame().AddStat(zombie.getKiller(), "ZombieKills", 1, false, false);
}
}
}

View File

@ -0,0 +1,23 @@
package nautilus.game.arcade.game.games.skywars.trackers;
import org.bukkit.event.EventHandler;
import nautilus.game.arcade.game.games.skywars.Skywars;
import nautilus.game.arcade.game.modules.generator.GeneratorCollectEvent;
import nautilus.game.arcade.stats.StatTracker;
public class TNTStatTracker extends StatTracker<Skywars>
{
public TNTStatTracker(Skywars game)
{
super(game);
}
@EventHandler
public void onTNTPickup(GeneratorCollectEvent event)
{
addStat(event.getPlayer(), "BombPickups", 1, false, false);
}
}

View File

@ -0,0 +1,37 @@
package nautilus.game.arcade.game.modules.generator;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class GeneratorCollectEvent extends PlayerEvent
{
private static final HandlerList HANDLER_LIST = new HandlerList();
private final Generator _generator;
public GeneratorCollectEvent(Player who, Generator generator)
{
super(who);
_generator = generator;
}
public Generator getGenerator()
{
return _generator;
}
public static HandlerList getHandlerList()
{
return HANDLER_LIST;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
}

View File

@ -1,38 +0,0 @@
package nautilus.game.arcade.stats;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.skywars.events.PlayerKillZombieEvent;
import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
public class SkywarsKillZombieStatTracker extends StatTracker<Game>
{
public SkywarsKillZombieStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onKillZombie(PlayerKillZombieEvent event)
{
if (getGame().GetState() != Game.GameState.Live)
return;
if (!(event.getWho() instanceof Player))
{
return;
}
if (!(event.getZombie() instanceof Zombie))
{
return;
}
addStat(event.getWho(), "ZombieKills", 1, false, false);
}
}

View File

@ -1,26 +0,0 @@
package nautilus.game.arcade.stats;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.skywars.events.TNTPickupEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
public class SkywarsTNTStatTracker extends StatTracker<Game>
{
public SkywarsTNTStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onTNTPickup(TNTPickupEvent event)
{
if (getGame().GetState() != Game.GameState.Live)
return;
addStat(event.getWho(), "BombPickups", 1, false, false);
}
}