shared codeblock updates

This commit is contained in:
Madpeter 2020-04-29 03:43:17 +01:00
parent 1ff8fd7228
commit a4deb6857a
9 changed files with 190 additions and 334 deletions

View file

@ -8,7 +8,7 @@ using OpenMetaverse;
namespace BSB.Commands.CMD_Parcel namespace BSB.Commands.CMD_Parcel
{ {
public class AbandonLand : CoreCommand public class AbandonLand : ParcelCommand_RequirePerms
{ {
public override string Helpfile { get { return "Abandons the parcel the bot is currently on, returning it to Linden's or Estate owner"; } } public override string Helpfile { get { return "Abandons the parcel the bot is currently on, returning it to Linden's or Estate owner"; } }
@ -16,25 +16,9 @@ namespace BSB.Commands.CMD_Parcel
{ {
if (base.CallFunction(args) == true) if (base.CallFunction(args) == true)
{ {
int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); bot.GetClient.Parcels.ReleaseParcel(bot.GetClient.Network.CurrentSim, targetparcel.LocalID);
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)
{
bot.GetClient.Parcels.ReleaseParcel(bot.GetClient.Network.CurrentSim, localid);
return true; return true;
} }
else
{
return Failed("Incorrect perms to control parcel");
}
}
else
{
return Failed("Unable to find parcel in memory, please wait and try again");
}
}
return false; return false;
} }
} }

View file

@ -8,26 +8,15 @@ using OpenMetaverse;
namespace BSB.Commands.CMD_Parcel namespace BSB.Commands.CMD_Parcel
{ {
public class GetParcelDesc : CoreCommand public class GetParcelDesc : ParcelCommand_CheckParcel_1arg_smart
{ {
public override string[] ArgTypes { get { return new[] { "Smart"}; } }
public override string[] ArgHints { get { return new[] { "Smart reply [Channel|Avatar|http url]" }; } }
public override int MinArgs { get { return 1; } }
public override string Helpfile { get { return "Fetchs the current parcels desc and sends it to the smart reply target on [ARG 1]"; } } public override string Helpfile { get { return "Fetchs the current parcels desc and sends it to the smart reply target on [ARG 1]"; } }
public override bool CallFunction(string[] args) public override bool CallFunction(string[] args)
{ {
if (base.CallFunction(args) == true) if (base.CallFunction(args) == true)
{ {
int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); return bot.GetCommandsInterface.SmartCommandReply(args[0], targetparcel.Desc, CommandName);
if (bot.GetClient.Network.CurrentSim.Parcels.ContainsKey(localid) == true)
{
return bot.GetCommandsInterface.SmartCommandReply(args[0], bot.GetClient.Network.CurrentSim.Parcels[localid].Desc, CommandName);
}
else
{
return Failed("Unable to find parcel in memory, please wait and try again");
}
} }
return false; return false;
} }

View file

@ -8,26 +8,15 @@ using OpenMetaverse;
namespace BSB.Commands.CMD_Parcel namespace BSB.Commands.CMD_Parcel
{ {
public class GetParcelName : CoreCommand public class GetParcelName : ParcelCommand_CheckParcel_1arg_smart
{ {
public override string[] ArgTypes { get { return new[] { "Smart"}; } }
public override string[] ArgHints { get { return new[] { "Smart reply [Channel|Avatar|http url]" }; } }
public override int MinArgs { get { return 1; } }
public override string Helpfile { get { return "Fetchs the current parcels name and sends it to the smart reply target on [ARG 1]"; } } public override string Helpfile { get { return "Fetchs the current parcels name and sends it to the smart reply target on [ARG 1]"; } }
public override bool CallFunction(string[] args) public override bool CallFunction(string[] args)
{ {
if (base.CallFunction(args) == true) if (base.CallFunction(args) == true)
{ {
int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); return bot.GetCommandsInterface.SmartCommandReply(args[0], targetparcel.Name, CommandName);
if (bot.GetClient.Network.CurrentSim.Parcels.ContainsKey(localid) == true)
{
return bot.GetCommandsInterface.SmartCommandReply(args[0], bot.GetClient.Network.CurrentSim.Parcels[localid].Name, CommandName);
}
else
{
return Failed("Unable to find parcel in memory, please wait and try again");
}
} }
return false; return false;
} }

View file

@ -6,7 +6,7 @@ using System.Text;
namespace BSB.Commands.CMD_Parcel namespace BSB.Commands.CMD_Parcel
{ {
class ParcelBuy : CoreCommand class ParcelBuy : ParcelCommand_CheckParcel
{ {
public override string[] ArgTypes { get { return new[] { "Number" }; } } public override string[] ArgTypes { get { return new[] { "Number" }; } }
public override string[] ArgHints { get { return new[] { "expected price to pay" }; } } public override string[] ArgHints { get { return new[] { "expected price to pay" }; } }
@ -16,18 +16,14 @@ namespace BSB.Commands.CMD_Parcel
{ {
if (base.CallFunction(args) == true) if (base.CallFunction(args) == true)
{ {
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];
int expected_price = -1; int expected_price = -1;
if (args.Length == 1) if (args.Length == 1)
{ {
int.TryParse(args[0], out expected_price); int.TryParse(args[0], out expected_price);
} }
if ((p.SalePrice == expected_price) || (expected_price == -1)) if ((targetparcel.SalePrice == expected_price) || (expected_price == -1))
{ {
bot.GetClient.Parcels.Buy(bot.GetClient.Network.CurrentSim, localid, false, UUID.Zero, false, p.Area, p.SalePrice); bot.GetClient.Parcels.Buy(bot.GetClient.Network.CurrentSim, targetparcel.LocalID, false, UUID.Zero, false, targetparcel.Area, targetparcel.SalePrice);
return true; return true;
} }
else else
@ -35,11 +31,6 @@ namespace BSB.Commands.CMD_Parcel
return Failed("Expected price is not -1 or matchs: " + expected_price.ToString() + ""); return Failed("Expected price is not -1 or matchs: " + expected_price.ToString() + "");
} }
} }
else
{
return Failed("Unable to find parcel in memory, please wait and try again");
}
}
return false; return false;
} }
} }

View file

@ -1,55 +1,22 @@
using System; using System.Threading;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using BetterSecondBotShared.logs;
using BetterSecondBotShared.Static;
using OpenMetaverse; using OpenMetaverse;
namespace BSB.Commands.CMD_Parcel namespace BSB.Commands.CMD_Parcel
{ {
public class ParcelDeedToGroup : ParcelCommand_RequirePerms_1arg_Group
public class ParcelDeedToGroup : CoreCommand
{ {
public override string[] ArgTypes { get { return new[] { "UUID" }; } }
public override string[] ArgHints { get { return new[] { "Group UUID" }; } }
public override int MinArgs { get { return 1; } }
public override string Helpfile { get { return "transfers the current parcel ownership to a group"; } } public override string Helpfile { get { return "transfers the current parcel ownership to a group"; } }
public override bool CallFunction(string[] args) public override bool CallFunction(string[] args)
{ {
if (base.CallFunction(args) == true) if (base.CallFunction(args) == true)
{ {
if (UUID.TryParse(args[0], out UUID groupuuid) == true) targetparcel.GroupID = groupuuid;
{ targetparcel.Update(bot.GetClient.Network.CurrentSim, false);
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)
{
p.GroupID = groupuuid;
p.Update(bot.GetClient.Network.CurrentSim, false);
Thread.Sleep(1000); Thread.Sleep(1000);
bot.GetClient.Parcels.DeedToGroup(bot.GetClient.Network.CurrentSim, localid, groupuuid); bot.GetClient.Parcels.DeedToGroup(bot.GetClient.Network.CurrentSim, targetparcel.LocalID, groupuuid);
return true; 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("Unable to process group uuid");
}
}
return false; return false;
} }
} }

View file

@ -5,7 +5,7 @@ using System.Text;
namespace BSB.Commands.CMD_Parcel namespace BSB.Commands.CMD_Parcel
{ {
class ParcelReturnTargeted : CoreCommand class ParcelReturnTargeted : ParcelCommand_RequirePerms
{ {
public override string[] ArgTypes { get { return new[] { "Avatar" }; } } public override string[] ArgTypes { get { return new[] { "Avatar" }; } }
public override string[] ArgHints { get { return new[] { "Avatar [UUID or Firstname Lastname]" }; } } public override string[] ArgHints { get { return new[] { "Avatar [UUID or Firstname Lastname]" }; } }
@ -18,26 +18,10 @@ namespace BSB.Commands.CMD_Parcel
{ {
if (UUID.TryParse(args[0], out UUID avatarUUID) == true) if (UUID.TryParse(args[0], out UUID avatarUUID) == true)
{ {
int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); bot.GetClient.Parcels.ReturnObjects(bot.GetClient.Network.CurrentSim, targetparcel.LocalID, ObjectReturnType.None, new List<UUID>() { avatarUUID });
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)
{
bot.GetClient.Parcels.ReturnObjects(bot.GetClient.Network.CurrentSim, localid, ObjectReturnType.None, new List<UUID>() { avatarUUID });
return true; return true;
} }
else else
{
return Failed("Parcel perm check failed");
}
}
else
{
return Failed("Unable to find parcel in memory, please wait and try again");
}
}
else
{ {
return Failed("Invaild avatar UUID"); return Failed("Invaild avatar UUID");
} }

View file

@ -6,7 +6,7 @@ using System.Text;
namespace BSB.Commands.CMD_Parcel namespace BSB.Commands.CMD_Parcel
{ {
class ParcelSetMedia : CoreCommand class ParcelSetMedia : ParcelCommand_RequirePerms
{ {
public override string[] ArgTypes { get { return new[] { "Flag [Repeatable]" }; } } public override string[] ArgTypes { get { return new[] { "Flag [Repeatable]" }; } }
public override string[] ArgHints { get { return new[] { "See flags table" }; } } public override string[] ArgHints { get { return new[] { "See flags table" }; } }
@ -16,12 +16,6 @@ namespace BSB.Commands.CMD_Parcel
public override bool CallFunction(string[] args) public override bool CallFunction(string[] args)
{ {
if (base.CallFunction(args) == true) if (base.CallFunction(args) == true)
{
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)
{ {
bool all_flags_ok = true; bool all_flags_ok = true;
string why_failed = ""; string why_failed = "";
@ -38,25 +32,25 @@ namespace BSB.Commands.CMD_Parcel
{ {
if (bits[1] == "IMG-PNG") if (bits[1] == "IMG-PNG")
{ {
p.Media.MediaType = "image/png"; targetparcel.Media.MediaType = "image/png";
} }
else if (bits[1] == "IMG-JPG") else if (bits[1] == "IMG-JPG")
{ {
p.Media.MediaType = "image/jpeg"; targetparcel.Media.MediaType = "image/jpeg";
} }
else if (bits[1] == "VID-MP4") else if (bits[1] == "VID-MP4")
{ {
p.Media.MediaType = "video/mp4"; targetparcel.Media.MediaType = "video/mp4";
} }
else if (bits[1] == "VID-AVI") else if (bits[1] == "VID-AVI")
{ {
p.Media.MediaType = "video/x-msvideo"; targetparcel.Media.MediaType = "video/x-msvideo";
} }
else if (bits[1].StartsWith("Custom-") == true) else if (bits[1].StartsWith("Custom-") == true)
{ {
string mime = bits[1]; string mime = bits[1];
mime = mime.Replace("Custom-", ""); mime = mime.Replace("Custom-", "");
p.Media.MediaType = mime; targetparcel.Media.MediaType = mime;
} }
else else
{ {
@ -73,11 +67,11 @@ namespace BSB.Commands.CMD_Parcel
{ {
if (bits[0] == "MediaHeight") if (bits[0] == "MediaHeight")
{ {
p.Media.MediaHeight = size; targetparcel.Media.MediaHeight = size;
} }
else if (bits[0] == "MediaWidth") else if (bits[0] == "MediaWidth")
{ {
p.Media.MediaWidth = size; targetparcel.Media.MediaWidth = size;
} }
else else
{ {
@ -99,7 +93,7 @@ namespace BSB.Commands.CMD_Parcel
{ {
if (UUID.TryParse(bits[1], out UUID texture) == true) if (UUID.TryParse(bits[1], out UUID texture) == true)
{ {
p.Media.MediaID = texture; targetparcel.Media.MediaID = texture;
} }
else else
{ {
@ -109,19 +103,19 @@ namespace BSB.Commands.CMD_Parcel
} }
case "MediaURL": case "MediaURL":
{ {
p.Media.MediaURL = bits[1]; targetparcel.Media.MediaURL = bits[1];
break; break;
} }
case "MediaDesc": case "MediaDesc":
{ {
p.Media.MediaDesc = bits[1]; targetparcel.Media.MediaDesc = bits[1];
break; break;
} }
case "MediaAutoScale": case "MediaAutoScale":
{ {
if (bool.TryParse(bits[1], out bool output) == true) if (bool.TryParse(bits[1], out bool output) == true)
{ {
p.Media.MediaAutoScale = output; targetparcel.Media.MediaAutoScale = output;
} }
else else
{ {
@ -133,7 +127,7 @@ namespace BSB.Commands.CMD_Parcel
{ {
if (bool.TryParse(bits[1], out bool output) == true) if (bool.TryParse(bits[1], out bool output) == true)
{ {
p.Media.MediaLoop = output; targetparcel.Media.MediaLoop = output;
} }
else else
{ {
@ -166,7 +160,7 @@ namespace BSB.Commands.CMD_Parcel
} }
if (all_flags_ok == true) if (all_flags_ok == true)
{ {
p.Update(bot.GetClient.Network.CurrentSim, false); targetparcel.Update(bot.GetClient.Network.CurrentSim, false);
return true; return true;
} }
else else
@ -174,16 +168,6 @@ namespace BSB.Commands.CMD_Parcel
return Failed(why_failed); return Failed(why_failed);
} }
} }
else
{
return Failed("Do not have expected perms for this parcel!");
}
}
else
{
return Failed("Unable to find parcel in memory, please wait and try again");
}
}
return false; return false;
} }
} }

View file

@ -8,7 +8,7 @@ using OpenMetaverse;
namespace BSB.Commands.CMD_Parcel namespace BSB.Commands.CMD_Parcel
{ {
public class SetParcelDesc : CoreCommand public class SetParcelDesc : ParcelCommand_RequirePerms
{ {
public override string[] ArgTypes { get { return new[] { "String" }; } } public override string[] ArgTypes { get { return new[] { "String" }; } }
public override string[] ArgHints { get { return new[] { "The new desc" }; } } public override string[] ArgHints { get { return new[] { "The new desc" }; } }
@ -19,26 +19,10 @@ namespace BSB.Commands.CMD_Parcel
{ {
if (base.CallFunction(args) == true) if (base.CallFunction(args) == true)
{ {
int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); targetparcel.Desc = args[0];
if (bot.GetClient.Network.CurrentSim.Parcels.ContainsKey(localid) == true) targetparcel.Update(bot.GetClient.Network.CurrentSim, false);
{
Parcel p = bot.GetClient.Network.CurrentSim.Parcels[localid];
if (parcel_static.has_parcel_perm(p, bot) == true)
{
p.Desc = args[0];
p.Update(bot.GetClient.Network.CurrentSim, false);
return true; return true;
} }
else
{
return Failed("Incorrect perms to control parcel");
}
}
else
{
return Failed("Unable to find parcel in memory, please wait and try again");
}
}
return false; return false;
} }
} }

View file

@ -8,7 +8,7 @@ using OpenMetaverse;
namespace BSB.Commands.CMD_Parcel namespace BSB.Commands.CMD_Parcel
{ {
public class SetParcelSale : CoreCommand public class SetParcelSale : ParcelCommand_RequirePerms
{ {
public override string[] ArgTypes { get { return new[] { "Number","Avatar" }; } } public override string[] ArgTypes { get { return new[] { "Number","Avatar" }; } }
public override string[] ArgHints { get { return new[] { "L$ amount to mark the parcel for sale as (Range: 1 to 99999 unless [ARG 2] is set)", "Avatar who can buy the land (If set allows you to set the sell price to zero)" }; } } public override string[] ArgHints { get { return new[] { "L$ amount to mark the parcel for sale as (Range: 1 to 99999 unless [ARG 2] is set)", "Avatar who can buy the land (If set allows you to set the sell price to zero)" }; } }
@ -19,12 +19,6 @@ namespace BSB.Commands.CMD_Parcel
public override bool CallFunction(string[] args) public override bool CallFunction(string[] args)
{ {
if (base.CallFunction(args) == true) if (base.CallFunction(args) == true)
{
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)
{ {
if (int.TryParse(args[0], out int price) == true) if (int.TryParse(args[0], out int price) == true)
{ {
@ -41,11 +35,11 @@ namespace BSB.Commands.CMD_Parcel
{ {
if (price <= 99999) if (price <= 99999)
{ {
p.SalePrice = price; targetparcel.SalePrice = price;
p.AuthBuyerID = target_buyer; targetparcel.AuthBuyerID = target_buyer;
parcel_static.ParcelSetFlag(ParcelFlags.ForSale, p, true); parcel_static.ParcelSetFlag(ParcelFlags.ForSale, targetparcel, true);
parcel_static.ParcelSetFlag(ParcelFlags.ForSaleObjects, p, false); parcel_static.ParcelSetFlag(ParcelFlags.ForSaleObjects, targetparcel, false);
p.Update(bot.GetClient.Network.CurrentSim, false); targetparcel.Update(bot.GetClient.Network.CurrentSim, false);
return true; return true;
} }
else else
@ -63,16 +57,6 @@ namespace BSB.Commands.CMD_Parcel
return Failed("Unable to process price"); return Failed("Unable to process price");
} }
} }
else
{
return Failed("Incorrect perms to control parcel");
}
}
else
{
return Failed("Unable to find parcel in memory, please wait and try again");
}
}
return false; return false;
} }
} }