From 175e9c14e0d720442dcc95f84cac019fd5b723e9 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 4 Jul 2016 13:54:45 +1000 Subject: [PATCH] Remove /ozone and make it part of /zone with /zone map. --- Commands/CmdOverseer.cs | 15 ++---------- Commands/Moderation/CmdOZone.cs | 43 --------------------------------- Commands/Moderation/CmdZone.cs | 37 +++++++++++++++++++++++----- MCGalaxy_.csproj | 1 - 4 files changed, 33 insertions(+), 63 deletions(-) delete mode 100644 Commands/Moderation/CmdOZone.cs diff --git a/Commands/CmdOverseer.cs b/Commands/CmdOverseer.cs index 5319ddc95..815b4b6e8 100644 --- a/Commands/CmdOverseer.cs +++ b/Commands/CmdOverseer.cs @@ -148,7 +148,7 @@ namespace MCGalaxy.Commands if (osPerm == LevelPermission.Nobody) osPerm = GrpCommands.MinPerm(this); - ZoneAll(lvl, p.name); + CmdZone.ZoneAll(lvl, p.name); Group grp = Group.findPerm(osPerm); if (grp != null) { Command.all.Find("perbuild").Use(null, lvl.name + " " + grp.name); @@ -249,7 +249,7 @@ namespace MCGalaxy.Commands Player.Message(p, "You did not specify a name to allow building on your map."); return; } - ZoneAll(p.level, value); + CmdZone.ZoneAll(p.level, value); Player.Message(p, "Added zone for &b" + value); Player.Message(p, value + " has been allowed building on your map."); } else if (cmd == "DEL") { @@ -320,17 +320,6 @@ namespace MCGalaxy.Commands } } - static void ZoneAll(Level lvl, string owner) { - Level.Zone zn = default(Level.Zone); - zn.bigX = (ushort)(lvl.Width - 1); - zn.bigY = (ushort)(lvl.Height - 1); - zn.bigZ = (ushort)(lvl.Length - 1); - zn.Owner = owner; - - lvl.ZoneList.Add(zn); - LevelDB.CreateZone(lvl.name, zn); - } - static void EnsureFileExists(string path) { if (!Directory.Exists("levels/blacklists/")) Directory.CreateDirectory("levels/blacklists/"); diff --git a/Commands/Moderation/CmdOZone.cs b/Commands/Moderation/CmdOZone.cs deleted file mode 100644 index 0df6581a2..000000000 --- a/Commands/Moderation/CmdOZone.cs +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright 2011 MCForge - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.opensource.org/licenses/ecl2.php - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. - */ -namespace MCGalaxy.Commands { - public sealed class CmdOZone : Command { - public override string name { get { return "ozone"; } } - public override string shortcut { get { return "oz"; } } - public override string type { get { return CommandTypes.Moderation; } } - public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - public override bool museumUsable { get { return false; } } - public override void Help(Player p) { - Player.Message(p, "/ozone - Zones the entire map to "); - Player.Message(p, "To delete a zone, just use /zone del anywhere on the map"); - } - - public override void Use(Player p, string message) { - if (message == "") { Help(p); return; } - - int x2 = p.level.Width - 1; - int y2 = p.level.Height - 1; - int z2 = p.level.Length - 1; - Command zone = Command.all.Find("zone"); - Command click = Command.all.Find("click"); - zone.Use(p, "add " + message); - click.Use(p, 0 + " " + 0 + " " + 0); - click.Use(p, x2 + " " + y2 + " " + z2); - } - } -} diff --git a/Commands/Moderation/CmdZone.cs b/Commands/Moderation/CmdZone.cs index d636d9bee..c963af77e 100644 --- a/Commands/Moderation/CmdZone.cs +++ b/Commands/Moderation/CmdZone.cs @@ -31,6 +31,9 @@ namespace MCGalaxy.Commands { new CommandPerm(LevelPermission.Operator, "+ can create zones"), }; } } + public override CommandAlias[] Aliases { + get { return new[] { new CommandAlias("ozone", "map"), new CommandAlias("oz", "map") }; } + } public override void Use(Player p, string message) { string[] args = message.Split(' '); @@ -38,16 +41,16 @@ namespace MCGalaxy.Commands { Player.Message(p, "Place a block where you would like to check for zones."); p.MakeSelection(1, null, CheckZone); } else if (args[0].CaselessEq("add")) { - if (!CheckExtraPerm(p, 3)) { MessageNeedExtra(p, "can create zones.", 3); return; } - if (args.Length == 1) { Help(p); return; } - - if (Group.Find(args[1]) != null) - args[1] = "grp" + Group.Find(args[1]).name; - if (!ValidName(p, args[1], "player or rank")) return; + if (!CheckAdd(p, args)) return; Player.Message(p, "Place two blocks to determine the edges."); Player.Message(p, "Zone for: &b" + args[1] + "."); p.MakeSelection(2, args[1], AddZone); + } else if (args[0].CaselessEq("map")) { + if (!CheckAdd(p, args)) return; + + ZoneAll(p.level, args[1]); + Player.Message(p, "Added zone for &b" + args[1]); } else if (args[0].CaselessEq("del") && args.Length > 1 && args[1].CaselessEq("all")) { if (!CheckExtraPerm(p, 2)) { MessageNeedExtra(p, "can delete all zones.", 2); return; } DeleteAll(p); @@ -67,6 +70,17 @@ namespace MCGalaxy.Commands { } } + internal static void ZoneAll(Level lvl, string owner) { + Level.Zone zn = default(Level.Zone); + zn.bigX = (ushort)(lvl.Width - 1); + zn.bigY = (ushort)(lvl.Height - 1); + zn.bigZ = (ushort)(lvl.Length - 1); + zn.Owner = owner; + + lvl.ZoneList.Add(zn); + LevelDB.CreateZone(lvl.name, zn); + } + internal static void DeleteAll(Player p) { for (int i = 0; i < p.level.ZoneList.Count; i++) { Level.Zone Zn = p.level.ZoneList[i]; @@ -78,6 +92,16 @@ namespace MCGalaxy.Commands { } } + bool CheckAdd(Player p, string[] args) { + if (!CheckExtraPerm(p, 3)) { MessageNeedExtra(p, "can create zones.", 3); return false; } + if (args.Length == 1) { Help(p); return false; } + + if (Group.Find(args[1]) != null) + args[1] = "grp" + Group.Find(args[1]).name; + if (!ValidName(p, args[1], "player or rank")) return false; + return true; + } + bool CheckZone(Player p, Vec3S32[] marks, object state, byte type, byte extType) { Level lvl = p.level; Vec3S32 P = marks[0]; @@ -148,6 +172,7 @@ namespace MCGalaxy.Commands { public override void Help(Player p) { Player.Message(p, "%T/zone add [name] %H- Creates a zone only [name] can build in"); Player.Message(p, "%T/zone add [rank] %H- Creates a zone only [rank]+ can build in"); + Player.Message(p, "%T/zone map [name/rank] %H- /zone add across the entire map"); Player.Message(p, "%T/zone del %H- Deletes the zone clicked"); } } diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index 27d0af280..51f99cd74 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -305,7 +305,6 @@ -