2007-11-06 09:26:10 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2008-07-21 21:12:59 +00:00
|
|
|
namespace OpenMetaverse.TestClient
|
2007-11-06 09:26:10 +00:00
|
|
|
{
|
|
|
|
|
public class ObjectInventoryCommand : Command
|
|
|
|
|
{
|
|
|
|
|
public ObjectInventoryCommand(TestClient testClient)
|
|
|
|
|
{
|
|
|
|
|
Name = "objectinventory";
|
|
|
|
|
Description = "Retrieves a listing of items inside an object (task inventory). Usage: objectinventory [objectID]";
|
2008-07-25 08:55:36 +00:00
|
|
|
Category = CommandCategory.Inventory;
|
2007-11-06 09:26:10 +00:00
|
|
|
}
|
|
|
|
|
|
2008-07-25 05:15:05 +00:00
|
|
|
public override string Execute(string[] args, UUID fromAgentID)
|
2007-11-06 09:26:10 +00:00
|
|
|
{
|
|
|
|
|
if (args.Length != 1)
|
|
|
|
|
return "Usage: objectinventory [objectID]";
|
|
|
|
|
|
|
|
|
|
uint objectLocalID;
|
2008-07-25 05:15:05 +00:00
|
|
|
UUID objectID;
|
|
|
|
|
if (!UUID.TryParse(args[0], out objectID))
|
2007-11-06 09:26:10 +00:00
|
|
|
return "Usage: objectinventory [objectID]";
|
|
|
|
|
|
2020-05-09 12:59:06 -05:00
|
|
|
Primitive found = Client.Network.CurrentSim.ObjectsPrimitives.Find(prim => prim.ID == objectID);
|
2007-11-06 09:26:10 +00:00
|
|
|
if (found != null)
|
|
|
|
|
objectLocalID = found.LocalID;
|
|
|
|
|
else
|
2022-02-25 19:38:11 -06:00
|
|
|
return "Couldn't find prim " + objectID;
|
2007-11-06 09:26:10 +00:00
|
|
|
|
2008-08-21 01:19:06 +00:00
|
|
|
List<InventoryBase> items = Client.Inventory.GetTaskInventory(objectID, objectLocalID, 1000 * 30);
|
2007-11-06 09:26:10 +00:00
|
|
|
|
|
|
|
|
if (items != null)
|
|
|
|
|
{
|
2022-02-25 19:38:11 -06:00
|
|
|
string result = string.Empty;
|
2007-11-06 09:26:10 +00:00
|
|
|
|
2021-07-25 11:10:52 -05:00
|
|
|
foreach (var i in items)
|
2007-11-06 09:26:10 +00:00
|
|
|
{
|
2021-07-25 11:10:52 -05:00
|
|
|
if (i is InventoryFolder)
|
2008-08-21 01:19:06 +00:00
|
|
|
{
|
2021-07-25 11:10:52 -05:00
|
|
|
result += $"[Folder] Name: {i.Name}" + Environment.NewLine;
|
2008-08-21 01:19:06 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-07-25 11:10:52 -05:00
|
|
|
InventoryItem item = (InventoryItem)i;
|
|
|
|
|
result += $"[Item] Name: {item.Name} Desc: {item.Description} Type: {item.AssetType}" + Environment.NewLine;
|
2008-08-21 01:19:06 +00:00
|
|
|
}
|
2007-11-06 09:26:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "Failed to download task inventory for " + objectLocalID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|