void LoadItems() { List <Item> items = new List <Item>(); foreach (var val in itemTypes) { if (!val.Value.Enabled) { continue; } GatherItems(val.Key, val.Value, items); } foreach (Item item in items) { try { api.RegisterItem(item); } catch (Exception e) { api.Server.LogError("Failed registering item {0}: {1}", item.Code, e); } } }
void LoadItems(List <RegistryObjectType>[] variantLists) { // Step2: create all the items from the itemtypes, and register them: this has to be on the main thread as the registry is not thread-safe LoadFromVariants(variantLists, "item", (variants) => { foreach (ItemType type in variants) { Item item = type.CreateItem(api); try { api.RegisterItem(item); } catch (Exception e) { api.Server.LogError("Failed registering item {0}: {1}", item.Code, e); } } }); }