mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
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:
parent
4f8b279c63
commit
4fefcf14e0
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands {
|
|||||||
p.SendMessage("Your rank is set to have 0 overseer maps. Therefore, you may not use overseer.");
|
p.SendMessage("Your rank is set to have 0 overseer maps. Therefore, you may not use overseer.");
|
||||||
if (message == "") { Help(p); return; }
|
if (message == "") { Help(p); return; }
|
||||||
|
|
||||||
string[] parts = message.SplitSpaces(3);
|
string[] parts = message.SplitSpaces(3);
|
||||||
string cmd = parts[0].ToUpper();
|
string cmd = parts[0].ToUpper();
|
||||||
string arg = parts.Length > 1 ? parts[1].ToUpper() : "";
|
string arg = parts.Length > 1 ? parts[1].ToUpper() : "";
|
||||||
string arg2 = parts.Length > 2 ? parts[2] : "";
|
string arg2 = parts.Length > 2 ? parts[2] : "";
|
||||||
@ -99,7 +99,7 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
void HandleEnvCommand(Player p, string type, string value) {
|
void HandleEnvCommand(Player p, string type, string value) {
|
||||||
string arg = value == "" ? "normal" : value;
|
string arg = value == "" ? "normal" : value;
|
||||||
if (CmdEnvironment.Handle(p, type.ToLower(), arg)) return;
|
if (CmdEnvironment.Handle(p, type.ToLower(), arg)) return;
|
||||||
Player.MessageLines(p, envHelp);
|
Player.MessageLines(p, envHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,46 +112,34 @@ 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;
|
||||||
|
|
||||||
string[] args = value.TrimEnd().Split(' ');
|
string[] args = value.TrimEnd().Split(' ');
|
||||||
if (args.Length == 3) value += " flat";
|
if (args.Length == 3) value += " flat";
|
||||||
|
|
||||||
Player.Message(p, "Creating a new map for you: " + level);
|
Player.Message(p, "Creating a new map for you: " + level);
|
||||||
Command.all.Find("newlvl").Use(p, level + " " + value);
|
Command.all.Find("newlvl").Use(p, level + " " + value);
|
||||||
|
|
||||||
// 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)
|
LevelPermission osPerm = Server.osPerbuildDefault;
|
||||||
osPerm = GrpCommands.MinPerm(this);
|
if (osPerm == LevelPermission.Nobody)
|
||||||
|
osPerm = GrpCommands.MinPerm(this);
|
||||||
CmdZone.ZoneAll(lvl, p.name);
|
|
||||||
Group grp = Group.findPerm(osPerm);
|
CmdZone.ZoneAll(lvl, p.name);
|
||||||
if (grp != null) {
|
Group grp = Group.findPerm(osPerm);
|
||||||
Command.all.Find("perbuild").Use(null, lvl.name + " " + grp.name);
|
if (grp == null) return;
|
||||||
Player.Message(p, "Use %T/os zone add [name] %Sto allow " +
|
|
||||||
"players ranked below " + grp.ColoredName + " %Sto build in the map.");
|
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);
|
||||||
}
|
}
|
||||||
@ -262,7 +249,7 @@ namespace MCGalaxy.Commands {
|
|||||||
}
|
}
|
||||||
Player blocked = PlayerInfo.Find(value);
|
Player blocked = PlayerInfo.Find(value);
|
||||||
if (blocked == null) { Player.Message(p, "Cannot find player."); return; }
|
if (blocked == null) { Player.Message(p, "Cannot find player."); return; }
|
||||||
if (blocked.name.CaselessEq(p.name)) { Player.Message(p, "You can't blacklist yourself"); return; }
|
if (blocked.name.CaselessEq(p.name)) { Player.Message(p, "You can't blacklist yourself"); return; }
|
||||||
|
|
||||||
string path = "levels/blacklists/" + p.level.name + ".txt";
|
string path = "levels/blacklists/" + p.level.name + ".txt";
|
||||||
if (File.Exists(path) && File.ReadAllText(path).Contains(blocked.name)) {
|
if (File.Exists(path) && File.ReadAllText(path).Contains(blocked.name)) {
|
||||||
@ -278,8 +265,8 @@ namespace MCGalaxy.Commands {
|
|||||||
Server.s.Log("Error saving level blacklist");
|
Server.s.Log("Error saving level blacklist");
|
||||||
}
|
}
|
||||||
Player.Message(p, blocked.name + " has been blacklisted from your map.");
|
Player.Message(p, blocked.name + " has been blacklisted from your map.");
|
||||||
if (blocked.level.name == p.level.name) {
|
if (blocked.level.name == p.level.name) {
|
||||||
PlayerActions.ChangeMap(blocked, Server.mainLevel.name); return;
|
PlayerActions.ChangeMap(blocked, Server.mainLevel.name); return;
|
||||||
}
|
}
|
||||||
} else if (cmd == "UNBLOCK") {
|
} else if (cmd == "UNBLOCK") {
|
||||||
if (value == "") {
|
if (value == "") {
|
||||||
@ -330,6 +317,23 @@ namespace MCGalaxy.Commands {
|
|||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
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
|
||||||
@ -351,7 +355,7 @@ namespace MCGalaxy.Commands {
|
|||||||
Player.Message(p, "%T/os [command] [args]");
|
Player.Message(p, "%T/os [command] [args]");
|
||||||
Player.Message(p, "%HAllows you to modify and manage your personal realms.");
|
Player.Message(p, "%HAllows you to modify and manage your personal realms.");
|
||||||
Player.Message(p, "%HCommands: %Sgo, map, spawn, zone, kick, " +
|
Player.Message(p, "%HCommands: %Sgo, map, spawn, zone, kick, " +
|
||||||
"kickall, env, preset, levelblock(lb)");
|
"kickall, env, preset, levelblock(lb)");
|
||||||
Player.Message(p, "%T/os zone add [name] %H- allows [name] to build in the world.");
|
Player.Message(p, "%T/os zone add [name] %H- allows [name] to build in the world.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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.",
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user