2.3.2_B
Compatibility
Changes
点击看中文
Gost 2.3.2_B 更新日志
- 本版本为 2.3.2 的补丁更新,聚焦背包返还系统的稳定性问题,同时重做玩家掉线处理逻辑。
- 未涉及新增玩法,插件版本号与配置版本号保持不变。
🐛 修复:背包返还失效(返还出游戏道具)
-
问题现象 部分情况下,玩家游戏结束/离开对局后,返还的背包里混入了游戏内道具(如肾上腺素、狂暴药水等),而不是玩家进入游戏前的原始物品。
-
问题根因 背包快照在保存时使用了 [player.getInventory().getContents()],其内部物品与游戏内实际物品存在引用共享。当游戏开局后执行"清空背包 + 发放游戏道具"时,这份快照会被连带污染,最终返还给玩家的是被污染后的"游戏背包"。此外,快照保存没有任何防重复覆盖保护,一旦在对局中被二次保存,也会用游戏背包覆盖原始背包。
-
修复内容
①快照深拷贝:新增物品克隆逻辑,保存和返还时均逐个 [ItemStack.clone()],彻底切断快照与游戏内物品的引用共享;同时 Location 也做克隆,防止后续传送污染快照。
②防重复覆盖:[savePlayerState] 增加保护——若该玩家已存在原始快照,则跳过重复保存并输出警告日志,杜绝"用游戏背包覆盖原始背包"。
③清空前兜底:清空背包[(updatePlayerInventory)]前若发现该玩家在游戏中却没有快照,立即补保存一次,确保清空前一定存在原始备份。
④顺序固化:在加入游戏流程中明确标注"先保存原始背包、再清空/初始化"的固定顺序,防止后续改动误调次序。
⑤诊断日志:保存与返还均打印背包物品数量(已保存玩家 X 的原始背包(N 个物品) / 已返还玩家 X 的原始背包(N 个物品)),便于日后定位问题。
🐛 优化:玩家掉线处理
-
调整内容 玩家掉线一律视为主动退出对局与队列,并立即还原其原始背包,不再区分在线状态。
-
具体改动
①掉线即退出对局:玩家掉线时无条件执行退出对局流程,立即还原原始背包;还原动作在 PlayerQuitEvent 中同步执行(此时玩家数据尚未落盘),因此即使玩家已经离线,背包也能被正确还原。、
②掉线即退出队列:若玩家在匹配队列中掉线,自动退出队列并退还入场费。
③静默处理:掉线场景不再向玩家发送任何提示消息(避免向已断线玩家发包),但队列退还、Boss 栏刷新、广播等逻辑照常执行。
④快照遗留兜底:若玩家已不在对局中但仍存在遗留快照,退出流程会补做一次背包还原,防止快照残留未处理。
Gost 2.3.2_B Changelog
- This release is a patch update for version 2.3.2, focusing on resolving stability issues in the backpack restoration system and completely reworking the logic for handling player disconnections.
- No new gameplay features have been added; plugin and configuration versions remain unchanged.
🐛 Fix: Backpack restoration failure (restoring in-game items instead of original contents)
-
Issue description
In certain cases, after players end or leave a game session, their restored backpacks contain in-game items (such as adrenaline or berserk potions) rather than the original items they had before entering the game. -
Root cause
The backpack snapshot was saved using [player.getInventory().getContents()], which shares references with actual in-game items. When "clearing the backpack and distributing in-game items" occurs at game start, this snapshot becomes contaminated, resulting in the player receiving a polluted "game backpack" upon restoration. Additionally, there was no protection against overwriting during snapshot saving—any secondary save during the match would overwrite the original backpack with the current game inventory. -
Fixes implemented
① Deep copy of snapshots: Added item cloning logic to perform [ItemStack.clone()] individually during both saving and restoring, completely severing reference sharing between snapshots and in-game items. Locations are also cloned to prevent contamination via teleportation later.
② Prevent duplicate overwrites: Added protection in [savePlayerState]—if a player already has an existing original snapshot, skip redundant saves and log a warning, preventing the original backpack from being overwritten by the game inventory.
③ Preemptive backup before clearing: Before clearing the backpack [in updatePlayerInventory], if a player is detected in the game but lacks a snapshot, immediately save one first, ensuring that a valid original backup exists prior to clearing.
④ Fixed execution order: Clearly define the fixed sequence in the game joining process—"first save original backpack, then clear/reset"—to prevent future modifications from accidentally reversing the order.
⑤ Diagnostic logging: Log the number of items in the backpack during both saving and restoring (e.g., "Saved player X's original backpack (N items)" / "Restored player X's original backpack (N items)") to facilitate future issue tracking.
🐛 Optimization: Player disconnection handling
-
Changes made
All player disconnections are now treated as voluntary exits from the game and queue, triggering immediate restoration of the original backpack without distinction based on online status. -
Specific changes
① Disconnection = exit: Unconditionally trigger the game exit procedure when a player disconnects, immediately restoring the original backpack. The restoration action runs synchronously within the PlayerQuitEvent (before player data is persisted), ensuring correct backpack restoration even if the player is already offline. 、
② Disconnection results in queue exit: If a player disconnects while in the matchmaking queue, they will be automatically removed from the queue and their entry fee refunded.
③ Silent handling: No notification messages will be sent to players upon disconnection (to avoid sending packets to disconnected users), but queue refunds, boss bar refreshes, broadcasts, and other logic will proceed as normal.
④ Snapshot fallback protection: If a player is no longer in the game session but has leftover snapshots, the exit process will perform an additional inventory restore to prevent unprocessed snapshot remnants.
Projects on Modrinth are automatically available through a Maven repository for use with JVM build tools such as Gradle. To learn more about the Modrinth Maven API, click here.
Note: When available, you should use the creator's maven repo instead as it will have transitive dependency information that the Modrinth Maven API does not. You may also end up with duplicate dependencies if you use a mix of Modrinth and non-Modrinth Maven repositories for your dependencies, because the group identifier will be different when served through the Modrinth Maven API.
Maven coordinates:
Version ID:
build.gradle:
repositories {
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
// forRepositories(fg.repository) // Uncomment when using ForgeGradle
filter {
includeGroup "maven.modrinth"
}
}
}
// Standard Gradle dependency
dependencies {
implementation "maven.modrinth:SKYebqyY:kIfv6kYB"
}
// Legacy Loom dependency
dependencies {
modImplementation "maven.modrinth:SKYebqyY:kIfv6kYB"
}

