using System; using System.Collections.Generic; using System.Text; using BetterSecondBotShared.logs; using BetterSecondBotShared.Static; using OpenMetaverse; namespace BSB.Commands.CMD_Parcel { public class GetParcelFlags : CoreCommand { public override string[] ArgTypes { get { return new[] { "Smart", "String" }; } } public override string[] ArgHints { get { return new[] { "Smart reply [Channel|Avatar|http url]", "[Repeatable] flag name" }; } } public override int MinArgs { get { return 1; } } public override string Helpfile { get { return "Returns the value of the parcel flags (At the parcel on the bot is currently on)
" + "requested on [ARG 2+] via [ARG 1] smart reply target
" + "If you request multiple Flags they are split with CSV
You can also get all the flags skipping [ARG 2]

" + "" + helpers.create_dirty_table(parcel_static.get_flag_names()) + "

Example: getparcelflag|||0~#~ForSale
Example: getparcelflag|||12"; } } public override bool CallFunction(string[] args) { if (base.CallFunction(args) == true) { Dictionary flags = parcel_static.get_flags_list(); List get_flags = new List(); List otherargs = new List(args); string target = otherargs[0]; otherargs.RemoveAt(0); if (otherargs.Count == 0) { otherargs.Add("ALL"); } if (otherargs[0] == "ALL") { foreach (string A in flags.Keys) { get_flags.Add(A); } } else { foreach (string a in otherargs) { if (flags.ContainsKey(a) == true) { get_flags.Add(a); } else { ConsoleLog.Warn("Flag: " + a + " is unknown"); } } } if (get_flags.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]; StringBuilder reply = new StringBuilder(); string addon = ""; foreach (string cfg in get_flags) { if (flags.ContainsKey(cfg) == true) { reply.Append(addon); reply.Append(cfg); reply.Append("="); reply.Append(p.Flags.HasFlag(flags[cfg]).ToString()); addon = ","; } } return bot.GetCommandsInterface.SmartCommandReply(target, reply.ToString(), CommandName); } else { return Failed("Unable to find parcel in memory, please wait and try again"); } } else { return Failed("No accepted flags"); } } return false; } } }