From da8dae3b5b2841beae82e74122e72086a1d70ac1 Mon Sep 17 00:00:00 2001 From: youpaishidifu <1@ypshidifu.cn> Date: Wed, 11 Nov 2026 21:14:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC115=E6=89=B9=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=80=80=E5=87=BA=E9=A2=86=E5=9C=B0=E8=BF=9D=E7=A6=81?= =?UTF-8?q?=E5=93=81=E5=8F=8C=E5=80=8D=E9=80=80=E8=BF=98=E6=BC=8F=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:onQuit 只清 playerCurrentArea 与效果标记,未清 confiscatedStore (违禁品没收暂存,内存态 Map>>)。 玩家在 returnOnLeave=true 的领地被没收违禁品后直接退游戏, 暂存记录残留;下次登录进服再进入该领地时,handleConfiscate 因背包已无该物品而 count=0 不再暂存,但 handleConfiscateReturn 在离开领地时会把残留暂存再退一遍——同一份物品被处理两次, 表现为「退出领地时背包已满→掉落脚下→玩家捡起→再退一次」的双倍刷出。 修复:新增 clearConfiscatedStore(UUID),onQuit 时整玩家清空暂存, 无论是否在线都不留尾巴。 --- src/main/java/Sdf1_login/AreaProtection.java | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/Sdf1_login/AreaProtection.java b/src/main/java/Sdf1_login/AreaProtection.java index 213763e..d3674bc 100644 --- a/src/main/java/Sdf1_login/AreaProtection.java +++ b/src/main/java/Sdf1_login/AreaProtection.java @@ -512,6 +512,10 @@ public class AreaProtection implements Listener { pendingClearEffects.remove(uid); } + // ★ 清违禁品暂存(防离线退还漏洞:退出时没收记录必须随之作废, + // 否则下次进服再进领地会重复走一遍归还,等于同一份物品被处理两次) + clearConfiscatedStore(uid); + // 清标记 playerMarkedEffects.remove(uid); playerCurrentArea.remove(uid); @@ -13238,6 +13242,24 @@ public class AreaProtection implements Listener { } } + /** + * ★ 玩家退出时清空其违禁品暂存(防离线退还漏洞)。 + *

+ * 背景:confiscatedStore 是内存态,onQuit 原本只清 playerCurrentArea + * 与效果标记,不清暂存。若玩家「退出领地时背包已满」,归还逻辑 + * {@link #handleConfiscateReturn} 会先把物品 addItem 进背包、 + * 放不下的再 dropItemNaturally 掉到脚下——但玩家已不在线, + * 这些掉落实体在玩家下次进入领地前一直存在;更严重的是,暂存记录 + * 不会被清除,玩家下次登录进服后只要再次进入该领地(returnOnLeave=true), + * 上次没退还的部分会再次走一遍 addItem/drop,等于同一份物品被处理两次。 + *

+ * 修复:退出时整玩家清空暂存,无论是否在线都不再留尾巴。 + */ + public void clearConfiscatedStore(UUID uid) { + if (uid == null) return; + confiscatedStore.remove(uid); + } + @EventHandler(priority = EventPriority.HIGHEST) public void onEntityDamage( org.bukkit.event.entity.EntityDamageByEntityEvent e) {