Os map add now sets perbuild to /os rank, partially addresses #153.

This commit is contained in:
UnknownShadow200 2016-05-04 11:17:35 +10:00
parent 11fc79ebad
commit aeb49df1fd
4 changed files with 34 additions and 18 deletions

View File

@ -103,11 +103,11 @@ namespace MCGalaxy.Commands
string col = value == "" ? "normal" : value;
Command.all.Find("env").Use(p, "l " + type.ToLower() + " " + col);
} else if (type == "WEATHER") {
if (value.CaselessEq("SUN") || value.CaselessEq("NORMAL")) {
if (value.CaselessEq("SUN") || value.CaselessEq("NORMAL")) {
Command.all.Find("env").Use(p, "weather 0");
} else if (value.CaselessEq("RAIN")) {
} else if (value.CaselessEq("RAIN")) {
Command.all.Find("env").Use(p, "weather 1");
} else if (value.CaselessEq("SNOW")) {
} else if (value.CaselessEq("SNOW")) {
Command.all.Find("env").Use(p, "weather 2");
} else {
Player.SendMessage(p, "/os env weather [sun/rain/snow/normal] -- Changes the weather of your map.");
@ -150,7 +150,6 @@ namespace MCGalaxy.Commands
}
}
if (value == "") value = "128 64 128 flat";
else if (value.IndexOf(' ') == -1) value = "128 64 128 " + value;
@ -159,6 +158,19 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Creating a new map for you: " + level);
Command.all.Find("newlvl").Use(p, level + " " + value);
// Set default perbuild permissions
Command.all.Find("load").Use(p, level);
Level lvl = LevelInfo.FindExact(level);
if (lvl != null) {
LevelPermission osPerm = GrpCommands.MinPerm(this);
Group grp = Group.findPerm(osPerm);
if (grp != null) {
Command.all.Find("perbuild").Use(null, lvl.name + " " + grp.name);
Player.SendMessage(p, "Use %T/os zone add [name] %Sto allow " +
"players ranked below " + grp.ColoredName + " %Sto build in the map.");
}
}
} else if (cmd == "PHYSICS") {
if (value == "0" || value == "1" || value == "2" || value == "3" || value == "4" || value == "5")
Command.all.Find("physics").Use(p, p.level.name + " " + value);
@ -357,6 +369,7 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Accepted commands:");
Player.SendMessage(p, "go, map, spawn, zone, kick, kickall, env, " +
"preset, levelblock/lb");
Player.SendMessage(p, "/os zone add [name] - allows [name] to build in the world.");
}
}
}

View File

@ -147,7 +147,7 @@ namespace MCGalaxy.Commands
if (c.name == null) continue;
if (!colors) cmds.Append(", ").Append(c.name);
else cmds.Append(", ").Append(GetColor(c.name)).Append(c.name);
else cmds.Append(", ").Append(GetColor(c)).Append(c.name);
}
Player.SendMessage(p, "Available commands:");
@ -161,7 +161,7 @@ namespace MCGalaxy.Commands
StringBuilder cmds = new StringBuilder();
foreach (Command c in Command.all.commands) {
if (c.name == null) continue;
cmds.Append(", ").Append(GetColor(c.name)).Append(c.name);
cmds.Append(", ").Append(GetColor(c)).Append(c.name);
}
Player.SendMessage(p, "All commands:");
@ -177,7 +177,7 @@ namespace MCGalaxy.Commands
string disabled = Command.GetDisabledReason(c.Enabled);
if (p == null || p.group.CanExecute(c) && disabled == null) {
if (!c.type.Contains(typeName) || c.name == null) continue;
cmds.Append(", ").Append(GetColor(c.name)).Append(c.name);
cmds.Append(", ").Append(GetColor(c)).Append(c.name);
}
}
@ -193,7 +193,7 @@ namespace MCGalaxy.Commands
Command cmd = Command.all.Find(message);
if (cmd == null) return false;
cmd.Help(p);
LevelPermission minPerm = GrpCommands.allowedCommands.Find(C => C.commandName == cmd.name).lowestRank;
LevelPermission minPerm = GrpCommands.MinPerm(cmd);
Player.SendMessage(p, "Rank needed: " + GetColoredRank(minPerm));
PrintAliases(p, cmd);
@ -324,8 +324,8 @@ namespace MCGalaxy.Commands
return false;
}
static string GetColor(string cmd) {
LevelPermission perm = GrpCommands.allowedCommands.Find(C => C.commandName == cmd).lowestRank;
static string GetColor(Command cmd) {
LevelPermission perm = GrpCommands.MinPerm(cmd);
Group grp = Group.findPerm(perm);
return grp == null ? "&f" : grp.color;
}

View File

@ -26,8 +26,7 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public CmdBotSummon() { }
public override void Use(Player p, string message)
{
public override void Use(Player p, string message) {
if (message == "") { Help(p); return; }
if (p == null) { MessageInGameOnly(p); return; }
@ -36,8 +35,8 @@ namespace MCGalaxy.Commands
if (p.level != who.level) { Player.SendMessage(p, who.name + " is in a different level."); return; }
who.SetPos(p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]);
}
public override void Help(Player p)
{
public override void Help(Player p) {
Player.SendMessage(p, "/botsummon <name> - Summons a bot to your position.");
}
}

View File

@ -35,10 +35,14 @@ namespace MCGalaxy {
public static LevelPermission defaultRanks(string command) {
Command cmd = Command.all.Find(command);
return cmd != null ? cmd.defaultRank : LevelPermission.Null;
}
public static LevelPermission MinPerm(Command cmd) {
var perms = GrpCommands.allowedCommands.Find(C => C.commandName == cmd.name);
return perms == null ? cmd.defaultRank : perms.lowestRank;
}
public static void fillRanks() {
foundCommands = Command.all.commandNames();
allowedCommands = new List<rankAllowance>();