From ddc86f089738072270e963758e4f6e0f7ed6db0d Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 22 Jan 2016 19:13:23 -0500 Subject: [PATCH] Add Speediest Builderizer achievement --- .../core/achievement/Achievement.java | 6 +++++ .../games/speedbuilders/SpeedBuilders.java | 9 ++++---- .../events/PerfectBuildEvent.java | 10 ++++++-- .../stattrackers/DependableTracker.java | 2 +- .../stattrackers/FirstBuildTracker.java | 2 +- .../stattrackers/PerfectionistTracker.java | 2 +- .../SpeediestBuilderizerTracker.java | 23 +++++++++++++++++++ 7 files changed, 45 insertions(+), 9 deletions(-) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{speedbuilder => speedbuilders}/stattrackers/DependableTracker.java (88%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{speedbuilder => speedbuilders}/stattrackers/FirstBuildTracker.java (89%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{speedbuilder => speedbuilders}/stattrackers/PerfectionistTracker.java (95%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/SpeediestBuilderizerTracker.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index eee405349..48ddcd897 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -878,6 +878,12 @@ public enum Achievement new String[]{"Speed Builders.PerfectWins"}, new String[]{"Win a game of Speed Builder with a perfect build every round"}, new int[]{1}, + AchievementCategory.SPEED_BUILDERS), + + SPEED_BUILDERS_SPEEDIEST("Speediest Builderizer", 2000, + new String[]{"Speed Builders.SpeediestBuilderizer"}, + new String[]{"Perfect a build in less than 10 seconds"}, + new int[]{1}, AchievementCategory.SPEED_BUILDERS); private String _name; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java index cdf414f3a..ce39524a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -31,9 +31,9 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.speedbuilder.stattrackers.DependableTracker; -import nautilus.game.arcade.game.games.speedbuilder.stattrackers.FirstBuildTracker; -import nautilus.game.arcade.game.games.speedbuilder.stattrackers.PerfectionistTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.DependableTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.FirstBuildTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.PerfectionistTracker; import nautilus.game.arcade.game.games.speedbuilders.data.BuildData; import nautilus.game.arcade.game.games.speedbuilders.data.DemolitionData; import nautilus.game.arcade.game.games.speedbuilders.data.MobData; @@ -611,7 +611,8 @@ public class SpeedBuilders extends SoloGame if (_buildRecreations.get(player).calculateScoreFromBuild(_currentBuild) == _currentBuild.getPerfectScore()) { - PerfectBuildEvent perfectBuildEvent = new PerfectBuildEvent(player, SpeedBuilders.this); + long timeElapsed = System.currentTimeMillis() - _stateTime; + PerfectBuildEvent perfectBuildEvent = new PerfectBuildEvent(player, timeElapsed, SpeedBuilders.this); Bukkit.getServer().getPluginManager().callEvent(perfectBuildEvent); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/events/PerfectBuildEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/events/PerfectBuildEvent.java index 3608c9e23..a2fcc31e9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/events/PerfectBuildEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/events/PerfectBuildEvent.java @@ -8,15 +8,16 @@ import org.bukkit.event.HandlerList; public class PerfectBuildEvent extends Event { - private static final HandlerList handlers = new HandlerList(); private Player _player; private SpeedBuilders _game; + private long _timeElapsed; // Build time elapsed in ms - public PerfectBuildEvent(Player player, SpeedBuilders game) + public PerfectBuildEvent(Player player, long timeElapsed, SpeedBuilders game) { _player = player; + _timeElapsed = timeElapsed; _game = game; } @@ -25,6 +26,11 @@ public class PerfectBuildEvent extends Event return _player; } + public long getTimeElapsed() + { + return _timeElapsed; + } + public SpeedBuilders getGame() { return _game; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilder/stattrackers/DependableTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/DependableTracker.java similarity index 88% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilder/stattrackers/DependableTracker.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/DependableTracker.java index abc6056f3..2996d9db2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilder/stattrackers/DependableTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/DependableTracker.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.speedbuilder.stattrackers; +package nautilus.game.arcade.game.games.speedbuilders.stattrackers; import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilder/stattrackers/FirstBuildTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/FirstBuildTracker.java similarity index 89% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilder/stattrackers/FirstBuildTracker.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/FirstBuildTracker.java index da81b578a..c79c55e41 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilder/stattrackers/FirstBuildTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/FirstBuildTracker.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.speedbuilder.stattrackers; +package nautilus.game.arcade.game.games.speedbuilders.stattrackers; import org.bukkit.event.EventHandler; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilder/stattrackers/PerfectionistTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/PerfectionistTracker.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilder/stattrackers/PerfectionistTracker.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/PerfectionistTracker.java index 76e4ca997..1dbca3847 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilder/stattrackers/PerfectionistTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/PerfectionistTracker.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.speedbuilder.stattrackers; +package nautilus.game.arcade.game.games.speedbuilders.stattrackers; import java.util.Map.Entry; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/SpeediestBuilderizerTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/SpeediestBuilderizerTracker.java new file mode 100644 index 000000000..800277a22 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/SpeediestBuilderizerTracker.java @@ -0,0 +1,23 @@ +package nautilus.game.arcade.game.games.speedbuilders.stattrackers; + +import org.bukkit.event.EventHandler; + +import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; +import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; +import nautilus.game.arcade.stats.StatTracker; + +public class SpeediestBuilderizerTracker extends StatTracker +{ + public SpeediestBuilderizerTracker(SpeedBuilders game) + { + super(game); + } + + @EventHandler + public void onPerfectBuild(PerfectBuildEvent event) + { + if (event.getTimeElapsed() < 10000) // 10 Seconds + addStat(event.getPlayer(), "SpeediestBuilderizer", 1, true, false); + } + +}