Refactor inventory node loading logic

Simplifies the inventory node loading by replacing type checks with a string comparison on the entry type name. Removes redundant else-if block and ensures all entries are processed consistently.
This commit is contained in:
Madpeter 2025-10-03 01:25:35 +01:00
parent 70c1dcc86c
commit e14ba787d4

View file

@ -1124,16 +1124,13 @@ namespace SecondBotEvents.Commands
List<InventoryBase> folderlist = GetClient().Inventory.Store.GetContents(folder);
foreach (InventoryBase entry in folderlist)
{
if (entry is InventoryFolder)
string entrytype = entry.GetType().Name.Replace("Inventory", "");
if (entrytype == "Folder")
{
myentry.Children.Add(LoadInventoryNode(entry.UUID, entry.Name));
continue;
}
else if (entry is InventoryItem)
{
string entrytype = entry.GetType().Name.Replace("Inventory", "");
myentry.Children.Add(new InventoryNodeEntry() { Children = null, InventoryType = entrytype, Name = entry.Name, UUID = entry.UUID.ToString() });
}
myentry.Children.Add(new InventoryNodeEntry() { Children = null, InventoryType = entrytype, Name = entry.Name, UUID = entry.UUID.ToString() });
}
return myentry;
}