Rename /levels to /loaded and /worlds to /levels, as when people are doing /levels they probably want to see all maps

This commit is contained in:
UnknownShadow200 2020-03-09 23:15:23 +11:00
parent a6f29ac285
commit a1af75ff62
8 changed files with 106 additions and 107 deletions

View File

@ -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.");
}
}
}

View File

@ -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.");
}
}
}

View File

@ -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.");
}
}
}

View File

@ -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 {

View File

@ -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) {

View File

@ -43,7 +43,7 @@ namespace MCGalaxy {
public byte[][] CustomBlocks;
public int ChunksX, ChunksY, ChunksZ;
/// <summary> Relatively quick guess at whether this map might use custom blocks. </summary>
/// <summary> Relatively quick guess at whether this level might use custom blocks. </summary>
public bool MightHaveCustomBlocks() {
byte[][] customBlocks = CustomBlocks;
if (customBlocks == null) return false;
@ -80,7 +80,7 @@ namespace MCGalaxy {
}
/// <summary> Gets the block at the given coordinates. </summary>
/// <returns> Block.Invalid if coordinates outside map. </returns>
/// <returns> Block.Invalid if coordinates outside level. </returns>
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 {
}
/// <summary> Gets the block at the given coordinates. </summary>
/// <returns> Block.Invalid if coordinates outside map. </returns>
/// <returns> Block.Invalid if coordinates outside level. </returns>
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);

View File

@ -66,8 +66,7 @@ namespace MCGalaxy {
/// <summary> Whether block changes made on this level should be saved to the BlockDB and .lvl files. </summary>
public bool SaveChanges = true;
/// <summary> Whether this map sees server-wide chat. </summary>
/// <remarks> true if both worldChat and Server.worldChat are true. </remarks>
/// <summary> Whether players on this level sees server-wide chat. </summary>
public bool SeesServerWideChat { get { return Config.ServerWideChat && Server.Config.ServerWideChat; } }
internal readonly object saveLock = new object(), botsIOLock = new object();

View File

@ -252,7 +252,7 @@
<Compile Include="Commands\Information\CmdRankInfo.cs" />
<Compile Include="Commands\Information\CmdServerInfo.cs" />
<Compile Include="Commands\Information\CmdLastCmd.cs" />
<Compile Include="Commands\Information\CmdLevels.cs" />
<Compile Include="Commands\Information\CmdLoaded.cs" />
<Compile Include="Commands\Information\CmdMapInfo.cs" />
<Compile Include="Commands\Information\CmdNews.cs" />
<Compile Include="Commands\Information\CmdOpRules.cs" />
@ -265,7 +265,7 @@
<Compile Include="Commands\Information\CmdDevs.cs" />
<Compile Include="Commands\Information\CmdTime.cs" />
<Compile Include="Commands\Information\CmdTop.cs" />
<Compile Include="Commands\Information\CmdWorlds.cs" />
<Compile Include="Commands\Information\CmdLevels.cs" />
<Compile Include="Commands\Information\CmdView.cs" />
<Compile Include="Commands\Information\CmdViewRanks.cs" />
<Compile Include="Commands\Information\CmdWhere.cs" />