diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index 9c2256131..afc99d3e7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -8,6 +8,7 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Effect; +import org.bukkit.EntityEffect; import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.Material; @@ -45,12 +46,14 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.Game.GameState; @@ -62,6 +65,8 @@ import net.minecraft.server.v1_7_R3.Navigation; public class CastleSiege extends TeamGame { + private ArrayList _lastScoreboard = new ArrayList(); + private long _tntSpawn = 0; private ArrayList _tntSpawns = new ArrayList(); private ArrayList _tntWeakness = new ArrayList(); @@ -105,7 +110,7 @@ public class CastleSiege extends TeamGame F.elem(C.cRed + "Undead") + C.cWhite + " lose when the sun rises.", }); - + _help = new String[] { "Marksmen are extremely important to defence!", @@ -115,7 +120,7 @@ public class CastleSiege extends TeamGame "Weak points are marked by cracked stone brick.", "Undead can break fences with their axes.", "Undead Archers must pick up arrows from the ground.", - + }; this.HungerSet = 20; @@ -123,7 +128,7 @@ public class CastleSiege extends TeamGame this.WorldTimeSet = 14000; //14000 this.BlockPlaceAllow.add(85); - _kingName = C.cYellow + C.Bold + "King Jonalon"; + _kingName = C.cYellow + C.Bold + "King Sparklez"; } @Override @@ -149,6 +154,8 @@ public class CastleSiege extends TeamGame { if (kit.GetName().contains("Castle")) team.GetRestrictedKits().add(kit); + + team.SetName("Undead"); } else { @@ -156,6 +163,8 @@ public class CastleSiege extends TeamGame team.GetRestrictedKits().add(kit); team.SetRespawnTime(8); + + team.SetName("Defenders"); } } } @@ -302,16 +311,28 @@ public class CastleSiege extends TeamGame Player damager = event.GetDamagerPlayer(true); if (damager == null) return; - + GameTeam team = GetTeam(damager); if (team != null && team.GetColor() == ChatColor.RED) { + if (!Recharge.Instance.use(damager, "Damage King", 400, false, false)) + return; + + _king.playEffect(EntityEffect.HURT); + _kingDamager = damager; _kingHealth--; + if (_kingHealth < 0) + _kingHealth = 0; + + WriteScoreboard(); + if (_kingHealth <= 0) _king.damage(500); + + EndCheck(); } } @@ -338,10 +359,10 @@ public class CastleSiege extends TeamGame } @EventHandler - public void PlayerDeath(PlayerDeathEvent event) + public void PlayerDeath(PlayerGameRespawnEvent event) { - if (GetTeam(ChatColor.AQUA).HasPlayer(event.getEntity())) - SetKit(event.getEntity(), GetKits()[3], true); + if (GetTeam(ChatColor.AQUA).HasPlayer(event.GetPlayer())) + SetKit(event.GetPlayer(), GetKits()[3], true); } @Override @@ -351,16 +372,15 @@ public class CastleSiege extends TeamGame if (event.getType() != UpdateType.FAST) return; - //King - if (_king != null && _king.isValid()) - { - GetObjectiveSide().getScore(C.cYellow + C.Bold + "Kings Health").setScore(_kingHealth); - } + WriteScoreboard(); + } - //Teams + public void WriteScoreboard() + { + //Get Values HashMap _scoreGroup = new HashMap(); - _scoreGroup.put(C.cAqua + "Wolves", 0); _scoreGroup.put(C.cAqua + "Defenders", 0); + _scoreGroup.put(C.cDAqua + "Wolves", 0); _scoreGroup.put(C.cRed + "Undead", 0); for (Player player : UtilServer.getPlayers()) @@ -375,7 +395,7 @@ public class CastleSiege extends TeamGame { if (kit.GetName().contains("Wolf")) { - _scoreGroup.put(C.cAqua + "Wolves", 1 + _scoreGroup.get(C.cAqua + "Wolves")); + _scoreGroup.put(C.cDAqua + "Wolves", 1 + _scoreGroup.get(C.cDAqua + "Wolves")); } else { @@ -388,9 +408,82 @@ public class CastleSiege extends TeamGame } } + //Wipe Last + for (String string : _lastScoreboard) + GetScoreboard().resetScores(string); + _lastScoreboard.clear(); + + int line = 1; + String space = " "; + + //Teams for (String group : _scoreGroup.keySet()) { - GetObjectiveSide().getScore(group).setScore(_scoreGroup.get(group)); + //Score + String out = ChatColor.getLastColors(group) + _scoreGroup.get(group) + " Players"; + + if (out.length() >= 16) + out = out.substring(0, 15); + + _lastScoreboard.add(out); + + GetObjectiveSide().getScore(out).setScore(line++); + + //Team + out = group; + + if (out.length() >= 16) + out = out.substring(0, 15); + + _lastScoreboard.add(out); + + GetObjectiveSide().getScore(out).setScore(line++); + + //Space + space += " "; + out = space; + + if (out.length() >= 16) + out = out.substring(0, 15); + + _lastScoreboard.add(out); + + GetObjectiveSide().getScore(out).setScore(line++); + } + + //King + if (_king != null && _king.isValid()) + { + //Score + String out = _kingHealth + " Health"; + + if (out.length() >= 16) + out = out.substring(0, 15); + + _lastScoreboard.add(out); + + GetObjectiveSide().getScore(out).setScore(line++); + + //Text + out = C.cYellow + C.Bold + "King"; + + if (out.length() >= 16) + out = out.substring(0, 15); + + _lastScoreboard.add(out); + + GetObjectiveSide().getScore(out).setScore(line++); + + //Space + space += " "; + out = space; + + if (out.length() >= 16) + out = out.substring(0, 15); + + _lastScoreboard.add(out); + + GetObjectiveSide().getScore(out).setScore(line++); } } @@ -404,7 +497,6 @@ public class CastleSiege extends TeamGame { SetCustomWinLine(_kingName + ChatColor.RESET + " has survived the seige!"); - SetState(GameState.End); AnnounceEnd(GetTeam(ChatColor.AQUA)); for (GameTeam team : GetTeamList()) @@ -421,6 +513,8 @@ public class CastleSiege extends TeamGame if (player.isOnline()) AddGems(player, 10, "Participation", false); } + + SetState(GameState.End); } if (!_king.isValid()) @@ -433,7 +527,6 @@ public class CastleSiege extends TeamGame else SetCustomWinLine(_kingName + ChatColor.RESET + " has died!"); - SetState(GameState.End); AnnounceEnd(GetTeam(ChatColor.RED)); for (GameTeam team : GetTeamList()) @@ -450,6 +543,8 @@ public class CastleSiege extends TeamGame if (player.isOnline()) AddGems(player, 10, "Participation", false); } + + SetState(GameState.End); } } @@ -461,7 +556,7 @@ public class CastleSiege extends TeamGame if (event.getType() != UpdateType.SEC) return; - + if (!UtilTime.elapsed(this.GetStateTime(), 20000)) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index ee33787d5..30312cb5a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -717,7 +717,7 @@ public class GameFlagManager implements Listener ((player.getLocation().getY() > game.WorldData.MaxY || player.getLocation().getY() < game.WorldData.MinY) && game.IsAlive(player))) { - if (!Manager.IsAlive(player)) + if (!Manager.IsAlive(player) || ((CraftPlayer)player).getHandle().spectating) { player.teleport(game.GetSpectatorLocation()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java index 2e721a75f..326cbcbb6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java @@ -11,6 +11,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.Game.GameState; +import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -73,8 +74,16 @@ public class MiscManager implements Listener return; Player player = UtilPlayer.searchExact(event.getWhoClicked().getName()); + if (player == null) + return; + + if (player.getGameMode() != GameMode.SURVIVAL && !player.isOp()) + { + event.setCancelled(true); + player.closeInventory(); + } - if (Manager.GetGame().IsLive() && !Manager.GetGame().IsAlive(player)) + else if (Manager.GetGame().IsLive() && !Manager.GetGame().IsAlive(player) && !((CraftPlayer)player).getHandle().spectating) { event.setCancelled(true); player.closeInventory();