用户定调原文:「玩家加入竞技场时,读一次成就,已有→跳过,若无→保持现状, 高频无条件清理」。老玩家进服前早已手打拿全成就,旧 handEarned 方案会把它 当场撤销=分歧。 - 删 handEarned(按「未穿装备完成」标记,口径有分歧)。 - 新增 pvpPreExisting(UUID→进场时 done=true 的成就快照)+ inPvpWorld (当前在 PVP 世界的玩家标记)。 - tickPlayer/checkArmorAndRevokeOnJoin 复用 ensurePvpSnapshot:进 PVP 世界 首次读一次 5 条受管控成就 isDone,done 的进快照→永久跳过;没 done 的 →高频无条件清理(revokeAll)。离开 PVP 世界清快照,下次再进重读。 - Done 事件只压播报+尽力撤销,不再做手打标记;forgetPlayer 离场清快照。
This commit is contained in:
@@ -99,9 +99,13 @@ public class AchievementEffectGuard implements Listener {
|
|||||||
private final Set<String> revokedLogged = new HashSet<>();
|
private final Set<String> revokedLogged = new HashSet<>();
|
||||||
/** 装备成就撤销冷却(玩家UUID:成就key → 10 秒内同成就不再重复处理,扼制连刷) */
|
/** 装备成就撤销冷却(玩家UUID:成就key → 10 秒内同成就不再重复处理,扼制连刷) */
|
||||||
private final Set<String> armorRevokeCooldown = new HashSet<>();
|
private final Set<String> armorRevokeCooldown = new HashSet<>();
|
||||||
/** ★ 第123批再续11:玩家手打完成的成就(uid:advKey)。玩家未穿插件装备且不在 PVP 世界
|
/** ★ 第123批再续12:玩家「进入 PVP 竞技场前已有」的受管控成就(UUID → 进场时 isDone=true 的
|
||||||
* 时完成过该成就 → 记入此集合,高频定时器不再监管(用户定调:独立完成一次后插件不再管) */
|
* 成就 key 集合)。进场快照:进竞技场时读一次 5 条受管控成就,已有(done)= 手打过的 →
|
||||||
private final Set<String> handEarned = new HashSet<>();
|
* 永久跳过,高频定时器不再监管;没有(done=false)= 插件给的 → 高频无条件清理。
|
||||||
|
* 离开 PVP 世界即清空快照,下次再进重新读(对齐用户「加入竞技场时读一次」定调)。 */
|
||||||
|
private final Map<UUID, Set<String>> pvpPreExisting = new HashMap<>();
|
||||||
|
/** 当前处于 PVP 世界的玩家(UUID)。用于判定「首次进入」触发进场快照 */
|
||||||
|
private final Set<UUID> inPvpWorld = new HashSet<>();
|
||||||
|
|
||||||
private final Main plugin;
|
private final Main plugin;
|
||||||
|
|
||||||
@@ -115,10 +119,10 @@ public class AchievementEffectGuard implements Listener {
|
|||||||
|
|
||||||
public AchievementEffectGuard(Main plugin) {
|
public AchievementEffectGuard(Main plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
// ★ 第123批再续11:用户定调——挂高频定时器一直撤销。玩家在 PVP 场地内、
|
// ★ 第123批再续12:用户定调——进场读一次成就:已有(手打过)→ 跳过;
|
||||||
// 穿着插件给的服装,只要受管控成就 done,每 tick 扫到就撤一次。
|
// 若无 → 保持现状高频无条件清理。玩家在 PVP 场地穿插件服装,进场前没
|
||||||
// MC 给一次(穿插件装备触发 criterion 重授),插件就撤销一次。
|
// 拿过的受管控成就,高频定时器「MC 给一次就撤一次」;进场前已拿过的
|
||||||
// 直到玩家独立完成一次(未穿插件装备时 done),handEarned 记录后不再监管。
|
// 成就(老玩家手打过)永久不碰。不脱装备、不丢弃。
|
||||||
startHighFrequencyRevokeTimer();
|
startHighFrequencyRevokeTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,9 +141,10 @@ public class AchievementEffectGuard implements Listener {
|
|||||||
* true。定时器是最终兜底:只要玩家还穿着插件装备站在 PVP 世界,每秒钟都会再撤一次,
|
* true。定时器是最终兜底:只要玩家还穿着插件装备站在 PVP 世界,每秒钟都会再撤一次,
|
||||||
* 存档里永远写不进 done=true(或写完下一秒又被撤掉重算)。</p>
|
* 存档里永远写不进 done=true(或写完下一秒又被撤掉重算)。</p>
|
||||||
*
|
*
|
||||||
* <p>监管口径:PVP 世界 + 穿插件装备(lore 带 [PVP竞技场专属])+ 成就 isDone()
|
* <p>★ 第123批再续12 监管口径(用户定调「进场读一次成就,已有→跳过,若无→
|
||||||
* + 该成就不在 handEarned(手打完成集合)→ revokeAll。药水类两条同样受监管
|
* 高频无条件清理」):进 PVP 竞技场时读一次 5 条受管控成就,进场前已 done 的
|
||||||
* (身上还带插件效果时)。</p>
|
* (老玩家手打过)记入进场快照 pvpPreExisting、永久不碰;进场前未 done 的
|
||||||
|
* (插件给的)由高频定时器「MC 给一次就撤一次」。离开 PVP 世界清空快照。</p>
|
||||||
*/
|
*/
|
||||||
private void startHighFrequencyRevokeTimer() {
|
private void startHighFrequencyRevokeTimer() {
|
||||||
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||||
@@ -156,26 +161,43 @@ public class AchievementEffectGuard implements Listener {
|
|||||||
}, 20L, 20L);
|
}, 20L, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 定时器单玩家判定:PVP 世界 + 穿插件装备 → 监管全部受管控成就 */
|
/**
|
||||||
|
* 定时器单玩家判定(★ 第123批再续12 进场快照方案):
|
||||||
|
*
|
||||||
|
* <p>用户定调:「玩家加入竞技场时,读一次成就,已有→跳过,若无→保持现状,
|
||||||
|
* 高频无条件清理」。判定基准是<b>进入 PVP 竞技场那一刻</b>的成就状态,不是
|
||||||
|
* 「是否手打过」——老玩家进服前早已手打拿全,进场时成就 done=true → 进快照 →
|
||||||
|
* 永久不碰;新玩家/没成就的进场时 done=false → 不在快照 → 高频无条件清。
|
||||||
|
* 离开 PVP 世界即清空快照,下次再进重新读。</p>
|
||||||
|
*/
|
||||||
private void tickPlayer(Player p) {
|
private void tickPlayer(Player p) {
|
||||||
UUID uid = p.getUniqueId();
|
UUID uid = p.getUniqueId();
|
||||||
// 监管前提:玩家在 PVP 世界 + 穿着插件发放的装备(用户定调:穿了装备直接打)
|
if (isPVPWorld(p)) {
|
||||||
if (!isPVPWorld(p) || !isWearingPVPEquipment(p)) return;
|
// 首次进入 PVP 世界:读一次 5 条受管控成就,done=true 的记入「进场前已有」快照
|
||||||
|
ensurePvpSnapshot(p);
|
||||||
|
// 监管前提:PVP 世界 + 穿插件装备(用户定调:穿了装备直接打)
|
||||||
|
if (!isWearingPVPEquipment(p)) return;
|
||||||
|
Set<String> preExisting = pvpPreExisting.get(uid);
|
||||||
|
if (preExisting == null) preExisting = java.util.Collections.emptySet();
|
||||||
|
// 高频清理:只清「进场前没有」的受管控成就(插件给的);进场前已有的跳过
|
||||||
|
for (String key : allGuardedKeys()) {
|
||||||
|
if (preExisting.contains(key)) continue; // 进场前已有(手打过)→ 不碰
|
||||||
|
if (!isDone(p, key)) continue; // 未完成 → 无可撤
|
||||||
|
revokeAll(p, key, "高频定时器:PVP世界穿插件装备,进场前未获得的成就被重授");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 离开 PVP 世界:重置快照与在场所标记,下次再进重新读一次
|
||||||
|
inPvpWorld.remove(uid);
|
||||||
|
pvpPreExisting.remove(uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 装备类三条
|
/** 全部受管控成就 key(药水 2 + 装备 3),快照与高频清理共用 */
|
||||||
for (String key : ARMOR_ADV_KEYS) {
|
private List<String> allGuardedKeys() {
|
||||||
if (handEarned.contains(uid + ":" + key)) continue; // 手打完成 → 不再监管
|
List<String> all = new java.util.ArrayList<>(ARMOR_ADV_KEYS);
|
||||||
revokeAll(p, key, "高频定时器:PVP世界穿着插件发放装备且装备成就已完成");
|
all.add(ADV_KEY_ALL_POTIONS);
|
||||||
}
|
all.add(ADV_KEY_ALL_EFFECTS);
|
||||||
// 药水类两条(身上还带插件效果时才撤,避免误伤已自然到期)
|
return all;
|
||||||
if (hasPluginMarkedEffects(p)) {
|
|
||||||
if (isDone(p, ADV_KEY_ALL_POTIONS) && !handEarned.contains(uid + ":" + ADV_KEY_ALL_POTIONS)) {
|
|
||||||
revokeAll(p, ADV_KEY_ALL_POTIONS, "高频定时器:PVP世界穿着插件发放装备且身上带插件效果");
|
|
||||||
}
|
|
||||||
if (isDone(p, ADV_KEY_ALL_EFFECTS) && !handEarned.contains(uid + ":" + ADV_KEY_ALL_EFFECTS)) {
|
|
||||||
revokeAll(p, ADV_KEY_ALL_EFFECTS, "高频定时器:PVP世界穿着插件发放装备且身上带插件效果");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 成就是否已 done(定时器用,容忍 null) */
|
/** 成就是否已 done(定时器用,容忍 null) */
|
||||||
@@ -233,10 +255,9 @@ public class AchievementEffectGuard implements Listener {
|
|||||||
for (java.util.Iterator<String> it = armorRevokeCooldown.iterator(); it.hasNext(); ) {
|
for (java.util.Iterator<String> it = armorRevokeCooldown.iterator(); it.hasNext(); ) {
|
||||||
if (it.next().startsWith(uid + ":")) it.remove();
|
if (it.next().startsWith(uid + ":")) it.remove();
|
||||||
}
|
}
|
||||||
// handEarned 是 Set<String>(uid:advKey),前缀清理
|
// ★ 第123批再续12:离场清掉进场快照与在场所标记(避免离线残留影响下次进场)
|
||||||
for (java.util.Iterator<String> it = handEarned.iterator(); it.hasNext(); ) {
|
pvpPreExisting.remove(uid);
|
||||||
if (it.next().startsWith(uid + ":")) it.remove();
|
inPvpWorld.remove(uid);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 该玩家当前是否还带着插件给的效果(诊断用) */
|
/** 该玩家当前是否还带着插件给的效果(诊断用) */
|
||||||
@@ -399,24 +420,19 @@ public class AchievementEffectGuard implements Listener {
|
|||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
if (p == null || !p.isOnline()) return;
|
if (p == null || !p.isOnline()) return;
|
||||||
|
|
||||||
// ① 手打完成标记:玩家未穿插件装备且不在 PVP 世界时完成成就 → 记入手打集合,
|
// ★ 第123批再续12:Done 事件只压播报+尽力撤销,不再做「手打完成」标记——
|
||||||
// 以后高频定时器不再监管该成就(用户定调:直到玩家独立完成一次,插件不再监管)
|
// 监管口径已改为「进场快照」(见 tickPlayer):进竞技场时读一次成就,
|
||||||
if (isGuardedAdvancement(key) || isGuardedArmorAdvancement(key)) {
|
// 已有→跳过,没有→高频无条件清。进场前已拿的成就即便此刻又 Done,
|
||||||
if (!isWearingPVPEquipment(p) && !isPVPWorld(p)) {
|
// 高频定时器也不会碰(不在快照清理范围)。
|
||||||
handEarned.add(p.getUniqueId() + ":" + key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ② 已手打完成的成就不再撤销(玩家独立达成,监管解除)
|
|
||||||
if (handEarned.contains(p.getUniqueId() + ":" + key)) return;
|
|
||||||
|
|
||||||
// ③ 药水类两条:身上带插件给的效果 → 压制播报 + 尽力撤销
|
// 药水类两条:身上带插件给的效果 → 压制播报 + 尽力撤销
|
||||||
if (isGuardedAdvancement(key)) {
|
if (isGuardedAdvancement(key)) {
|
||||||
if (hasPluginMarkedEffects(p)) {
|
if (hasPluginMarkedEffects(p)) {
|
||||||
suppressAndRevoke(event, p, key, "成就完成时检测到插件来源效果");
|
suppressAndRevoke(event, p, key, "成就完成时检测到插件来源效果");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// ④ 装备类三条:PVP 世界 + 穿插件装备 → 压制播报 + 尽力撤销(60秒冷却防抖)
|
// 装备类三条:PVP 世界 + 穿插件装备 → 压制播报 + 尽力撤销(60秒冷却防抖)
|
||||||
if (isGuardedArmorAdvancement(key)) {
|
if (isGuardedArmorAdvancement(key)) {
|
||||||
if (!isPVPWorld(p) || !isWearingPVPEquipment(p)) return;
|
if (!isPVPWorld(p) || !isWearingPVPEquipment(p)) return;
|
||||||
if (!armorRevokeCooldown.add(p.getUniqueId() + ":" + key)) {
|
if (!armorRevokeCooldown.add(p.getUniqueId() + ":" + key)) {
|
||||||
@@ -646,14 +662,38 @@ public class AchievementEffectGuard implements Listener {
|
|||||||
* 覆盖 grant 事件之外的路径(如插件重启期间发放装备后才进的服)。
|
* 覆盖 grant 事件之外的路径(如插件重启期间发放装备后才进的服)。
|
||||||
*/
|
*/
|
||||||
private void checkArmorAndRevokeOnJoin(Player p) {
|
private void checkArmorAndRevokeOnJoin(Player p) {
|
||||||
if (!isPVPWorld(p) || !isWearingPVPEquipment(p)) return;
|
// ★ 第123批再续12:进服复核同样尊重「进场快照」——在 PVP 世界且快照未建则先建
|
||||||
for (String key : ARMOR_ADV_KEYS) {
|
// (读一次进场前成就状态),只清「进场前未获得」的成就,老玩家手打过的不碰。
|
||||||
Advancement adv = resolveAdvancement(key);
|
UUID uid = p.getUniqueId();
|
||||||
if (adv == null) continue;
|
if (!isPVPWorld(p)) return;
|
||||||
AdvancementProgress prog = p.getAdvancementProgress(adv);
|
if (!inPvpWorld.contains(uid)) {
|
||||||
if (prog == null || !prog.isDone()) continue; // 未获得的不动
|
inPvpWorld.add(uid);
|
||||||
revokeAll(p, key, "进服复核:PVP世界穿着插件发放装备且装备成就已完成");
|
Set<String> snapshot = new HashSet<>();
|
||||||
|
for (String key : allGuardedKeys()) {
|
||||||
|
if (isDone(p, key)) snapshot.add(key);
|
||||||
|
}
|
||||||
|
pvpPreExisting.put(uid, snapshot);
|
||||||
}
|
}
|
||||||
|
if (!isWearingPVPEquipment(p)) return;
|
||||||
|
Set<String> preExisting = pvpPreExisting.get(uid);
|
||||||
|
if (preExisting == null) preExisting = java.util.Collections.emptySet();
|
||||||
|
for (String key : allGuardedKeys()) {
|
||||||
|
if (preExisting.contains(key)) continue; // 进场前已有(手打过)→ 不碰
|
||||||
|
if (!isDone(p, key)) continue; // 未完成 → 无可撤
|
||||||
|
revokeAll(p, key, "进服复核:PVP世界穿插件装备,进场前未获得的成就被重授");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 建立进场快照(进 PVP 世界时读一次受管控成就状态),幂等 */
|
||||||
|
private void ensurePvpSnapshot(Player p) {
|
||||||
|
UUID uid = p.getUniqueId();
|
||||||
|
if (inPvpWorld.contains(uid)) return;
|
||||||
|
inPvpWorld.add(uid);
|
||||||
|
Set<String> snapshot = new HashSet<>();
|
||||||
|
for (String key : allGuardedKeys()) {
|
||||||
|
if (isDone(p, key)) snapshot.add(key);
|
||||||
|
}
|
||||||
|
pvpPreExisting.put(uid, snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 是否是本守卫管的三条装备成就 */
|
/** 是否是本守卫管的三条装备成就 */
|
||||||
|
|||||||
Reference in New Issue
Block a user