Skip to content

BossLock:1.4.5兼容修复 - #1212

Merged
ACaiCat merged 4 commits into
UnrealMultiple:masterfrom
yejiu0210:fix/bosslock-multipart-1211
Oct 31, 2026
Merged

ACaiCat merged 4 commits into
UnrealMultiple:masterfrom
yejiu0210:fix/bosslock-multipart-1211

Conversation

@yejiu0210

@yejiu0210 yejiu0210 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

修复多部位 Boss 的进度锁判定与生成拦截,关联 #1211。

  • 将骷髅王与手臂、机械骷髅王与武器、蠕虫体节等按完整 Boss 分组处理;兼容旧部位 ID 配置与记录,同组采用最晚解锁时间,列表合并展示,2 秒内合并重复拦截播报。分组使用 Terraria.ID.NPCID 命名常量。
  • 在骷髅王、血肉墙和 Boss 生成入口提前检查锁定状态;美杜莎生成前统一检查机械 Boss,避免部分生成及无效 NPC 索引异常。
  • 拦截时直接移除同组部位并同步,不触发死亡、掉落或击败进度。
  • 缺少解锁记录时保持锁定,支持通过 /bl edit 单独补齐;加载和重载不重置现有解锁时间。
  • /bl reset 先读取磁盘最新配置,再以事务替换记录;配置或写入异常时保留原记录。分组查询与删除均使用参数化 SQL。
  • 配置 NpcId 支持文档列出的中文 Boss 名称(例如“机械骷髅王”),兼容数字 ID 和数字字符串,写回时统一保存数字 ID;未知名称拒绝读取,不改动现有进度。
  • 版本更新至 2.0.0.6,补充配置与兼容行为说明。

Sourcery 摘要

完善多部位首领的统一进度锁定与安全生成拦截,同时增强配置兼容性和进度数据保护。

新功能:

  • 支持将多部位首领按完整首领统一管理进度,并兼容部位 ID 的旧配置和记录。
  • 支持在配置中使用中文首领名称、数字 ID 或数字字符串,并统一保存为数字 ID。

问题修复:

  • 修复多部位首领的锁定判定、生成拦截及组合召唤场景下的异常问题。
  • 修复缺失进度记录时错误放行、重复拦截播报,以及拦截后触发死亡或击败进度的问题。

改进:

  • 改进进度列表的分组展示、同组解锁时间合并和独立进度补齐能力。
  • 使配置重载保留现有解锁时间,并让重置操作在配置读取或写入失败时保留原有进度。

文档:

  • 补充多部位首领、配置别名及兼容行为说明。

杂项:

  • 将插件版本更新至 2.0.0.6。
Original summary in English

Sourcery 总结

强化多部件 Boss 和复合 Boss 的进度锁定机制,同时保留现有配置和解锁数据。

新功能:

  • 支持对多部件 Boss 进行分组进度锁定,同时兼容旧版身体部位 ID 和记录。
  • 配置中支持使用已记录的中文 Boss 名称、数字 ID 和数字字符串,并将保存的 ID 规范化为数字。

错误修复:

  • 防止被锁定的 Boss 和复合机械 Boss 召唤物部分生成,或导致无效的 NPC 索引访问。
  • 移除被阻止生成的 Boss 分组时,不触发死亡、掉落或击败进度,并合并重复通知。
  • 配置加载或重置写入失败时保留现有进度;缺失的解锁记录在修复前仍保持锁定。

改进:

  • 聚合分组 Boss 记录和显示时采用最新解锁时间,并优先保留永久锁定状态。
  • 新增事务式进度替换和参数化分组数据库操作。
  • 重新加载后保留解锁时间,并提供更清晰的配置与兼容性说明。

文档:

  • 说明多部件 Boss 分组、配置别名、兼容行为、重置与重新加载语义,以及支持的 Boss 名称。

杂项:

  • 将插件版本更新至 2.0.0.6。
Original summary in English

Sourcery 总结

加强了多部分首领的进度锁定和召唤拦截,同时提升配置兼容性并保护现有进度数据。

新功能:

  • 为多部分首领添加统一的进度锁定组,同时兼容旧版部件 ID 和记录。
  • 配置支持中文首领名称别名、数字 ID 和数字字符串,并以规范的数字格式进行序列化。

错误修复:

  • 防止被锁定的多部分首领和组合首领只生成部分实体,或导致 NPC 索引无效错误。
  • 缺失进度记录时仍保持锁定,抑制重复的锁定通知,并防止被拦截的生成操作触发死亡、掉落或击败进度。

改进:

  • 按完整首领对进度显示和查询进行分组,采用最新解锁时间并保留永久锁定状态。
  • 重新加载时保留现有解锁时间,并允许通过编辑单独完成进度。

文档:

  • 记录多部分首领行为、支持的配置别名、兼容性规则,以及安全的重置和重新加载行为。

杂项:

  • 将插件版本更新至 2.0.0.6。
Original summary in English

Sourcery 摘要

强化多部位与复合 Boss 的统一进度锁定和安全生成拦截,同时提升配置兼容性与进度数据保护。

新功能:

  • 统一按完整首领分组管理多部位 Boss 的进度锁,并兼容旧版部位配置与记录。
  • 支持在配置中使用中文 Boss 名称、数字 ID 和数字字符串,并规范化为数字 ID 保存。

错误修复:

  • 修复复合及多部位 Boss 被锁定时出现的部分生成、无效索引,以及拦截后触发死亡或击败进度的问题。
  • 修复缺少进度记录时错误放行,以及重复发送拦截通知的问题。

改进:

  • 改进 Boss 进度的分组查询、展示与时间合并,并在重新加载时保留现有解锁时间。
  • 增强进度编辑与重置的数据保护,在读取或写入配置失败时保留原有记录。

文档:

  • 补充多部位 Boss、配置别名及进度兼容行为的说明。

杂项:

  • 将插件版本更新至 2.0.0.6。
Original summary in English

Summary by Sourcery

强化多部位与复合 Boss 的统一进度锁定和安全生成拦截,同时提升配置兼容性与进度数据保护。

New Features:

  • 统一按完整首领分组管理多部位 Boss 的进度锁,并兼容旧部位配置与记录。
  • 支持在配置中使用中文 Boss 名称、数字 ID 和数字字符串,并规范化保存为数字 ID。

Bug Fixes:

  • 修复复合及多部位 Boss 被锁定时的部分生成、无效索引和拦截后触发死亡或击败进度问题。
  • 修复缺少进度记录时错误放行及重复拦截通知问题。

Enhancements:

  • 改进 Boss 进度的分组查询、展示与时间合并,并保留重载时的现有解锁时间。
  • 增强进度编辑与重置的数据保护,在配置读取或写入失败时保留原有记录。

Documentation:

  • 补充多部位 Boss、配置别名及进度兼容行为说明。

Chores:

  • 将插件版本更新至 2.0.0.6。

@yejiu0210
yejiu0210 requested a review from a team as a code owner October 31, 2026 05:04

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好 - 我发现了 1 个安全问题

安全问题:

  • 在 SQL 语句中检测到格式化字符串。如果未正确清理 SQL 语句中的变量,可能会导致 SQL 注入。请改用预处理语句。你可以使用“SqlCommand”和“SqlParameter”获取 PreparedStatement。(链接)
Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/BossLock/Database.cs" line_range="146-147" />
<code_context>
        command.CommandText = replaceAll ? "DELETE FROM boss_lock;"
            : $"DELETE FROM boss_lock WHERE npc_id IN ({string.Join(',', rows.Keys.SelectMany(BossGroup.Members).Distinct())});";
</code_context>
<issue_to_address>
**security (csharp.lang.security.sqli.csharp-sqli):** Detected a formatted string in a SQL statement. This could lead to SQL injection if variables in the SQL statement are not properly sanitized. Use a prepared statements instead. You can obtain a PreparedStatement using 'SqlCommand' and 'SqlParameter'.

*Source: opengrep*
</issue_to_address>

Sourcery 对开源项目免费使用——如果你喜欢我们的评审,请考虑分享 ✨
Original comment in English

Hey - I've found 1 security issue

Security issues:

  • Detected a formatted string in a SQL statement. This could lead to SQL injection if variables in the SQL statement are not properly sanitized. Use a prepared statements instead. You can obtain a PreparedStatement using 'SqlCommand' and 'SqlParameter'. (link)
Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/BossLock/Database.cs" line_range="146-147" />
<code_context>
        command.CommandText = replaceAll ? "DELETE FROM boss_lock;"
            : $"DELETE FROM boss_lock WHERE npc_id IN ({string.Join(',', rows.Keys.SelectMany(BossGroup.Members).Distinct())});";
</code_context>
<issue_to_address>
**security (csharp.lang.security.sqli.csharp-sqli):** Detected a formatted string in a SQL statement. This could lead to SQL injection if variables in the SQL statement are not properly sanitized. Use a prepared statements instead. You can obtain a PreparedStatement using 'SqlCommand' and 'SqlParameter'.

*Source: opengrep*
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/BossLock/Database.cs Resolved
@yejiu0210 yejiu0210 closed this Oct 31, 2026
@yejiu0210 yejiu0210 reopened this Oct 31, 2026
// 配置别名不依赖服务器的显示语言;写回时统一保存数字 ID。
public sealed class NpcIdConverter : JsonConverter<int>
{
private static readonly Dictionary<string, int> Names = new(StringComparer.OrdinalIgnoreCase)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方支持一下本地化,可以用GetString

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好——我已经审查了你的更改,整体看起来很棒!


Sourcery 对开源项目免费——如果你喜欢我们的评审,欢迎考虑分享 ✨
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好——我发现了 2 个问题

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/BossLock/NpcIdConverter.cs" line_range="50-52" />
<code_context>
+    public override int ReadJson(JsonReader reader, Type objectType, int existingValue,
+        bool hasExistingValue, JsonSerializer serializer)
+    {
+        if (reader.TokenType == JsonToken.Integer && reader.Value is long number &&
+            number >= 0 && number < NPCID.Count)
+        {
+            return (int)number;
+        }
</code_context>
<issue_to_address>
**Numeric NPC IDs are rejected**

When the JSON `NpcId` is an ordinary in-range integer token, `JsonTextReader` supplies ordinary in-range integer tokens as boxed `int` values, so the `reader.Value is long` check fails and `NpcIdConverter` throws; `Config.Read` then fails to load configurations that use numeric `NpcId` values, including existing configs.

Accept the integer representations returned by the JSON reader, or convert the token with a checked integer conversion.
</issue_to_address>

### Comment 2
<location path="src/BossLock/BossGroup.cs" line_range="22" />
<code_context>
+        [NPCID.Pumpking, NPCID.PumpkingBlade],
+        [NPCID.MartianSaucerCore, NPCID.MartianSaucer, NPCID.MartianSaucerTurret, NPCID.MartianSaucerCannon],
+        [NPCID.MoonLordCore, NPCID.MoonLordHead, NPCID.MoonLordHand, NPCID.MoonLordFreeEye],
+        [NPCID.CultistBoss, NPCID.CultistBossClone],
+        [NPCID.PirateShip, NPCID.PirateShipCannon]
+    ];
</code_context>
<issue_to_address>
**Moon Lord leech blobs bypass locks**

When a leech blob is spawned while the Moon Lord is configured as locked, `BossGroup.Root` leaves `MoonLordLeechBlob` ungrouped, so `SpawnGuard.IsBlocked` does not associate that Moon Lord component with a configured `MoonLordCore` lock and allows it to spawn. The component therefore escapes the group-wide lock and cleanup behavior.

Add `NPCID.MoonLordLeechBlob` to the Moon Lord group so lock checks and removal use the Moon Lord root.
</issue_to_address>

Sourcery 对开源项目免费——如果你喜欢我们的评审,欢迎分享 ✨
Original comment in English

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/BossLock/NpcIdConverter.cs" line_range="50-52" />
<code_context>
+    public override int ReadJson(JsonReader reader, Type objectType, int existingValue,
+        bool hasExistingValue, JsonSerializer serializer)
+    {
+        if (reader.TokenType == JsonToken.Integer && reader.Value is long number &&
+            number >= 0 && number < NPCID.Count)
+        {
+            return (int)number;
+        }
</code_context>
<issue_to_address>
**Numeric NPC IDs are rejected**

When the JSON `NpcId` is an ordinary in-range integer token, `JsonTextReader` supplies ordinary in-range integer tokens as boxed `int` values, so the `reader.Value is long` check fails and `NpcIdConverter` throws; `Config.Read` then fails to load configurations that use numeric `NpcId` values, including existing configs.

Accept the integer representations returned by the JSON reader, or convert the token with a checked integer conversion.
</issue_to_address>

### Comment 2
<location path="src/BossLock/BossGroup.cs" line_range="22" />
<code_context>
+        [NPCID.Pumpking, NPCID.PumpkingBlade],
+        [NPCID.MartianSaucerCore, NPCID.MartianSaucer, NPCID.MartianSaucerTurret, NPCID.MartianSaucerCannon],
+        [NPCID.MoonLordCore, NPCID.MoonLordHead, NPCID.MoonLordHand, NPCID.MoonLordFreeEye],
+        [NPCID.CultistBoss, NPCID.CultistBossClone],
+        [NPCID.PirateShip, NPCID.PirateShipCannon]
+    ];
</code_context>
<issue_to_address>
**Moon Lord leech blobs bypass locks**

When a leech blob is spawned while the Moon Lord is configured as locked, `BossGroup.Root` leaves `MoonLordLeechBlob` ungrouped, so `SpawnGuard.IsBlocked` does not associate that Moon Lord component with a configured `MoonLordCore` lock and allows it to spawn. The component therefore escapes the group-wide lock and cleanup behavior.

Add `NPCID.MoonLordLeechBlob` to the Moon Lord group so lock checks and removal use the Moon Lord root.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/BossLock/NpcIdConverter.cs Resolved
Comment thread src/BossLock/BossGroup.cs Resolved
@ACaiCat
ACaiCat enabled auto-merge October 31, 2026 05:43
@ACaiCat ACaiCat linked an issue Oct 31, 2026 that may be closed by this pull request
2 tasks done
@ACaiCat
ACaiCat added this pull request to the merge queue Oct 31, 2026
Merged via the queue into UnrealMultiple:master with commit 2be7e2b Oct 31, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] BossLock骷髅王禁止生成无效

2 participants