diff --git a/Commands/CmdOverseer.cs b/Commands/CmdOverseer.cs index 9c6110990..1115cc3f6 100644 --- a/Commands/CmdOverseer.cs +++ b/Commands/CmdOverseer.cs @@ -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."); @@ -148,17 +148,29 @@ namespace MCGalaxy.Commands if (level == p.name.ToLower()) { p.SendMessage("You have reached the limit for your overseer maps."); return; } - } - + } if (value == "") value = "128 64 128 flat"; else if (value.IndexOf(' ') == -1) value = "128 64 128 " + value; string[] args = value.TrimEnd().Split(' '); if (args.Length == 3) value += " flat"; - + 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."); } } } \ No newline at end of file diff --git a/Commands/Information/CmdHelp.cs b/Commands/Information/CmdHelp.cs index 600d3e62f..dc2229106 100644 --- a/Commands/Information/CmdHelp.cs +++ b/Commands/Information/CmdHelp.cs @@ -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); } } @@ -192,8 +192,8 @@ namespace MCGalaxy.Commands bool ParseCommand(Player p, string message) { 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; + cmd.Help(p); + 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; } diff --git a/Commands/Moderation/CmdBotSummon.cs b/Commands/Moderation/CmdBotSummon.cs index b4b6f2066..d0d20bc82 100644 --- a/Commands/Moderation/CmdBotSummon.cs +++ b/Commands/Moderation/CmdBotSummon.cs @@ -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 - Summons a bot to your position."); } } diff --git a/Player/Group/GroupCommands.cs b/Player/Group/GroupCommands.cs index 45002f722..987b0f7b0 100644 --- a/Player/Group/GroupCommands.cs +++ b/Player/Group/GroupCommands.cs @@ -35,9 +35,13 @@ 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();