From a1af75ff62a2b8f6d58d2a7baaaafe1ceb5112db Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 9 Mar 2020 23:15:23 +1100 Subject: [PATCH] Rename /levels to /loaded and /worlds to /levels, as when people are doing /levels they probably want to see all maps --- MCGalaxy/Commands/Information/CmdLevels.cs | 69 +++++++++++++----- MCGalaxy/Commands/Information/CmdLoaded.cs | 46 ++++++++++++ MCGalaxy/Commands/Information/CmdWorlds.cs | 81 ---------------------- MCGalaxy/Commands/World/CmdLoad.cs | 2 - MCGalaxy/Commands/building/CmdBrush.cs | 2 +- MCGalaxy/Levels/Level.Blocks.cs | 6 +- MCGalaxy/Levels/Level.Fields.cs | 3 +- MCGalaxy/MCGalaxy_.csproj | 4 +- 8 files changed, 106 insertions(+), 107 deletions(-) create mode 100644 MCGalaxy/Commands/Information/CmdLoaded.cs delete mode 100644 MCGalaxy/Commands/Information/CmdWorlds.cs diff --git a/MCGalaxy/Commands/Information/CmdLevels.cs b/MCGalaxy/Commands/Information/CmdLevels.cs index c2e0982f9..ca841a070 100644 --- a/MCGalaxy/Commands/Information/CmdLevels.cs +++ b/MCGalaxy/Commands/Information/CmdLevels.cs @@ -1,6 +1,6 @@ /* - Copyright 2012 MCForge - + Copyright 2011 MCForge + Dual-licensed under the Educational Community License, Version 2.0 and the GNU General Public License, Version 3 (the "Licenses"); you may not use this file except in compliance with the Licenses. You may @@ -16,32 +16,69 @@ permissions and limitations under the Licenses. */ using System; +using System.IO; -namespace MCGalaxy.Commands.Info { - public sealed class CmdLevels : Command2 { +namespace MCGalaxy.Commands.Info { + public sealed class CmdLevels : Command2 { public override string name { get { return "Levels"; } } - public override string shortcut { get { return "Maps"; } } + public override string shortcut { get { return "Worlds"; } } public override string type { get { return CommandTypes.Information; } } public override bool UseableWhenFrozen { get { return true; } } + public override CommandAlias[] Aliases { + get { return new[] { new CommandAlias("Maps") }; } + } public override void Use(Player p, string message, CommandData data) { - Level[] loaded = LevelInfo.Loaded.Items; - p.Message("Loaded maps [physics level] (&c[no] %Sif not visitable): "); - MultiPageOutput.Output(p, loaded, (lvl) => FormatMap(p, lvl), - "Levels", "maps", message, false); - p.Message("Use %T/Worlds %Sfor all levels."); + string[] files = LevelInfo.AllMapFiles(); + p.Message("Levels (&c[no] %Sif not visitable): "); + MultiPageOutput.Output(p, files, (file) => FormatMap(p, file), + "Levels", "levels", message, false); } - static string FormatMap(Player p, Level lvl) { - bool canVisit = p.IsSuper || lvl.VisitAccess.CheckAllowed(p); - string physics = " [" + lvl.physics + "]"; - string visit = canVisit ? "" : " &c[no]"; - return lvl.ColoredName + physics + visit; + static string FormatMap(Player p, string file) { + LevelPermission visitP, buildP; + bool loadOnGoto; + string map = Path.GetFileNameWithoutExtension(file); + RetrieveProps(map, out visitP, out buildP, out loadOnGoto); + + LevelPermission maxPerm = visitP; + if (maxPerm < buildP) maxPerm = buildP; + + string visit = loadOnGoto && p.Rank >= visitP ? "" : " &c[no]"; + return Group.GetColor(maxPerm) + map + visit; } + static void RetrieveProps(string level, out LevelPermission visit, + out LevelPermission build, out bool loadOnGoto) { + visit = LevelPermission.Guest; + build = LevelPermission.Guest; + loadOnGoto = true; + + string propsPath = LevelInfo.PropsPath(level); + SearchArgs args = new SearchArgs(); + if (!PropertiesFile.Read(propsPath, ref args, ProcessLine)) return; + + visit = Group.ParsePermOrName(args.Visit, visit); + build = Group.ParsePermOrName(args.Build, build); + if (!bool.TryParse(args.LoadOnGoto, out loadOnGoto)) + loadOnGoto = true; + } + + static void ProcessLine(string key, string value, ref SearchArgs args) { + if (key.CaselessEq("pervisit")) { + args.Visit = value; + } else if (key.CaselessEq("perbuild")) { + args.Build = value; + } else if (key.CaselessEq("loadongoto")) { + args.LoadOnGoto = value; + } + } + + struct SearchArgs { public string Visit, Build, LoadOnGoto; } + public override void Help(Player p) { p.Message("%T/Levels"); - p.Message("%HLists all loaded levels and their physics levels."); + p.Message("%HLists levels and whether you can go to them."); } } } diff --git a/MCGalaxy/Commands/Information/CmdLoaded.cs b/MCGalaxy/Commands/Information/CmdLoaded.cs new file mode 100644 index 000000000..44d69a18d --- /dev/null +++ b/MCGalaxy/Commands/Information/CmdLoaded.cs @@ -0,0 +1,46 @@ +/* + Copyright 2012 MCForge + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.opensource.org/licenses/ecl2.php + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. + */ +using System; + +namespace MCGalaxy.Commands.Info { + public sealed class CmdLoaded : Command2 { + public override string name { get { return "Loaded"; } } + public override string type { get { return CommandTypes.Information; } } + public override bool UseableWhenFrozen { get { return true; } } + + public override void Use(Player p, string message, CommandData data) { + Level[] loaded = LevelInfo.Loaded.Items; + p.Message("Loaded levels [physics level] (&c[no] %Sif not visitable): "); + MultiPageOutput.Output(p, loaded, (lvl) => FormatMap(p, lvl), + "Levels", "levels", message, false); + p.Message("Use %T/Levels %Sfor all levels."); + } + + static string FormatMap(Player p, Level lvl) { + bool canVisit = p.IsSuper || lvl.VisitAccess.CheckAllowed(p); + string physics = " [" + lvl.physics + "]"; + string visit = canVisit ? "" : " &c[no]"; + return lvl.ColoredName + physics + visit; + } + + public override void Help(Player p) { + p.Message("%T/Loaded"); + p.Message("%HLists loaded levels and their physics levels."); + } + } +} diff --git a/MCGalaxy/Commands/Information/CmdWorlds.cs b/MCGalaxy/Commands/Information/CmdWorlds.cs deleted file mode 100644 index 3ffcc80c0..000000000 --- a/MCGalaxy/Commands/Information/CmdWorlds.cs +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright 2011 MCForge - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.opensource.org/licenses/ecl2.php - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. - */ -using System; -using System.IO; - -namespace MCGalaxy.Commands.Info { - public sealed class CmdWorlds : Command2 { - 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 UseableWhenFrozen { get { return true; } } - - public override void Use(Player p, string message, CommandData data) { - string[] files = LevelInfo.AllMapFiles(); - p.Message("Maps (&c[no] %Sif not visitable): "); - MultiPageOutput.Output(p, files, (file) => FormatMap(p, file), - "Worlds", "maps", message, false); - } - - static string FormatMap(Player p, string file) { - LevelPermission visitP, buildP; - bool loadOnGoto; - string map = Path.GetFileNameWithoutExtension(file); - RetrieveProps(map, out visitP, out buildP, out loadOnGoto); - - LevelPermission maxPerm = visitP; - if (maxPerm < buildP) maxPerm = buildP; - - string visit = loadOnGoto && p.Rank >= visitP ? "" : " &c[no]"; - return Group.GetColor(maxPerm) + map + visit; - } - - static void RetrieveProps(string level, out LevelPermission visit, - out LevelPermission build, out bool loadOnGoto) { - visit = LevelPermission.Guest; - build = LevelPermission.Guest; - loadOnGoto = true; - - string propsPath = LevelInfo.PropsPath(level); - SearchArgs args = new SearchArgs(); - if (!PropertiesFile.Read(propsPath, ref args, ProcessLine)) return; - - visit = Group.ParsePermOrName(args.Visit, visit); - build = Group.ParsePermOrName(args.Build, build); - if (!bool.TryParse(args.LoadOnGoto, out loadOnGoto)) - loadOnGoto = true; - } - - static void ProcessLine(string key, string value, ref SearchArgs args) { - if (key.CaselessEq("pervisit")) { - args.Visit = value; - } else if (key.CaselessEq("perbuild")) { - args.Build = value; - } else if (key.CaselessEq("loadongoto")) { - args.LoadOnGoto = value; - } - } - - struct SearchArgs { public string Visit, Build, LoadOnGoto; } - - public override void Help(Player p) { - p.Message("%T/Worlds"); - p.Message("%HLists maps/levels, and their accessible state."); - } - } -} diff --git a/MCGalaxy/Commands/World/CmdLoad.cs b/MCGalaxy/Commands/World/CmdLoad.cs index fb6691113..7464b37b9 100644 --- a/MCGalaxy/Commands/World/CmdLoad.cs +++ b/MCGalaxy/Commands/World/CmdLoad.cs @@ -16,8 +16,6 @@ permissions and limitations under the Licenses. */ using System; -using System.IO; -using MCGalaxy.Events.LevelEvents; namespace MCGalaxy.Commands.World { public sealed class CmdLoad : Command2 { diff --git a/MCGalaxy/Commands/building/CmdBrush.cs b/MCGalaxy/Commands/building/CmdBrush.cs index 2a93adf20..48e7b492a 100644 --- a/MCGalaxy/Commands/building/CmdBrush.cs +++ b/MCGalaxy/Commands/building/CmdBrush.cs @@ -59,7 +59,7 @@ namespace MCGalaxy.Commands.Building { p.Message("%HOutputs the help for the brush with that name."); List(p); p.Message("%H- If \"skip\" is used for a block name, " + - "existing blocks in the map will not be replaced by this block."); + "existing blocks in the map will not be replaced by this block."); } public override void Help(Player p, string message) { diff --git a/MCGalaxy/Levels/Level.Blocks.cs b/MCGalaxy/Levels/Level.Blocks.cs index dab26cdaa..37a2abfbd 100644 --- a/MCGalaxy/Levels/Level.Blocks.cs +++ b/MCGalaxy/Levels/Level.Blocks.cs @@ -43,7 +43,7 @@ namespace MCGalaxy { public byte[][] CustomBlocks; public int ChunksX, ChunksY, ChunksZ; - /// Relatively quick guess at whether this map might use custom blocks. + /// Relatively quick guess at whether this level might use custom blocks. public bool MightHaveCustomBlocks() { byte[][] customBlocks = CustomBlocks; if (customBlocks == null) return false; @@ -80,7 +80,7 @@ namespace MCGalaxy { } /// Gets the block at the given coordinates. - /// Block.Invalid if coordinates outside map. + /// Block.Invalid if coordinates outside level. public BlockID GetBlock(ushort x, ushort y, ushort z) { if (x >= Width || y >= Height || z >= Length || blocks == null) return Block.Invalid; byte raw = blocks[x + Width * (z + y * Length)]; @@ -94,7 +94,7 @@ namespace MCGalaxy { } /// Gets the block at the given coordinates. - /// Block.Invalid if coordinates outside map. + /// Block.Invalid if coordinates outside level. public BlockID GetBlock(ushort x, ushort y, ushort z, out int index) { if (x >= Width || y >= Height || z >= Length || blocks == null) { index = -1; return Block.Invalid; } index = x + Width * (z + y * Length); diff --git a/MCGalaxy/Levels/Level.Fields.cs b/MCGalaxy/Levels/Level.Fields.cs index 16d64d19a..b0c47e0b5 100644 --- a/MCGalaxy/Levels/Level.Fields.cs +++ b/MCGalaxy/Levels/Level.Fields.cs @@ -66,8 +66,7 @@ namespace MCGalaxy { /// Whether block changes made on this level should be saved to the BlockDB and .lvl files. public bool SaveChanges = true; - /// Whether this map sees server-wide chat. - /// true if both worldChat and Server.worldChat are true. + /// Whether players on this level sees server-wide chat. public bool SeesServerWideChat { get { return Config.ServerWideChat && Server.Config.ServerWideChat; } } internal readonly object saveLock = new object(), botsIOLock = new object(); diff --git a/MCGalaxy/MCGalaxy_.csproj b/MCGalaxy/MCGalaxy_.csproj index aef2bf390..c21b5bc10 100644 --- a/MCGalaxy/MCGalaxy_.csproj +++ b/MCGalaxy/MCGalaxy_.csproj @@ -252,7 +252,7 @@ - + @@ -265,7 +265,7 @@ - +