Master Builders, added stats

This commit is contained in:
Teddy 2016-01-18 10:32:38 +00:00
parent c16a719be1
commit 56b3e482f2
5 changed files with 70 additions and 10 deletions

View File

@ -16,7 +16,7 @@ import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.barbarians.kits.*; import nautilus.game.arcade.game.games.barbarians.kits.*;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.stats.BlockBreakStat; import nautilus.game.arcade.stats.BlockBreakStatTracker;
public class Barbarians extends SoloGame public class Barbarians extends SoloGame
{ {
@ -62,7 +62,7 @@ public class Barbarians extends SoloGame
this.BlockBreakAllow.add(136); this.BlockBreakAllow.add(136);
registerStatTrackers( registerStatTrackers(
new BlockBreakStat(this, true) new BlockBreakStatTracker(this, true)
); );
registerChatStats( registerChatStats(

View File

@ -37,6 +37,9 @@ import nautilus.game.arcade.game.games.build.gui.MobShop;
import nautilus.game.arcade.game.games.build.gui.OptionsShop; import nautilus.game.arcade.game.games.build.gui.OptionsShop;
import nautilus.game.arcade.game.games.build.kits.KitBuilder; import nautilus.game.arcade.game.games.build.kits.KitBuilder;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.stats.BlockBreakStatTracker;
import nautilus.game.arcade.stats.BlockPlaceStatTracker;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Effect; import org.bukkit.Effect;
@ -216,7 +219,15 @@ public class Build extends SoloGame
_optionsShop = new OptionsShop(this, getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation()); _optionsShop = new OptionsShop(this, getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation());
_shopItem = ItemStackFactory.Instance.CreateStack(Material.DIAMOND, (byte) 0, 1, C.cGreen + "Options"); _shopItem = ItemStackFactory.Instance.CreateStack(Material.DIAMOND, (byte) 0, 1, C.cGreen + "Options");
registerChatStats(); registerStatTrackers(
new BlockBreakStatTracker(this, false),
new BlockPlaceStatTracker(this, new Material[]{})
);
registerChatStats(
new ChatStatData("BlocksPlaced", "Blocks Placed", true),
new ChatStatData("BlocksBroken", "Blocks Broken", true)
);
} }
@EventHandler @EventHandler

View File

@ -354,6 +354,7 @@ public class GameChatManager implements Listener
/** DONE */ /** DONE */
// BaconBrawl // BaconBrawl
// Barbarians // Barbarians
// Bridges
/** BROKEN */ /** BROKEN */
// BossBattles // BossBattles

View File

@ -10,29 +10,29 @@ import nautilus.game.arcade.game.Game;
/** /**
* Created by TeddehDev on 15/01/2016. * Created by TeddehDev on 15/01/2016.
*/ */
public class BlockBreakStat extends StatTracker<Game> public class BlockBreakStatTracker extends StatTracker<Game>
{ {
private Game _game;
private boolean _blockDamage; private boolean _blockDamage;
/** /**
* @param game
* @param blockDamage * @param blockDamage
* - true = triggers block damage event * - true = triggers block damage event
* - false = triggers block break event * - false = triggers block break event
*/ */
public BlockBreakStat(Game game, boolean blockDamage) public BlockBreakStatTracker(Game game, boolean blockDamage)
{ {
super(game); super(game);
_game = game;
_blockDamage = blockDamage; _blockDamage = blockDamage;
} }
@EventHandler @EventHandler
public void blockBreak(BlockBreakEvent event) public void blockBreak(BlockBreakEvent event)
{ {
if(!_game.IsLive()) if(!getGame().IsLive())
return;
if(event.isCancelled())
return; return;
if(_blockDamage) if(_blockDamage)
@ -48,7 +48,10 @@ public class BlockBreakStat extends StatTracker<Game>
@EventHandler @EventHandler
public void blockBreak(BlockDamageEvent event) public void blockBreak(BlockDamageEvent event)
{ {
if(!_game.IsLive()) if(!getGame().IsLive())
return;
if(event.isCancelled())
return; return;
if(!_blockDamage) if(!_blockDamage)

View File

@ -0,0 +1,45 @@
package nautilus.game.arcade.stats;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent;
import nautilus.game.arcade.game.Game;
/**
* Created by TeddehDev on 15/01/2016.
*/
public class BlockPlaceStatTracker extends StatTracker<Game>
{
private Material[] _ignore;
public BlockPlaceStatTracker(Game game, Material[] ignore)
{
super(game);
_ignore = ignore;
}
@EventHandler
public void blockPlace(BlockPlaceEvent event)
{
if(!getGame().IsLive())
return;
if(event.isCancelled())
return;
Player player = event.getPlayer();
if(player == null)
return;
for(Material material : _ignore)
{
if(event.getBlock().getType() == material)
continue;
addStat(event.getPlayer(), "BlocksPlaced", 1, false, false);
}
}
}