private void SetFlags(CommandArgs args) { if (args.Parameters.Count == 1 && args.Parameters[0] == "flags") { string flags = string.Join(", ", Enum.GetNames(typeof(Flags))); args.Player.SendInfoMessage("Available flags: {0}", flags); return; } if (args.Parameters.Count < 3) { args.Player.SendMessage("Invalid usage: /rflag(/rf) set|del [region name] [flag]", Color.Red); return; } string regionname = args.Parameters[1]; string flag = args.Parameters[2]; FlaggedRegion reg = regions.getRegion(regionname); if (reg == null) { args.Player.SendMessage("Invalid region", Color.Red); return; } switch (args.Parameters[0]) { case "set": case "define": { Flags enumval; if (Flags.TryParse(flag.ToUpper(), out enumval)) { reg.SetFlags(enumval); if (!regions.UpdateRegion(regionname)) { args.Player.SendMessage("Region doesn't exist.", Color.Red); } args.Player.SendMessage(String.Format("Region '{0}' now has Flag '{1}'.", regionname, flag), Color.Green); } else { args.Player.SendMessage("Invalid flag", Color.Red); } break; } case "del": case "delete": { Flags enumval; if (Flags.TryParse(flag.ToUpper(), out enumval)) { reg.DelFlags(enumval); if (!regions.UpdateRegion(regionname)) { args.Player.SendMessage("Region doesn't exist.", Color.Red); } args.Player.SendMessage(String.Format("Flag '{0}' has been deleted from '{1}'.", flag, regionname), Color.Green); } else { args.Player.SendMessage("Invalid flag", Color.Red); } break; } } }