1. PVPTestManager.backupInventory: allEmpty 分支不再标记 inventoryOwnedByPvp (pvp_test 恒 skipDb=true 不写 DB, 标记会让还原读 DB→null→空背包) 改为快照 0 件净背包, 还原=0 件=空背包(玩家本就空手进场, 正确) 2. PVPTestManager.reclaimAndStripPVPSpecialEquip: 新增公共方法, 供 StackConfigManager 0信任炸开前清理 PVP/练习装备残留 3. StackConfigManager.clearAll + rescanPlayerInventory: 炸开前调用 stripPVPEquipmentAllPlayers 清理 PVP 残留 避免裸练习装备(无标记)被误炸到相邻空槽 4. 修复 StackConfigManager 新增方法: stripPVPEquipment + stripPVPEquipmentAllPlayers
This commit is contained in:
@@ -971,19 +971,21 @@ public class PVPTestManager implements Listener {
|
||||
int stripped = 回收PVPSpecialEquip(p);
|
||||
boolean allEmpty = isInventoryEmpty(p);
|
||||
if (allEmpty) {
|
||||
// ★ 续24:全空 = 真实背包已被 PVP 系统备份到 DB(进场时序:PVP 先备份+清空+发装备,
|
||||
// 靶场随后看到的是 PVP 专属装备被回收后的空包)。此时必须从 PVP 系统 DB 取
|
||||
// 真实进场前背包快照到 pendingPVPPickup,供还原后补回;否则还原=空。
|
||||
inventoryOwnedByPvp.add(p.getUniqueId());
|
||||
InventoryBackup dbPickup = readPVPPickupFromDb(p);
|
||||
if (dbPickup != null) {
|
||||
pendingPVPPickup.put(p.getUniqueId(), dbPickup);
|
||||
}
|
||||
int dbCount = 0;
|
||||
if (dbPickup != null) for (ItemStack it : dbPickup.contents) if (it != null) dbCount++;
|
||||
// ★ 续24-C 守卫:背包全空(净物 0 件)说明玩家进场时本就空手(或 PVP 清空后无真实物),
|
||||
// 净背包就是空。PVP 系统对 pvp_test 世界 skipDb=true 不写 DB(备份只在内存),
|
||||
// 若标记 PVP-owned 会让还原路径读 PVP DB(必然 null)→ 还原=空背包。
|
||||
// 正确语义:背包全空 → 还原就是空背包(进场时本就无物),绝不动 PVP DB。
|
||||
// 此时不标记 PVP-owned,走下方净背包路径快照 0 件;还原还原 0 件=空背包(玩家本就空手进场,正确)。
|
||||
// ★ 续24:若背包非全空(真实净物>0)→ 继续走下方净背包路径快照真实物品。
|
||||
// 全空但玩家确实有「PVP DB 备份」的场景(主竞技场 skipDb=false 写了 DB)需另行处理——
|
||||
// 但靶场 pvp_test 恒为 skipDb=true,DB 无备份,故全空=净背包就是空,直接走净背包路径。
|
||||
inventoryBackups.put(p.getUniqueId(), new InventoryBackup(
|
||||
new ItemStack[0], new ItemStack[4], null, 0, 0f));
|
||||
pendingPVPPickup.put(p.getUniqueId(), new InventoryBackup(
|
||||
new ItemStack[0], new ItemStack[4], null, 0, 0f));
|
||||
plugin.getLogger().info("[PVP测试] 玩家 " + p.getName()
|
||||
+ " 进场背包回收 " + stripped + " 件PVP/练习装备后为空(真实背包归PVP系统DB),"
|
||||
+ "已从PVP DB快照真实净物品 " + dbCount + " 件,死亡/离场还原后将补回");
|
||||
+ " 进场背包回收 " + stripped + " 件PVP/练习装备后为空(净背包=空,玩家本就空手进场),"
|
||||
+ "死亡/离场还原后补回 0 件(=空背包)");
|
||||
return;
|
||||
}
|
||||
// ★ 非全空:玩家带入了非PVP物品。先二次回收所有PVP/练习装备(含裸练习武器/盾/弓/肉),
|
||||
@@ -1132,6 +1134,14 @@ public class PVPTestManager implements Listener {
|
||||
return count;
|
||||
}
|
||||
|
||||
/** ★ 续24-C:供 StackConfigManager 0信任炸开前调用,清理 PVP/练习装备残留。
|
||||
* PVP 系统发放在背包的裸装备(无标记)或带标记装备,在堆叠停用炸开前需先回收,
|
||||
* 避免被误炸到相邻空槽导致玩家背包多出 PVP 装备。
|
||||
* @return 回收件数 */
|
||||
public int reclaimAndStripPVPSpecialEquip(Player p) {
|
||||
return 回收PVPSpecialEquip(p);
|
||||
}
|
||||
|
||||
|
||||
/** ★ 续22:解析 PVP 系统 DB 备份的背包/盔甲字符串(BukkitObjectOutputStream+Base64,PVPArenaManager.serializeItems 格式) */
|
||||
private ItemStack[] deserializePvpItems(String data) {
|
||||
|
||||
@@ -93,6 +93,31 @@ public class StackConfigManager implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/** ★ 续24-C:清理 PVP/练习装备残留(PVP 系统发放在背包的裸装备/带标记装备),
|
||||
* 在 0信任炸开前调用,避免 PVP 专属装备被误炸。返回回收件数。 */
|
||||
private int stripPVPEquipment(Player p) {
|
||||
try {
|
||||
PVPTestManager test = plugin.getPVPTestManager();
|
||||
if (test == null) return 0;
|
||||
return test.reclaimAndStripPVPSpecialEquip(p);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("[物品堆叠] PVP 装备残留清理异常: " + e.getMessage());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** ★ 续24-C:遍历所有在线玩家,清理 PVP/练习装备残留。返回总回收件数。 */
|
||||
private int stripPVPEquipmentAllPlayers() {
|
||||
int total = 0;
|
||||
for (org.bukkit.entity.Player p : plugin.getServer().getOnlinePlayers()) {
|
||||
total += stripPVPEquipment(p);
|
||||
}
|
||||
if (total > 0) {
|
||||
plugin.getLogger().info("[物品堆叠] 炸开前清理 PVP/练习装备残留: 共回收 " + total + " 件");
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public StackConfigManager(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
this.configFile = new File(plugin.getDataFolder(), "物品堆叠修改/item.md");
|
||||
@@ -336,6 +361,9 @@ public class StackConfigManager implements Listener {
|
||||
// 保证坏配置下在线玩家「已堆叠物品」被强制拆散还原,不依赖文件再次变更。
|
||||
lastFileHash = null;
|
||||
plugin.getLogger().warning("[物品堆叠] ★ 配置无效,已清空全部堆叠映射并强制停用(交还MC原版堆叠逻辑): " + reason);
|
||||
// ★ 续24-C:炸开前清理 PVP/练习装备残留(PVP 系统发放的裸装备/带标记装备),
|
||||
// 避免被误炸到相邻空槽导致玩家背包多出 PVP 装备。
|
||||
stripPVPEquipmentAllPlayers();
|
||||
// 映射已清空 → applyStackSize 不再写新组件;已写入组件的物品需还原(强制拆散)
|
||||
rescanOnlinePlayers();
|
||||
}
|
||||
@@ -446,6 +474,12 @@ public class StackConfigManager implements Listener {
|
||||
try {
|
||||
ItemStack[] contents = inv.getContents();
|
||||
if (contents == null) return;
|
||||
// ★ 续24-C:炸开前清理 PVP/练习装备残留(PVP 系统发放的裸装备/带标记装备),
|
||||
// 避免被误炸到相邻空槽导致玩家背包多出 PVP 装备。
|
||||
int pvpStripped = stripPVPEquipment(player);
|
||||
if (pvpStripped > 0) {
|
||||
contents = inv.getContents(); // PVP 清理后刷新 contents
|
||||
}
|
||||
for (int i = 0; i < contents.length; i++) {
|
||||
ItemStack item = contents[i];
|
||||
if (item == null || item.getType() == Material.AIR) continue;
|
||||
|
||||
Reference in New Issue
Block a user