using System; using System.Collections.Generic; using BetterSecondBotShared.logs; using BetterSecondBotShared.Static; using OpenMetaverse; namespace BSB.Commands.CMD_Parcel { public class SetParcelFlag : ParcelCommand_RequirePerms_1arg { public override string[] ArgTypes { get { return new[] { "Text=True|False" }; } } public override string[] ArgHints { get { return new[] { "[Repeatable] flag args" }; } } public override string Helpfile { get { return "Sets the parcel flags of the parcel the bot is currently standing on
" + "Example:AllowFly=False~#~AllowDamage=True
" + helpers.create_dirty_table(parcel_static.get_flag_names()) +"
"; } } public override bool CallFunction(string[] args) { if (base.CallFunction(args) == true) { List acceptablewords = new List(); Dictionary flags = parcel_static.get_flags_list(); acceptablewords.AddRange(new[] { "True", "False" }); Dictionary setflags = new Dictionary(); foreach (string a in args) { string[] parts = a.Split('=',StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2) { if (flags.ContainsKey(parts[0]) == true) { if (acceptablewords.Contains(parts[1])) { setflags.Add(parts[0], Convert.ToBoolean(parts[1])); } else { LogFormater.Crit("Unable to set flag " + parts[0] + " to : " + parts[1] + ""); } } else { LogFormater.Warn("Flag: " + parts[0] + " is unknown"); } } else { LogFormater.Warn("Flag: " + a + " missing = True|False"); } } if (setflags.Count > 0) { int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); if (bot.GetClient.Network.CurrentSim.Parcels.ContainsKey(localid) == true) { Parcel p = bot.GetClient.Network.CurrentSim.Parcels[localid]; if (parcel_static.has_parcel_perm(p, bot) == true) { foreach (KeyValuePair cfg in setflags) { if (flags.ContainsKey(cfg.Key) == true) { parcel_static.ParcelSetFlag(flags[cfg.Key], p, cfg.Value); } } p.Update(bot.GetClient.Network.CurrentSim, false); return true; } else { return Failed("Incorrect perms to control parcel"); } } else { return Failed("Unable to find parcel in memory, please wait and try again"); } } else { return Failed("No accepted flags"); } } return false; } } }