From de1ee4f6cb377b3111ac370e505f3b7b474a15f7 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Sun, 31 Jan 2016 23:50:23 +0200 Subject: [PATCH] Spectator and chicken attack changes. --- .../identified-project-coordinates.json | 2 +- .../arcade/game/games/mineware/Challenge.java | 1 - .../arcade/game/games/mineware/MineWare.java | 102 ++++++++++++++---- .../removed/ChallengeDiamondFall.java | 6 +- 4 files changed, 88 insertions(+), 23 deletions(-) diff --git a/.recommenders/caches/identified-project-coordinates.json b/.recommenders/caches/identified-project-coordinates.json index 6ae9d225e..9e26dfeeb 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:\\@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 +{} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java index 262436f13..dd00004cf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java @@ -187,7 +187,6 @@ public abstract class Challenge implements Listener public void setCompleted(Player player, boolean invis) { if (_completed.contains(player)) - return; if (invis) 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 17d4e0995..a057bc2d7 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 @@ -17,6 +17,7 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Chicken; +import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -74,8 +75,8 @@ import nautilus.game.arcade.game.games.mineware.challenges.ChallengeFallingBlock import nautilus.game.arcade.game.games.mineware.challenges.ChallengeFastFood; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeFishingDay; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeInfestation; -import nautilus.game.arcade.game.games.mineware.challenges.ChallengeKingOfTheHill; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeKangarooJump; +import nautilus.game.arcade.game.games.mineware.challenges.ChallengeKingOfTheHill; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeLavaRun; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeMilkACow; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeMineADiamond; @@ -112,7 +113,7 @@ import nautilus.game.arcade.kit.Kit; public class MineWare extends TeamGame implements IThrown { - private int _livesAmount = 5; + private int _livesAmount = 1; private String _restrictCommand = "restrict"; private String _skipCommand = "skip"; @@ -371,6 +372,7 @@ public class MineWare extends TeamGame implements IThrown if (!_sendingMessages && !_messagesSent) { + addEffectsToPlayers(); startChallengeDescriptionThread(); // return; @@ -500,6 +502,15 @@ public class MineWare extends TeamGame implements IThrown } } + private void addEffectsToPlayers() + { + for (Player player : GetPlayers(true)) + { + player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Integer.MAX_VALUE, 1)); + player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1)); + } + } + private void startChallengeDescriptionThread() { Thread thread = new Thread(new Runnable() @@ -644,27 +655,40 @@ public class MineWare extends TeamGame implements IThrown if (getLives(cAlive) != 0) alive++; - if (_challenge != null && _challengeStarted) - { - Scoreboard.Write(C.cGreen + C.Bold + "Alive"); - Scoreboard.Write("" + _challenge.getCurrentyAlive(false).size()); + Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + C.Bold + "Completed"); - Scoreboard.Write("" + _challenge.getCompleted().size()); + Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.Write(alive + " "); - Scoreboard.Write(C.cGray + C.Bold + "Dead"); - Scoreboard.Write("" + _challenge.getLost().size()); - } + boolean check = _challenge != null && _challengeStarted; Scoreboard.WriteBlank(); Scoreboard.Write(C.cGreen + C.Bold + "Alive"); - Scoreboard.Write(alive + " "); + + if (check) + Scoreboard.Write("" + _challenge.getCurrentyAlive(false).size()); + else + Scoreboard.Write("-"); Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + C.Bold + "Dead"); - Scoreboard.Write((GetPlayers(false).size() - alive) + " "); + Scoreboard.Write(C.cGold + C.Bold + "Completed"); + + if (check) + Scoreboard.Write("" + _challenge.getCompleted().size()); + else + Scoreboard.Write("-"); + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cGray + C.Bold + "Dead"); + + if (check) + Scoreboard.Write("" + _challenge.getLost().size()); + else + Scoreboard.Write("-"); + } else { @@ -831,7 +855,7 @@ public class MineWare extends TeamGame implements IThrown } @EventHandler - public void onPlayerMove(PlayerMoveEvent event) + public void onChallengeFreeze(PlayerMoveEvent event) { if (!IsLive()) return; @@ -857,7 +881,7 @@ public class MineWare extends TeamGame implements IThrown } @EventHandler - public void onPlayerDeath(PlayerDeathEvent event) + public void onChallengeDeath(PlayerDeathEvent event) { if (_challenge == null) return; @@ -889,7 +913,12 @@ public class MineWare extends TeamGame implements IThrown _lives.put(player, lives); if (lives > 0) + { taskFailedMessage(player, lives); + + if (isDeath) + Manager.addSpectator(player, true); + } else { if (alive <= 3) @@ -945,8 +974,7 @@ public class MineWare extends TeamGame implements IThrown if (GetState() == GameState.Recruit && GetCountdown() >= 0 && GetPlayers(false).size() < 2) { - UtilServer - .broadcast(F.main(GetName(), C.cRed + "This game requires at least 2 players to start.")); + UtilServer.broadcast(F.main(GetName(), C.cRed + "This game requires at least 2 players to start.")); SetCountdown(-1); Manager.GetLobby().DisplayWaiting(); } @@ -1313,6 +1341,44 @@ public class MineWare extends TeamGame implements IThrown return _chickenAttack; } + /** + * Returns the list of players contained on the player's team. + * + * @param aliveOnly Whether or not to select all players. + */ + @Override + public ArrayList GetPlayers(boolean aliveOnly) + { + return _playersTeam.GetPlayers(aliveOnly); + } + + /** + * Checks on the player's team, whether the player is alive or not. + * + * @param entity The player (or entity if no cast is applied) to check. + */ + @Override + public boolean IsAlive(Entity entity) + { + if (entity instanceof Player) + { + Player player = (Player) entity; + + if (_playersTeam.HasPlayer(player)) + { + return _playersTeam.IsAlive(player); + } + else + { + return false; + } + } + else + { + return false; + } + } + @Override public void Collide(LivingEntity target, Block block, ProjectileUser data) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/removed/ChallengeDiamondFall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/removed/ChallengeDiamondFall.java index d3fda0025..ffdaaa37e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/removed/ChallengeDiamondFall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/removed/ChallengeDiamondFall.java @@ -27,9 +27,9 @@ public class ChallengeDiamondFall extends Challenge } @Override - public boolean finish() + public boolean canFinish() { - if (super.finish()) + if (super.canFinish()) { final HashMap diamonds = new HashMap(); ArrayList players = getChallengers(); @@ -65,7 +65,7 @@ public class ChallengeDiamondFall extends Challenge } } - return super.finish(); + return super.canFinish(); } @Override