From 90c4dedf274193a67722c70f717c82bbc4932a8c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 20 Mar 2016 23:31:51 +1100 Subject: [PATCH] Do not change the direct color field of players, only change in the spawn packet. --- Commands/Fun/ZombieSurvival/CmdReferee.cs | 5 +---- Commands/Moderation/CmdVoteKick.cs | 10 +++++----- Commands/Moderation/CmdWarn.cs | 2 +- Games/ZombieSurvival/ZombieGame.Core.cs | 16 +++++----------- Games/ZombieSurvival/ZombieGame.cs | 13 +++++++------ Player/Player.cs | 4 +++- 6 files changed, 22 insertions(+), 28 deletions(-) diff --git a/Commands/Fun/ZombieSurvival/CmdReferee.cs b/Commands/Fun/ZombieSurvival/CmdReferee.cs index 8f3207cf5..811d6b117 100644 --- a/Commands/Fun/ZombieSurvival/CmdReferee.cs +++ b/Commands/Fun/ZombieSurvival/CmdReferee.cs @@ -33,7 +33,6 @@ namespace MCGalaxy.Commands { if (p.referee) { p.referee = false; LevelPermission perm = Group.findPlayerGroup(name).Permission; - Player.GlobalDespawn(p, false); Player.SendChatFrom(p, p.FullName + " %Sis no longer a referee", false); if (Server.zombie.RoundInProgress) { @@ -44,7 +43,6 @@ namespace MCGalaxy.Commands { Server.zombie.Infected.Remove(p); Server.zombie.Alive.Add(p); Server.zombie.UpdateAllPlayerStatus(); - p.color = p.group.color; } } else { p.referee = true; @@ -52,8 +50,7 @@ namespace MCGalaxy.Commands { Player.GlobalDespawn(p, false); Server.zombie.Alive.Remove(p); Server.zombie.Infected.Remove(p); - Server.zombie.UpdateAllPlayerStatus(); - p.color = p.group.color; + Server.zombie.UpdateAllPlayerStatus(); if (Server.zombie.RoundInProgress) Server.zombie.AssignFirstZombie(); } diff --git a/Commands/Moderation/CmdVoteKick.cs b/Commands/Moderation/CmdVoteKick.cs index c097b2894..62f1f36be 100644 --- a/Commands/Moderation/CmdVoteKick.cs +++ b/Commands/Moderation/CmdVoteKick.cs @@ -38,13 +38,13 @@ namespace MCGalaxy.Commands if (who.group.Permission >= p.group.Permission) { - Player.SendChatFrom(p, p.color + p.DisplayName + " " + Server.DefaultColor + "tried to votekick " + who.color + who.DisplayName + " " + Server.DefaultColor + "but failed!", false); + Player.SendChatFrom(p, p.color + p.DisplayName + " %Stried to votekick " + who.color + who.DisplayName + " %Sbut failed!", false); return; } - Chat.GlobalMessageOps(p.color + p.DisplayName + Server.DefaultColor + " used &a/votekick"); - Player.GlobalMessage("&9A vote to kick " + who.color + who.DisplayName + " " + Server.DefaultColor + "has been called!"); - Player.GlobalMessage("&9Type &aY " + Server.DefaultColor + "or &cN " + Server.DefaultColor + "to vote."); + Chat.GlobalMessageOps(p.color + p.DisplayName + " %Sused &a/votekick"); + Player.GlobalMessage("&9A vote to kick " + who.color + who.DisplayName + " %Shas been called!"); + Player.GlobalMessage("&9Type &aY %Sor &cN %Sto vote."); // 1/3rd of the players must vote or nothing happens // Keep it at 0 to disable min number of votes @@ -88,7 +88,7 @@ namespace MCGalaxy.Commands } else { - Player.GlobalMessage(who.color + who.DisplayName + " " + Server.DefaultColor + "shall remain!"); + Player.GlobalMessage(who.color + who.DisplayName + " %Sshall remain!"); } voteTimer.Dispose(); diff --git a/Commands/Moderation/CmdWarn.cs b/Commands/Moderation/CmdWarn.cs index 0d2b528a4..523966773 100644 --- a/Commands/Moderation/CmdWarn.cs +++ b/Commands/Moderation/CmdWarn.cs @@ -49,7 +49,7 @@ namespace MCGalaxy.Commands { } else if (who.warn == 1) { Player.SendMessage(who, "Do it one more time and you will get kicked!"); } else if (who.warn == 2) { - Player.GlobalMessage(who.color + who.DisplayName + " " + "%Swas warn-kicked by " + warnedby); + Player.GlobalMessage(who.color + who.DisplayName + " %Swas warn-kicked by " + warnedby); who.Kick("KICKED BECAUSE " + reason + ""); } who.warn++; diff --git a/Games/ZombieSurvival/ZombieGame.Core.cs b/Games/ZombieSurvival/ZombieGame.Core.cs index 867a47412..54b96eb9a 100644 --- a/Games/ZombieSurvival/ZombieGame.Core.cs +++ b/Games/ZombieSurvival/ZombieGame.Core.cs @@ -130,10 +130,7 @@ namespace MCGalaxy.Games { Player[] online = PlayerInfo.Online.Items; foreach (Player p in online) { - if (p.referee) { - p.color = p.group.color; - } else if (p.level.name.CaselessEq(CurrentLevelName)) { - p.color = p.group.color; + if (!p.referee && p.level.name.CaselessEq(CurrentLevelName)) { players.Add(p); nonRefPlayers++; } @@ -203,8 +200,8 @@ namespace MCGalaxy.Games { } static void UpdatePlayerColor(Player p, string color) { - if (p.color == color) return; - p.color = color; + if (p.lastSpawnColor == color) return; + p.lastSpawnColor = color; Player.GlobalDespawn(p, false); Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false); } @@ -273,7 +270,6 @@ namespace MCGalaxy.Games { pl.playersInfected = 0; pl.money += money; pl.infected = false; - pl.color = pl.group.color; if (pl.referee) { pl.SendMessage("You gained one " + Server.moneys + " because you're a ref. Would you like a medal as well?"); pl.money++; @@ -289,10 +285,8 @@ namespace MCGalaxy.Games { p.infected = false; p.playersInfected = 0; - if (p.level.name.CaselessEq(CurrentLevelName)) { - p.color = p.group.color; - playersString += p.group.color + p.DisplayName + Colors.white + ", "; - } + if (p.level.name.CaselessEq(CurrentLevelName)) + playersString += p.color + p.DisplayName + Colors.white + ", "; } void ChooseNextLevel() { diff --git a/Games/ZombieSurvival/ZombieGame.cs b/Games/ZombieSurvival/ZombieGame.cs index 48dc7ae3c..fe1b4d8ba 100644 --- a/Games/ZombieSurvival/ZombieGame.cs +++ b/Games/ZombieSurvival/ZombieGame.cs @@ -133,7 +133,7 @@ namespace MCGalaxy.Games { } Player zombie = alive[index]; - Player.GlobalMessage(zombie.FullName + " %Scontinued the infection!"); + CurrentLevel.ChatLevel(zombie.FullName + " %Scontinued the infection!"); InfectPlayer(zombie); } @@ -156,21 +156,22 @@ namespace MCGalaxy.Games { } void ChangeLevel(string next) { + if (CurrentLevel != null) { + CurrentLevel.ChatLevel("The next map has been chosen - " + Colors.red + next.ToLower()); + CurrentLevel.ChatLevel("Please wait while you are transfered."); + } + CurrentLevelName = next; queLevel = false; nextLevel = ""; Command.all.Find("load").Use(null, next.ToLower() + " 0"); CurrentLevel = LevelInfo.Find(next); - - Player.GlobalMessage("The next map has been chosen - " + Colors.red + next.ToLower()); - Player.GlobalMessage("Please wait while you are transfered."); - string oldLevel = Server.mainLevel.name; if (Server.ZombieOnlyServer) Server.mainLevel = CurrentLevel; Player[] online = PlayerInfo.Online.Items; foreach (Player pl in online) { - if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(LastLevelName)) { + if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(LastLevelName)) { pl.SendMessage("Going to the next map!"); Command.all.Find("goto").Use(pl, next); } diff --git a/Player/Player.cs b/Player/Player.cs index f9910aa89..d6b8072b2 100644 --- a/Player/Player.cs +++ b/Player/Player.cs @@ -198,6 +198,7 @@ namespace MCGalaxy { public bool aka = false; public bool flipHead = true; public int playersInfected = 0; + internal string lastSpawnColor = ""; //Tnt Wars public bool PlayingTntWars = false; @@ -487,7 +488,8 @@ namespace MCGalaxy { public static void GlobalSpawn(Player p, ushort x, ushort y, ushort z, byte rotx, byte roty, bool self, string possession = "") { - Player[] players = PlayerInfo.Online.Items; + Player[] players = PlayerInfo.Online.Items; + p.lastSpawnColor = p.infected ? Colors.red : p.color; foreach (Player other in players) { if (other.Loading && p != other) continue; if (p.level != other.level || (p.hidden && !self)) continue;