mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Change /unloaded to /worlds, which just outputs all maps, regardless of whether loaded or not.
This commit is contained in:
parent
2697c934cd
commit
fc27c18379
@ -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<string> GetMaps(string[] files) {
|
||||
List<string> maps = new List<string>(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.");
|
||||
}
|
||||
}
|
||||
}
|
@ -273,7 +273,7 @@
|
||||
<Compile Include="Commands\Information\CmdDevs.cs" />
|
||||
<Compile Include="Commands\Information\CmdTime.cs" />
|
||||
<Compile Include="Commands\Information\CmdTop.cs" />
|
||||
<Compile Include="Commands\Information\CmdUnloaded.cs" />
|
||||
<Compile Include="Commands\Information\CmdWorlds.cs" />
|
||||
<Compile Include="Commands\Information\CmdView.cs" />
|
||||
<Compile Include="Commands\Information\CmdViewRanks.cs" />
|
||||
<Compile Include="Commands\Information\CmdWhere.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;
|
||||
|
@ -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()")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user