From 3d12196b179ca197d3a393ce985db214c1a7b76d Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Thu, 26 Jun 2014 18:38:11 -0700 Subject: [PATCH 1/2] Merge UHC Public Small refactor for player ranks in games. Trimed scoreboard teams to 16 chars. --- .../nautilus/game/arcade/ArcadeManager.java | 6 - .../src/nautilus/game/arcade/game/Game.java | 17 + .../nautilus/game/arcade/game/GameTeam.java | 36 + .../nautilus/game/arcade/game/SoloGame.java | 83 +- .../nautilus/game/arcade/game/TeamGame.java | 24 + .../game/arcade/game/games/GameScore.java | 9 +- .../game/games/baconbrawl/BaconBrawl.java | 30 - .../game/games/barbarians/Barbarians.java | 30 - .../arcade/game/games/deathtag/DeathTag.java | 52 +- .../game/games/dragonescape/DragonEscape.java | 19 +- .../game/arcade/game/games/draw/Draw.java | 6 +- .../game/games/evolution/Evolution.java | 6 +- .../arcade/game/games/milkcow/MilkCow.java | 12 +- .../game/arcade/game/games/quiver/Quiver.java | 6 +- .../game/games/squidshooter/SquidShooter.java | 7 +- .../game/arcade/game/games/uhc/UHC.java | 941 +++++------------- .../games/zombiesurvival/ZombieSurvival.java | 38 +- .../game/arcade/managers/GameChatManager.java | 9 +- .../game/arcade/managers/GameGemManager.java | 3 - .../arcade/managers/GameLobbyManager.java | 17 +- .../game/arcade/managers/GameManager.java | 7 + .../arcade/managers/GamePlayerManager.java | 30 +- .../game/arcade/managers/MiscManager.java | 5 +- .../arcade/scoreboard/GameScoreboard.java | 28 +- 24 files changed, 477 insertions(+), 944 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 5fd2bb608..4565e3d6e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -429,12 +429,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation if (_game == null || _game.GetState() == GameState.Recruit) { - if (_game != null && _game.GetType() == GameType.UHC) - { - event.setMotd(ChatColor.RED + "UHC - Season 5"); - return; - } - if (_game != null && _game.GetCountdown() != -1) { event.setMotd(ChatColor.GREEN + "Starting in " + _game.GetCountdown() + " Seconds" + extrainformation); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index c9da551bd..8221d2a04 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; @@ -24,6 +25,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.games.GameScore; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; @@ -371,6 +373,12 @@ public abstract class Game implements Listener System.out.println("Created Team: " + team.GetName()); } + + public void RemoveTeam(GameTeam team) + { + if (GetTeamList().remove(team)) + System.out.println("Deleted Team: " + team.GetName()); + } public boolean HasTeam(GameTeam team) { @@ -1000,4 +1008,13 @@ public abstract class Game implements Listener { return _prepareCountdown; } + + @EventHandler + public void TeamPlayerPlacement(PlayerStateChangeEvent event) + { + GameTeam team = GetTeam(event.GetPlayer()); + + if (team != null) + team.SetPlacement(event.GetPlayer(), event.GetState()); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index 6aa4231a9..8a1a7e15e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -10,6 +10,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; @@ -65,6 +66,9 @@ public class GameTeam private int _spawnDistance = 0; private boolean _visible = true; + + //Records order players go out in + protected ArrayList _places = new ArrayList(); public GameTeam(Game host, String name, ChatColor color, ArrayList spawns) { @@ -338,4 +342,36 @@ public class GameTeam { return _respawnTime; } + + public void SetPlacement(Player player, PlayerState state) + { + if (state == PlayerState.OUT) + if (!_places.contains(player)) + _places.add(0, player); + + else + _places.remove(player); + } + + public ArrayList GetPlacements(boolean includeAlivePlayers) + { + if (includeAlivePlayers) + { + ArrayList placesClone = new ArrayList(); + + for (Player player : _places) + { + placesClone.add(player); + } + + for (Player player : GetPlayers(true)) + { + _places.add(0, player); + } + + return placesClone; + } + + return _places; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java index fba11ea0a..a2e8e5965 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java @@ -19,86 +19,70 @@ import nautilus.game.arcade.kit.Kit; public abstract class SoloGame extends Game { - protected ArrayList _places = new ArrayList(); + private GameTeam _players; public SoloGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) { super(manager, gameType, kits, gameDesc); } - + @EventHandler public void CustomTeamGeneration(GameStateChangeEvent event) { if (event.GetState() != GameState.Recruit) return; - - this.GetTeamList().get(0).SetColor(ChatColor.YELLOW); - this.GetTeamList().get(0).SetName("Players"); + + _players = GetTeamList().get(0); + _players.SetColor(ChatColor.YELLOW); + _players.SetName("Players"); } - - @EventHandler - public void EndStateChange(PlayerStateChangeEvent event) - { - if (event.GetState() == PlayerState.OUT) - if (!_places.contains(event.GetPlayer())) - _places.add(0, event.GetPlayer()); - - else - _places.remove(event.GetPlayer()); - } - + @Override public void EndCheck() { if (!IsLive()) return; - //Add Winner - if (GetPlayers(true).size() == 1) - { - SetPlayerState(GetPlayers(true).get(0), PlayerState.OUT); - return; - } - - if (GetPlayers(true).size() <= 0) + if (GetPlayers(true).size() <= 1) { + ArrayList places = _players.GetPlacements(true); + //Announce - AnnounceEnd(_places); - + AnnounceEnd(places); + //Gems - if (_places.size() >= 1) - AddGems(_places.get(0), 20, "1st Place", false); - - if (_places.size() >= 2) - AddGems(_places.get(1), 15, "2nd Place", false); - - if (_places.size() >= 3) - AddGems(_places.get(2), 10, "3rd Place", false); - + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false); + + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false); + + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false); + for (Player player : GetPlayers(false)) if (player.isOnline()) AddGems(player, 10, "Participation", false); - + //End SetState(GameState.End); - } } - + @Override @EventHandler public void ScoreboardUpdate(UpdateEvent event) { if (event.getType() != UpdateType.FAST) return; - + if (GetTeamList().isEmpty()) return; - + Scoreboard.Reset(); - + GameTeam team = GetTeamList().get(0); - + if (team.GetPlayers(false).size() < 16) { for (Player player : team.GetPlayers(false)) @@ -123,23 +107,18 @@ public abstract class SoloGame extends Game else { Scoreboard.WriteBlank(); - + Scoreboard.Write(C.cGreen + "Players Alive"); Scoreboard.Write("" + team.GetPlayers(true).size()); - + Scoreboard.WriteBlank(); Scoreboard.Write(C.cRed + "Players Dead"); Scoreboard.Write("" + (team.GetPlayers(false).size() - team.GetPlayers(true).size())); } - + Scoreboard.Draw(); } - - public ArrayList GetPlaces() - { - return _places; - } - + public int GetScoreboardScore(Player player) { return 0; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java index 98645457b..87bc9342f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java @@ -18,10 +18,14 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.PlayerStateChangeEvent; +import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.Kit; public abstract class TeamGame extends Game { + protected ArrayList _places = new ArrayList(); + private NautHashMap _rejoinTime = new NautHashMap(); protected NautHashMap RejoinTeam = new NautHashMap(); protected NautHashMap RejoinKit = new NautHashMap(); @@ -33,6 +37,26 @@ public abstract class TeamGame extends Game super(manager, gameType, kits, gameDesc); } + @EventHandler + public void EndStateChange(PlayerStateChangeEvent event) + { + GameTeam team = this.GetTeam(event.GetPlayer()); + if (team == null) + return; + + if (event.GetState() == PlayerState.OUT) + if (!team.IsTeamAlive()) + _places.add(0, team); + + else + _places.remove(team); + } + + public ArrayList GetPlaces() + { + return _places; + } + @EventHandler(priority = EventPriority.LOWEST) public void PlayerQuit(PlayerQuitEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/GameScore.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/GameScore.java index 19f9bcecb..7b544ae4a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/GameScore.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/GameScore.java @@ -1,8 +1,10 @@ package nautilus.game.arcade.game.games; +import nautilus.game.arcade.game.PlayerScore; + import org.bukkit.entity.Player; -public class GameScore +public class GameScore implements PlayerScore { public org.bukkit.entity.Player Player; public double Score; @@ -12,4 +14,9 @@ public class GameScore Player = player; Score = i; } + + public Player GetPlayer() + { + return Player; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java index 25606e5a9..4bb71b3f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java @@ -38,36 +38,6 @@ public class BaconBrawl extends SoloGame this.PrepareFreeze = false; } - - @Override - public void EndCheck() - { - if (!IsLive()) - return; - - if (GetPlayers(true).size() <= 1) - { - if (GetPlayers(true).size() == 1) - GetPlaces().add(0, GetPlayers(true).get(0)); - - if (GetPlaces().size() >= 1) - AddGems(GetPlaces().get(0), 15, "1st Place", false); - - if (GetPlaces().size() >= 2) - AddGems(GetPlaces().get(1), 10, "2nd Place", false); - - if (GetPlaces().size() >= 3) - AddGems(GetPlaces().get(2), 5, "3rd Place", false); - - for (Player player : GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false); - - SetState(GameState.End); - AnnounceEnd(GetPlaces()); - } - } - @EventHandler public void Hunger(UpdateEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java index 3bc9dfecb..9a769fe02 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java @@ -60,36 +60,6 @@ public class Barbarians extends SoloGame this.BlockBreakAllow.add(136); } - - @Override - public void EndCheck() - { - if (!IsLive()) - return; - - if (GetPlayers(true).size() <= 1) - { - if (GetPlayers(true).size() == 1) - GetPlaces().add(0, GetPlayers(true).get(0)); - - if (GetPlaces().size() >= 1) - AddGems(GetPlaces().get(0), 15, "1st Place", false); - - if (GetPlaces().size() >= 2) - AddGems(GetPlaces().get(1), 10, "2nd Place", false); - - if (GetPlaces().size() >= 3) - AddGems(GetPlaces().get(2), 5, "3rd Place", false); - - for (Player player : GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false); - - SetState(GameState.End); - AnnounceEnd(GetPlaces()); - } - } - @EventHandler public void BlockDamage(BlockDamageEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java index 468d1eea5..a59611d46 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java @@ -1,5 +1,7 @@ package nautilus.game.arcade.game.games.deathtag; +import java.util.ArrayList; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -20,6 +22,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.deathtag.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; @@ -30,7 +33,7 @@ public class DeathTag extends SoloGame private GameTeam _chasers; private NautHashMap _deathLocation = new NautHashMap(); - + private int _currentSpeed = -1; public DeathTag(ArcadeManager manager) @@ -56,9 +59,9 @@ public class DeathTag extends SoloGame this.DeathOut = false; this.HungerSet = 20; - + this.CompassEnabled = true; - + this.PrepareFreeze = false; } @@ -106,7 +109,7 @@ public class DeathTag extends SoloGame { return _runners; } - + @EventHandler public void UpdateSpeed(UpdateEvent event) { @@ -115,9 +118,9 @@ public class DeathTag extends SoloGame if (event.getType() != UpdateType.SLOW) return; - + double ratio = (double)_chasers.GetPlayers(false).size() / (double)GetPlayers(false).size(); - + if (_currentSpeed == -1 && ratio > 0.25) { Announce(C.cGreen + C.Bold + "Runners receive Speed I"); @@ -134,7 +137,7 @@ public class DeathTag extends SoloGame _currentSpeed = 2; } } - + @EventHandler public void ApplyConditions(UpdateEvent event) { @@ -143,17 +146,17 @@ public class DeathTag extends SoloGame if (event.getType() != UpdateType.FAST) return; - + if (_currentSpeed >= 0) for (Player player : _runners.GetPlayers(false)) { Manager.GetCondition().Factory().Speed("Runner", player, player, 1.9, _currentSpeed, false, false, true); } - + for (Player player : _chasers.GetPlayers(false)) { Manager.GetCondition().Factory().Regen("Undying", player, player, 1.9, 4, false, false, false); - + if (_currentSpeed < 0) Manager.GetCondition().Factory().Speed("Haste", player, player, 1.9, 0, false, false, true); } @@ -189,15 +192,16 @@ public class DeathTag extends SoloGame public void SetChaser(Player player, boolean forced) { - if (!GetPlaces().contains(player)) - GetPlaces().add(0, player); + //Set them as OUT! + if (GetTeam(player) != null) + GetTeam(player).SetPlacement(player, PlayerState.OUT); SetPlayerTeam(player, _chasers); //Kit Kit newKit = GetKits()[5]; //Normal if (forced) newKit = GetKits()[4]; //Alpha - + SetKit(player, newKit, false); newKit.ApplyKit(player); @@ -262,24 +266,24 @@ public class DeathTag extends SoloGame if (_runners.GetPlayers(true).size() <= 1) { - if (_runners.GetPlayers(true).size() == 1) - GetPlaces().add(0, GetPlayers(true).get(0)); + ArrayList places = _runners.GetPlacements(true); - if (GetPlaces().size() >= 1) - AddGems(GetPlaces().get(0), 15, "1st Place", false); + if (places.size() >= 1) + AddGems(places.get(0), 15, "1st Place", false); - if (GetPlaces().size() >= 2) - AddGems(GetPlaces().get(1), 10, "2nd Place", false); + if (places.size() >= 2) + AddGems(places.get(1), 10, "2nd Place", false); - if (GetPlaces().size() >= 3) - AddGems(GetPlaces().get(2), 5, "3rd Place", false); + if (places.size() >= 3) + AddGems(places.get(2), 5, "3rd Place", false); for (Player player : GetPlayers(false)) if (player.isOnline()) AddGems(player, 10, "Participation", false); + AnnounceEnd(places); + SetState(GameState.End); - AnnounceEnd(GetPlaces()); } } @@ -307,7 +311,7 @@ public class DeathTag extends SoloGame return true; } - + @Override public double GetKillsGems(Player killer, Player killed, boolean assist) { @@ -315,7 +319,7 @@ public class DeathTag extends SoloGame { return 4; } - + return 0; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index b40a556af..43ef585f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -350,26 +350,25 @@ public class DragonEscape extends SoloGame { SortScores(); - _places.clear(); - + ArrayList places = new ArrayList(); for (DragonScore score : _ranks) - _places.add(score.Player); + places.add(score.Player); //Announce - AnnounceEnd(_places); + AnnounceEnd(places); //Gems if (_winner != null) AddGems(_winner, 10, "Course Complete", false); - if (_places.size() >= 1) - AddGems(_places.get(0), 20, "1st Place", false); + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false); - if (_places.size() >= 2) - AddGems(_places.get(1), 15, "2nd Place", false); + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false); - if (_places.size() >= 3) - AddGems(_places.get(2), 10, "3rd Place", false); + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false); for (Player player : GetPlayers(false)) if (player.isOnline()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 8c7e00eec..3f3470149 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -580,9 +580,9 @@ public class Draw extends SoloGame SortScores(); //Set Places - _places.clear(); + ArrayList places = new ArrayList(); for (int i=0 ; i<_ranks.size() ; i++) - _places.add(i, _ranks.get(i).Player); + places.add(i, _ranks.get(i).Player); //Award Gems if (_ranks.size() >= 1) @@ -600,7 +600,7 @@ public class Draw extends SoloGame AddGems(player, 10, "Participation", false); SetState(GameState.End); - AnnounceEnd(_places); + AnnounceEnd(places); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index 962f5d92a..f3570be42 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -257,9 +257,9 @@ public class Evolution extends SoloGame SortScores(); //Set Places - _places.clear(); + ArrayList places = new ArrayList(); for (int i=0 ; i<_ranks.size() ; i++) - _places.add(i, _ranks.get(i).Player); + places.add(i, _ranks.get(i).Player); //Award Gems if (_ranks.size() >= 1) @@ -277,7 +277,7 @@ public class Evolution extends SoloGame AddGems(player, 10, "Participation", false); SetState(GameState.End); - AnnounceEnd(_places); + AnnounceEnd(places); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java index 7f808b338..7f78e1c8f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java @@ -42,6 +42,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.milkcow.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; @@ -279,8 +280,9 @@ public class MilkCow extends SoloGame public void SetCow(Player player, boolean forced) { - if (!GetPlaces().contains(player)) - GetPlaces().add(0, player); + //Set them as OUT! + if (GetTeam(player) != null) + GetTeam(player).SetPlacement(player, PlayerState.OUT); SetPlayerTeam(player, _cows); @@ -424,9 +426,9 @@ public class MilkCow extends SoloGame SortScores(); //Set Places - _places.clear(); + ArrayList places = new ArrayList(); for (int i=0 ; i<_ranks.size() ; i++) - _places.add(i, _ranks.get(i).Player); + places.add(i, _ranks.get(i).Player); //Award Gems if (_ranks.size() >= 1) @@ -444,7 +446,7 @@ public class MilkCow extends SoloGame AddGems(player, 10, "Participation", false); SetState(GameState.End); - AnnounceEnd(_places); + AnnounceEnd(places); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java index 1e12d2f86..d45cd6541 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java @@ -289,9 +289,9 @@ public class Quiver extends SoloGame if ((!_ranks.isEmpty() && _ranks.get(0).Kills >= 20) || GetPlayers(true).size() <= 1) { //Set Places - _places.clear(); + ArrayList places = new ArrayList(); for (int i=0 ; i<_ranks.size() ; i++) - _places.add(i, _ranks.get(i).Player); + places.add(i, _ranks.get(i).Player); //Award Gems if (_ranks.size() >= 1) @@ -323,7 +323,7 @@ public class Quiver extends SoloGame AddGems(player, 10, "Participation", false); SetState(GameState.End); - AnnounceEnd(_places); + AnnounceEnd(places); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java index b3b74e98f..2a2d9fc8f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java @@ -171,10 +171,11 @@ public class SquidShooter extends SoloGame if ((!_ranks.isEmpty() && _ranks.get(0).Kills >= 20) || GetPlayers(true).size() <= 1) { + ArrayList places = new ArrayList(); + //Set Places - _places.clear(); for (int i=0 ; i<_ranks.size() ; i++) - _places.add(i, _ranks.get(i).Player); + places.add(i, _ranks.get(i).Player); //Award Gems if (_ranks.size() >= 1) @@ -192,7 +193,7 @@ public class SquidShooter extends SoloGame AddGems(player, 10, "Participation", false); SetState(GameState.End); - AnnounceEnd(_places); + AnnounceEnd(places); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index d2b8ecaba..8d3df9203 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -55,12 +55,15 @@ import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapelessRecipe; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.TimeUtil; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilMath; @@ -73,40 +76,30 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatLog; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.GameLobbyManager; public class UHC extends TeamGame { private NautHashMap _deathTime = new NautHashMap(); - private NautHashMap _combatTime = new NautHashMap(); - private int _borders = 1250; - - private boolean _borderShrink = true; - private int _borderShrinkSize = 1250; + private int _borderSize = 1250; private int _gameMinutes = 0; + private int _safeTime = 10; private long _lastMinute = System.currentTimeMillis(); - private boolean _soloGame = false; - private boolean _timerStarted = false; - private boolean _ended = false; - - private boolean _dragonMode = false; - private ArrayList _portalBlock = null; - private ArrayList _portal = null; - private boolean _portalCreated = false; - private GameTeam _lastDragonDamager = null; + private Objective _scoreObj; - private Location _exitLocation = null; - public UHC(ArcadeManager manager) { super(manager, GameType.UHC, @@ -117,8 +110,9 @@ public class UHC extends TeamGame }, new String[] { - "20 minutes of no PvP", + "10 minutes of no PvP", "No default health regeneration", + "Borders shrink over time", "Last player/team alive wins!" }); @@ -135,27 +129,24 @@ public class UHC extends TeamGame this.InventoryOpen = true; this.DeathOut = true; - this.QuitOut = false; - RejoinTime = 1800000; + this.QuitOut = true; this.CreatureAllow = true; this.AnnounceStay = false; - this.AnnounceJoinQuit = false; - this.AnnounceSilence = false; - this.DisplayLobbySide = false; + this.DisplayLobbySide = true; this.DeathMessages = false; this.SoupEnabled = false; - this.IdleKick = false; - this.AutoStart = false; - this.CompassEnabled = false; - + this.IdleKick = true; + this.AutoStart = true; + this.CompassEnabled = true; + this.WorldBoundaryKill = false; - + WorldTimeSet = -1; CraftRecipes(); @@ -165,51 +156,27 @@ public class UHC extends TeamGame //Disable Anti-Stack Manager.GetAntiStack().SetEnabled(false); + + _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Health", "health"); + _scoreObj.setDisplaySlot(DisplaySlot.PLAYER_LIST); } @Override public void ParseData() { - WorldData.World.setDifficulty(Difficulty.HARD); - - _portalBlock = WorldData.GetDataLocs("YELLOW"); - _portal = WorldData.GetDataLocs("BLACK"); - - //Set Portal Blocks - for (int i=0 ; i<_portalBlock.size() ; i++) - { - if (i<9) - _portalBlock.get(i).getBlock().setTypeIdAndData(Material.ENDER_PORTAL_FRAME.getId(), (byte)4, true); - else - _portalBlock.get(i).getBlock().setTypeIdAndData(Material.ENDER_PORTAL_FRAME.getId(), (byte)0, true); - } + WorldData.World.setDifficulty(Difficulty.HARD); } - + @EventHandler public void endPortalTransfer(final PlayerPortalEvent event) { if (event.getCause() == TeleportCause.END_PORTAL) - { event.setCancelled(true); - event.getPlayer().teleport(((CraftServer)Bukkit.getServer()).getHandle().getServer().getPlayerList().calculateTarget(event.getPlayer().getLocation(), ((CraftWorld)Bukkit.getWorld("world_the_end")).getHandle())); - } - } - - @EventHandler - public void endPortalCreation(final EntityCreatePortalEvent event) - { - if (event.getEntity() instanceof EnderDragon) - { - event.setCancelled(true); - } } @EventHandler public void TimeUpdate(UpdateEvent event) { - if (!_timerStarted) - return; - if (!IsLive()) return; @@ -222,81 +189,23 @@ public class UHC extends TeamGame _gameMinutes++; _lastMinute = System.currentTimeMillis(); - if (_gameMinutes == 5) + if (_gameMinutes < _safeTime) { - Announce(ChatColor.WHITE + C.Bold + "PvP enabled in 15 minutes."); + Announce(ChatColor.WHITE + C.Bold + "PvP enabled in " + (_safeTime - _gameMinutes) + " minutes."); } - else if (_gameMinutes == 10) + else if (_gameMinutes == _safeTime) { - Announce(ChatColor.WHITE + C.Bold + "PvP enabled in 10 minutes."); - } - else if (_gameMinutes == 15) - { - Announce(ChatColor.WHITE + C.Bold + "PvP enabled in 5 minutes."); - } - else if (_gameMinutes == 16) - { - Announce(ChatColor.WHITE + C.Bold + "PvP enabled in 4 minutes."); - } - else if (_gameMinutes == 17) - { - Announce(ChatColor.WHITE + C.Bold + "PvP enabled in 3 minutes."); - } - else if (_gameMinutes == 18) - { - Announce(ChatColor.WHITE + C.Bold + "PvP enabled in 2 minutes."); - } - else if (_gameMinutes == 19) - { - Announce(ChatColor.WHITE + C.Bold + "PvP enabled in 1 minutes."); - } - else if (_gameMinutes == 20) - { - Announce(ChatColor.WHITE + C.Bold + "PvP enabled! 20 minutes have passed."); + Announce(ChatColor.WHITE + C.Bold + "PvP has been enabled!"); + + for (Player player : UtilServer.getPlayers()) + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 1f); this.DamagePvP = true; } - else if (_gameMinutes % 20 == 0) + else if (_gameMinutes % 15 == 0) { Announce(ChatColor.WHITE + C.Bold + _gameMinutes + " minutes have passed."); } - - //Shrink Borders - if (_borderShrink && _gameMinutes >= 90 && _borderShrinkSize > 50) - { - int time = (_gameMinutes - 90) % 20; - - int newSize = Math.max(50, _borderShrinkSize - 150); - - //Shrink - if (_gameMinutes >= 110 && time == 0) - { - Announce(ChatColor.RED + C.Bold + "Borders have shrunk to " + ChatColor.YELLOW + C.Bold + "+/-" + newSize + ChatColor.RED + C.Bold + "!"); - _borderShrinkSize = newSize; - } - - //Warnings - if (time == 0) - { - //Announce(ChatColor.GOLD + C.Bold + "Borders will shrink to " + ChatColor.YELLOW + C.Bold + "+/-" + newSize + ChatColor.GOLD + C.Bold + " in 20 minutes."); - } - else if (time == 5) - { - Announce(ChatColor.GOLD + C.Bold + "Borders will shrink to " + ChatColor.YELLOW + C.Bold + "+/-" + newSize + ChatColor.GOLD + C.Bold + " in 15 minutes."); - } - else if (time == 10) - { - Announce(ChatColor.GOLD + C.Bold + "Borders will shrink to " + ChatColor.YELLOW + C.Bold + "+/-" + newSize + ChatColor.GOLD + C.Bold + " in 10 minutes."); - } - else if (time == 15) - { - Announce(ChatColor.GOLD + C.Bold + "Borders will shrink to " + ChatColor.YELLOW + C.Bold + "+/-" + newSize + ChatColor.GOLD + C.Bold + " in 5 minutes."); - } - else if (time == 19) - { - Announce(ChatColor.GOLD + C.Bold + "Borders will shrink to " + ChatColor.YELLOW + C.Bold + "+/-" + newSize + ChatColor.GOLD + C.Bold + " in 1 minute."); - } - } } @EventHandler @@ -305,9 +214,6 @@ public class UHC extends TeamGame if (event.GetState() != GameState.Prepare) return; - //Disable Damage Manager - Manager.GetDamage().SetEnabled(false); - WorldData.World.setTime(2000); //Kill Evil Mobs @@ -319,12 +225,9 @@ public class UHC extends TeamGame ent.remove(); } - //Blindness + //Hunger for (Player player : GetPlayers(true)) { - Manager.GetCondition().Factory().Blind("Start Blind", player, player, 8, 1, false, false, false); - Manager.GetCondition().Factory().Slow("Start Slow", player, player, 8, 4, false, false, false, false); - player.setSaturation(3f); player.setExhaustion(0f); } @@ -338,44 +241,57 @@ public class UHC extends TeamGame //Allowed if ( - event.getTo().getX() < WorldData.MaxX && - event.getTo().getX() >= WorldData.MinX && - event.getTo().getZ() < WorldData.MaxZ && - event.getTo().getZ() >= WorldData.MinZ) - return; - - Location from = event.getFrom(); - if (from.getX() >= WorldData.MaxX) from.setX(WorldData.MaxX - 1); - if (from.getX() < WorldData.MinX) from.setX(WorldData.MinX + 1); - if (from.getZ() >= WorldData.MaxZ) from.setZ(WorldData.MaxZ - 1); - if (from.getZ() < WorldData.MinZ) from.setZ(WorldData.MinZ + 1); - - event.setTo(event.getFrom()); - - event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.NOTE_BASS, 0.5f, 1f); - } - - @EventHandler - public void WorldBoundaryShrinkCheck(PlayerMoveEvent event) - { - if (!IsLive()) - return; - - //Allowed - if ( - event.getTo().getX() < _borderShrinkSize && - event.getTo().getX() >= -_borderShrinkSize && - event.getTo().getZ() < _borderShrinkSize && - event.getTo().getZ() >= -_borderShrinkSize) + event.getTo().getX() < _borderSize&& + event.getTo().getX() >= -_borderSize && + event.getTo().getZ() < _borderSize && + event.getTo().getZ() >= -_borderSize) return; if (Recharge.Instance.use(event.getPlayer(), "Border Shrink", 500, false, false)) { Manager.GetCondition().Factory().Poison("Border", event.getPlayer(), event.getPlayer(), 1.9, 0, false, false, false); - Manager.GetCondition().Factory().Speed("Border", event.getPlayer(), event.getPlayer(), 1.9, 1, false, false, false); - Manager.GetCondition().Factory().DigFast("Border", event.getPlayer(), event.getPlayer(), 1.9, 1, false, false, false); } } + + @EventHandler + public void WorldBoundaryCheck(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (Player player : GetPlayers(true)) + { + if (Math.abs(player.getLocation().getX()) + 5 < _borderSize && Math.abs(player.getLocation().getZ()) + 5 < _borderSize) + continue; + + for (Block block : UtilBlock.getInRadius(player.getLocation(), 5d).keySet()) + { + if (Math.abs(block.getX()) < _borderSize && Math.abs(block .getZ()) + 5 < _borderSize) + continue; + + if (!UtilBlock.airFoliage(block)) + continue; + + if (!UtilBlock.solid(block.getRelative(BlockFace.DOWN))) + continue; + + block.setType(Material.FIRE); + } + } + } + + @EventHandler + public void WorldBoundaryShrink(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.SLOW) + return; + + if (_borderSize > 16) + _borderSize--; + } @EventHandler public void WorldBoundarySet(GameStateChangeEvent event) @@ -384,130 +300,120 @@ public class UHC extends TeamGame return; long time = System.currentTimeMillis(); - - this.WorldData.MinX = -_borders; - this.WorldData.MaxX = _borders; - this.WorldData.MinZ = -_borders; - this.WorldData.MaxZ = _borders; - + + this.WorldData.MinX = -_borderSize; + this.WorldData.MaxX = _borderSize; + this.WorldData.MinZ = -_borderSize; + this.WorldData.MaxZ = _borderSize; + this.WorldData.MinY = -1000; this.WorldData.MaxY = 1000; - + for (int y=0 ; y<128 ; y++) - for (int x=-_borders ; x<_borders ; x++) - for (int z=-_borders ; z<_borders ; z++) + for (int x=-_borderSize ; x<_borderSize ; x++) + for (int z=-_borderSize ; z<_borderSize ; z++) { - if (x == -_borders || x == _borders-1 || z == -_borders || z == _borders-1) + if (x == -_borderSize || x == _borderSize-1 || z == -_borderSize || z == _borderSize-1) { MapUtil.QuickChangeBlockAt(WorldData.World, x, y, z , 159, (byte)14); } } - + System.out.println("Time: " + UtilTime.MakeStr(System.currentTimeMillis() - time)); } - @EventHandler - public void WorldBoundaryBlockBreak(BlockBreakEvent event) - { - Block block = event.getBlock(); - - if ( - block.getX() < WorldData.MaxX && - block.getX() >= WorldData.MinX && - block.getZ() < WorldData.MaxZ && - block.getZ() >= WorldData.MinZ) - return; - - event.setCancelled(true); - } - - @EventHandler(priority = EventPriority.LOW) - public void GenerateTeamNames(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Recruit) - return; - - //Solo - if (GetTeamList().size() > 10) - { - int i = 0; - for (GameTeam team : GetTeamList()) - { - team.SetColor(ChatColor.WHITE); - team.SetName(i+""); - - i++; - } - - _soloGame = true; - - return; - } - - for (GameTeam team : GetTeamList()) - { - if (team.GetColor() == ChatColor.RED) team.SetName("Red"); - else if (team.GetColor() == ChatColor.GOLD) team.SetName("Orange"); - else if (team.GetColor() == ChatColor.YELLOW) team.SetName("Yellow"); - else if (team.GetColor() == ChatColor.GREEN) team.SetName("Green"); - else if (team.GetColor() == ChatColor.DARK_BLUE) team.SetName("Blue"); - else if (team.GetColor() == ChatColor.AQUA) team.SetName("Aqua"); - else if (team.GetColor() == ChatColor.LIGHT_PURPLE) team.SetName("Purple"); - else if (team.GetColor() == ChatColor.WHITE) team.SetName("White"); - } - } - - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void GenerateSpawns(GameStateChangeEvent event) { if (event.GetState() != GameState.Recruit) - return; + return; - for (GameTeam team : GetTeamList()) + //Wipe Spawns + for (GameTeam team : this.GetTeamList()) { team.GetSpawns().clear(); } + + TimeUtil.start("UHC Spawn Generation"); - for (GameTeam team : GetTeamList()) + //Solo Game + if (this.GetTeamList().size() == 1) { - Location loc = GetRandomSpawn(null); + while (GetTeamList().get(0).GetSpawns().size() < this.GetPlayers(true).size()) + { + Location loc = GetRandomSpawn(null); - double dist = 250; - if (_soloGame) - dist = 80; + //Dynamically scale distance requirement based on how many teams need to fit + double dist = (2*_borderSize) / (Math.sqrt(this.GetPlayers(true).size()) + 3); - //Ensure 250 Blocks between Teams - while (true) - { - boolean clash = false; + //Ensure distance between Teams + while (true) + { + boolean clash = false; - for (GameTeam otherTeam : GetTeamList()) - { - if (otherTeam.GetSpawns().isEmpty()) - continue; - - if (UtilMath.offset(loc, otherTeam.GetSpawn()) < dist) + for (Location otherSpawn : GetTeamList().get(0).GetSpawns()) { - clash = true; + if (UtilMath.offset(loc, otherSpawn) < dist) + { + clash = true; + break; + } + } + + if (!clash) break; - } + + loc = GetRandomSpawn(null); } - if (!clash) - break; - - loc = GetRandomSpawn(null); - } - - team.GetSpawns().add(loc); - - while (team.GetSpawns().size() < 5) - { - Location other = GetRandomSpawn(loc); - - team.GetSpawns().add(other); + GetTeamList().get(0).GetSpawns().add(loc); } } + //Team Game + else + { + for (GameTeam team : GetTeamList()) + { + Location loc = GetRandomSpawn(null); + + //Dynamically scale distance requirement based on how many teams need to fit + double dist = (2*_borderSize) / (Math.sqrt(GetTeamList().size()) + 3); + + //Ensure distance between Teams + while (true) + { + boolean clash = false; + + for (GameTeam otherTeam : GetTeamList()) + { + if (otherTeam.GetSpawns().isEmpty()) + continue; + + if (UtilMath.offset(loc, otherTeam.GetSpawn()) < dist) + { + clash = true; + break; + } + } + + if (!clash) + break; + + loc = GetRandomSpawn(null); + } + + team.GetSpawns().add(loc); + + while (team.GetSpawns().size() < 5) + { + Location other = GetRandomSpawn(loc); + + team.GetSpawns().add(other); + } + } + } + + TimeUtil.stop("UHC Spawn Generation"); } public Location GetRandomSpawn(Location around) @@ -524,7 +430,10 @@ public class UHC extends TeamGame //Get Team Location if (around == null) { - block = UtilBlock.getHighest(WorldData.World, -900 + UtilMath.r(1800), -900 + UtilMath.r(1800), ignore); + int x = (int)(UtilMath.r((int)(1.8*_borderSize)) - (0.9*_borderSize)); + int z = (int)(UtilMath.r((int)(1.8*_borderSize)) - (0.9*_borderSize)); + + block = UtilBlock.getHighest(WorldData.World, x, z, ignore); } //Get Radius Location else @@ -542,7 +451,7 @@ public class UHC extends TeamGame if (block.getTypeId() != 0 || block.getRelative(BlockFace.UP).getTypeId() != 0) continue; - loc = block.getLocation().add(0.5, 0, 0.5); + loc = block.getLocation().add(0.5, 0.5, 0.5); } return loc; @@ -627,11 +536,11 @@ public class UHC extends TeamGame if (!_deathTime.containsKey(player.getName())) continue; - if (!UtilTime.elapsed(_deathTime.get(player.getName()), 60000)) + if (!UtilTime.elapsed(_deathTime.get(player.getName()), 20000)) continue; - player.kickPlayer(C.cYellow + "60 Seconds have passed since you died.\nYou have been removed."); _deathTime.remove(player.getName()); + Manager.GetPortal().SendPlayerToServer(player, "Lobby"); } } @@ -677,72 +586,17 @@ public class UHC extends TeamGame return; } } - */ + */ @EventHandler - public void DamageRecord(EntityDamageEvent event) + public void DamageCancel(CustomDamageEvent event) { - if (event.isCancelled()) - return; - - LivingEntity damagerEnt = UtilEvent.GetDamagerEntity(event, true); - - //No PvP - if (_gameMinutes < 20) + if (_gameMinutes < _safeTime && event.GetDamagerPlayer(true) != null) { - if (damagerEnt != null && damagerEnt instanceof Player && event.getEntity() instanceof Player) - { - event.setCancelled(true); - return; - } - } - - //Damager - if (damagerEnt != null) - { - if (damagerEnt instanceof Player) - { - Player damager = (Player)damagerEnt; - - //Damager Not Alive - if (!IsAlive(damager)) - { - event.setCancelled(true); - return; - } - //Damager Alive - else - { - _combatTime.put(damager.getName(), System.currentTimeMillis()); - } - } - } - - //Damagee - if (event.getEntity() instanceof Player) - { - Player damagee = (Player)event.getEntity(); - - if (!UtilTime.elapsed(GetStateTime(), 20000)) - { - event.setCancelled(true); - return; - } - - //Damagee Not Alive - if (!IsAlive(damagee)) - { - event.setCancelled(true); - return; - } - //Damagee Alive - else if (damagerEnt != null && damagerEnt instanceof Player) - { - _combatTime.put(damagee.getName(), System.currentTimeMillis()); - } + event.SetCancelled("Game Not Started"); } } - + @EventHandler public void CreatureCull(UpdateEvent event) { @@ -809,7 +663,6 @@ public class UHC extends TeamGame CraftingInventory inv = (CraftingInventory)event.getInventory(); - //Allow Normal Gold Apples for (ItemStack item : inv.getMatrix()) if (item != null && item.getType() != Material.AIR) if (item.getType() == Material.GOLD_INGOT) @@ -834,7 +687,6 @@ public class UHC extends TeamGame CraftingInventory inv = (CraftingInventory)event.getInventory(); - //Allow Normal Gold Apples for (ItemStack item : inv.getMatrix()) if (item != null && item.getType() != Material.AIR) if (item.getType() == Material.SKULL) @@ -920,11 +772,6 @@ public class UHC extends TeamGame } } - @EventHandler - public void KillCancel(PlayerCommandPreprocessEvent event) - { - - } @EventHandler public void Commands(PlayerCommandPreprocessEvent event) @@ -932,31 +779,6 @@ public class UHC extends TeamGame if (event.getMessage().startsWith("/kill")) event.setCancelled(true); - if (event.getMessage().startsWith("/uhc timer start")) - { - event.setCancelled(true); - _timerStarted = true; - - Announce(event.getPlayer().getName() + " started the 20 minute timer!"); - } - - if (event.getMessage().startsWith("/uhc game start")) - { - this.SetCountdownForce(true); - this.SetCountdown(11); - event.setCancelled(true); - - Announce(event.getPlayer().getName() + " started the game!"); - } - - if (event.getMessage().startsWith("/uhc game stop")) - { - this.SetState(GameState.End); - event.setCancelled(true); - - Announce(event.getPlayer().getName() + " stopped the game!"); - } - if (event.getMessage().startsWith("/uhc time day")) { this.WorldTimeSet = 4000; @@ -980,20 +802,7 @@ public class UHC extends TeamGame Announce(event.getPlayer().getName() + " set time to Day and Night!"); } - - if (event.getMessage().startsWith("/dragondamage")) - { - if (event.getPlayer().getName().equals("Chiss")) - { - for (Entity ent : event.getPlayer().getWorld().getEntities()) - { - if (ent instanceof EnderDragon) - { - ((EnderDragon) ent).damage(100, event.getPlayer()); - } - } - } - } + } @EventHandler(priority = EventPriority.LOWEST) @@ -1008,6 +817,7 @@ public class UHC extends TeamGame event.setCancelled(false); } + /* @EventHandler public void TabHealth(UpdateEvent event) { @@ -1053,137 +863,7 @@ public class UHC extends TeamGame e.printStackTrace(); } } - } - - @Override - public boolean CanJoinTeam(GameTeam team) - { - if (_soloGame) - return (team.GetPlayers(true).isEmpty()); - - return (team.GetPlayers(true).size() < 4); - } - - @Override - public void AnnounceGame() - { - for (Player player : UtilServer.getPlayers()) - { - player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f); - - for (int i=0 ; i<6-GetDesc().length ; i++) - UtilPlayer.message(player, ""); - - UtilPlayer.message(player, ArcadeFormat.Line); - - UtilPlayer.message(player, C.cYellow+ C.Bold + this.GetName()); - UtilPlayer.message(player, ""); - - for (String line : this.GetDesc()) - { - UtilPlayer.message(player, C.cWhite + "- " + line); - } - - UtilPlayer.message(player, ""); - UtilPlayer.message(player, C.cWhite + "Created and Hosted by " + C.cYellow + C.Bold + "Mineplex.com"); - - UtilPlayer.message(player, ArcadeFormat.Line); - } - } - - @Override - public void AnnounceEnd(GameTeam team) - { - for (Player player : UtilServer.getPlayers()) - { - player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f); - - UtilPlayer.message(player, ""); - UtilPlayer.message(player, ArcadeFormat.Line); - - UtilPlayer.message(player, C.cYellow+ C.Bold + this.GetName()); - UtilPlayer.message(player, ""); - UtilPlayer.message(player, ""); - - if (team != null) - { - WinnerTeam = team; - Winner = team.GetName() + " Team"; - - if (_soloGame) - UtilPlayer.message(player, team.GetColor() + C.Bold + team.GetPlayers(false).get(0).getName() + " won the match!"); - else - UtilPlayer.message(player, team.GetColor() + C.Bold + "Team " + team.GetName() + " won the match!"); - } - else - { - UtilPlayer.message(player, ChatColor.WHITE + "§lNobody won the game..."); - } - - UtilPlayer.message(player, ""); - UtilPlayer.message(player, ""); - UtilPlayer.message(player, C.cWhite + "Created and Hosted by " + C.cYellow + C.Bold + "Mineplex.com"); - - UtilPlayer.message(player, ArcadeFormat.Line); - } - } - - public void AnnounceEndLose() - { - for (Player player : UtilServer.getPlayers()) - { - player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f); - - UtilPlayer.message(player, ""); - UtilPlayer.message(player, ArcadeFormat.Line); - - UtilPlayer.message(player, C.cYellow+ C.Bold + this.GetName()); - UtilPlayer.message(player, ""); - UtilPlayer.message(player, ""); - - UtilPlayer.message(player, ChatColor.WHITE + "§lEnder Dragon has won the game..."); - - UtilPlayer.message(player, ""); - UtilPlayer.message(player, ""); - UtilPlayer.message(player, C.cWhite + "Created and Hosted by " + C.cYellow + C.Bold + "Mineplex.com"); - - UtilPlayer.message(player, ArcadeFormat.Line); - } - } - - @Override - public boolean AdvertiseText(GameLobbyManager gameLobbyManager, int _advertiseStage) - { - if (_advertiseStage == 0) - { - gameLobbyManager.WriteAdvertiseLine(" ", 0, 159, (byte)15); - gameLobbyManager.WriteAdvertiseLine("ULTRA HARDCORE", 1, 159, (byte)15); - gameLobbyManager.WriteAdvertiseLine("CODED AND HOSTED BY", 2, 159, (byte)15); - gameLobbyManager.WriteAdvertiseLine("MINEPLEX.COM", 3, 159, (byte)4); - gameLobbyManager.WriteAdvertiseLine(" ", 4, 159, (byte)15); - } - else if (_advertiseStage == 1) - { - gameLobbyManager.WriteAdvertiseLine(" ", 0, 159, (byte)15); - gameLobbyManager.WriteAdvertiseLine("JOIN", 1, 159, (byte)15); - gameLobbyManager.WriteAdvertiseLine("MINEPLEX.COM", 2, 159, (byte)4); - gameLobbyManager.WriteAdvertiseLine("TO PLAY", 3, 159, (byte)15); - gameLobbyManager.WriteAdvertiseLine(" ", 4, 159, (byte)15); - } - - return true; - } - - @Override - public void Announce(String message) - { - for (Player player : UtilServer.getPlayers()) - { - UtilPlayer.message(player, message); - } - - System.out.println("[Announcement] " + message); - } + }*/ @Override public void EndCheck() @@ -1191,208 +871,121 @@ public class UHC extends TeamGame if (!IsLive()) return; - if (_ended) - return; - - ArrayList teamsAlive = new ArrayList(); - - //Online Teams - for (GameTeam team : this.GetTeamList()) - if (team.GetPlayers(true).size() > 0) - teamsAlive.add(team); - - //Offline Player Team - for (GameTeam team : RejoinTeam.values()) - teamsAlive.add(team); - - if (!_dragonMode && teamsAlive.size() == 1) + //Solo + if (GetTeamList().size() == 1) { - AnnounceEnd(teamsAlive.get(0)); - - _ended = true; - } + if (GetPlayers(true).size() <= 1) + { + ArrayList places = GetTeamList().get(0).GetPlacements(true); + + //Announce + AnnounceEnd(places); - if (teamsAlive.size() == 0) - { - //Announce - AnnounceEndLose(); + //Gems + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false); - //End - _ended = true; - //SetState(GameState.End); - } - } + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false); - @EventHandler - public void DragonDamage(EntityDamageEvent event) - { - if (!_dragonMode) - return; - - if (!IsLive()) - return; + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false); - if (_ended) - return; + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false); - if (!(event.getEntity() instanceof EnderDragon)) - return; - - //Damager - LivingEntity damagerEnt = UtilEvent.GetDamagerEntity(event, true); - if (damagerEnt != null) - { - if (damagerEnt instanceof Player) - { - Player damager = (Player)damagerEnt; - - GameTeam team = GetTeam(damager); - - if (team != null) - { - if (_lastDragonDamager == null || !_lastDragonDamager.equals(team)) - { - _lastDragonDamager = team; - } - } + //End + SetState(GameState.End); } } - } - - @EventHandler - public void DragonDeath(EntityDeathEvent event) - { - if (!_dragonMode) - return; - - if (!IsLive()) - return; - - if (_ended) - return; - - if (_lastDragonDamager == null) - return; - - if (!(event.getEntity() instanceof EnderDragon)) - return; - - AnnounceEnd(_lastDragonDamager); - _ended = true; - } - - @EventHandler - public void PortalCreate(UpdateEvent event) - { - if (!_dragonMode) - return; - - if (!InProgress()) - return; - - if (event.getType() != UpdateType.SEC) - return; - - boolean complete = true; - for (Location loc : _portalBlock) - { - if (loc.getBlock().getType() != Material.ENDER_PORTAL_FRAME) - loc.getBlock().setType(Material.ENDER_PORTAL_FRAME); - - if (loc.getBlock().getData() < 4) - complete = false; - } - - if (complete) - { - if (!_portalCreated) - { - for (Player player : UtilServer.getPlayers()) - player.playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 1f); - - Announce(ChatColor.WHITE + C.Bold + "The portal to The End has been opened!"); - } - - _portalCreated = true; - - for (Location loc : _portal) - loc.getBlock().setTypeIdAndData(Material.ENDER_PORTAL.getId(), (byte)0, false); - } else { - for (Location loc : _portal) - loc.getBlock().setType(Material.AIR); - } - } + ArrayList teamsAlive = new ArrayList(); - @EventHandler - public void PortalBreak(BlockBreakEvent event) - { - if (!_dragonMode) - return; - - if (event.getBlock().getType() == Material.ENDER_PORTAL_FRAME) - event.setCancelled(true); + //Online Teams + for (GameTeam team : this.GetTeamList()) + if (team.GetPlayers(true).size() > 0) + teamsAlive.add(team); + + //Offline Player Team + for (GameTeam team : RejoinTeam.values()) + teamsAlive.add(team); + + if (teamsAlive.size() <= 1) + { + AnnounceEnd(teamsAlive.get(0)); + SetState(GameState.End); + } + } } @Override @EventHandler public void ScoreboardUpdate(UpdateEvent event) { + if (event != null && event.getType() != UpdateType.FAST) + return; + ScoreboardWrite(); } - @EventHandler - public void EndUpdate(UpdateEvent event) + public void ScoreboardWrite() { - if (event.getType() != UpdateType.SEC) - return; + Scoreboard.Reset(); - if (!IsLive()) - return; - - if (!_ended) - return; - - GameTeam endTeam = GetTeam(ChatColor.GRAY); - - if (endTeam == null) - { - endTeam = new GameTeam(this, "Post Game", ChatColor.GRAY, GetTeamList().get(0).GetSpawns()); - AddTeam(endTeam); - } - - for (Player player : UtilServer.getPlayers()) - { - GameTeam team = GetTeam(player); + Scoreboard.WriteBlank(); - if (team != null && !endTeam.equals(team)) - { - team.RemovePlayer(player); - Manager.Clear(player); - - endTeam.AddPlayer(player); - player.setGameMode(GameMode.CREATIVE); - player.setFlying(true); - } - } - } - - @EventHandler - public void EndCommands(PlayerCommandPreprocessEvent event) - { - if (!IsLive()) - return; - - if (!_ended) - return; - - if (event.getMessage().startsWith("/world")) + //Solo + if (GetTeamList().size() == 1) { - event.setCancelled(true); - event.getPlayer().teleport(_portalBlock.get(0).clone().add(0, 10, 0)); - event.getPlayer().setGameMode(GameMode.CREATIVE); - event.getPlayer().setFlying(true); + if (GetPlayers(true).size() < 10) + { + for (Player player : GetPlayers(true)) + { + Scoreboard.WriteOrdered("Health", player.getName(), (int)player.getHealth(), true); + } + } + else + { + Scoreboard.Write(C.cYellow + C.Bold + "Players"); + Scoreboard.Write(GetPlayers(true).size() + " Alive"); + } } + //Team + else + { + ArrayList aliveList = new ArrayList(); + + for (GameTeam team : GetTeamList()) + if (team.IsTeamAlive()) + aliveList.add(team); + + if (GetPlayers(true).size() < 10) + { + for (Player player : GetPlayers(true)) + { + Scoreboard.WriteOrdered("Health", GetTeam(player).GetColor() + player.getName(), (int)player.getHealth(), true); + } + } + else if (aliveList.size() < 10) + { + for (GameTeam team : aliveList) + { + Scoreboard.WriteOrdered("Players", team.GetName(), team.GetPlayers(true).size(), true); + } + } + else + { + Scoreboard.Write(C.cYellow + C.Bold + "Teams"); + Scoreboard.Write(GetTeamList().size() + " Alive"); + } + } + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Borders"); + Scoreboard.Write("+-" + _borderSize); + + Scoreboard.Draw(); } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java index 3b861afab..56aac033b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.zombiesurvival; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -29,6 +30,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.zombiesurvival.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; @@ -141,9 +143,11 @@ public class ZombieSurvival extends SoloGame public void SetChaser(Player player, boolean forced) { - if (!GetPlaces().contains(player)) - GetPlaces().add(0, player); + //Set them as OUT! + if (GetTeam(player) != null) + GetTeam(player).SetPlacement(player, PlayerState.OUT); + //Change to Undead SetPlayerTeam(player, _undead); //Kit @@ -323,35 +327,25 @@ public class ZombieSurvival extends SoloGame if (_survivors.GetPlayers(true).size() <= 1) { - if (_survivors.GetPlayers(true).size() == 1) - GetPlaces().add(0, GetPlayers(true).get(0)); + ArrayList places = _survivors.GetPlacements(true); + + if (places.size() >= 1) + AddGems(places.get(0), 15, "1st Place", false); - if (GetPlaces().size() >= 1) - AddGems(GetPlaces().get(0), 15, "1st Place", false); + if (places.size() >= 2) + AddGems(places.get(1), 10, "2nd Place", false); - if (GetPlaces().size() >= 2) - AddGems(GetPlaces().get(1), 10, "2nd Place", false); + if (places.size() >= 3) + AddGems(places.get(2), 5, "3rd Place", false); - if (GetPlaces().size() >= 3) - AddGems(GetPlaces().get(2), 5, "3rd Place", false); - /* - int sections = GetPlaces().size()/10; - - for (int i=0 ; i<5 ; i++) - { - for (int j=i*sections ; j < j*sections + sections ; j++) - { - AddGems(GetPlaces().get(j), 5-i, "Top " + ((i+1)*10) + "%", false); - } - } - */ for (Player player : GetPlayers(false)) if (player.isOnline()) AddGems(player, 10, "Participation", false); + AnnounceEnd(places); + SetState(GameState.End); - AnnounceEnd(GetPlaces()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java index cd86714b4..48b6f0f5c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java @@ -61,10 +61,10 @@ public class GameChatManager implements Listener //Rank Prefix String rankStr = ""; - if (rank != Rank.ALL && (Manager.GetGame() != null && Manager.GetGame().GetType() != GameType.UHC)) + if (rank != Rank.ALL) rankStr = rank.GetTag(true, true) + " "; - if (ownsUltra && !rank.Has(Rank.ULTRA) && (Manager.GetGame() != null && Manager.GetGame().GetType() != GameType.UHC)) + if (ownsUltra && !rank.Has(Rank.ULTRA)) rankStr = Rank.ULTRA.GetTag(true, true) + " "; //Base Format @@ -91,11 +91,6 @@ public class GameChatManager implements Listener { globalMessage = true; event.setFormat(dead + rankStr + team.GetColor() + "%1$s " + C.cWhite + "%2$s"); - - if (Manager.GetGame().GetType() == GameType.UHC) - event.setFormat(ChatColor.YELLOW + "%1$s " + ChatColor.WHITE + "%2$s"); - else - event.setFormat(dead + rankStr + team.GetColor() + "%1$s " + C.cWhite + "%2$s"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java index 4947164fa..da639e4cf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java @@ -132,9 +132,6 @@ public class GameGemManager implements Listener if (Manager.IsTournamentServer()) return; - if (game.GetType() == GameType.UHC) - return; - //Inform Gems AnnounceGems(game, player, game.GetPlayerGems().get(player), give); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index ddf146109..18d459147 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -302,22 +302,9 @@ public class GameLobbyManager implements IPacketRunnable, Listener CreateScoreboards(); return; } - - //UHC Empty - if (game.GetTeamList().size() > 10 && game.GetType() == GameType.UHC) - { - WriteTeamLine("Season", 0, 159, (byte)15); - WriteTeamLine("7", 1, 159, (byte)4); - - WriteKitLine("Season", 0, 159, (byte)15); - WriteKitLine("7", 1, 159, (byte)4); - - CreateScoreboards(); - return; - } - + //Standard - if (game.GetKits().length > 1 || game.GetType() != GameType.UHC) + if (game.GetKits().length > 1 || game.GetTeamList().size() < 6) { //Display ArrayList teams = new ArrayList(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index e59faffc6..8c161d004 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -171,6 +171,13 @@ public class GameManager implements Listener } } else if (game.GetType() != GameType.UHC) + { + if (UtilTime.elapsed(game.GetStateTime(), 10800000)) + { + game.SetState(GameState.End); + } + } + else { if (UtilTime.elapsed(game.GetStateTime(), 1200000)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index d529610c7..bce01006f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -218,19 +218,6 @@ public class GamePlayerManager implements Listener if (past != null) { game.RemoveTeamPreference(player); - - if (game.GetType() == GameType.UHC) - { - String players = ""; - for (Player other : game.GetTeamPreferences().get(past)) - players += other.getName() + " "; - - if (players.length() > 0) - players = players.substring(0, players.length()-1); - - for (Player other : game.GetTeamPreferences().get(past)) - UtilPlayer.message(other, past.GetFormattedName() + " Team: " + ChatColor.RESET + players); - } } if (!game.GetTeamPreferences().containsKey(team)) @@ -239,22 +226,7 @@ public class GamePlayerManager implements Listener game.GetTeamPreferences().get(team).add(player); } - if (game.GetType() == GameType.UHC) - { - String players = ""; - for (Player other : game.GetTeamPreferences().get(team)) - players += other.getName() + " "; - - if (players.length() > 0) - players = players.substring(0, players.length()-1); - - for (Player other : game.GetTeamPreferences().get(team)) - UtilPlayer.message(other, team.GetFormattedName() + " Team: " + ChatColor.RESET + players); - } - else - { - UtilPlayer.message(player, F.main("Team", "You are " + F.elem(game.GetTeamQueuePosition(player)) + " in queue for " + F.elem(team.GetFormattedName() + " Team") + ".")); - } + UtilPlayer.message(player, F.main("Team", "You are " + F.elem(game.GetTeamQueuePosition(player)) + " in queue for " + F.elem(team.GetFormattedName() + " Team") + ".")); } @EventHandler(priority = EventPriority.LOWEST) 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 326cbcbb6..6e5ba5a8f 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 @@ -119,10 +119,7 @@ public class MiscManager implements Listener if (Manager.GetGame() == null) return; - - if (Manager.GetGame().GetType() == GameType.UHC) - return; - + for (Player player : UtilServer.getPlayers()) { if (!Manager.GetGame().IsAlive(player)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java index bd75a6ff6..72f73bbb6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java @@ -49,6 +49,11 @@ public class GameScoreboard { return _sideObjective; } + + public String ParseTeamName(String name) + { + return name.substring(0, Math.min(16, name.length())); + } public void CreateTeams() { @@ -57,16 +62,7 @@ public class GameScoreboard //Base Groups for (Rank rank : Rank.values()) { - //Spectator - if (rank == Rank.ALL) - { - _scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(ChatColor.GRAY + ""); - } - else - { - _scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(ChatColor.GRAY + ""); - //_scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(rank.Color + C.Bold + rank.Name.toUpperCase() + ChatColor.RESET + " " + ChatColor.GRAY); - } + _scoreboard.registerNewTeam(ParseTeamName(rank.Name + "SPEC")).setPrefix(ChatColor.GRAY + ""); } //Team Groups @@ -74,15 +70,7 @@ public class GameScoreboard { for (Rank rank : Rank.values()) { - if (rank == Rank.ALL) - { - _scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + ""); - } - else - { - //_scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.Color + C.Bold + rank.Name.toUpperCase() + ChatColor.RESET + " " + team.GetColor()); - _scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + ""); - } + _scoreboard.registerNewTeam(ParseTeamName(rank.Name + team.GetName().toUpperCase())).setPrefix(team.GetColor() + ""); } } } @@ -95,7 +83,7 @@ public class GameScoreboard if (teamName == null) teamName = ""; - String team = Game.Manager.GetClients().Get(player).GetRank().Name + teamName; + String team = ParseTeamName(Game.Manager.GetClients().Get(player).GetRank().Name + teamName); try { From 60a6f2219472999817c2fe50dad4badf2eec588b Mon Sep 17 00:00:00 2001 From: Peter Miller Date: Fri, 27 Jun 2014 17:01:54 -0400 Subject: [PATCH 2/2] Added functionality for retrieving serverName from Bungee --- .../src/mineplex/core/portal/Portal.java | 74 ++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 8e4708c17..e93e69db4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -1,6 +1,8 @@ package mineplex.core.portal; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -15,6 +17,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.messaging.PluginMessageListener; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; @@ -23,7 +26,7 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -public class Portal extends MiniPlugin +public class Portal extends MiniPlugin implements PluginMessageListener { private static Object _transferLock = new Object(); @@ -34,12 +37,14 @@ public class Portal extends MiniPlugin private boolean _retrieve = true; private CoreClientManager _clientier; + private String serverName = ""; public Portal(JavaPlugin plugin) { super("Portal", plugin); Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord"); + Bukkit.getMessenger().registerIncomingPluginChannel(GetPlugin(), "BungeeCord", this); _repository.initialize(plugin.getConfig().getBoolean("serverstatus.us")); _clientier = CoreClientManager.Initialize(plugin, plugin.getConfig().getString("webServer")); @@ -93,6 +98,34 @@ public class Portal extends MiniPlugin } }, 20L); } + + private void ProcessServerName(final Player player) + { + ByteArrayOutputStream b = new ByteArrayOutputStream(); + DataOutputStream out = new DataOutputStream(b); + + try + { + out.writeUTF("GetServer"); + } + catch (IOException e) + { + // Can never happen + } + finally + { + try + { + out.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + player.sendPluginMessage(GetPlugin(), "BungeeCord", b.toByteArray()); + } private void SendPlayerToServerWithMessage(Player player, String serverName) { @@ -180,7 +213,8 @@ public class Portal extends MiniPlugin if(args.length == 0) { - player.sendMessage(ChatColor.YELLOW + "You are currently on server: " + ChatColor.GOLD + GetPlugin().getServer().getName() + " " + GetPlugin().getServer().getServerName()); + ProcessServerName(player); + player.sendMessage(ChatColor.YELLOW + "You are currently on server: " + ChatColor.GOLD + serverName); return; } else if(args.length == 1) @@ -256,4 +290,40 @@ public class Portal extends MiniPlugin } } } + + @Override + public void onPluginMessageReceived(String channel, Player player, byte[] message) + { + if (!channel.equals("BungeeCord")) + { + return; + } + + DataInputStream in = new DataInputStream(new ByteArrayInputStream(message)); + + try + { + String subchannel = in.readUTF(); + + if (subchannel.equals("GetServer")) + { + serverName = in.readUTF(); + } + } + catch (IOException e) + { + // Should never happen + } + finally + { + try + { + in.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } }