Fix inventory link deduplication with AssetType.Link

This commit is contained in:
RebeccaNod1 2026-05-08 19:50:30 -06:00
parent a37bc42a0e
commit 9788254f6f

View file

@ -131,14 +131,24 @@ namespace BetterSecondBot.Static
{ {
if (contents.Count > 0) if (contents.Count > 0)
{ {
HashSet<UUID> seen = []; HashSet<UUID> seenIds = [];
foreach (InventoryBase item in contents) foreach (InventoryBase item in contents)
{ {
if (seen.Contains(item.UUID)) if (item is InventoryItem itm)
{
UUID effectiveID = itm.UUID;
// If it's a link, the AssetUUID is the UUID of the item it points to
if (itm.AssetType == AssetType.Link)
{
effectiveID = itm.AssetUUID;
}
if (seenIds.Contains(effectiveID))
{ {
continue; continue;
} }
seen.Add(item.UUID); seenIds.Add(effectiveID);
mapitem = new InventoryMapItem mapitem = new InventoryMapItem
{ {
name = item.Name, name = item.Name,
@ -147,6 +157,17 @@ namespace BetterSecondBot.Static
}; };
entrys.Add(mapitem); entrys.Add(mapitem);
} }
else if (item is InventoryFolder fold)
{
mapitem = new InventoryMapItem
{
name = fold.Name,
id = fold.UUID.ToString(),
typename = "Folder"
};
entrys.Add(mapitem);
}
}
} }
} }
return entrys; return entrys;