From 72fb2317b906d10309b19da5d0dd93339df45f05 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Sat, 23 Jan 2016 14:31:36 +0200 Subject: [PATCH] Update team creation and winner placement, fix NPE on Veteran Tracker. --- .../identified-project-coordinates.json | 2 +- .../arcade/game/games/mineware/MineWare.java | 101 +++++++++++------- .../games/mineware/effect/ChickenAttack.java | 2 - .../stats/MinewareVeteranTracker.java | 5 +- 4 files changed, 68 insertions(+), 42 deletions(-) diff --git a/.recommenders/caches/identified-project-coordinates.json b/.recommenders/caches/identified-project-coordinates.json index d25dc21ec..6a53c5af7 100644 --- a/.recommenders/caches/identified-project-coordinates.json +++ b/.recommenders/caches/identified-project-coordinates.json @@ -1 +1 @@ -[[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Libraries\\craftbukkit.jar","type":"JAR","hints":{}},"ABSENT"],[{"location":"C:\\Program Files\\Java\\jre1.8.0_51","type":"JRE","hints":{}},"jre:jre:1.8.0"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Nautilus.Game.Arcade","type":"PROJECT","hints":{"PROJECT_NAME":"Nautilus.Game.Arcade"}},"ABSENT"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Mineplex.Core.Common","type":"PROJECT","hints":{"PROJECT_NAME":"Mineplex.Core.Common"}},"ABSENT"]] \ No newline at end of file +[[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Nautilus.Game.Arcade","type":"PROJECT","hints":{"PROJECT_NAME":"Nautilus.Game.Arcade"}},"ABSENT"],[{"location":"C:\\Program Files\\Java\\jre1.8.0_51","type":"JRE","hints":{}},"jre:jre:1.8.0"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Libraries\\craftbukkit.jar","type":"JAR","hints":{}},"ABSENT"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Mineplex.Core.Common","type":"PROJECT","hints":{"PROJECT_NAME":"Mineplex.Core.Common"}},"ABSENT"]] \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java index b2894101d..3bb2e120f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java @@ -110,7 +110,7 @@ import nautilus.game.arcade.kit.Kit; public class MineWare extends TeamGame implements IThrown { - private int _livesAmount = 1; + private int _livesAmount = 2; private GameTeam _playersTeam; private GameTeam _chickenTeam; @@ -174,27 +174,20 @@ public class MineWare extends TeamGame implements IThrown new MinewareKangarooAtHeart(this) ); } - + @EventHandler public void onTeamCreation(GameStateChangeEvent event) { if (event.GetState() != GameState.Recruit) return; - - for (GameTeam team : GetTeamList()) - { - if (team.GetColor() == ChatColor.YELLOW) - { - team.SetName("Players"); - _playersTeam = team; - } - else if (team.GetColor() == ChatColor.WHITE) - { - team.SetName("Chickens"); - team.SetVisible(false); - _chickenTeam = team; - } - } + + _playersTeam = GetTeamList().get(0); + _playersTeam.SetColor(ChatColor.YELLOW); + _playersTeam.SetName("Players"); + + _chickenTeam = new GameTeam(this, "Chickens", ChatColor.WHITE, _playersTeam.GetSpawns()); + _chickenTeam.SetVisible(false); + GetTeamList().add(_chickenTeam); } // Debug Only @@ -206,7 +199,7 @@ public class MineWare extends TeamGame implements IThrown String restrictCommand = "restrict"; String skipCommand = "skip"; String message = event.getMessage(); - + if (player.isOp()) { if (message.startsWith("/" + restrictCommand)) @@ -368,30 +361,60 @@ public class MineWare extends TeamGame implements IThrown if (living <= 1) { - SetState(GameState.End); - AnnounceEnd(getWinners()); + Collections.reverse(_places); - for(Player players: GetPlayers(false)) + if (!_places.contains(GetPlayers(true).get(0))) + _places.add(0, GetPlayers(true).get(0)); + + if (_places.size() >= 1) { - if(getWinners().contains(players)) - { - AddGems(players, 40, "First Place", false, false); - } - - if(_places.size() >= 1) - { - AddGems(_places.get(0), 20, "Third Place", false, false); - } - - if(_places.size() >= 2) + AddGems(_places.get(0), 40, "First Place", false, false); + + if (_places.size() >= 2) { AddGems(_places.get(1), 30, "Second Place", false, false); + + if (_places.size() >= 3) + { + AddGems(_places.get(2), 20, "Third Place", false, false); + } } - - AddGems(players, 10, "Participation", false, false); } + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + + AnnounceEnd(_places); + SetState(GameState.End); } } + +// if (living <= 1) +// { +// SetState(GameState.End); +// AnnounceEnd(getWinners()); +// +// for(Player players: GetPlayers(false)) +// { +// if(getWinners().contains(players)) +// { +// AddGems(players, 40, "First Place", false, false); +// } +// +// if(_places.size() >= 1) +// { +// AddGems(_places.get(0), 20, "Third Place", false, false); +// } +// +// if(_places.size() >= 2) +// { +// AddGems(_places.get(1), 30, "Second Place", false, false); +// } +// +// AddGems(players, 10, "Participation", false, false); +// } +// } @Override public boolean isInsideMap(Player player) @@ -1060,10 +1083,10 @@ public class MineWare extends TeamGame implements IThrown _places.add(player); } - gameLostMessage(player); + // gameLostMessage(player); Scoreboard.ResetScore(player.getName()); - if (isDeath) + if (isDeath && playersAlive > 2) { // Manager.addSpectator(player, true); _chickenAttack.start(player); @@ -1234,6 +1257,12 @@ public class MineWare extends TeamGame implements IThrown { return _chickenTeam; } + + @Override + public ArrayList getWinners() + { + return _places; + } @Override public void Idle(ProjectileUser data) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java index a6dd5bfa3..e4400711c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java @@ -17,10 +17,8 @@ import org.bukkit.scheduler.BukkitRunnable; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.disguise.disguises.DisguiseChicken; -import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.mineware.MineWare; public class ChickenAttack diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/stats/MinewareVeteranTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/stats/MinewareVeteranTracker.java index 0ed4cd13e..4d7b003f7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/stats/MinewareVeteranTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/stats/MinewareVeteranTracker.java @@ -14,15 +14,14 @@ public class MinewareVeteranTracker extends StatTracker public MinewareVeteranTracker(Game game) { super(game); - System.out.println("1"); } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void tracePlayerWin(GameStateChangeEvent event) { - if(event.GetState() == GameState.End) + if (event.GetState() == GameState.End) { - for(Player player: getGame().getWinners()) + for (Player player: getGame().getWinners()) { addStat(player, "Veteran", 1, true, false); }