From 0e697e279b0d28c550bef4b0760d32210c4624c8 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Thu, 25 Feb 2016 23:35:38 +0200 Subject: [PATCH] Player death handling and chicken attack changes. --- .../ui/page/AchievementMainPage.java | 2 +- .../src/nautilus/game/arcade/GameType.java | 6 +- .../game/games/mineware/BawkBawkBattles.java | 96 +++++++++++++------ .../arcade/game/games/mineware/Challenge.java | 8 +- .../ChallengeMiniOneInTheQuiver.java | 62 ++++++------ .../games/mineware/effect/ChickenAttack.java | 8 +- 6 files changed, 114 insertions(+), 68 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java index 3817df163..f7e5f244f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java @@ -46,7 +46,7 @@ public class AchievementMainPage extends ShopPageBase pageLayout = new ItemLayout( - "XXXXOXXXO", + "OXOXOXOXO", "OXOXOXOXO", "OXOXOXOXO", "OXOXOXOXO").getItemSlots(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 00d3962a5..73c8f3bad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -1,5 +1,7 @@ package nautilus.game.arcade; +import org.bukkit.Material; + import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; import nautilus.game.arcade.game.Game; @@ -67,8 +69,6 @@ import nautilus.game.arcade.game.games.wither.WitherGame; import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.game.games.zombiesurvival.ZombieSurvival; -import org.bukkit.Material; - public enum GameType { //Mini @@ -142,7 +142,7 @@ public enum GameType GameType.Cards, GameType.CastleSiege, GameType.ChampionsDominate, GameType.ChampionsTDM, GameType.Christmas, GameType.DeathTag, GameType.DragonEscape, GameType.DragonEscapeTeams, GameType.DragonRiders, GameType.Dragons, GameType.Draw, GameType.Evolution, GameType.Gravity, GameType.Halloween, GameType.HideSeek, - GameType.HoleInTheWall, GameType.Horse, GameType.Micro, GameType.MilkCow, GameType.MineStrike, GameType.MineWare, + GameType.HoleInTheWall, GameType.Horse, GameType.Micro, GameType.MilkCow, GameType.MineStrike, GameType.BawkBawkBattles, GameType.OldMineWare, GameType.Paintball, GameType.Quiver, GameType.QuiverTeams, GameType.Runner, GameType.SearchAndDestroy, GameType.Sheep, GameType.Skywars, GameType.SkywarsTeams, GameType.Smash, GameType.SmashDomination, GameType.SmashTeams, GameType.Snake, GameType.SneakyAssassins, GameType.SnowFight, GameType.Spleef, GameType.SpleefTeams, GameType.SquidShooter, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java index 57f15c9c8..a8eab375f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java @@ -26,6 +26,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -118,7 +119,7 @@ import nautilus.game.arcade.kit.Kit; public class BawkBawkBattles extends TeamGame implements IThrown { - private int _livesAmount = 1; + private int _livesAmount = 2; private String _restrictCommand = "restrict"; private String _skipCommand = "skip"; @@ -160,6 +161,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown DamageSelf = false; DamageTeamSelf = true; + DamageTeamOther = false; DamagePvP = false; DamagePvE = false; DamageEvP = false; @@ -174,6 +176,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown TeleportsDisqualify = false; GiveClock = false; + // TODO: Temporary + CompassEnabled = false; + CompassGiveItem = false; + Manager.GetCreature().SetDisableCustomDrops(true); populateChallenges(); @@ -406,12 +412,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown { _crumbling = true; - UtilServer.broadcast(F.main(GetName(), "The map has started to crumble.")); - - for (Player player : UtilServer.getPlayers()) - if (IsAlive(player)) - UtilPlayer.message(player, - F.main(GetName(), "Challenge ends when there's only 1 player alive.")); + for (Player player : getChallengers()) + { + UtilTextMiddle.display(null, "The map has started to crumble.", 5, 50, 5, player); + } } else if (canEndChallengeFromCrumble()) { @@ -658,7 +662,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown int alive = 0; for (Player cAlive : _lives.keySet()) - if (getLives(cAlive) != 0) + if (lives(cAlive) != 0) alive++; Scoreboard.WriteBlank(); @@ -702,7 +706,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown for (Player player : GetPlayers(true)) { - int currentLives = getLives(player); + int currentLives = lives(player); String status; String currentlyOut = ""; @@ -816,7 +820,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown C.cRed + C.Bold + "3", C.cYellow + C.Bold + "2", C.cGreen + C.Bold + "1", - C.cGreen + C.Bold + "GO!"); + C.cWhite + C.Bold + "GO!"); @Override public void run() @@ -912,7 +916,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown if (!event.GetCondition().GetReason().equals("Spectator")) return; - System.out.println("Cancelled"); event.setCancelled(true); } @@ -942,35 +945,46 @@ public class BawkBawkBattles extends TeamGame implements IThrown } else { - handleFailure(player, false); + handleFailure(player, false, true); } } public int looseLife(Player player) { - int lives = getLives(player); + int lives = lives(player); lives -= 1; - _lives.put(player, lives); + + if (lives >= 0) + _lives.put(player, lives); + return lives; } - + public void handleFailure(Player player, boolean looseLife) + { + handleFailure(player, looseLife, false); + } + + public void handleFailure(Player player, boolean looseLife, boolean cloak) { if (looseLife) looseLife(player); - taskFailedMessage(player, getLives(player)); - SetPlayerState(player, PlayerState.OUT); + taskFailedMessage(player, lives(player)); + // SetPlayerState(player, PlayerState.OUT); Manager.addSpectator(player, true); + + if (cloak) + Manager.GetCondition().Factory().Cloak("Challenge Death", player, player, 7777, true, true); } - + @EventHandler public void onChickenApproachPlayer(UpdateEvent event) { if (!IsLive()) return; - if (event.getType() != UpdateType.FASTER) + if (event.getType() != UpdateType.TICK) return; for (Player player : GetPlayers(true)) @@ -979,18 +993,18 @@ public class BawkBawkBattles extends TeamGame implements IThrown { if (player.equals(other)) continue; - + if (UtilMath.offset(other, player) > 5) continue; - - if (Recharge.Instance.use(other, "Approach Alive Player", 500, false, false)) + + if (Recharge.Instance.use(player, "Approach Alive Player", 500, false, false)) { Entity bottom = other; while (bottom.getVehicle() != null) bottom = bottom.getVehicle(); - + UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(player, bottom), 1.6, true, 0.8, 0, 10, true); - other.playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); + other.playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2.0F, 0.5F); } } } @@ -998,14 +1012,31 @@ public class BawkBawkBattles extends TeamGame implements IThrown private void gameLostMessage(Player player) { - UtilPlayer.message(player, C.cRed + C.Bold + "You are out of the game!"); - player.playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f); + UtilPlayer.message(player, ""); + UtilPlayer.message(player, C.cRed + C.Bold + "You are out of the game."); + player.playSound(player.getLocation(), Sound.EXPLODE, 2.0F, 1.0F); + UtilPlayer.message(player, ""); } private void taskFailedMessage(Player player, int lives) { + UtilPlayer.message(player, ""); UtilPlayer.message(player, C.cRed + C.Bold + "You failed the task!"); - UtilPlayer.message(player, C.cRed + C.Bold + "You have " + lives + " lives left!"); + + String suffix = "lives"; + + if (lives == 1) + suffix = "life"; + + String msg = C.Bold + "You have " + F.elem(C.Bold + lives) + C.Bold + " " + suffix + " left."; + + if (lives <= 0) + msg = C.Bold + "You don't have any lives left."; + + UtilPlayer.message(player, C.cGray + msg); + UtilPlayer.message(player, ""); + + player.playSound(player.getLocation(), Sound.NOTE_BASS, 2.0F, 1.0F); } @EventHandler @@ -1168,6 +1199,11 @@ public class BawkBawkBattles extends TeamGame implements IThrown { event.setCancelled(true); } + + if (event.getCause() == DamageCause.VOID) + { + chicken.teleport(_chickenAttack.getPlatformCenter()); + } } } @@ -1261,7 +1297,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown return true; } - private int getLives(Player player) + private int lives(Player player) { if (!_lives.containsKey(player)) return 0; @@ -1290,7 +1326,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown for (Player player : GetPlayers(false)) { - if (getLives(player) > 0) + if (lives(player) > 0) { living++; } @@ -1298,7 +1334,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown if (living <= 1) { - SetCustomWinLine("You have defeated Bawk Bawk!"); Collections.reverse(_places); if (!_places.contains(GetPlayers(true).get(0))) @@ -1323,6 +1358,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown if (player.isOnline()) AddGems(player, 10, "Participation", false, false); + SetCustomWinLine("You have defeated Bawk Bawk!"); AnnounceEnd(_places); SetState(GameState.End); } 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 a069ccc1a..87cf029c6 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 @@ -196,7 +196,11 @@ public abstract class Challenge implements Listener } _completed.add(player); + + UtilPlayer.message(player, ""); UtilPlayer.message(player, C.cGreen + C.Bold + "You completed the task!"); + UtilPlayer.message(player, ""); + player.playSound(player.getLocation(), Sound.LEVEL_UP, 2.0F, 1.0F); } @@ -216,11 +220,11 @@ public abstract class Challenge implements Listener if (invis) { _invisPlayers.add(player); - Host.Manager.GetCondition().Factory().Cloak("Completed", player, player, 7777, true, false); + Host.Manager.GetCondition().Factory().Cloak("Lost", player, player, 7777, true, false); } - Host.handleFailure(player, true); UtilInv.Clear(player); + Host.handleFailure(player, true); } public void setLost(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMiniOneInTheQuiver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMiniOneInTheQuiver.java index b02aba04d..0b0635516 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMiniOneInTheQuiver.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMiniOneInTheQuiver.java @@ -27,7 +27,8 @@ public class ChallengeMiniOneInTheQuiver extends Challenge { public ChallengeMiniOneInTheQuiver(BawkBawkBattles host) { - super(host, ChallengeType.LastStanding, "Mini OITQ", false, true, "Do not get hit!", "You receive a new arrow every 4 seconds.", "Last man standing wins!"); + super(host, ChallengeType.LastStanding, "Mini OITQ", false, true, "Avoid getting hit by arrows.", "You receive an arrow every 4 seconds.", + "Last man standing wins!"); } @Override @@ -35,11 +36,11 @@ public class ChallengeMiniOneInTheQuiver extends Challenge { ArrayList spawns = new ArrayList(); - for(int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++) + for (int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++) { - for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++) + for (int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++) { - if(x % 2 == 0 && z % 2 == 0) + if (x % 2 == 0 && z % 2 == 0) { spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5)); } @@ -54,9 +55,9 @@ public class ChallengeMiniOneInTheQuiver extends Challenge Host.DamagePvP = false; Host.DamagePvE = false; - for(Entity entities : Host.WorldData.World.getEntities()) + for (Entity entities : Host.WorldData.World.getEntities()) { - if(entities instanceof Arrow) + if (entities instanceof Arrow) { entities.remove(); } @@ -66,7 +67,7 @@ public class ChallengeMiniOneInTheQuiver extends Challenge @Override public void setupPlayers() { - for(Player player : Host.GetPlayers(true)) + for (Player player : Host.GetPlayers(true)) { player.getInventory().addItem(new ItemBuilder(Material.BOW).setTitle(C.cGreen + "1Shot1Kill").build()); player.getInventory().addItem(new ItemStack(Material.ARROW)); @@ -78,48 +79,47 @@ public class ChallengeMiniOneInTheQuiver extends Challenge @Override public void generateRoom() { - for(int x = -getArenaSize(); x <= getArenaSize(); x++) + for (int x = -getArenaSize(); x <= getArenaSize(); x++) { - for(int z = -getArenaSize(); z <= getArenaSize(); z++) + for (int z = -getArenaSize(); z <= getArenaSize(); z++) { - forloopY: - for(int y = 0; y <= 1; y++) + forloopY: for (int y = 0; y <= 1; y++) { Block b = getCenter().getBlock().getRelative(x, y, z); - if(y == 0) + if (y == 0) { b.setType(Material.GRASS); } else { - if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize()) + if (Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize()) { b.setType(Material.FENCE); } - if(Math.abs(x) == getArenaSize() - 2 || Math.abs(z) == getArenaSize() - 2) + if (Math.abs(x) == getArenaSize() - 2 || Math.abs(z) == getArenaSize() - 2) { - if(y == 1) + if (y == 1) { - if(UtilMath.r(8) == 0) + if (UtilMath.r(8) == 0) { - for(Location spawns: getSpawns()) + for (Location spawns : getSpawns()) { - if(spawns.getBlockX() == b.getLocation().getBlockX() && spawns.getBlockZ() == b.getLocation().getBlockZ()) + if (spawns.getBlockX() == b.getLocation().getBlockX() && spawns.getBlockZ() == b.getLocation().getBlockZ()) { continue forloopY; } } b.setType(Material.STAINED_CLAY); b.getRelative(BlockFace.UP).setType(Material.STAINED_CLAY); - - b.setData((byte)14); - b.getRelative(BlockFace.UP).setData((byte)14); + + b.setData((byte) 14); + b.getRelative(BlockFace.UP).setData((byte) 14); } } } } - if(b.getType() != Material.AIR) + if (b.getType() != Material.AIR) { addBlock(b.getRelative(BlockFace.UP)); addBlock(b); @@ -133,21 +133,21 @@ public class ChallengeMiniOneInTheQuiver extends Challenge @EventHandler public void giveArrowHandler(UpdateEvent event) { - if(!Host.IsLive()) + if (!Host.IsLive()) { return; } - if(event.getType() != UpdateType.SLOW) + if (event.getType() != UpdateType.SLOW) { return; } - for(Player player: Host.GetPlayers(true)) + for (Player player : Host.GetPlayers(true)) { - if(isLost(player)) + if (isLost(player)) { continue; } - if(UtilInv.contains(player, Material.ARROW, (byte)0, 1)) + if (UtilInv.contains(player, Material.ARROW, (byte) 0, 1)) { continue; } @@ -159,22 +159,22 @@ public class ChallengeMiniOneInTheQuiver extends Challenge @EventHandler public void onArrowHitPlayer(EntityDamageByEntityEvent event) { - if(!Host.IsLive()) + if (!Host.IsLive()) { return; } - if(!(event.getDamager() instanceof Arrow)) // Damager = Arrow (player) + if (!(event.getDamager() instanceof Arrow)) // Damager = Arrow (player) { return; } - if(!(event.getEntity() instanceof Player)) // Damaged = player + if (!(event.getEntity() instanceof Player)) // Damaged = player { return; } Arrow arrow = (Arrow) event.getDamager(); Player shooter = (Player) arrow.getShooter(); Player damaged = (Player) event.getEntity(); - if(isLost(shooter) || !Host.IsPlaying(shooter) || shooter.equals(damaged)) + if (isLost(shooter) || !Host.IsPlaying(shooter) || shooter.equals(damaged)) { event.setCancelled(true); return; 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 05a730712..6861bc4e1 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 @@ -78,7 +78,7 @@ public class ChickenAttack player.teleport(_center); - UtilTextMiddle.display(null, C.cRed + C.Bold + "Chicken Attack!", 5, 40, 5, player); + UtilTextMiddle.display(C.cRed + "Chicken Attack", "You ran out of lives!", 5, 40, 5, player); player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1.0F, 1.0F); debugDeathTask(player); @@ -107,6 +107,7 @@ public class ChickenAttack _host.SetPlayerState(player, PlayerState.OUT); DisguiseChicken disguise = new DisguiseChicken(player); + disguise.setBaby(); _host.Manager.GetDisguise().disguise(disguise, UtilServer.getPlayers()); player.teleport(_host.GetSpectatorLocation()); @@ -155,4 +156,9 @@ public class ChickenAttack _chickens.clear(); } + + public Location getPlatformCenter() + { + return _center; + } }