Skip to content

feat: 新增插件 HerbBloom / BottleRefund / NurseHeal;TerraNews 草药提醒 - #1215

Merged
ACaiCat merged 5 commits into
UnrealMultiple:masterfrom
zlqd123:pr/add-new-plugins
Nov 9, 2026
Merged

ACaiCat merged 5 commits into
UnrealMultiple:masterfrom
zlqd123:pr/add-new-plugins

Conversation

@zlqd123

@zlqd123 zlqd123 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

新增 3 个自研插件 + 2 个更新(TShock 6.2.1 · Terraria 1.4.5.8,作者:不是现在):

新增

  • HerbBloom 全草药常开:成熟即开花、无视昼夜/天气/月相,开花后永不回退(霜花逻辑推广到全品种);生长默认原版速度
  • BottleRefund 玻璃瓶回收:喝药延迟数秒全面结算后返还玻璃瓶,合并堆叠/入箱/丢弃/移入银行不误发
  • NurseHeal 护士治疗:护士对话按原版定价(快乐度/世界进度/专家大师/折扣卡)扣费回满血,并移除可移除减益;800 像素距离校验

更新

  • TerraNews v1.1.1:草药提醒(满月/血月死亡草、雨天水叶草、火焰花窗口)与旅商播报优化
  • FullHealthRespawn v1.2.1 / Starfall v2.0.3:署名统一

全部在本仓库模板(TShock 6.2.1)下编译通过(0 警告 0 错误),配置驱动、无游戏内指令。

Sourcery 摘要

新增三个可配置的游戏玩法插件,并扩展 TerraNews,加入草药采收通知,同时统一插件元数据。

新功能:

  • 新增 HerbBloom,使所有种类的草药无论环境条件如何都能持续开花,并支持配置生长行为。
  • 新增 BottleRefund,在药水被消耗后返还可配置的物品,同时避免因物品在物品栏间转移、存入储物空间或掉落而触发返还。
  • 新增 NurseHeal,通过护士提供完全治疗和可解除的减益清除,并采用原版风格的定价和距离验证。
  • 扩展 TerraNews,加入可配置的草药采收提醒,涵盖月相、降雨和火焰花盛开时段。

改进:

  • 统一插件作者信息元数据,并更新 FullHealthRespawn 和 Starfall 的版本。
  • 改进 TerraNews 事件播报,支持单独控制草药提醒,并将旅行商人公告分开处理。

构建:

  • 添加项目定义,并在解决方案中注册新插件。

文档:

  • 添加 HerbBloom、BottleRefund 和 NurseHeal 的使用、配置及行为说明,并更新 TerraNews 文档。
Original summary in English

Summary by Sourcery

Add three configurable gameplay plugins and expand TerraNews with herb harvest notifications while standardizing plugin metadata.

New Features:

  • Add HerbBloom to keep all herb varieties blooming regardless of environmental conditions, with configurable growth behavior.
  • Add BottleRefund to return configurable items for consumed potions while avoiding refunds for inventory transfers, storage, and drops.
  • Add NurseHeal to provide full healing and removable debuff cleansing through the nurse using vanilla-style pricing and distance validation.
  • Extend TerraNews with configurable herb harvest reminders for moon phases, rain, and fireblossom blooming periods.

Enhancements:

  • Unify plugin authorship metadata and update FullHealthRespawn and Starfall versions.
  • Improve TerraNews event reporting with independent herb reminder switches and separate traveling merchant announcements.

Build:

  • Add project definitions and register the new plugins in the solution.

Documentation:

  • Add usage, configuration, and behavior documentation for HerbBloom, BottleRefund, and NurseHeal, and update TerraNews documentation.

@zlqd123
zlqd123 requested a review from a team as a code owner November 9, 2026 00:51

@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.

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

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

## Individual Comments

### Comment 1
<location path="src/NurseHeal/PaymentService.cs" line_range="82-87" />
<code_context>
+        var filled = new List<int>();
+        if (!AllocateChange(change, free, filled))
+        {
+            foreach (Snapshot s in snapshot)
+            {
+                s.Item.type = s.Type;
+                s.Item.stack = s.Stack;
+                s.Item.prefix = s.Prefix;
+            }
+            return DeductResult.Fail("背包无法容纳找零(空间不足),本次未扣费");
+        }
</code_context>
<issue_to_address>
**Rejected treatment creates coins**

When change needs more slots than are available, after allocation has filled at least one originally empty slot, `AllocateChange` writes partial change before returning false, but the failure branch restores only the original coin snapshots. The new stacks remain alongside the restored balance, so the player keeps extra coins after treatment is refused.

Clear every partially filled originally empty slot during rollback, or calculate the required slots before mutating the inventory.

Also at `src/NurseHeal/PaymentService.cs:121-122`.
</issue_to_address>

### Comment 2
<location path="src/BottleRefund/BottleRefundPlugin.cs" line_range="51-53" />
<code_context>
+
+        private static string ConfigPath => Path.Combine(TShock.SavePath, "BottleRefund.json");
+
+        // 网络槽位:0..TrashItem-1 为主背包/钱币/弹药区;TrashItem 为垃圾桶;≥Bank1_0 为各类银行。
+        // 只跟踪主背包区,垃圾桶与银行整体排除。
+        private static readonly int SlotRange = PlayerItemSlotID.TrashItem;
+
+        private volatile BottleRefundConfig? _config;
</code_context>
<issue_to_address>
**Storage moves earn refunds**

When a player moves a one-count potion from the tracked inventory into a bank or the trash, `OnPlayerSlot` ignores destination slots at or beyond `TrashItem`, so `Settle` sees the unmatched inventory decrease as drinking a potion and grants a bottle.

Track bank and trash destination changes, or otherwise exclude storage moves from drink detection.

Also at `src/BottleRefund/BottleRefundPlugin.cs:173-174`, `src/BottleRefund/BottleRefundPlugin.cs:418-419`.
</issue_to_address>

### Comment 3
<location path="src/BottleRefund/BottleRefundPlugin.cs" line_range="164-192" />
<code_context>
+        private void OnPlayerSlot(object? sender, GetDataHandlers.PlayerSlotEventArgs e)
</code_context>
<issue_to_address>
**Forged inventory deltas grant free items**

When a non-SSC player can submit accepted `PlayerSlot` updates for a potion slot, `OnPlayerSlot` records client-reported stack changes as inventory deltas, and `Settle` counts an unmatched one-item decrease as a drink before `GiveItem` issues the configured refund. A player can submit a valid potion stack increase followed by a one-item decrease, earning refunds without consuming potions.

Base refunds on a server-authoritative potion-consumption signal, or otherwise verify the slot change against server-owned inventory state before treating it as a drink.

Also at `src/BottleRefund/BottleRefundPlugin.cs:418-419`, `src/BottleRefund/BottleRefundPlugin.cs:445`.
</issue_to_address>

### Comment 4
<location path="src/NurseHeal/PaymentService.cs" line_range="18" />
<code_context>
+{
+    private sealed record CoinSlot(Item Item, int SlotId);
+
+    private const int CoinStackMax = 999; // 原版钱币堆叠上限(旧版误用 100,白白多占 10 倍槽位)
+
+    private static readonly int[] CoinIds = { 71, 72, 73, 74 };
</code_context>
<issue_to_address>
**Change uses undersized coin stacks**

When the change fits within the coin item's actual stack limit but requires multiple stacks of 999, `AllocateChange` limits coin stacks to 999 instead of using the coin item's stack limit, so it requires extra slots and rejects a treatment the inventory could hold.

Use each coin item's actual `maxStack` when splitting change.

Also at `src/NurseHeal/PaymentService.cs:119`.
</issue_to_address>

### Comment 5
<location path="src/BottleRefund/BottleRefundPlugin.cs" line_range="228-235" />
<code_context>
+            long key = ((long)e.ID << 8) | (byte)e.Slot;
+            lock (_lock)
+            {
+                _chestMirror.TryGetValue(key, out var old);
+                _chestMirror[key] = (e.Type, e.Stacks);
+                var ledger = GetLedger(plr.Index, Now);
+                if (old.Type == e.Type)
+                {
+                    int delta = e.Stacks - old.Stack;
+                    if (delta > 0 && _potionSet.Contains(e.Type))
+                        AddEntry(ledger, ledger.ChestIncreases, Now, e.Type, delta);
+                }
+                else if (e.Type > 0 && e.Stacks > 0 && _potionSet.Contains(e.Type))
</code_context>
<issue_to_address>
**Chest changes hide consumed potions**

When the first observed change to a pre-filled potion chest slot is a deposit or partial withdrawal, and the player drinks the same potion before settlement, `_chestMirror` has no baseline for the slot, so the first update can be recorded as an increase equal to the resulting stack. `Settle` can match that phantom increase to the drink and withhold the refund.

Establish the chest slot's current stack as a baseline before recording subsequent deposit deltas.
</issue_to_address>

### Comment 6
<location path="src/BottleRefund/BottleRefundPlugin.cs" line_range="481" />
<code_context>
+            for (int i = 0; i < incs.Count; i++)
+            {
+                var e = incs[i];
+                if (!e.Used && e.Amount == dec.Amount && e.Time >= dec.Time - 0.5)
+                {
+                    e.Used = true;
</code_context>
<issue_to_address>
**Later pickups suppress refunds**

When a player gains an equal-sized stack of the same potion after drinking and before settlement, `TryMatchExact` matches an increase occurring after a decrease, so it classifies the drink as a move and the player receives no refund.

Restrict move matching to inventory changes that can represent the other side of the same move, rather than matching later gains.
</issue_to_address>

### Comment 7
<location path="src/HerbBloom/HerbBloomPlugin.cs" line_range="216" />
<code_context>
+                    ushort type = tile.type;
+                    if (type == TileMature || (scanImmature && type == TileImmature))
+                    {
+                        _pending.Enqueue(new PendingChange { X = (short)x, Y = (short)y, ExpectedType = type });
+                        found++;
+                    }
</code_context>
<issue_to_address>
**Overlapping scans accelerate growth**

When active players' scan areas overlap around immature herbs, `ScanCycle` queues the same herb from each overlapping area, and `Pump` rolls the growth chance for every queued copy. The herb therefore matures faster than its configured per-scan probability.

Deduplicate pending herb coordinates before queuing or processing growth rolls.

Also at `src/HerbBloom/HerbBloomPlugin.cs:176`, `src/HerbBloom/HerbBloomPlugin.cs:307`.
</issue_to_address>

### Comment 8
<location path="src/BottleRefund/BottleRefundConfig.cs" line_range="86-89" />
<code_context>
+
+        public void Sanitize()
+        {
+            RefundChance = Math.Max(0.0, Math.Min(1.0, RefundChance));
+            RefundCountPerDrink = Math.Max(0, Math.Min(999, RefundCountPerDrink));
+            RefundItemId = Math.Max(1, Math.Min(10000, RefundItemId));
+            SettlementDelaySeconds = Math.Max(1.0, Math.Min(300.0, SettlementDelaySeconds));
+            LedgerLimit = Math.Max(10, Math.Min(100000, LedgerLimit));
+            if (Blacklist == null)
</code_context>
<issue_to_address>
**NaN values evade config bounds**

When a configuration file contains a NaN floating-point value accepted by Json.NET, `Math.Min`/`Math.Max` leave `NaN` unchanged. In BottleRefund, a NaN settlement delay makes the readiness comparison false, so ledgers never settle and refunds are eventually dropped; in HerbBloom, a NaN growth chance makes both rejection comparisons false, so every scanned immature herb matures.

Reject or replace non-finite floating-point settings before applying the bounds.

Also at `src/HerbBloom/HerbBloomConfig.cs:98-99`.
</issue_to_address>

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

Hey - I've found 8 issues

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

## Individual Comments

### Comment 1
<location path="src/NurseHeal/PaymentService.cs" line_range="82-87" />
<code_context>
+        var filled = new List<int>();
+        if (!AllocateChange(change, free, filled))
+        {
+            foreach (Snapshot s in snapshot)
+            {
+                s.Item.type = s.Type;
+                s.Item.stack = s.Stack;
+                s.Item.prefix = s.Prefix;
+            }
+            return DeductResult.Fail("背包无法容纳找零(空间不足),本次未扣费");
+        }
</code_context>
<issue_to_address>
**Rejected treatment creates coins**

When change needs more slots than are available, after allocation has filled at least one originally empty slot, `AllocateChange` writes partial change before returning false, but the failure branch restores only the original coin snapshots. The new stacks remain alongside the restored balance, so the player keeps extra coins after treatment is refused.

Clear every partially filled originally empty slot during rollback, or calculate the required slots before mutating the inventory.

Also at `src/NurseHeal/PaymentService.cs:121-122`.
</issue_to_address>

### Comment 2
<location path="src/BottleRefund/BottleRefundPlugin.cs" line_range="51-53" />
<code_context>
+
+        private static string ConfigPath => Path.Combine(TShock.SavePath, "BottleRefund.json");
+
+        // 网络槽位:0..TrashItem-1 为主背包/钱币/弹药区;TrashItem 为垃圾桶;≥Bank1_0 为各类银行。
+        // 只跟踪主背包区,垃圾桶与银行整体排除。
+        private static readonly int SlotRange = PlayerItemSlotID.TrashItem;
+
+        private volatile BottleRefundConfig? _config;
</code_context>
<issue_to_address>
**Storage moves earn refunds**

When a player moves a one-count potion from the tracked inventory into a bank or the trash, `OnPlayerSlot` ignores destination slots at or beyond `TrashItem`, so `Settle` sees the unmatched inventory decrease as drinking a potion and grants a bottle.

Track bank and trash destination changes, or otherwise exclude storage moves from drink detection.

Also at `src/BottleRefund/BottleRefundPlugin.cs:173-174`, `src/BottleRefund/BottleRefundPlugin.cs:418-419`.
</issue_to_address>

### Comment 3
<location path="src/BottleRefund/BottleRefundPlugin.cs" line_range="164-192" />
<code_context>
+        private void OnPlayerSlot(object? sender, GetDataHandlers.PlayerSlotEventArgs e)
</code_context>
<issue_to_address>
**Forged inventory deltas grant free items**

When a non-SSC player can submit accepted `PlayerSlot` updates for a potion slot, `OnPlayerSlot` records client-reported stack changes as inventory deltas, and `Settle` counts an unmatched one-item decrease as a drink before `GiveItem` issues the configured refund. A player can submit a valid potion stack increase followed by a one-item decrease, earning refunds without consuming potions.

Base refunds on a server-authoritative potion-consumption signal, or otherwise verify the slot change against server-owned inventory state before treating it as a drink.

Also at `src/BottleRefund/BottleRefundPlugin.cs:418-419`, `src/BottleRefund/BottleRefundPlugin.cs:445`.
</issue_to_address>

### Comment 4
<location path="src/NurseHeal/PaymentService.cs" line_range="18" />
<code_context>
+{
+    private sealed record CoinSlot(Item Item, int SlotId);
+
+    private const int CoinStackMax = 999; // 原版钱币堆叠上限(旧版误用 100,白白多占 10 倍槽位)
+
+    private static readonly int[] CoinIds = { 71, 72, 73, 74 };
</code_context>
<issue_to_address>
**Change uses undersized coin stacks**

When the change fits within the coin item's actual stack limit but requires multiple stacks of 999, `AllocateChange` limits coin stacks to 999 instead of using the coin item's stack limit, so it requires extra slots and rejects a treatment the inventory could hold.

Use each coin item's actual `maxStack` when splitting change.

Also at `src/NurseHeal/PaymentService.cs:119`.
</issue_to_address>

### Comment 5
<location path="src/BottleRefund/BottleRefundPlugin.cs" line_range="228-235" />
<code_context>
+            long key = ((long)e.ID << 8) | (byte)e.Slot;
+            lock (_lock)
+            {
+                _chestMirror.TryGetValue(key, out var old);
+                _chestMirror[key] = (e.Type, e.Stacks);
+                var ledger = GetLedger(plr.Index, Now);
+                if (old.Type == e.Type)
+                {
+                    int delta = e.Stacks - old.Stack;
+                    if (delta > 0 && _potionSet.Contains(e.Type))
+                        AddEntry(ledger, ledger.ChestIncreases, Now, e.Type, delta);
+                }
+                else if (e.Type > 0 && e.Stacks > 0 && _potionSet.Contains(e.Type))
</code_context>
<issue_to_address>
**Chest changes hide consumed potions**

When the first observed change to a pre-filled potion chest slot is a deposit or partial withdrawal, and the player drinks the same potion before settlement, `_chestMirror` has no baseline for the slot, so the first update can be recorded as an increase equal to the resulting stack. `Settle` can match that phantom increase to the drink and withhold the refund.

Establish the chest slot's current stack as a baseline before recording subsequent deposit deltas.
</issue_to_address>

### Comment 6
<location path="src/BottleRefund/BottleRefundPlugin.cs" line_range="481" />
<code_context>
+            for (int i = 0; i < incs.Count; i++)
+            {
+                var e = incs[i];
+                if (!e.Used && e.Amount == dec.Amount && e.Time >= dec.Time - 0.5)
+                {
+                    e.Used = true;
</code_context>
<issue_to_address>
**Later pickups suppress refunds**

When a player gains an equal-sized stack of the same potion after drinking and before settlement, `TryMatchExact` matches an increase occurring after a decrease, so it classifies the drink as a move and the player receives no refund.

Restrict move matching to inventory changes that can represent the other side of the same move, rather than matching later gains.
</issue_to_address>

### Comment 7
<location path="src/HerbBloom/HerbBloomPlugin.cs" line_range="216" />
<code_context>
+                    ushort type = tile.type;
+                    if (type == TileMature || (scanImmature && type == TileImmature))
+                    {
+                        _pending.Enqueue(new PendingChange { X = (short)x, Y = (short)y, ExpectedType = type });
+                        found++;
+                    }
</code_context>
<issue_to_address>
**Overlapping scans accelerate growth**

When active players' scan areas overlap around immature herbs, `ScanCycle` queues the same herb from each overlapping area, and `Pump` rolls the growth chance for every queued copy. The herb therefore matures faster than its configured per-scan probability.

Deduplicate pending herb coordinates before queuing or processing growth rolls.

Also at `src/HerbBloom/HerbBloomPlugin.cs:176`, `src/HerbBloom/HerbBloomPlugin.cs:307`.
</issue_to_address>

### Comment 8
<location path="src/BottleRefund/BottleRefundConfig.cs" line_range="86-89" />
<code_context>
+
+        public void Sanitize()
+        {
+            RefundChance = Math.Max(0.0, Math.Min(1.0, RefundChance));
+            RefundCountPerDrink = Math.Max(0, Math.Min(999, RefundCountPerDrink));
+            RefundItemId = Math.Max(1, Math.Min(10000, RefundItemId));
+            SettlementDelaySeconds = Math.Max(1.0, Math.Min(300.0, SettlementDelaySeconds));
+            LedgerLimit = Math.Max(10, Math.Min(100000, LedgerLimit));
+            if (Blacklist == null)
</code_context>
<issue_to_address>
**NaN values evade config bounds**

When a configuration file contains a NaN floating-point value accepted by Json.NET, `Math.Min`/`Math.Max` leave `NaN` unchanged. In BottleRefund, a NaN settlement delay makes the readiness comparison false, so ledgers never settle and refunds are eventually dropped; in HerbBloom, a NaN growth chance makes both rejection comparisons false, so every scanned immature herb matures.

Reject or replace non-finite floating-point settings before applying the bounds.

Also at `src/HerbBloom/HerbBloomConfig.cs:98-99`.
</issue_to_address>

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

Comment on lines +82 to +87
foreach (Snapshot s in snapshot)
{
s.Item.type = s.Type;
s.Item.stack = s.Stack;
s.Item.prefix = s.Prefix;
}

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.

🔴 严重 · 拒绝治疗后仍会产生金币

当找零所需的槽位多于可用槽位时,如果分配过程已经填充了至少一个原本为空的槽位,AllocateChange 会在返回 false 前写入部分找零;但失败分支只会恢复原有金币快照。新金币堆会与恢复后的余额同时保留,因此玩家在治疗被拒绝后仍会得到额外金币。

回滚时清空所有被部分填充的原本空槽位,或者在修改物品栏之前先计算所需槽位。

另见 src/NurseHeal/PaymentService.cs:121-122。

供 AI 代理使用的提示
在 `src/NurseHeal/PaymentService.cs` 第 82-87 行:

**拒绝治疗后仍会产生金币**

当找零所需的槽位多于可用槽位时,如果分配过程已经填充了至少一个原本为空的槽位,`AllocateChange` 会在返回 false 前写入部分找零;但失败分支只会恢复原有金币快照。新金币堆会与恢复后的余额同时保留,因此玩家在治疗被拒绝后仍会得到额外金币。

回滚时清空所有被部分填充的原本空槽位,或者在修改物品栏之前先计算所需槽位。

另见 `src/NurseHeal/PaymentService.cs:121-122`。
Original comment in English

🔴 Critical · Rejected treatment creates coins

When change needs more slots than are available, after allocation has filled at least one originally empty slot, AllocateChange writes partial change before returning false, but the failure branch restores only the original coin snapshots. The new stacks remain alongside the restored balance, so the player keeps extra coins after treatment is refused.

Clear every partially filled originally empty slot during rollback, or calculate the required slots before mutating the inventory.

Also at src/NurseHeal/PaymentService.cs:121-122.

Prompt for AI agents
In `src/NurseHeal/PaymentService.cs` at lines 82-87:

**Rejected treatment creates coins**

When change needs more slots than are available, after allocation has filled at least one originally empty slot, `AllocateChange` writes partial change before returning false, but the failure branch restores only the original coin snapshots. The new stacks remain alongside the restored balance, so the player keeps extra coins after treatment is refused.

Clear every partially filled originally empty slot during rollback, or calculate the required slots before mutating the inventory.

Also at `src/NurseHeal/PaymentService.cs:121-122`.

Comment on lines +51 to +53
// 网络槽位:0..TrashItem-1 为主背包/钱币/弹药区;TrashItem 为垃圾桶;≥Bank1_0 为各类银行。
// 只跟踪主背包区,垃圾桶与银行整体排除。
private static readonly int SlotRange = PlayerItemSlotID.TrashItem;

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 的药水从受跟踪的物品栏移入银行或垃圾栏时,OnPlayerSlot 会忽略索引大于或等于 TrashItem 的目标槽位,因此 Settle 会把未匹配的物品栏数量减少视为喝掉了药水,并发放一瓶药水。

跟踪银行和垃圾栏中的目标槽位变更,或以其他方式排除存储移动,不将其判定为饮用。

另见 src/BottleRefund/BottleRefundPlugin.cs:173-174、src/BottleRefund/BottleRefundPlugin.cs:418-419。

供 AI 代理使用的提示
在 `src/BottleRefund/BottleRefundPlugin.cs` 第 51-53 行:

**存储物品也会获得退款**

当玩家将一瓶数量为 1 的药水从受跟踪的物品栏移入银行或垃圾栏时,`OnPlayerSlot` 会忽略索引大于或等于 `TrashItem` 的目标槽位,因此 `Settle` 会把未匹配的物品栏数量减少视为喝掉了药水,并发放一瓶药水。

跟踪银行和垃圾栏中的目标槽位变更,或以其他方式排除存储移动,不将其判定为饮用。

另见 `src/BottleRefund/BottleRefundPlugin.cs:173-174`、`src/BottleRefund/BottleRefundPlugin.cs:418-419`。
Original comment in English

🟠 High · Storage moves earn refunds

When a player moves a one-count potion from the tracked inventory into a bank or the trash, OnPlayerSlot ignores destination slots at or beyond TrashItem, so Settle sees the unmatched inventory decrease as drinking a potion and grants a bottle.

Track bank and trash destination changes, or otherwise exclude storage moves from drink detection.

Also at src/BottleRefund/BottleRefundPlugin.cs:173-174, src/BottleRefund/BottleRefundPlugin.cs:418-419.

Prompt for AI agents
In `src/BottleRefund/BottleRefundPlugin.cs` at lines 51-53:

**Storage moves earn refunds**

When a player moves a one-count potion from the tracked inventory into a bank or the trash, `OnPlayerSlot` ignores destination slots at or beyond `TrashItem`, so `Settle` sees the unmatched inventory decrease as drinking a potion and grants a bottle.

Track bank and trash destination changes, or otherwise exclude storage moves from drink detection.

Also at `src/BottleRefund/BottleRefundPlugin.cs:173-174`, `src/BottleRefund/BottleRefundPlugin.cs:418-419`.

Comment on lines +164 to +192
private void OnPlayerSlot(object? sender, GetDataHandlers.PlayerSlotEventArgs e)
{
var cfg = _config;
if (cfg == null || !cfg.Enabled)
return;
var plr = e.Player;
if (plr == null || e.PlayerId != plr.Index || plr.IgnoreSSCPackets)
return;
int slot = e.Slot;
if (slot < 0 || slot >= SlotRange)
return;

lock (_lock)
{
var st = GetMirror(plr.Index);
int oldType = st.Type[slot];
int oldStack = st.Stack[slot];
st.Type[slot] = (short)e.Type;
st.Stack[slot] = (short)e.Stack;
double t = Now;
var ledger = GetLedger(plr.Index, t);

if (oldType == e.Type)
{
int delta = e.Stack - oldStack;
if (delta == 0)
return;
if (_potionSet.Contains(e.Type))
AddEntry(ledger, delta < 0 ? ledger.Decreases : ledger.Increases, t, e.Type, Math.Abs(delta));

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.

🟡 中 · 伪造物品栏变化可免费获得物品

如果非 SSC 玩家可以提交被接受的药水槽 PlayerSlot 更新,OnPlayerSlot 就会将客户端报告的堆叠变化记录为物品栏变化;随后 Settle 会把未匹配的单件减少计为饮用,再由 GiveItem 发放配置的退款。玩家可以先提交有效的药水堆叠增加,再提交单件减少,从而不消耗药水也能获得退款。

应基于服务器权威的药水消耗信号发放退款;或者在将槽位变化视为饮用之前,根据服务器持有的物品栏状态进行核验。

另见 src/BottleRefund/BottleRefundPlugin.cs:418-419、src/BottleRefund/BottleRefundPlugin.cs:445。

供 AI 代理使用的提示
在 `src/BottleRefund/BottleRefundPlugin.cs` 第 164-192 行:

**伪造物品栏变化可免费获得物品**

如果非 SSC 玩家可以提交被接受的药水槽 `PlayerSlot` 更新,`OnPlayerSlot` 就会将客户端报告的堆叠变化记录为物品栏变化;随后 `Settle` 会把未匹配的单件减少计为饮用,再由 `GiveItem` 发放配置的退款。玩家可以先提交有效的药水堆叠增加,再提交单件减少,从而不消耗药水也能获得退款。

应基于服务器权威的药水消耗信号发放退款;或者在将槽位变化视为饮用之前,根据服务器持有的物品栏状态进行核验。

另见 `src/BottleRefund/BottleRefundPlugin.cs:418-419`、`src/BottleRefund/BottleRefundPlugin.cs:445`。
Original comment in English

🟡 Medium · Forged inventory deltas grant free items

When a non-SSC player can submit accepted PlayerSlot updates for a potion slot, OnPlayerSlot records client-reported stack changes as inventory deltas, and Settle counts an unmatched one-item decrease as a drink before GiveItem issues the configured refund. A player can submit a valid potion stack increase followed by a one-item decrease, earning refunds without consuming potions.

Base refunds on a server-authoritative potion-consumption signal, or otherwise verify the slot change against server-owned inventory state before treating it as a drink.

Also at src/BottleRefund/BottleRefundPlugin.cs:418-419, src/BottleRefund/BottleRefundPlugin.cs:445.

Prompt for AI agents
In `src/BottleRefund/BottleRefundPlugin.cs` at lines 164-192:

**Forged inventory deltas grant free items**

When a non-SSC player can submit accepted `PlayerSlot` updates for a potion slot, `OnPlayerSlot` records client-reported stack changes as inventory deltas, and `Settle` counts an unmatched one-item decrease as a drink before `GiveItem` issues the configured refund. A player can submit a valid potion stack increase followed by a one-item decrease, earning refunds without consuming potions.

Base refunds on a server-authoritative potion-consumption signal, or otherwise verify the slot change against server-owned inventory state before treating it as a drink.

Also at `src/BottleRefund/BottleRefundPlugin.cs:418-419`, `src/BottleRefund/BottleRefundPlugin.cs:445`.

{
private sealed record CoinSlot(Item Item, int SlotId);

private const int CoinStackMax = 999; // 原版钱币堆叠上限(旧版误用 100,白白多占 10 倍槽位)

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.

🟡 中 · 找零使用了容量过小的金币堆

当找零总量没有超过金币物品的实际堆叠上限,但需要拆分成多个 999 枚的金币堆时,AllocateChange 会将金币堆限制为 999 枚,而不是使用金币物品的堆叠上限,因此需要更多槽位,并拒绝本可放入物品栏的治疗。

拆分找零时使用每种金币物品的实际 maxStack。

另见 src/NurseHeal/PaymentService.cs:119。

供 AI 代理使用的提示
在 `src/NurseHeal/PaymentService.cs` 第 18 行:

**找零使用了容量过小的金币堆**

当找零总量没有超过金币物品的实际堆叠上限,但需要拆分成多个 999 枚的金币堆时,`AllocateChange` 会将金币堆限制为 999 枚,而不是使用金币物品的堆叠上限,因此需要更多槽位,并拒绝本可放入物品栏的治疗。

拆分找零时使用每种金币物品的实际 `maxStack`。

另见 `src/NurseHeal/PaymentService.cs:119`。
Original comment in English

🟡 Medium · Change uses undersized coin stacks

When the change fits within the coin item's actual stack limit but requires multiple stacks of 999, AllocateChange limits coin stacks to 999 instead of using the coin item's stack limit, so it requires extra slots and rejects a treatment the inventory could hold.

Use each coin item's actual maxStack when splitting change.

Also at src/NurseHeal/PaymentService.cs:119.

Prompt for AI agents
In `src/NurseHeal/PaymentService.cs` at line 18:

**Change uses undersized coin stacks**

When the change fits within the coin item's actual stack limit but requires multiple stacks of 999, `AllocateChange` limits coin stacks to 999 instead of using the coin item's stack limit, so it requires extra slots and rejects a treatment the inventory could hold.

Use each coin item's actual `maxStack` when splitting change.

Also at `src/NurseHeal/PaymentService.cs:119`.

Comment on lines +228 to +235
_chestMirror.TryGetValue(key, out var old);
_chestMirror[key] = (e.Type, e.Stacks);
var ledger = GetLedger(plr.Index, Now);
if (old.Type == e.Type)
{
int delta = e.Stacks - old.Stack;
if (delta > 0 && _potionSet.Contains(e.Type))
AddEntry(ledger, ledger.ChestIncreases, Now, e.Type, delta);

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.

🟡 中 · 箱子变化会掩盖已饮用的药水

如果预先装有药水的箱子槽位首次观察到的变化是存入物品或部分取出,并且玩家在结算前喝下了同一种药水,_chestMirror 就没有该槽位的基准值,因此首次更新可能会被记录为增加了相当于最终堆叠数量的数量。Settle 可能会将这次虚假的增加与饮用操作匹配,从而不发放退款。

在记录后续存入变化之前,先将箱子槽位当前的堆叠数量设为基准值。

供 AI 代理使用的提示
在 `src/BottleRefund/BottleRefundPlugin.cs` 第 228-235 行:

**箱子变化会掩盖已饮用的药水**

如果预先装有药水的箱子槽位首次观察到的变化是存入物品或部分取出,并且玩家在结算前喝下了同一种药水,`_chestMirror` 就没有该槽位的基准值,因此首次更新可能会被记录为增加了相当于最终堆叠数量的数量。`Settle` 可能会将这次虚假的增加与饮用操作匹配,从而不发放退款。

在记录后续存入变化之前,先将箱子槽位当前的堆叠数量设为基准值。
Original comment in English

🟡 Medium · Chest changes hide consumed potions

When the first observed change to a pre-filled potion chest slot is a deposit or partial withdrawal, and the player drinks the same potion before settlement, _chestMirror has no baseline for the slot, so the first update can be recorded as an increase equal to the resulting stack. Settle can match that phantom increase to the drink and withhold the refund.

Establish the chest slot's current stack as a baseline before recording subsequent deposit deltas.

Prompt for AI agents
In `src/BottleRefund/BottleRefundPlugin.cs` at lines 228-235:

**Chest changes hide consumed potions**

When the first observed change to a pre-filled potion chest slot is a deposit or partial withdrawal, and the player drinks the same potion before settlement, `_chestMirror` has no baseline for the slot, so the first update can be recorded as an increase equal to the resulting stack. `Settle` can match that phantom increase to the drink and withhold the refund.

Establish the chest slot's current stack as a baseline before recording subsequent deposit deltas.

for (int i = 0; i < incs.Count; i++)
{
var e = incs[i];
if (!e.Used && e.Amount == dec.Amount && e.Time >= dec.Time - 0.5)

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.

🟡 中 · 后续拾取会导致退款被抑制

如果玩家喝药后、结算前拾取了数量相同的同种药水堆叠,TryMatchExact 会将减少之后发生的增加匹配起来,因此会把饮用判定为物品移动,玩家也就收不到退款。

仅将移动匹配限制在可能代表同一次移动另一端的物品栏变化中,不要匹配之后发生的拾取。

供 AI 代理使用的提示
在 `src/BottleRefund/BottleRefundPlugin.cs` 第 481 行:

**后续拾取会导致退款被抑制**

如果玩家喝药后、结算前拾取了数量相同的同种药水堆叠,`TryMatchExact` 会将减少之后发生的增加匹配起来,因此会把饮用判定为物品移动,玩家也就收不到退款。

仅将移动匹配限制在可能代表同一次移动另一端的物品栏变化中,不要匹配之后发生的拾取。
Original comment in English

🟡 Medium · Later pickups suppress refunds

When a player gains an equal-sized stack of the same potion after drinking and before settlement, TryMatchExact matches an increase occurring after a decrease, so it classifies the drink as a move and the player receives no refund.

Restrict move matching to inventory changes that can represent the other side of the same move, rather than matching later gains.

Prompt for AI agents
In `src/BottleRefund/BottleRefundPlugin.cs` at line 481:

**Later pickups suppress refunds**

When a player gains an equal-sized stack of the same potion after drinking and before settlement, `TryMatchExact` matches an increase occurring after a decrease, so it classifies the drink as a move and the player receives no refund.

Restrict move matching to inventory changes that can represent the other side of the same move, rather than matching later gains.

ushort type = tile.type;
if (type == TileMature || (scanImmature && type == TileImmature))
{
_pending.Enqueue(new PendingChange { X = (short)x, Y = (short)y, ExpectedType = type });

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.

🟡 中 · 重叠扫描会加快生长

当活跃玩家的扫描区域在未成熟的草药附近重叠时,ScanCycle 会从每个重叠区域都将同一株草药加入队列,而 Pump 会对队列中的每个副本都进行一次生长概率判定。因此,草药成熟的速度会快于配置的单次扫描概率所预期的速度。

在将待处理的草药坐标加入队列或进行生长概率判定之前,先对其去重。

另见 src/HerbBloom/HerbBloomPlugin.cs:176、src/HerbBloom/HerbBloomPlugin.cs:307。

供 AI 代理使用的提示
在 `src/HerbBloom/HerbBloomPlugin.cs` 第 216 行:

**重叠扫描会加快生长**

当活跃玩家的扫描区域在未成熟的草药附近重叠时,`ScanCycle` 会从每个重叠区域都将同一株草药加入队列,而 `Pump` 会对队列中的每个副本都进行一次生长概率判定。因此,草药成熟的速度会快于配置的单次扫描概率所预期的速度。

在将待处理的草药坐标加入队列或进行生长概率判定之前,先对其去重。

另见 `src/HerbBloom/HerbBloomPlugin.cs:176`、`src/HerbBloom/HerbBloomPlugin.cs:307`。
Original comment in English

🟡 Medium · Overlapping scans accelerate growth

When active players' scan areas overlap around immature herbs, ScanCycle queues the same herb from each overlapping area, and Pump rolls the growth chance for every queued copy. The herb therefore matures faster than its configured per-scan probability.

Deduplicate pending herb coordinates before queuing or processing growth rolls.

Also at src/HerbBloom/HerbBloomPlugin.cs:176, src/HerbBloom/HerbBloomPlugin.cs:307.

Prompt for AI agents
In `src/HerbBloom/HerbBloomPlugin.cs` at line 216:

**Overlapping scans accelerate growth**

When active players' scan areas overlap around immature herbs, `ScanCycle` queues the same herb from each overlapping area, and `Pump` rolls the growth chance for every queued copy. The herb therefore matures faster than its configured per-scan probability.

Deduplicate pending herb coordinates before queuing or processing growth rolls.

Also at `src/HerbBloom/HerbBloomPlugin.cs:176`, `src/HerbBloom/HerbBloomPlugin.cs:307`.

Comment on lines +86 to +89
RefundChance = Math.Max(0.0, Math.Min(1.0, RefundChance));
RefundCountPerDrink = Math.Max(0, Math.Min(999, RefundCountPerDrink));
RefundItemId = Math.Max(1, Math.Min(10000, RefundItemId));
SettlementDelaySeconds = Math.Max(1.0, Math.Min(300.0, SettlementDelaySeconds));

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.

🟡 中 · NaN 值可绕过配置边界限制

当配置文件包含 Json.NET 接受的 NaN 浮点值时,Math.Min/Math.Max 会让 NaN 保持不变。在 BottleRefund 中,NaN 结算延迟会导致就绪状态比较结果为 false,因此账本永远不会结算,退款最终会被丢弃;在 HerbBloom 中,NaN 生长概率会使两项拒绝比较都返回 false,因此每株被扫描到的未成熟草药都会成熟。

在应用边界限制之前,拒绝或替换非有限浮点设置。

另见 src/HerbBloom/HerbBloomConfig.cs:98-99。

供 AI 代理使用的提示
在 `src/BottleRefund/BottleRefundConfig.cs` 第 86-89 行:

**NaN 值可绕过配置边界限制**

当配置文件包含 Json.NET 接受的 NaN 浮点值时,`Math.Min`/`Math.Max` 会让 `NaN` 保持不变。在 BottleRefund 中,NaN 结算延迟会导致就绪状态比较结果为 false,因此账本永远不会结算,退款最终会被丢弃;在 HerbBloom 中,NaN 生长概率会使两项拒绝比较都返回 false,因此每株被扫描到的未成熟草药都会成熟。

在应用边界限制之前,拒绝或替换非有限浮点设置。

另见 `src/HerbBloom/HerbBloomConfig.cs:98-99`。
Original comment in English

🟡 Medium · NaN values evade config bounds

When a configuration file contains a NaN floating-point value accepted by Json.NET, Math.Min/Math.Max leave NaN unchanged. In BottleRefund, a NaN settlement delay makes the readiness comparison false, so ledgers never settle and refunds are eventually dropped; in HerbBloom, a NaN growth chance makes both rejection comparisons false, so every scanned immature herb matures.

Reject or replace non-finite floating-point settings before applying the bounds.

Also at src/HerbBloom/HerbBloomConfig.cs:98-99.

Prompt for AI agents
In `src/BottleRefund/BottleRefundConfig.cs` at lines 86-89:

**NaN values evade config bounds**

When a configuration file contains a NaN floating-point value accepted by Json.NET, `Math.Min`/`Math.Max` leave `NaN` unchanged. In BottleRefund, a NaN settlement delay makes the readiness comparison false, so ledgers never settle and refunds are eventually dropped; in HerbBloom, a NaN growth chance makes both rejection comparisons false, so every scanned immature herb matures.

Reject or replace non-finite floating-point settings before applying the bounds.

Also at `src/HerbBloom/HerbBloomConfig.cs:98-99`.

@ACaiCat
ACaiCat added this pull request to the merge queue Nov 9, 2026
Merged via the queue into UnrealMultiple:master with commit f662dc5 Nov 9, 2026
2 checks passed
@zlqd123
zlqd123 deleted the pr/add-new-plugins branch November 14, 2026 11:49
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.

2 participants