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:
parent
70c1dcc86c
commit
e14ba787d4
1 changed files with 4 additions and 7 deletions
|
|
@ -1124,16 +1124,13 @@ namespace SecondBotEvents.Commands
|
||||||
List<InventoryBase> folderlist = GetClient().Inventory.Store.GetContents(folder);
|
List<InventoryBase> folderlist = GetClient().Inventory.Store.GetContents(folder);
|
||||||
foreach (InventoryBase entry in folderlist)
|
foreach (InventoryBase entry in folderlist)
|
||||||
{
|
{
|
||||||
|
string entrytype = entry.GetType().Name.Replace("Inventory", "");
|
||||||
if (entry is InventoryFolder)
|
if (entrytype == "Folder")
|
||||||
{
|
{
|
||||||
myentry.Children.Add(LoadInventoryNode(entry.UUID, entry.Name));
|
myentry.Children.Add(LoadInventoryNode(entry.UUID, entry.Name));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (entry is InventoryItem)
|
myentry.Children.Add(new InventoryNodeEntry() { Children = null, InventoryType = entrytype, Name = entry.Name, UUID = entry.UUID.ToString() });
|
||||||
{
|
|
||||||
string entrytype = entry.GetType().Name.Replace("Inventory", "");
|
|
||||||
myentry.Children.Add(new InventoryNodeEntry() { Children = null, InventoryType = entrytype, Name = entry.Name, UUID = entry.UUID.ToString() });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return myentry;
|
return myentry;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue