private void OnAllPlayersBlockChangeOnHigh(Player sender, BlockChangeEventArgs args) { var zones = Zone.FindAllWithin(new Vector3D(args.X, args.Z, args.Y)); foreach (var zone in zones) { if (zone.CanBuildIn(sender)) { continue; } sender.SendMessage("You cannot build in this Zone! This zone if for: " + (PlayerGroup.FindPermInt(zone.Permission) ?? ("Permission: " + zone.Permission)) + " or higher!"); args.Cancel(); return; } }
public void Use(Player p, string[] args) { if (args.Length < 1) { Help(p); return; } switch (args[0].ToLower()) { case "add": case "a": if (args.Length != 3) { Help(p); return; } if (Zone.GetZoneByName(args[1]) != null) { p.SendMessage("Zone by that name already exists!"); return; } byte b = 0; try { b = byte.Parse(args[2]); } catch { try { b = PlayerGroup.Find(args[2]); } catch { p.SendMessage("Error parsing permission"); return; } } if (b > p.Group.Permission) { p.SendMessage("Cannot create a zone with higher permission then yourself!"); return; } p.SendMessage("Please place the first block to define the region"); p.OnPlayerBlockChange.Normal += OnPlayerBlockChangeOnNormal; var data = new KeyValuePair <string, byte>(args[1], b); p.SetDatapass(Name, data); break; case "delete": case "del": case "d": if (args.Length > 2) { Help(p); return; } if (args.Length == 2) { var zone = Zone.GetZoneByName(args[1]); if (zone == null) { p.SendMessage("Zone not found!"); return; } if (zone.Permission > p.Group.Permission) { p.SendMessage("You cannot delete this zone!"); return; } zone.Delete(); p.SendMessage("Zone " + zone.Name + " has been deleted"); } p.OnPlayerBlockChange.Normal += (sender, eventArgs) => { eventArgs.Cancel(); eventArgs.Unregister(); var pos = new Vector3D(eventArgs.X, eventArgs.Z, eventArgs.Y); var zoneList = Zone.FindAllWithin(pos); Zone zone = null; if (zoneList.Count > 1) { sender.SendMessage("Too many zones found"); sender.SendMessage("Use /zone del <zone name> to delete the zone"); return; } if (zoneList.Count < 1) { sender.SendMessage("No zone found!"); return; } zone = zoneList[0]; if (zone.Permission > p.Group.Permission) { sender.SendMessage("You cannot delete this zone!"); return; } zone.Delete(); p.SendMessage("Zone " + zone.Name + " has been deleted"); }; break; case "list": case "l": Level l = null; if (args.Length == 2) { l = Level.FindLevel(args[1]); } if (l == null) { l = p.Level; } List <Zone> zones = Zone.GetAllZonesForLevel(l); var s = String.Join(", ", zones); p.SendMessage("Zones for Level " + l.Name + ": " + s); break; case "info": case "i": if (args.Length > 2) { Help(p); return; } if (args.Length == 2) { var zone = Zone.GetZoneByName(args[1]); if (zone == null) { p.SendMessage("Zone not found!"); return; } p.SendMessage("Zone name: &f" + zone.Name); p.SendMessage("Zone minimum permission: &0" + zone.Permission); p.SendMessage("Zone Owner: &f" + zone.Owner); p.SendMessage("Zone Level: &5" + zone.Level.Name); p.SendMessage("Can you build in this zone? " + ((zone.CanBuildIn(p)) ? "&9yes": "&4no")); } p.OnPlayerBlockChange.Normal += (sender, eventArgs) => { eventArgs.Cancel(); eventArgs.Unregister(); var pos = new Vector3D(eventArgs.X, eventArgs.Z, eventArgs.Y); var zoneList = Zone.FindAllWithin(pos); Zone zone = null; if (zoneList.Count > 1) { sender.SendMessage("Too many zones found"); sender.SendMessage("Use /zone del <zone name> to delete the zone"); return; } if (zoneList.Count < 1) { sender.SendMessage("No zone found!"); return; } zone = zoneList[0]; if (zone == null) { p.SendMessage("Zone not found!"); return; } sender.SendMessage("Zone name: &f" + zone.Name); sender.SendMessage("Zone minimum permission: &0" + zone.Permission); sender.SendMessage("Zone Owner: &f" + zone.Owner); sender.SendMessage("Zone Level: &5" + zone.Level.Name); sender.SendMessage("Can you build in this zone? " + ((zone.CanBuildIn(sender)) ? "&9yes" : "&4no")); }; break; } }