第70批:堆叠上限clamp到[1,99]修复Paper 26.3 IllegalArgumentException
Auto Release / build (push) Successful in 2m27s

Paper 26.3 BoundChecker.requireRange 强制 maxStackSize ∈ [1,99],
配置值120超出上限抛 IllegalArgumentException 中断 InventoryClick 事件。

修复:
- resolveAndAdd 解析时 clamp(日志播报值与实际一致)
- applyStackSize 写入时再 clamp 兜底(防御性,防绕过路径)
This commit is contained in:
youpaishidifu
2026-11-03 16:21:46 +08:00
parent 6c1922720d
commit 3d21e6d4f7
@@ -300,6 +300,8 @@ public class StackConfigManager implements Listener {
* 支持:英文直接匹配、中文翻译、通配符 *、中文通配符「所有」。 * 支持:英文直接匹配、中文翻译、通配符 *、中文通配符「所有」。
*/ */
private void resolveAndAdd(String key, int stackSize, Map<Material, Integer> out) { private void resolveAndAdd(String key, int stackSize, Map<Material, Integer> out) {
// ★ 第70批:Paper 26.3 强制 maxStackSize ∈ [1,99],配置值 clamp
stackSize = Math.max(1, Math.min(99, stackSize));
// 1. 通配符 * (如 oak_* 或 *_wool) // 1. 通配符 * (如 oak_* 或 *_wool)
if (key.contains("*")) { if (key.contains("*")) {
String[] parts = key.split("\\*", -1); String[] parts = key.split("\\*", -1);
@@ -395,7 +397,8 @@ public class StackConfigManager implements Listener {
if (max > 0 && item.getMaxStackSize() != max) { if (max > 0 && item.getMaxStackSize() != max) {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
if (meta != null) { if (meta != null) {
meta.setMaxStackSize(max); // ★ 第70批:防御性 clamp,防止任何路径绕过 resolveAndAdd 直接写入
meta.setMaxStackSize(Math.max(1, Math.min(99, max)));
item.setItemMeta(meta); item.setItemMeta(meta);
} }
return true; return true;