根因:onQuit 只清 playerCurrentArea 与效果标记,未清 confiscatedStore (违禁品没收暂存,内存态 Map<UUID, Map<areaName, List<ItemStack>>>)。 玩家在 returnOnLeave=true 的领地被没收违禁品后直接退游戏, 暂存记录残留;下次登录进服再进入该领地时,handleConfiscate 因背包已无该物品而 count=0 不再暂存,但 handleConfiscateReturn 在离开领地时会把残留暂存再退一遍——同一份物品被处理两次, 表现为「退出领地时背包已满→掉落脚下→玩家捡起→再退一次」的双倍刷出。 修复:新增 clearConfiscatedStore(UUID),onQuit 时整玩家清空暂存, 无论是否在线都不留尾巴。
This commit is contained in:
@@ -512,6 +512,10 @@ public class AreaProtection implements Listener {
|
|||||||
pendingClearEffects.remove(uid);
|
pendingClearEffects.remove(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 清违禁品暂存(防离线退还漏洞:退出时没收记录必须随之作废,
|
||||||
|
// 否则下次进服再进领地会重复走一遍归还,等于同一份物品被处理两次)
|
||||||
|
clearConfiscatedStore(uid);
|
||||||
|
|
||||||
// 清标记
|
// 清标记
|
||||||
playerMarkedEffects.remove(uid);
|
playerMarkedEffects.remove(uid);
|
||||||
playerCurrentArea.remove(uid);
|
playerCurrentArea.remove(uid);
|
||||||
@@ -13238,6 +13242,24 @@ public class AreaProtection implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 玩家退出时清空其违禁品暂存(防离线退还漏洞)。
|
||||||
|
* <p>
|
||||||
|
* 背景:confiscatedStore 是内存态,onQuit 原本只清 playerCurrentArea
|
||||||
|
* 与效果标记,不清暂存。若玩家「退出领地时背包已满」,归还逻辑
|
||||||
|
* {@link #handleConfiscateReturn} 会先把物品 addItem 进背包、
|
||||||
|
* 放不下的再 dropItemNaturally 掉到脚下——但玩家已不在线,
|
||||||
|
* 这些掉落实体在玩家下次进入领地前一直存在;更严重的是,暂存记录
|
||||||
|
* 不会被清除,玩家下次登录进服后只要再次进入该领地(returnOnLeave=true),
|
||||||
|
* 上次没退还的部分会再次走一遍 addItem/drop,等于同一份物品被处理两次。
|
||||||
|
* <p>
|
||||||
|
* 修复:退出时整玩家清空暂存,无论是否在线都不再留尾巴。
|
||||||
|
*/
|
||||||
|
public void clearConfiscatedStore(UUID uid) {
|
||||||
|
if (uid == null) return;
|
||||||
|
confiscatedStore.remove(uid);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onEntityDamage(
|
public void onEntityDamage(
|
||||||
org.bukkit.event.entity.EntityDamageByEntityEvent e) {
|
org.bukkit.event.entity.EntityDamageByEntityEvent e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user