124批续20:/pvp test 双系统备份冲突——PVPTestManager还原后回收PVP/练习装备,防死亡返回带出竞技场装备
Auto Release / build (push) Successful in 2m47s
Auto Release / build (push) Successful in 2m47s
This commit is contained in:
@@ -965,7 +965,64 @@ public class PVPTestManager implements Listener {
|
||||
p.getInventory().setItemInOffHand(b.offHand);
|
||||
p.setLevel(b.level);
|
||||
p.setExp(b.exp);
|
||||
plugin.getLogger().info("[PVP测试] 已还原玩家 " + p.getName() + " 的背包");
|
||||
// ★ 第124批续20(2026-11-17):还原后回收「PVP专属装备 + 练习装备」。
|
||||
// /pvp test 时 PVPArenaManager 与 PVPTestManager 两套系统都会备份/发装备,
|
||||
// 玩家死亡复活(onRespawn)/超时遣返(scheduleKickTimeout) 还原的是「进靶场那一刻
|
||||
// 含 PVP 专属装备(末地合金镐等)的背包」,若不回收,PVP/练习装备会混回主世界背包
|
||||
// (用户视频:死亡返回带出竞技场装备 + 背包混乱)。这里统一把带 PVP 标记的装备清掉。
|
||||
int reclaimed = 回收PVPSpecialEquip(p);
|
||||
plugin.getLogger().info("[PVP测试] 已还原玩家 " + p.getName() + " 的背包"
|
||||
+ (reclaimed > 0 ? "(并回收 " + reclaimed + " 件PVP/练习装备,防混回主世界)" : ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* ★ 第124批续20:回收背包里的 PVP 专属装备(lore 含「PVP竞技场专属」)
|
||||
* 与练习装备(显示名含「练习」),防止它们随备份还原混回主世界。
|
||||
* 回收物直接销毁(PVP 装备本就是插件发放的消耗物,不带回主世界是预期行为)。
|
||||
* @return 回收件数
|
||||
*/
|
||||
private int 回收PVPSpecialEquip(Player p) {
|
||||
int count = 0;
|
||||
ItemStack[] contents = p.getInventory().getContents();
|
||||
for (int i = 0; i < contents.length; i++) {
|
||||
if (contents[i] != null && isPVPSpecialItem(contents[i])) {
|
||||
count += contents[i].getAmount();
|
||||
contents[i] = null;
|
||||
}
|
||||
}
|
||||
p.getInventory().setContents(contents);
|
||||
ItemStack[] armor = p.getInventory().getArmorContents();
|
||||
for (int i = 0; i < armor.length; i++) {
|
||||
if (armor[i] != null && isPVPSpecialItem(armor[i])) {
|
||||
count += armor[i].getAmount();
|
||||
armor[i] = null;
|
||||
}
|
||||
}
|
||||
p.getInventory().setArmorContents(armor);
|
||||
ItemStack off = p.getInventory().getItemInOffHand();
|
||||
if (off != null && isPVPSpecialItem(off)) {
|
||||
count += off.getAmount();
|
||||
p.getInventory().setItemInOffHand(null);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/** 识别 PVP 专属装备(PVPArenaManager lore 口径)或 PVPTestManager 练习装备(显示名含「练习」) */
|
||||
private boolean isPVPSpecialItem(ItemStack item) {
|
||||
if (item == null) return false;
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return false;
|
||||
// PVPArenaManager 发的 PVP 专属装备:lore 含「PVP竞技场专属」
|
||||
List<String> lore = meta.getLore();
|
||||
if (lore != null) {
|
||||
for (String line : lore) {
|
||||
if (line != null && line.contains("PVP竞技场专属")) return true;
|
||||
}
|
||||
}
|
||||
// PVPTestManager 练习装备:显示名含「练习」(练习剑/练习护甲/练习盾牌/练习弓/练习弩)
|
||||
String dn = meta.getDisplayName();
|
||||
if (dn != null && dn.contains("练习")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void clearInventory(Player p) {
|
||||
|
||||
Reference in New Issue
Block a user