fix perbuild/pervisit max restrictions behaving improperly

This commit is contained in:
UnknownShadow200 2018-07-24 17:36:51 +10:00
parent e496de21f0
commit b489ce7cea
7 changed files with 9 additions and 34 deletions

View File

@ -220,9 +220,8 @@ namespace MCGalaxy {
len -= 4; i += 4;
// And then with "s://" or "://" ?
if (len >= 4 && chars[i] == 's' && chars[i + 1] == ':' && chars[i + 2] == '/' && chars[i + 3] == '/') return true;
if (len >= 3 && chars[i] == ':' && chars[i + 1] == '/' && chars[i + 2] == '/') return true;
return false;
if (chars[i] == 's') { len--; i++; }
return len >= 3 && chars[i] == ':' && chars[i + 1] == '/' && chars[i + 2] == '/';
}
static void Escape(char[] chars, int start, int end) {

View File

@ -71,8 +71,8 @@ namespace MCGalaxy.Commands.World {
}
public override void Help(Player p) {
p.Message("%T/Museum [map] [restore]");
p.Message("%HAllows you to access a restore of the map entered. Works on unloaded maps");
p.Message("%T/Museum [map] [backup]");
p.Message("%HTeleports you to a backup of the given map.");
}
}
}

View File

@ -84,7 +84,7 @@ namespace MCGalaxy.Commands.Building {
}
public override void Help(Player p) {
p.Message("%T/Sphere <brush args> <mode>");
p.Message("%T/Sphere <brush args>");
p.Message("%HCreates a sphere, with first point as centre, and second for radius");
p.Message("%T/Sphere [mode] <brush args>");
p.Message("%HModes: &fsolid/hollow/circle/hollowcircle");

View File

@ -45,20 +45,16 @@ namespace MCGalaxy.Generator {
return simpleGens.ContainsKey(s.ToLower());
}
/// <summary> Outputs list of all map generator themes to the given player. </summary>
public static void PrintThemes(Player p) {
p.Message("Simple themes: " + simpleGens.Keys.Join(", "));
p.Message("Advanced themes: " + advGens.Keys.Join(", "));
}
/// <summary> Retrieves the list of theme names of simple map generators. </summary>
public static IEnumerable<string> SimpleThemeNames { get { return simpleGens.Keys; } }
/// <summary> Retrieves the list of theme names of advanced map generators. </summary>
public static IEnumerable<string> AdvancedThemeNames { get { return advGens.Keys; } }
/// <summary> Returns whether the given axis length is acceptable for map generation. </summary>
public static bool OkayAxis(int len) {
return len >= 16 && len <= 8192 && (len % 16) == 0;
}

View File

@ -47,7 +47,7 @@ namespace MCGalaxy {
if (Whitelisted.CaselessContains(name)) return AccessResult.Whitelisted;
if (rank < Min) return AccessResult.BelowMinRank;
if (rank > Max && MaxCmd != null && CommandExtraPerms.Find(MaxCmd, 1).UsableBy(rank)) {
if (rank > Max && MaxCmd != null && !CommandExtraPerms.Find(MaxCmd, 1).UsableBy(rank)) {
return AccessResult.AboveMaxRank;
}
return AccessResult.Allowed;

View File

@ -25,27 +25,20 @@ namespace MCGalaxy.Levels.IO {
/// <summary> Reads/Loads block data (and potentially metadata) encoded in a particular format. </summary>
public abstract class IMapImporter {
/// <summary> The file extension of this format. </summary>
public abstract string Extension { get; }
/// <summary> Reads the data for a level from a file containing data encoded in this format. </summary>
/// <param name="metadata"> Whether metadata should be loaded. </param>
public Level Read(string path, string name, bool metadata) {
using (FileStream fs = File.OpenRead(path))
return Read(fs, name, metadata);
}
/// <summary> Reads the data for a level from a file containing data encoded in this format. </summary>
/// <param name="metadata"> Whether metadata should be loaded. </param>
public abstract Level Read(Stream src, string name, bool metadata);
/// <summary> Reads the dimensions for a level from a file containing data encoded in this format. </summary>
public Vec3U16 ReadDimensions(string path) {
using (FileStream fs = File.OpenRead(path))
return ReadDimensions(fs);
}
/// <summary> Reads the dimensions for a level from a file containing data encoded in this format. </summary>
public abstract Vec3U16 ReadDimensions(Stream src);
public static List<IMapImporter> Formats = new List<IMapImporter>() {
@ -70,17 +63,14 @@ namespace MCGalaxy.Levels.IO {
/// <summary> Writes/Saves block data (and potentially metadata) encoded in a particular format. </summary>
public abstract class IMapExporter {
/// <summary> The file extension of this format. </summary>
public abstract string Extension { get; }
/// <summary> Saves the data encoded in this format for a level to a file. </summary>
public void Write(string path, Level lvl) {
using (FileStream fs = File.Create(path)) {
Write(fs, lvl);
}
}
/// <summary> Saves the data encoded in this format for a level to a file. </summary>
public abstract void Write(Stream dst, Level lvl);
public static List<IMapExporter> Formats = new List<IMapExporter>() {

View File

@ -35,7 +35,6 @@ namespace MCGalaxy {
public List<Warp> Items = new List<Warp>();
public string Filename;
/// <summary> Finds the warp whose name caselessly equals the given name. </summary>
public Warp Find(string name) {
foreach (Warp wp in Items) {
if (wp.Name.CaselessEq(name)) return wp;
@ -43,38 +42,31 @@ namespace MCGalaxy {
return null;
}
/// <summary> Returns whether a warp with the given name exists. </summary>
public bool Exists(string name) { return Find(name) != null; }
/// <summary> Creates a new warp with the given name, located at the
/// player's current position, orientation, and level. </summary>
public void Create(string name, Player p) {
Warp warp = new Warp();
InitWarp(warp, name, p);
Make(warp, name, p);
Items.Add(warp);
Save();
}
void InitWarp(Warp warp, string name, Player p) {
void Make(Warp warp, string name, Player p) {
warp.Pos = p.Pos; warp.Name = name;
warp.Yaw = p.Rot.RotY; warp.Pitch = p.Rot.HeadX;
warp.Level = p.level.name;
}
/// <summary> Moves the given warp to the target
/// player's position, orientation, and map. </summary>
public void Update(Warp warp, Player p) {
InitWarp(warp, warp.Name, p);
Make(warp, warp.Name, p);
Save();
}
/// <summary> Removes the given warp. </summary>
public void Remove(Warp warp, Player p) {
Items.Remove(warp);
Save();
}
/// <summary> Attempts to move the given player to the given warp. </summary>
public void Goto(Warp warp, Player p) {
if (!p.level.name.CaselessEq(warp.Level)) {
PlayerActions.ChangeMap(p, warp.Level);
@ -89,7 +81,6 @@ namespace MCGalaxy {
}
/// <summary> Loads the list of warps from the file located at Filename. </summary>
public void Load() {
if (!File.Exists(Filename)) return;
using (StreamReader r = new StreamReader(Filename)) {
@ -116,7 +107,6 @@ namespace MCGalaxy {
}
}
/// <summary> Saves this list of warps to Filename. </summary>
public void Save() {
using (StreamWriter w = new StreamWriter(Filename)) {
foreach (Warp warp in Items) {