From 4784fe297b8ac47585d4a3b887914b58db8ca0c7 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 17 Oct 2019 20:55:55 +1100 Subject: [PATCH] code cleanup and make changing /map chat instantly change tab list --- MCGalaxy/Commands/World/CmdMap.cs | 2 +- MCGalaxy/Entity/TabList.cs | 8 +++++--- MCGalaxy/Levels/LevelOptions.cs | 7 ++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/MCGalaxy/Commands/World/CmdMap.cs b/MCGalaxy/Commands/World/CmdMap.cs index 4724d788d..c00eb707b 100644 --- a/MCGalaxy/Commands/World/CmdMap.cs +++ b/MCGalaxy/Commands/World/CmdMap.cs @@ -108,7 +108,7 @@ namespace MCGalaxy.Commands.World { p.Message("%TGeneral settings:"); p.Message(" MOTD: &b" + cfg.MOTD); - p.Message(" Roleplay (local level only) chat: " + GetBool(!cfg.ServerWideChat)); + p.Message(" Local level only chat: " + GetBool(!cfg.ServerWideChat)); p.Message(" Load on /goto: {0}%S, Auto unload: {1}", GetBool(cfg.LoadOnGoto), GetBool(cfg.AutoUnload)); p.Message(" Buildable: {0}%S, Deletable: {1}%S, Drawing: {2}", diff --git a/MCGalaxy/Entity/TabList.cs b/MCGalaxy/Entity/TabList.cs index 4ebdcd83d..32607f49b 100644 --- a/MCGalaxy/Entity/TabList.cs +++ b/MCGalaxy/Entity/TabList.cs @@ -43,9 +43,11 @@ namespace MCGalaxy { } static void GetEntry(Player p, Player dst, out string name, out string group) { - LevelConfig config = LevelInfo.GetConfig(p.level.name, out p.level); - string levelName = config.ServerWideChat ? p.level.name : p.level.name + Server.Config.DefaultColor+" "; - group = Server.Config.TablistGlobal ? "On " + levelName : "&fPlayers"; + string map = p.level.name; + // TODO: Make %S work with tab list names + if (!p.level.SeesServerWideChat) map += Server.Config.DefaultColor + " "; + + group = Server.Config.TablistGlobal ? "On " + map : "&fPlayers"; name = dst.Ignores.Nicks ? p.color + p.truename : p.ColoredName; OnTabListEntryAddedEvent.Call(p, ref name, ref group, dst); diff --git a/MCGalaxy/Levels/LevelOptions.cs b/MCGalaxy/Levels/LevelOptions.cs index 0148cf9d8..4745575ad 100644 --- a/MCGalaxy/Levels/LevelOptions.cs +++ b/MCGalaxy/Levels/LevelOptions.cs @@ -140,8 +140,13 @@ namespace MCGalaxy { static void SetDeletable(Player p, Level l, string v) { TogglePerms(p, l, ref l.Config.Deletable, "Deletable"); } static void SetChat(Player p, Level l, string v) { - Toggle(p, l, ref l.Config.ServerWideChat, "Roleplay (local level only) chat", true); + Toggle(p, l, ref l.Config.ServerWideChat, "Local level only chat", true); + Player[] players = PlayerInfo.Online.Items; + foreach (Player pl in players) { + if (pl.level == l) TabList.Update(pl, true); + } } + static void SetDrawing(Player p, Level l, string v) { Toggle(p, l, ref l.Config.Drawing, "Drawing commands"); }