diff --git a/MCGalaxy/Commands/Information/CmdUnloaded.cs b/MCGalaxy/Commands/Information/CmdWorlds.cs similarity index 71% rename from MCGalaxy/Commands/Information/CmdUnloaded.cs rename to MCGalaxy/Commands/Information/CmdWorlds.cs index 9653e930a..4745fbcb5 100644 --- a/MCGalaxy/Commands/Information/CmdUnloaded.cs +++ b/MCGalaxy/Commands/Information/CmdWorlds.cs @@ -21,29 +21,22 @@ using System.IO; using System.Text; namespace MCGalaxy.Commands.Info { - public sealed class CmdUnloaded : Command { - public override string name { get { return "Unloaded"; } } + public sealed class CmdWorlds : Command { + public override string name { get { return "Worlds"; } } + public override string shortcut { get { return "Unloaded"; } } public override string type { get { return CommandTypes.Information; } } public override bool museumUsable { get { return true; } } public override LevelPermission defaultRank { get { return LevelPermission.Guest; } } public override void Use(Player p, string message) { string[] files = LevelInfo.AllMapFiles(); - Player.Message(p, "Unloaded maps (&c[no] %Sif not visitable): "); - MultiPageOutput.Output(p, GetMaps(files), (map) => FormatMap(p, map), - "Unloaded", "maps", message, false); - } - - static List GetMaps(string[] files) { - List maps = new List(files.Length); - Level[] loaded = LevelInfo.Loaded.Items; - - foreach (string file in files) { - string map = Path.GetFileNameWithoutExtension(file); - if (IsLoaded(loaded, map)) continue; - maps.Add(map); + for (int i = 0; i < files.Length; i++) { + files[i] = Path.GetFileNameWithoutExtension(files[i]); } - return maps; + + Player.Message(p, "Maps (&c[no] %Sif not visitable): "); + MultiPageOutput.Output(p, files, (map) => FormatMap(p, map), + "Worlds", "maps", message, false); } static string FormatMap(Player p, string map) { @@ -58,13 +51,6 @@ namespace MCGalaxy.Commands.Info { return Group.GetColor(maxPerm) + map + visit; } - static bool IsLoaded(Level[] loaded, string level) { - foreach (Level lvl in loaded) { - if (lvl.name.CaselessEq(level)) return true; - } - return false; - } - static void RetrieveProps(string level, out LevelPermission visit, out LevelPermission build, out bool loadOnGoto) { visit = LevelPermission.Guest; @@ -95,8 +81,8 @@ namespace MCGalaxy.Commands.Info { struct SearchArgs { public string Visit, Build, LoadOnGoto; } public override void Help(Player p) { - Player.Message(p, "%T/Unloaded"); - Player.Message(p, "%H Lists unloaded maps/levels, and their accessible state."); + Player.Message(p, "%T/Worlds"); + Player.Message(p, "%HLists maps/levels, and their accessible state."); } } } diff --git a/MCGalaxy/MCGalaxy_.csproj b/MCGalaxy/MCGalaxy_.csproj index 08e224bb3..4a0fd296a 100644 --- a/MCGalaxy/MCGalaxy_.csproj +++ b/MCGalaxy/MCGalaxy_.csproj @@ -273,7 +273,7 @@ - + diff --git a/MCGalaxy/Network/Heartbeat/ClassiCube.cs b/MCGalaxy/Network/Heartbeat/ClassiCube.cs index 9dd2b66be..198441843 100644 --- a/MCGalaxy/Network/Heartbeat/ClassiCube.cs +++ b/MCGalaxy/Network/Heartbeat/ClassiCube.cs @@ -74,12 +74,8 @@ namespace MCGalaxy.Network { } static int PlayerCount() { - Player[] players = PlayerInfo.Online.Items; - int count = 0; - foreach (Player p in players) { - if (!p.hidden) count++; - } - // This may happen if a VIP or a dev/mod joins an already full server. + int count = PlayerInfo.NonHiddenCount(); + // This may happen if a VIP joins an already full server. if (count > ServerConfig.MaxPlayers) count = ServerConfig.MaxPlayers; return count; diff --git a/MCGalaxy/Player/PlayerInfo.cs b/MCGalaxy/Player/PlayerInfo.cs index 6b5257264..c4511d910 100644 --- a/MCGalaxy/Player/PlayerInfo.cs +++ b/MCGalaxy/Player/PlayerInfo.cs @@ -35,6 +35,13 @@ namespace MCGalaxy { return target != null && Entities.CanSee(p, target) ? target.ColoredName : GetColor(name) + name.RemoveLastPlus(); // TODO: select color from database? } + + public static int NonHiddenCount() { + Player[] players = Online.Items; + int count = 0; + foreach (Player p in players) { if (!p.hidden) count++; } + return count; + } [Obsolete("Prefer FindMatches() or FindExact()")]