From e14ba787d46b256ebbd27f8f9e5a71c1384fd7ac Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Fri, 3 Oct 2025 01:25:35 +0100 Subject: [PATCH] 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. --- SecondBotEvents/Commands/Inventory.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/SecondBotEvents/Commands/Inventory.cs b/SecondBotEvents/Commands/Inventory.cs index 61c819a..7f079c8 100644 --- a/SecondBotEvents/Commands/Inventory.cs +++ b/SecondBotEvents/Commands/Inventory.cs @@ -1124,16 +1124,13 @@ namespace SecondBotEvents.Commands List 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; }