Fix /os map buildable and /os map deletable giving 'Only X+ can set map options' when trying to use them. (Thanks A0)

This commit is contained in:
UnknownShadow200 2016-08-20 13:36:51 +10:00
parent 4f8b279c63
commit 4fefcf14e0
3 changed files with 48 additions and 42 deletions

View File

@ -112,20 +112,8 @@ namespace MCGalaxy.Commands {
byte mapNum = 0; byte mapNum = 0;
if (cmd == "ADD") { if (cmd == "ADD") {
string level = p.name.ToLower(); string level = NextLevel(p);
if (LevelInfo.ExistsOffline(level) || LevelInfo.ExistsOffline(level + "00")) { if (level == null) return;
for (int i = 2; i < p.group.OverseerMaps + 2; i++) {
if (LevelInfo.ExistsOffline(p.name.ToLower() + i)) continue;
if(i > p.group.OverseerMaps) {
p.SendMessage("You have reached the limit for your overseer maps."); return;
}
level = p.name.ToLower() + i;
break;
}
if (level == p.name.ToLower()) {
p.SendMessage("You have reached the limit for your overseer maps."); return;
}
}
if (value == "") value = "128 64 128 flat"; if (value == "") value = "128 64 128 flat";
else if (value.IndexOf(' ') == -1) value = "128 64 128 " + value; else if (value.IndexOf(' ') == -1) value = "128 64 128 " + value;
@ -139,19 +127,19 @@ namespace MCGalaxy.Commands {
// Set default perbuild permissions // Set default perbuild permissions
Command.all.Find("load").Use(p, level); Command.all.Find("load").Use(p, level);
Level lvl = LevelInfo.FindExact(level); Level lvl = LevelInfo.FindExact(level);
if (lvl != null) { if (lvl == null) return;
LevelPermission osPerm = Server.osPerbuildDefault;
if (osPerm == LevelPermission.Nobody)
osPerm = GrpCommands.MinPerm(this);
CmdZone.ZoneAll(lvl, p.name); LevelPermission osPerm = Server.osPerbuildDefault;
Group grp = Group.findPerm(osPerm); if (osPerm == LevelPermission.Nobody)
if (grp != null) { osPerm = GrpCommands.MinPerm(this);
Command.all.Find("perbuild").Use(null, lvl.name + " " + grp.name);
Player.Message(p, "Use %T/os zone add [name] %Sto allow " + CmdZone.ZoneAll(lvl, p.name);
"players ranked below " + grp.ColoredName + " %Sto build in the map."); Group grp = Group.findPerm(osPerm);
} if (grp == null) return;
}
Command.all.Find("perbuild").Use(null, lvl.name + " " + grp.name);
Player.Message(p, "Use %T/os zone add [name] %Sto allow " +
"players ranked below " + grp.ColoredName + " %Sto build in the map.");
} else if (cmd == "PHYSICS") { } else if (cmd == "PHYSICS") {
if (value == "0" || value == "1" || value == "2" || value == "3" || value == "4" || value == "5") if (value == "0" || value == "1" || value == "2" || value == "3" || value == "4" || value == "5")
CmdPhysics.SetPhysics(p.level, int.Parse(value)); CmdPhysics.SetPhysics(p.level, int.Parse(value));
@ -210,8 +198,7 @@ namespace MCGalaxy.Commands {
} else if (cmd == "GUNS") { } else if (cmd == "GUNS") {
Command.all.Find("allowguns").Use(p, ""); Command.all.Find("allowguns").Use(p, "");
} else if (cmd == "CHAT") { } else if (cmd == "CHAT") {
CmdMap.SetBool(p, p.level, ref p.level.worldChat, "Roleplay (level only) chat: ", true); CmdMap.SetMapOption(p, p.level, "chat", "");
Level.SaveSettings(p.level);
} else if (cmd == "RESTORE") { } else if (cmd == "RESTORE") {
Command.all.Find("restore").Use(p, value); Command.all.Find("restore").Use(p, value);
} else if (cmd == "PERVISIT") { } else if (cmd == "PERVISIT") {
@ -233,9 +220,9 @@ namespace MCGalaxy.Commands {
Command.all.Find("texture").Use(p, "levelzip " + value); Command.all.Find("texture").Use(p, "levelzip " + value);
} }
} else if (cmd == "BUILDABLE") { } else if (cmd == "BUILDABLE") {
Command.all.Find("map").Use(p, "buildable"); CmdMap.SetMapOption(p, p.level, "buildable", "");
} else if (cmd == "DELETABLE") { } else if (cmd == "DELETABLE") {
Command.all.Find("map").Use(p, "deletable"); CmdMap.SetMapOption(p, p.level, "deleteable", "");
} else { } else {
Player.MessageLines(p, mapHelp); Player.MessageLines(p, mapHelp);
} }
@ -331,6 +318,23 @@ namespace MCGalaxy.Commands {
File.Create(path).Dispose(); File.Create(path).Dispose();
} }
static string NextLevel(Player p) {
string level = p.name.ToLower();
if (LevelInfo.ExistsOffline(level) || LevelInfo.ExistsOffline(level + "00")) {
for (int i = 2; i < p.group.OverseerMaps + 2; i++) {
if (LevelInfo.ExistsOffline(p.name.ToLower() + i)) continue;
if(i > p.group.OverseerMaps) {
p.SendMessage("You have reached the limit for your overseer maps."); return null;
}
return p.name.ToLower() + i;
}
if (level == p.name.ToLower()) {
p.SendMessage("You have reached the limit for your overseer maps."); return null;
}
}
return level;
}
static string FirstMapName(Player p) { static string FirstMapName(Player p) {
/* Returns the proper name of the User Level. By default the User Level will be named /* Returns the proper name of the User Level. By default the User Level will be named
* "UserName" but was earlier named "UserName00". Therefore the Script checks if the old * "UserName" but was earlier named "UserName00". Therefore the Script checks if the old
@ -391,7 +395,7 @@ namespace MCGalaxy.Commands {
static string[] zoneHelp = { static string[] zoneHelp = {
"%T/os zone add [player/rank] %H- Adds a zone for a player or a rank, " + "%T/os zone add [player/rank] %H- Adds a zone for a player or a rank, " +
"allowing them to always build in your map.", "allowing them to always build in your map.",
"%T/os zone del all %H- Deletes all zones in your map.", "%T/os zone del all %H- Deletes all zones in your map.",
"%T/os zone list %H- Shows zones affecting a particular block.", "%T/os zone list %H- Shows zones affecting a particular block.",
"%T/os zone block [name] %H- Prevents them from joining your map.", "%T/os zone block [name] %H- Prevents them from joining your map.",

View File

@ -55,6 +55,9 @@ namespace MCGalaxy.Commands.World {
} }
if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "set map options."); return; } if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "set map options."); return; }
if (opt.CaselessEq("realmowner") && !CheckExtraPerm(p, 2)) {
MessageNeedExtra(p, "set personal realm owners.", 2); return;
}
SetMapOption(p, lvl, opt, value); SetMapOption(p, lvl, opt, value);
} }
@ -71,7 +74,7 @@ namespace MCGalaxy.Commands.World {
return args.Length == (optHasArg ? 2 : 1); return args.Length == (optHasArg ? 2 : 1);
} }
void SetMapOption(Player p, Level lvl, string opt, string value) { internal static void SetMapOption(Player p, Level lvl, string opt, string value) {
switch (opt.ToLower()) { switch (opt.ToLower()) {
case "theme": case "theme":
lvl.theme = value; lvl.theme = value;
@ -124,7 +127,6 @@ namespace MCGalaxy.Commands.World {
SetBool(p, lvl, ref lvl.Deletable, "Deletable: "); SetBool(p, lvl, ref lvl.Deletable, "Deletable: ");
lvl.UpdateBlockPermissions(); break; lvl.UpdateBlockPermissions(); break;
case "realmowner": case "realmowner":
if (!CheckExtraPerm(p, 2)) { MessageNeedExtra(p, "set personal realm owners.", 2); return; }
lvl.RealmOwner = value; lvl.RealmOwner = value;
if (value == "") Player.Message(p, "Removed realm owner for this level."); if (value == "") Player.Message(p, "Removed realm owner for this level.");
else Player.Message(p, "Set realm owner of this level to {0}.", value); else Player.Message(p, "Set realm owner of this level to {0}.", value);

View File

@ -112,7 +112,7 @@ namespace MCGalaxy.Util {
if (highlight) { if (highlight) {
DoHighlight(s, format, args); DoHighlight(s, format, args);
} else { } else {
if (!format.UndoEntry(p, path, marks, ref temp, start)) break; // TODO: fixy fix if (!format.UndoEntry(p, path, marks, ref temp, start)) break;
} }
if (args.Stop) break; if (args.Stop) break;
} }