diff --git a/MCGalaxy/Commands/Information/CmdLevels.cs b/MCGalaxy/Commands/Information/CmdLevels.cs index 1d9fa5f03..e3fd32a50 100644 --- a/MCGalaxy/Commands/Information/CmdLevels.cs +++ b/MCGalaxy/Commands/Information/CmdLevels.cs @@ -31,32 +31,25 @@ namespace MCGalaxy.Commands { public CmdLevels() { } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } - - string canVisit = "", canBuild = ""; Level[] loaded = LevelInfo.Loaded.Items; - foreach (Level lvl in loaded) { - if (p == null || lvl.permissionvisit <= p.Rank) { - if (Group.findPerm(lvl.permissionbuild) != null) - canVisit += ", " + Group.findPerm(lvl.permissionbuild).color + lvl.name + " &b[&f" + lvl.physics + "&b]"; - else - canVisit += ", " + lvl.name + " &b[" + lvl.physics + "]"; - } else { - if (Group.findPerm(lvl.permissionvisit) != null) - canBuild += ", " + Group.findPerm(lvl.permissionvisit).color + lvl.name + " &b[&f" + lvl.physics + "&b]"; - else - canBuild += ", " + lvl.name + " &b[&f" + lvl.physics + "&b]"; - } - } - - if (canVisit != "") - canVisit = canVisit.Remove(0, 2); - Player.Message(p, "Loaded levels [physics_level]: " + canVisit); - if (canBuild != "") - Player.Message(p, "Loaded levels you cannot visit: " + canBuild.Remove(0, 2)); + Player.Message(p, "Loaded maps [physics level] (&c[no] %Sif not visitable): "); + MultiPageOutput.Output(p, loaded, (lvl, i) => FormatMap(p, lvl), + "levels", "maps", message, false); Player.Message(p, "Use %T/unloaded %Sfor unloaded levels."); } + static string FormatMap(Player p, Level lvl) { + bool canVisit = Player.IsSuper(p); + if (!canVisit) { + LevelAccess access = lvl.VisitAccess.Check(p); + canVisit = access == LevelAccess.Allowed || access == LevelAccess.Whitelisted; + } + + string physics = " [" + lvl.physics + "]"; + string visit = canVisit ? "" : " &c[no]"; + return lvl.ColoredName + physics + visit; + } + public override void Help(Player p) { Player.Message(p, "%T/levels"); Player.Message(p, "%HLists all loaded levels and their physics levels."); diff --git a/MCGalaxy/Commands/Information/CmdUnloaded.cs b/MCGalaxy/Commands/Information/CmdUnloaded.cs index 33b52397f..f7dd5b941 100644 --- a/MCGalaxy/Commands/Information/CmdUnloaded.cs +++ b/MCGalaxy/Commands/Information/CmdUnloaded.cs @@ -32,7 +32,7 @@ namespace MCGalaxy.Commands { public override void Use(Player p, string message) { string[] files = Directory.GetFiles("levels", "*.lvl"); - Player.Message(p, "Unloaded maps (&c[no] %Sif not accessible): "); + Player.Message(p, "Unloaded maps (&c[no] %Sif not visitable): "); MultiPageOutput.Output(p, GetMaps(files), (map, i) => FormatMap(p, map), "unloaded", "maps", message, false); } @@ -54,9 +54,12 @@ namespace MCGalaxy.Commands { bool loadOnGoto; RetrieveProps(map, out visitP, out buildP, out loadOnGoto); - Group grp = Group.findPerm(buildP); + LevelPermission perm = visitP; + if (perm < buildP) perm = buildP; + Group grp = Group.findPerm(perm); + string color = grp == null ? "&f" : grp.color; - string visit = loadOnGoto && (p == null || p.Rank >= visitP) ? "" : " &c[no]" + color; + string visit = loadOnGoto && (p == null || p.Rank >= visitP) ? "" : " &c[no]"; return color + map + visit; }