Fix last commit.

This commit is contained in:
UnknownShadow200 2016-08-24 16:46:47 +10:00
parent 362112697b
commit cca3e10b8c
3 changed files with 15 additions and 15 deletions

View File

@ -25,12 +25,12 @@ namespace MCGalaxy.Commands.World {
public override bool museumUsable { get { return false; } } public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
protected Level GetArgs(Player p, string[] args, out Group grp) { protected Level GetArgs(Player p, string[] args, ref Group grp) {
if (args.Length == 1 && Player.IsSuper(p)) { if (args.Length == 1 && Player.IsSuper(p)) {
SuperRequiresArgs(p, "level"); return null; SuperRequiresArgs(p, "level"); return null;
} }
Level level = args.Length == 1 ? p.level : LevelInfo.FindMatches(p, args[0]); Level level = args.Length == 1 ? p.level : LevelInfo.FindMatches(p, args[0]);
if (level == null) return; if (level == null) return null;
string rank = args.Length == 1 ? args[0] : args[1]; string rank = args.Length == 1 ? args[0] : args[1];
grp = Group.FindMatches(p, rank); grp = Group.FindMatches(p, rank);

View File

@ -27,7 +27,7 @@ namespace MCGalaxy.Commands.World {
if (args.Length < 1 || args.Length > 2) { Help(p); return; } if (args.Length < 1 || args.Length > 2) { Help(p); return; }
Group grp = null; Group grp = null;
Level lvl = GetArgs(p, args, out grp); Level lvl = GetArgs(p, args, ref grp);
if (lvl != null) lvl.BuildAccess.SetMax(p, grp); if (lvl != null) lvl.BuildAccess.SetMax(p, grp);
} }
@ -45,7 +45,7 @@ namespace MCGalaxy.Commands.World {
if (args.Length < 1 || args.Length > 2) { Help(p); return; } if (args.Length < 1 || args.Length > 2) { Help(p); return; }
Group grp = null; Group grp = null;
Level lvl = GetArgs(p, args, out grp); Level lvl = GetArgs(p, args, ref grp);
if (lvl != null) lvl.BuildAccess.SetMin(p, grp); if (lvl != null) lvl.BuildAccess.SetMin(p, grp);
} }
@ -63,7 +63,7 @@ namespace MCGalaxy.Commands.World {
if (args.Length < 1 || args.Length > 2) { Help(p); return; } if (args.Length < 1 || args.Length > 2) { Help(p); return; }
Group grp = null; Group grp = null;
Level lvl = GetArgs(p, args, out grp); Level lvl = GetArgs(p, args, ref grp);
if (lvl != null) lvl.VisitAccess.SetMax(p, grp); if (lvl != null) lvl.VisitAccess.SetMax(p, grp);
} }
@ -87,7 +87,7 @@ namespace MCGalaxy.Commands.World {
} }
Group grp = null; Group grp = null;
Level lvl = GetArgs(p, args, out grp); Level lvl = GetArgs(p, args, ref grp);
if (lvl != null) lvl.VisitAccess.SetMin(p, grp); if (lvl != null) lvl.VisitAccess.SetMin(p, grp);
} }

View File

@ -106,7 +106,8 @@ namespace MCGalaxy {
/// had insufficient permission to change the minimum rank. </returns> /// had insufficient permission to change the minimum rank. </returns>
public bool SetMin(Player p, Group grp) { public bool SetMin(Player p, Group grp) {
string target = IsVisit ? "pervisit" : "perbuild"; string target = IsVisit ? "pervisit" : "perbuild";
if (!CheckRank(p, grp, target)) return false; if (!CheckRank(p, Min, target, false)) return false;
if (!CheckRank(p, grp.Permission, target, true)) return false;
Min = grp.Permission; Min = grp.Permission;
UpdateAllowBuild(); UpdateAllowBuild();
@ -119,7 +120,9 @@ namespace MCGalaxy {
/// had insufficient permission to change the minimum rank. </returns> /// had insufficient permission to change the minimum rank. </returns>
public bool SetMax(Player p, Group grp) { public bool SetMax(Player p, Group grp) {
string target = IsVisit ? "pervisitmax" : "perbuildmax"; string target = IsVisit ? "pervisitmax" : "perbuildmax";
if (grp.Permission != LevelPermission.Nobody && !CheckRank(p, grp, target)) return false; const LevelPermission ignore = LevelPermission.Nobody;
if (Max != ignore && !CheckRank(p, Max, target, false)) return false;
if (grp.Permission != ignore && !CheckRank(p, grp.Permission, target, true)) return false;
Max = grp.Permission; Max = grp.Permission;
UpdateAllowBuild(); UpdateAllowBuild();
@ -128,13 +131,10 @@ namespace MCGalaxy {
} }
bool CheckRank(Player p, Group grp, string target) { bool CheckRank(Player p, LevelPermission perm, string target, bool newPerm) {
if (p != null && Min > p.Rank) { if (p != null && perm > p.Rank) {
Player.Message(p, "You cannot change the {0} of a level with a {0} higher than your rank.", target); Player.Message(p, "You cannot change the {0} of a level {1} a {0} higher than your rank.",
return false; target, newPerm ? "to" : "with");
}
if (p != null && grp.Permission > p.Rank) {
Player.Message(p, "You cannot change the {0} of a level to a {0} higher than your rank.", target);
return false; return false;
} }
return true; return true;