From baa337d2253a762a1b5dd99038052b1fa4390a14 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 15 Jul 2017 15:48:12 +1000 Subject: [PATCH] CTF: group by team name in tab list --- MCGalaxy/Games/CTF/CtfGame.cs | 4 ++-- MCGalaxy/Games/CTF/CtfPlugin.cs | 18 ++++++++++++++++++ MCGalaxy/Levels/Level.Fields.cs | 1 - MCGalaxy/Player/Player.Handlers.cs | 9 +-------- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/MCGalaxy/Games/CTF/CtfGame.cs b/MCGalaxy/Games/CTF/CtfGame.cs index dda29cea3..306c11c1d 100644 --- a/MCGalaxy/Games/CTF/CtfGame.cs +++ b/MCGalaxy/Games/CTF/CtfGame.cs @@ -157,8 +157,8 @@ namespace MCGalaxy.Games { Player.Message(p, "No CTF maps were found."); return false; } - Blue = new CtfTeam2("blue", Colors.blue); - Red = new CtfTeam2("red", Colors.red); + Blue = new CtfTeam2("Blue", Colors.blue); + Red = new CtfTeam2("Red", Colors.red); LoadMap(maps[new Random().Next(maps.Count)]); Logger.Log(LogType.GameActivity, "[CTF] Running..."); diff --git a/MCGalaxy/Games/CTF/CtfPlugin.cs b/MCGalaxy/Games/CTF/CtfPlugin.cs index 4153a9d73..7c730174d 100644 --- a/MCGalaxy/Games/CTF/CtfPlugin.cs +++ b/MCGalaxy/Games/CTF/CtfPlugin.cs @@ -18,6 +18,7 @@ permissions and limitations under the Licenses. */ using System; +using MCGalaxy.Events.EntityEvents; using MCGalaxy.Events.LevelEvents; using MCGalaxy.Events.PlayerEvents; using MCGalaxy.Maths; @@ -37,6 +38,7 @@ namespace MCGalaxy.Games { OnPlayerDisconnectEvent.Register(HandleDisconnect, Priority.High); OnLevelUnloadEvent.Register(HandleLevelUnload, Priority.High); OnPlayerSpawningEvent.Register(HandlePlayerSpawning, Priority.High); + OnTabListEntryAddedEvent.Register(HandleTabListEntryAdded, Priority.High); } public override void Unload(bool shutdown) { @@ -47,6 +49,7 @@ namespace MCGalaxy.Games { OnPlayerDisconnectEvent.Unregister(HandleDisconnect); OnLevelUnloadEvent.Unregister(HandleLevelUnload); OnPlayerSpawningEvent.Unregister(HandlePlayerSpawning); + OnTabListEntryAddedEvent.Unregister(HandleTabListEntryAdded); } @@ -133,6 +136,21 @@ namespace MCGalaxy.Games { CtfTeam2 team = Game.TeamOf(p); if (team != null) pos = team.SpawnPos; + if (team != null && respawning) Game.DropFlag(p, team); + } + + void HandleTabListEntryAdded(Entity entity, ref string tabName, ref string tabGroup, Player dst) { + Player p = entity as Player; + if (p == null || !Game.started || p.level != Game.map) return; + CtfTeam2 team = Game.TeamOf(p); + + if (p.Game.Referee) { + tabGroup = "&2Referees"; + } else if (team != null) { + tabGroup = team.ColoredName + " &fteam"; + } else { + tabGroup = "&7Spectators"; + } } void HandlePlayerCommand(Player p, string cmd, string args) { diff --git a/MCGalaxy/Levels/Level.Fields.cs b/MCGalaxy/Levels/Level.Fields.cs index 14b1be59b..44bc5a4ce 100644 --- a/MCGalaxy/Levels/Level.Fields.cs +++ b/MCGalaxy/Levels/Level.Fields.cs @@ -81,7 +81,6 @@ namespace MCGalaxy { public bool backedup; public BlockDB BlockDB; public LevelAccessController VisitAccess, BuildAccess; - public bool ctfmode; // Physics fields and settings public int physics { diff --git a/MCGalaxy/Player/Player.Handlers.cs b/MCGalaxy/Player/Player.Handlers.cs index 31d45119b..8217ee2c2 100644 --- a/MCGalaxy/Player/Player.Handlers.cs +++ b/MCGalaxy/Player/Player.Handlers.cs @@ -391,14 +391,7 @@ namespace MCGalaxy { } } - if ( Game.team != null && this.level.ctfmode ) { - //if (carryingFlag) - //{ - // level.ctfgame.DropFlag(this, hasflag); - //} - Game.team.SpawnPlayer(this); - //this.health = 100; - } else if ( PlayingTntWars ) { + if (PlayingTntWars) { TntWarsKillStreak = 0; TntWarsScoreMultiplier = 1f; } else if ( Server.lava.active && Server.lava.HasPlayer(this) ) {