Skip to main content

Mod Details

SPT Item Creator

SPT Item Creator 0.1.1

Created by Suntion

657 Downloads

SPT 4.0.13 Compatible

This mod simplifies SPT item creation and enables efficient expansion through interface encapsulation and comprehensive documentation.

Latest Version 0.1.1
SPT 4.0.13

Updated Apr 4, 2:30 PM

41.38 KB

Version Notes
English

Fixes

  • Populated FleaPriceRoubles, HandbookPriceRoubles, HandbookParentId field mappings during NewItem object initialization (#9)
  • Fixed validation logic defects for HandbookParentId in CreateItemFromClone and CreateNewItem, removed incorrect required checks (#10, #11, #12)
  • Fixed redundant parameter issue in AddItemToAssort method calls

Refactoring & Optimization

  • Removed legacy AbstractNewItem abstract base class and its subclasses (NewItemCommon, NewItemAmmo, NewItemDrinkOrFood, NewItemMedical)
  • Unified NewItem architecture: All item types now share the NewItem class, with property application determined by the assigned AbstractInfo instance
  • Marked AmmoInfo class as [Obsolete], planned for refactoring in a future version
  • Marked BaseInfo.IsHadInit property as [Obsolete], to be removed after version 0.2.0
  • Added NewItemExtensions extension class, implementing ToStringWithStatus() and ToIdNameString() methods for unified log formatting output
  • Removed unused dependency injections (ISptLogger, DatabaseService) from DataLoader constructor
  • Added [UsedImplicitly] attribute to INewItem.PropertyOverride property to eliminate warnings

Data Format Changes

  • Removed the $type field from item templates (backward compatible reading retained)
  • Type mechanism clarification: Item properties are determined by the actually assigned Info fields, independent of baseInfo.type
  • Data files now support JSONC comments (single-line // and multi-line /* */), added StripJsoncComments method to DataLoader with state machine parsing logic

New Features

  • Support for Chinese rarity keys (Common, Rare, Super Rare, Nonexistent)
  • Support for Chinese item sound keys
  • Support for ammunition type item validation

Configuration Updates

  • Added cacheInitialized configuration option to control cache initialization skipping and state persistence
  • Added alwaysUpdateCache configuration option to force cache updates
  • Added requiredItemIds configuration option to validate existence and enabled status of required items
  • See Mod Configuration documentation for details

Validation System

  • Built a unified validator system, implementing IValidator interface and chaining calls
  • Added BaseInfoValidator: validates required fields, MongoId format, type validity
  • Added AttributeInfoValidator: validates positive integer dimensions, rarity, sound type
  • Added BuffsInfoValidator: validates Buff effect configurations
  • Added MedicalInfoValidator, DrinkFoodInfoValidator, AmmoInfoValidator: respectively validate medical, food/drink, and ammunition configuration logic
  • Removed invalid negative weight validation logic
  • Enhanced error collector to carry item path information for easier problem localization

Architecture Optimization

  • Changed UpdateProperties and UpdateDatabaseService methods to protected, restricting external calls
  • Enhanced null validation logic for BaseInfo and BuffsInfo
  • Improved deserialization error logging, added complete exception stack traces
中文

修复问题

  • 补全 NewItem 对象初始化时的 FleaPriceRoubles、HandbookPriceRoubles、HandbookParentId 字段映射 (#9)
  • 修正 CreateItemFromClone 和 CreateNewItem 中的 HandbookParentId 验证逻辑缺陷,移除错误的必填检查 (#10, #11, #12)
  • 修正 AddItemToAssort 方法调用中冗余参数的问题

重构优化

  • 移除旧版 AbstractNewItem 抽象基类及其子类实现(NewItemCommon, NewItemAmmo, NewItemDrinkOrFood, NewItemMedical)
  • 统一 NewItem 架构:所有物品类型共用 NewItem 类,通过已赋值的 AbstractInfo 实例决定属性应用
  • 标记 AmmoInfo 类为 [Obsolete],计划后续版本重构
  • 标记 BaseInfo.IsHadInit 属性为 [Obsolete],将在 0.2.0 版本后移除
  • 新增 NewItemExtensions 扩展类,实现 ToStringWithStatus() 和 ToIdNameString() 方法,统一日志格式化输出
  • 清理 DataLoader 构造函数中未使用的依赖注入(ISptLogger、DatabaseService)
  • INewItem.PropertyOverride 属性添加 [UsedImplicitly] 特性以消除警告

数据格式变更

  • 移除物品模板中的 $type 字段(保留向后兼容读取)
  • 类型机制澄清:物品属性由实际赋值的 Info 字段决定,与 baseInfo.type 无关
  • 数据文件现支持 JSONC 注释(单行 // 和多行 /* */),DataLoader 增加 StripJsoncComments 方法及状态机解析逻辑

新功能

  • 支持中文稀有度键(普通、稀有、超级稀有、不存在)
  • 支持中文物品音效键
  • 支持弹药类型物品验证

配置更新

  • 新增 cacheInitialized 配置项,控制缓存初始化跳过及状态持久化
  • 新增 alwaysUpdateCache 配置项,强制更新缓存
  • 新增 requiredItemIds 配置项,验证必需物品存在性与启用状态
  • 详见模组配置文档

验证系统

  • 构建统一验证器系统,实现 IValidator 接口与链式调用
  • 新增 BaseInfoValidator:验证必需字段、MongoId 格式、类型合法性
  • 新增 AttributeInfoValidator:验证尺寸正整数、稀有度、音效类型
  • 新增 BuffsInfoValidator:验证 Buff 效果配置
  • 新增 MedicalInfoValidator、DrinkFoodInfoValidator、AmmoInfoValidator:分别验证医疗、饮食及弹药配置逻辑
  • 移除无效的负数重量校验逻辑
  • 增强错误收集器,支持携带物品路径信息以便定位问题

架构优化

  • 将 UpdateProperties 和 UpdateDatabaseService 方法改为 protected,限制外部调用
  • 增强 BaseInfo 和 BuffsInfo 的空值校验逻辑
  • 改进反序列化错误日志,添加完整异常堆栈信息
This download is externally hosted.
Always scan for viruses.
Required Dependency

This mod requires the following mod to be installed. Please download and install it before using this mod.

This download is externally hosted.
Always scan for viruses.
Description
6 Versions
3 Addons
20 Comments

Required Dependency

The latest version of this mod requires the following mod to be installed as well.

Notice: This mod may make permanent changes to your profile, and may not be removable without starting a new profile. More information.

Details