Skip to content

Commit

Permalink
When doing /spin mirror, say to use /mirror instead
Browse files Browse the repository at this point in the history
Also slightly tidy up heartbeat error/mppass calculation code
  • Loading branch information
UnknownShadow200 committed Aug 13, 2021
1 parent 2e1c4e9 commit 4e0582a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
6 changes: 6 additions & 0 deletions MCGalaxy/Commands/building/CmdSpin.cs
Expand Up @@ -38,6 +38,12 @@ public sealed class CmdSpin : Command2 {
string opt = message.ToLower();
BlockDefinition[] defs = p.level.CustomBlockDefs;

// /Mirror used to be part of spin
if (opt.CaselessStarts("mirror")) {
p.Message("&T/Spin {0} &Sis deprecated. Use &T/Mirror &Sinstead", opt);
return;
}

string[] args = opt.SplitSpaces();
char axis = 'Y';
int angle = 90;
Expand Down
31 changes: 16 additions & 15 deletions MCGalaxy/Network/Heartbeat/ClassiCube.cs
Expand Up @@ -115,22 +115,23 @@ public sealed class ClassiCubeBeat : Heartbeat {

static string GetError(string json) {
JsonReader reader = new JsonReader(json);
string error = null;
// silly design, but form of json is:
// {
// "errors": [ ["Error 1"], ["Error 2"] ],
// "response": "",
// "status": "fail"
// }
JsonObject obj = reader.Parse() as JsonObject;
if (obj == null || !obj.ContainsKey("errors")) return null;

// silly design, but form of json is: "errors": [ ["Error1"], ["Error2"] ]
reader.OnMember = (obj, key, value) => {
if (key != "errors") return;
JsonArray errors = value as JsonArray;
if (errors == null) return;
foreach (object raw in errors) {
JsonArray err = raw as JsonArray;
if (err != null && err.Count > 0) error = (string)err[0];
}
};

reader.Parse();
return error;
JsonArray errors = obj["errors"] as JsonArray;
if (errors == null) return null;

foreach (object raw in errors) {
JsonArray err = raw as JsonArray;
if (err != null && err.Count > 0) return (string)err[0];
}
return null;
}
}
}
7 changes: 3 additions & 4 deletions MCGalaxy/Server/Authenticator.cs
Expand Up @@ -35,12 +35,11 @@ public abstract class Authenticator {
if (!Server.Config.VerifyNames) return true;
string calculated = Server.CalcMppass(p.truename);

if (!mppass.CaselessEq(calculated)) {
if (!IPUtil.IsPrivate(p.IP)) return false;
} else {
if (mppass.CaselessEq(calculated)) {
p.verifiedName = true;
return true;
}
return true;
return IPUtil.IsPrivate(p.IP);
}

/// <summary> Informs the given player that they must first
Expand Down

0 comments on commit 4e0582a

Please sign in to comment.