From 56b3e482f2f9ad26150dce20ecd2a514618e5aa8 Mon Sep 17 00:00:00 2001 From: Teddy Date: Mon, 18 Jan 2016 10:32:38 +0000 Subject: [PATCH] Master Builders, added stats --- .../game/games/barbarians/Barbarians.java | 4 +- .../game/arcade/game/games/build/Build.java | 13 +++++- .../arcade/managers/chat/GameChatManager.java | 1 + ...akStat.java => BlockBreakStatTracker.java} | 17 ++++--- .../arcade/stats/BlockPlaceStatTracker.java | 45 +++++++++++++++++++ 5 files changed, 70 insertions(+), 10 deletions(-) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/{BlockBreakStat.java => BlockBreakStatTracker.java} (79%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockPlaceStatTracker.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java index f35b44dba..c48e919eb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java @@ -16,7 +16,7 @@ import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.barbarians.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; -import nautilus.game.arcade.stats.BlockBreakStat; +import nautilus.game.arcade.stats.BlockBreakStatTracker; public class Barbarians extends SoloGame { @@ -62,7 +62,7 @@ public class Barbarians extends SoloGame this.BlockBreakAllow.add(136); registerStatTrackers( - new BlockBreakStat(this, true) + new BlockBreakStatTracker(this, true) ); registerChatStats( diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java index ea4b68bac..67a85265e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -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.kits.KitBuilder; 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.Effect; @@ -216,7 +219,15 @@ public class Build extends SoloGame _optionsShop = new OptionsShop(this, getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation()); _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 diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index b5511b1b7..b645a5da0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -354,6 +354,7 @@ public class GameChatManager implements Listener /** DONE */ // BaconBrawl // Barbarians +// Bridges /** BROKEN */ // BossBattles diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockBreakStat.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockBreakStatTracker.java similarity index 79% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockBreakStat.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockBreakStatTracker.java index e1b36d8d2..c89a37be8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockBreakStat.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockBreakStatTracker.java @@ -10,29 +10,29 @@ import nautilus.game.arcade.game.Game; /** * Created by TeddehDev on 15/01/2016. */ -public class BlockBreakStat extends StatTracker +public class BlockBreakStatTracker extends StatTracker { - private Game _game; private boolean _blockDamage; /** - * @param game * @param blockDamage * - true = triggers block damage event * - false = triggers block break event */ - public BlockBreakStat(Game game, boolean blockDamage) + public BlockBreakStatTracker(Game game, boolean blockDamage) { super(game); - _game = game; _blockDamage = blockDamage; } @EventHandler public void blockBreak(BlockBreakEvent event) { - if(!_game.IsLive()) + if(!getGame().IsLive()) + return; + + if(event.isCancelled()) return; if(_blockDamage) @@ -48,7 +48,10 @@ public class BlockBreakStat extends StatTracker @EventHandler public void blockBreak(BlockDamageEvent event) { - if(!_game.IsLive()) + if(!getGame().IsLive()) + return; + + if(event.isCancelled()) return; if(!_blockDamage) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockPlaceStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockPlaceStatTracker.java new file mode 100644 index 000000000..f210bc7d7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockPlaceStatTracker.java @@ -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 +{ + 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); + } + } +}