From ff703947e52d7e59fac54e86433b902f5d81600a Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 28 Jun 2017 11:05:05 +1000 Subject: [PATCH] Get rid of Group.concatList and Level.CheckLoadOnGoto Also less usage of ServerConfig.DefaultColor --- GUI/PropertyWindow/PropertyWindow.Games.cs | 4 ++-- MCGalaxy/Commands/Fun/CmdTntWars.cs | 2 +- MCGalaxy/Commands/Information/CmdViewRanks.cs | 4 ++-- MCGalaxy/Games/LavaSurvival/LavaSurvival.cs | 4 ++-- MCGalaxy/Levels/Level.cs | 8 -------- MCGalaxy/Player/Group/Group.cs | 14 -------------- MCGalaxy/Player/Player.Handlers.cs | 4 ++-- MCGalaxy/Player/PlayerActions.cs | 10 +++++++++- 8 files changed, 18 insertions(+), 32 deletions(-) diff --git a/GUI/PropertyWindow/PropertyWindow.Games.cs b/GUI/PropertyWindow/PropertyWindow.Games.cs index d8ef29a2d..e2f1083f3 100644 --- a/GUI/PropertyWindow/PropertyWindow.Games.cs +++ b/GUI/PropertyWindow/PropertyWindow.Games.cs @@ -569,7 +569,7 @@ namespace MCGalaxy.Gui { } } { - string mesg = pl.p.ColoredName + ServerConfig.DefaultColor + " " + "is now"; + string mesg = pl.p.ColoredName + " %Sis now"; if ( pl.Red ) { mesg += " on the " + Colors.red + "red team"; } @@ -577,7 +577,7 @@ namespace MCGalaxy.Gui { mesg += " on the " + Colors.blue + "blue team"; } if ( pl.spec ) { - mesg += ServerConfig.DefaultColor + " (as a spectator)"; + mesg += " (as a spectator)"; } Chat.MessageGlobal(mesg); } diff --git a/MCGalaxy/Commands/Fun/CmdTntWars.cs b/MCGalaxy/Commands/Fun/CmdTntWars.cs index 9dde73a96..0f3808bb4 100644 --- a/MCGalaxy/Commands/Fun/CmdTntWars.cs +++ b/MCGalaxy/Commands/Fun/CmdTntWars.cs @@ -172,7 +172,7 @@ namespace MCGalaxy.Commands.Fun { if (pl.Blue) msg += " on the " + Colors.blue + "blue team"; if (pl.spec) - msg += ServerConfig.DefaultColor + " (as a spectator)"; + msg += " %S(as a spectator)"; Chat.MessageGlobal(msg); } diff --git a/MCGalaxy/Commands/Information/CmdViewRanks.cs b/MCGalaxy/Commands/Information/CmdViewRanks.cs index 05042c260..066bab461 100644 --- a/MCGalaxy/Commands/Information/CmdViewRanks.cs +++ b/MCGalaxy/Commands/Information/CmdViewRanks.cs @@ -33,7 +33,7 @@ namespace MCGalaxy.Commands.Info { public override void Use(Player p, string message) { string[] args = message.SplitSpaces(2); if (message == "") { - Player.Message(p, "Available ranks: " + Group.concatList()); return; + Player.Message(p, "Available ranks: " +Group.GroupList.Join(g => g.ColoredName)); return; } string modifer = args.Length > 1 ? args[1] : ""; @@ -53,7 +53,7 @@ namespace MCGalaxy.Commands.Info { public override void Help(Player p) { Player.Message(p, "/viewranks [rank] - Shows all players who have [rank]"); Player.Message(p, "/viewranks banned - Shows all players who are banned."); - Player.Message(p, "Available ranks: " + Group.concatList()); + Player.Message(p, "Available ranks: " + Group.GroupList.Join(g => g.ColoredName)); } } } diff --git a/MCGalaxy/Games/LavaSurvival/LavaSurvival.cs b/MCGalaxy/Games/LavaSurvival/LavaSurvival.cs index 9b53238c6..d65d21f23 100644 --- a/MCGalaxy/Games/LavaSurvival/LavaSurvival.cs +++ b/MCGalaxy/Games/LavaSurvival/LavaSurvival.cs @@ -330,7 +330,7 @@ namespace MCGalaxy.Games if (!votes.ContainsKey(opt) && opt != map.name) { votes.Add(opt, 0); - str += ServerConfig.DefaultColor + ", &5" + opt.Capitalize(); + str += "%S, &5" + opt.Capitalize(); i++; } } @@ -483,7 +483,7 @@ namespace MCGalaxy.Games { StringBuilder sb = new StringBuilder(); foreach (KeyValuePair kvp in votes) - sb.AppendFormat("{0}, &5{1}", ServerConfig.DefaultColor, kvp.Key.Capitalize()); + sb.AppendFormat("%S, &5{0}", kvp.Key.Capitalize()); sb.Remove(0, 4); return sb.ToString(); } diff --git a/MCGalaxy/Levels/Level.cs b/MCGalaxy/Levels/Level.cs index 442fb7843..5f7575968 100644 --- a/MCGalaxy/Levels/Level.cs +++ b/MCGalaxy/Levels/Level.cs @@ -399,14 +399,6 @@ namespace MCGalaxy { lvl.UpdateBlockHandlers(); } - public static bool CheckLoadOnGoto(string givenName) { - string value = LevelInfo.FindOfflineProperty(givenName, "loadongoto"); - if (value == null) return true; - bool load; - if (!bool.TryParse(value, out load)) return true; - return load; - } - public void ChatLevel(string message) { ChatLevel(message, LevelPermission.Banned); } diff --git a/MCGalaxy/Player/Group/Group.cs b/MCGalaxy/Player/Group/Group.cs index e8670be6f..1be08f3a0 100644 --- a/MCGalaxy/Player/Group/Group.cs +++ b/MCGalaxy/Player/Group/Group.cs @@ -253,20 +253,6 @@ namespace MCGalaxy { } return Group.standard; } - - public static string concatList(bool includeColor = true, bool skipExtra = false, bool permissions = false) { - string sum = ""; - foreach (Group grp in Group.GroupList) { - if (skipExtra && (grp.Permission < LevelPermission.Guest || grp.Permission >= LevelPermission.Nobody)) continue; - - if (includeColor) sum += ", " + grp.ColoredName + ServerConfig.DefaultColor; - else if (permissions) sum += ", " + ((int)grp.Permission); - else sum += ", " + grp.name; - } - - if (includeColor) sum = sum.Remove(sum.Length - 2); - return sum.Remove(0, 2); - } /// Returns whether the given player is in the banned rank. diff --git a/MCGalaxy/Player/Player.Handlers.cs b/MCGalaxy/Player/Player.Handlers.cs index ba774961d..1c68d568e 100644 --- a/MCGalaxy/Player/Player.Handlers.cs +++ b/MCGalaxy/Player/Player.Handlers.cs @@ -560,8 +560,8 @@ namespace MCGalaxy { if ( it.GameMode == TntWarsGame.TntWarsGameMode.TDM ) { TntWarsGame.player pl = it.FindPlayer(this); foreach ( TntWarsGame.player p in it.Players ) { - if ( pl.Red && p.Red ) SendMessage(p.p, "To Team " + Colors.red + "-" + color + name + Colors.red + "- " + ServerConfig.DefaultColor + newtext); - if ( pl.Blue && p.Blue ) SendMessage(p.p, "To Team " + Colors.blue + "-" + color + name + Colors.blue + "- " + ServerConfig.DefaultColor + newtext); + if ( pl.Red && p.Red ) SendMessage(p.p, "To Team " + Colors.red + "-" + color + name + Colors.red + "- %S" + newtext); + if ( pl.Blue && p.Blue ) SendMessage(p.p, "To Team " + Colors.blue + "-" + color + name + Colors.blue + "- %S" + newtext); } Logger.Log(LogType.GameActivity, "[TNT Wars] [TeamChat (" + ( pl.Red ? "Red" : "Blue" ) + ") " + name + " " + newtext); diff --git a/MCGalaxy/Player/PlayerActions.cs b/MCGalaxy/Player/PlayerActions.cs index 0e2b5ed2c..faacbe24d 100644 --- a/MCGalaxy/Player/PlayerActions.cs +++ b/MCGalaxy/Player/PlayerActions.cs @@ -83,11 +83,19 @@ namespace MCGalaxy { } static bool LoadOfflineLevel(Player p, string name) { - if (!Level.CheckLoadOnGoto(name)) { + string propsPath = LevelInfo.FindPropertiesFile(name); + LevelConfig cfg = new LevelConfig(); + LevelConfig.Load(propsPath, cfg); + + if (!cfg.LoadOnGoto) { Player.Message(p, "Level \"{0}\" cannot be loaded using /goto.", name); return false; } + // LevelAccessController visitAccess = new LevelAccessController(null, cfg, true); + //bool ignorePerms = p.summonedMap != null && p.summonedMap.CaselessEq(name); + //if (!visitAccess.CheckDetailed(p, ignorePerms)) return false; + CmdLoad.LoadLevel(p, name, true); Level lvl = LevelInfo.FindExact(name); if (lvl != null) return GotoLevel(p, lvl);