internal static void ZoneRemove(Player player, Command cmd) { string zoneName = cmd.Next(); if (zoneName == null) { cdZoneRemove.PrintUsage(player); return; } Zone zone = player.World.Map.FindZone(zoneName); if (zone != null) { if (!zone.Controller.Check(player.Info) && !player.Info.Rank.AllowSecurityCircumvention) { player.Message("You are not allowed to remove zone {0}", zone.GetClassyName()); return; } if (!cmd.IsConfirmed) { player.AskForConfirmation(cmd, "You are about to remove zone {0}&S.", zone.GetClassyName()); return; } if (player.World.Map.RemoveZone(zoneName)) { player.Message("Zone \"{0}\" removed.", zoneName); } } else { player.Message("No zone with the name \"{0}\" was found.", zoneName); } }
internal static void ZoneEdit(Player player, Command cmd) { bool changesWereMade = false; string zoneName = cmd.Next(); if (zoneName == null) { player.Message("No zone name specified. See &H/help zedit"); return; } Zone zone = player.World.Map.FindZone(zoneName); if (zone == null) { player.Message("No zone found with the name \"{0}\". See &H/zones", zoneName); return; } string name; while ((name = cmd.Next()) != null) { if (name.Length < 2) { continue; } if (name.StartsWith("+")) { PlayerInfo info; if (!PlayerDB.FindPlayerInfo(name.Substring(1), out info)) { player.Message("More than one player found matching \"{0}\"", name.Substring(1)); return; } if (info == null) { player.NoPlayerMessage(name.Substring(1)); return; } // prevent players from whitelisting themselves to bypass protection if (!player.Info.Rank.AllowSecurityCircumvention && player.Info == info) { if (!zone.Controller.Check(info)) { player.Message("You must be {0}+&S to add yourself to this zone's whitelist.", zone.Controller.MinRank.GetClassyName()); continue; } } switch (zone.Controller.Include(info)) { case PermissionOverride.Deny: player.Message("{0}&S is no longer excluded from zone {1}", info.GetClassyName(), zone.GetClassyName()); changesWereMade = true; break; case PermissionOverride.None: player.Message("{0}&S is now included in zone {1}", info.GetClassyName(), zone.GetClassyName()); changesWereMade = true; break; case PermissionOverride.Allow: player.Message("{0}&S is already included in zone {1}", info.GetClassyName(), zone.GetClassyName()); break; } } else if (name.StartsWith("-")) { PlayerInfo info; if (!PlayerDB.FindPlayerInfo(name.Substring(1), out info)) { player.Message("More than one player found matching \"{0}\"", name.Substring(1)); return; } if (info == null) { player.NoPlayerMessage(name.Substring(1)); return; } switch (zone.Controller.Exclude(info)) { case PermissionOverride.Deny: player.Message("{0}&S is already excluded from zone {1}", info.GetClassyName(), zone.GetClassyName()); break; case PermissionOverride.None: player.Message("{0}&S is now excluded from zone {1}", info.GetClassyName(), zone.GetClassyName()); changesWereMade = true; break; case PermissionOverride.Allow: player.Message("{0}&S is no longer included in zone {1}", info.GetClassyName(), zone.GetClassyName()); changesWereMade = true; break; } } else { Rank minRank = RankManager.ParseRank(name); if (minRank != null) { // prevent players from lowering rank so bypass protection if (!player.Info.Rank.AllowSecurityCircumvention && zone.Controller.MinRank > player.Info.Rank && minRank <= player.Info.Rank) { player.Message("You are not allowed to lower the zone's rank."); continue; } if (zone.Controller.MinRank != minRank) { zone.Controller.MinRank = minRank; player.Message("Permission for zone \"{0}\" changed to {1}+", zone.Name, minRank.GetClassyName()); changesWereMade = true; } } else { player.NoRankMessage(name); } } if (changesWereMade) { zone.Edit(player.Info); player.World.Map.ChangedSinceSave = true; } else { player.Message("No changes were made to the zone."); } } }