- 误伤修复:enforceShieldConfiscationScan/onPVPShieldUse 加 customModeOwner!=null 前置,仅自定义模式房间+盾OFF生效;公开/私人房未指定模式不碰任何盾牌。 - 三振计数 registerShieldViolation:1/2 次警告(提示 违规 N/3),第 3 次遣返到 玩家自己的出生点(getBedOrSpawnLocation)并清零该玩家计数。 - 清零条件(或逻辑):① 玩家被遣返(自动清零)② 世界解散(deletePVPWorld 全量 clear)。 - 使用闸不再限定 PVP 标记盾(OFF 时任何盾都拦),主手/副手持盾即记违规。 Co-Authored-By: WorkBuddy <noreply@workbuddy.cn>
This commit is contained in:
co-authored by
WorkBuddy
parent
770ca9e816
commit
c8ecc2e0d7
@@ -199,6 +199,9 @@ public class PVPArenaManager implements Listener {
|
||||
private final Set<String> noBuildPlayers = ConcurrentHashMap.newKeySet();
|
||||
// ★ 第120批:本局开局房主名(自定义模式第一个带 cfg 进世界的人)
|
||||
private String customModeOwner = null;
|
||||
// ★ 第121批续8:OFF 模式盾牌三振计数(玩家名 -> 违规次数,1/2 警告,3 遣返到出生点并清零)。
|
||||
// 清零条件(或逻辑,满足任一即清零该玩家):① 玩家被遣返 ② 世界解散(全部清零)。
|
||||
private final Map<String, Integer> shieldViolations = new ConcurrentHashMap<>();
|
||||
// ★ 第120批:本局是否全局禁止破坏放置(forceEquip 无关,blockBreakPlace=否 即全局拦)
|
||||
private volatile boolean noBuildGlobal = false;
|
||||
// ★ 第120批:本局是否全局徒手(bareHands=开 即全员不发装备、不弹选装GUI)
|
||||
@@ -1270,6 +1273,8 @@ public class PVPArenaManager implements Listener {
|
||||
scoreEntries.clear();
|
||||
pvpScoreboard = null;
|
||||
}
|
||||
// ★ 第121批续8:世界解散 → 全部玩家盾牌违规计数清零(三振清零条件②)
|
||||
shieldViolations.clear();
|
||||
|
||||
// 兜底:把仍在世界内的玩家送回主世界。
|
||||
// ★ 若取到的落点本身还在本世界内(复活点被锁在竞技场),必须强制改用主世界出生点,
|
||||
@@ -1883,29 +1888,24 @@ public class PVPArenaManager implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
if (!inPVPArena.contains(player.getName())) return;
|
||||
|
||||
for (ItemStack hand : new ItemStack[]{
|
||||
player.getInventory().getItemInMainHand(),
|
||||
player.getInventory().getItemInOffHand()}) {
|
||||
if (hand == null || hand.getType() != Material.SHIELD) continue;
|
||||
ItemMeta hm = hand.getItemMeta();
|
||||
if (hm == null || !hm.hasLore()) continue;
|
||||
List<String> lore = hm.getLore();
|
||||
if (lore == null || !lore.contains(PVP_ITEM_MARKER)) continue;
|
||||
// ★ 第121批续8:仅自定义模式房间(customModeOwner!=null)+ 盾模式=OFF 才拦,
|
||||
// 非自定义房间(公开/私人房未指定模式)直接放行,不碰任何盾牌。
|
||||
if (customModeOwner == null) return;
|
||||
PVPCustomModeManager.CustomConfig useCfg = customCfg.get(customModeOwner);
|
||||
PVPCustomModeManager.ShieldMode useMode =
|
||||
(useCfg != null) ? useCfg.shieldMode : PVPCustomModeManager.ShieldMode.OFF;
|
||||
if (useMode != PVPCustomModeManager.ShieldMode.OFF) return; // FREE/ON 交还原版
|
||||
|
||||
// 仅当本局盾牌模式=OFF 才拦(FREE/ON 交还原版)
|
||||
// ★ 第121批续4:盾模式取房主键(customModeOwner),非房主键 customCfg.get(name)
|
||||
// 取不到房主配置会误判 OFF → 漏拦。
|
||||
PVPCustomModeManager.CustomConfig useCfg =
|
||||
(customModeOwner != null) ? customCfg.get(customModeOwner) : customCfg.get(player.getName());
|
||||
PVPCustomModeManager.ShieldMode useMode =
|
||||
(useCfg != null) ? useCfg.shieldMode : PVPCustomModeManager.ShieldMode.OFF;
|
||||
if (useMode != PVPCustomModeManager.ShieldMode.OFF) return;
|
||||
// 主手或副手持盾 → 拦 + 记三振
|
||||
boolean hasShield = false;
|
||||
ItemStack main = player.getInventory().getItemInMainHand();
|
||||
if (main != null && main.getType() == Material.SHIELD) hasShield = true;
|
||||
ItemStack off = player.getInventory().getItemInOffHand();
|
||||
if (off != null && off.getType() == Material.SHIELD) hasShield = true;
|
||||
if (!hasShield) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
player.sendMessage("§c§l[PVP] §f本局禁用盾牌,无法使用");
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1.0f, 1.0f);
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
registerShieldViolation(player);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@@ -3508,16 +3508,48 @@ public class PVPArenaManager implements Listener {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.6f, 1.2f);
|
||||
}
|
||||
|
||||
/**
|
||||
* 第121批续8:OFF 模式盾牌三振——记一次违规,1/2 次警告,第 3 次遣返到玩家自己的
|
||||
* 出生点并清零该玩家计数。
|
||||
* 清零条件(或逻辑,满足任一即清零该玩家):① 玩家被遣返(本方法内自动清零)
|
||||
* ② 世界解散(deletePVPWorld 时全量清空)。
|
||||
* 仅 OFF 模式 + PVP 世界调用;其他场景不记违规。
|
||||
*/
|
||||
private void registerShieldViolation(Player p) {
|
||||
String name = p.getName();
|
||||
int n = shieldViolations.merge(name, 1, Integer::sum);
|
||||
if (n <= 2) {
|
||||
// 前两次警告
|
||||
p.sendMessage("§e§l[PVP] §e盾牌违规 " + n + "/3 §f再次违规将被遣返到出生点");
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 0.4f, 1.2f);
|
||||
return;
|
||||
}
|
||||
// 第三次:遣返到玩家自己的出生点 + 清零
|
||||
p.sendMessage("§c§l[PVP] §f盾牌违规 3 次,已被遣返到你的出生点");
|
||||
Location dest = getBedOrSpawnLocation(p);
|
||||
if (dest == null || dest.getWorld() == null) {
|
||||
World main = Bukkit.getWorlds().get(0);
|
||||
dest = main.getSpawnLocation();
|
||||
}
|
||||
p.teleport(dest);
|
||||
shieldViolations.remove(name);
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ENDER_DRAGON_DEATH, 0.3f, 1.0f);
|
||||
plugin.getLogger().info("[PVP] 玩家 " + name + " 盾牌违规 3 次,已遣返到出生点并清零计数");
|
||||
}
|
||||
|
||||
/**
|
||||
* 第121批续7:OFF 模式全员禁盾——持续扫描没收盾牌(每秒 20 tick,由 loadConfig 定时任务驱动)。
|
||||
* UseCooldown 组件实测无效(OFF 时拦了右键,原版永不触发冷却),改为直接没收:
|
||||
* 扫背包+主手+副手+盔甲,发现盾牌立刻 setItem(null) 没收,玩家拿到的盾下一秒就被清。
|
||||
* 仅盾模式=OFF 时生效;FREE/ON 直接返回,交还原版冷却逻辑,不误伤。
|
||||
* 仅自定义模式房间 + 盾模式=OFF 时生效;FREE/ON/非自定义房间直接返回,交还原版,不误伤。
|
||||
* 范围:仅 PVP 世界在线玩家(isPVPWorld 判定),离开 PVP 世界后背包还原自动失效。
|
||||
*/
|
||||
private void enforceShieldConfiscationScan() {
|
||||
PVPCustomModeManager.CustomConfig ownerCfg =
|
||||
(customModeOwner != null) ? customCfg.get(customModeOwner) : null;
|
||||
// ★ 第121批续8:仅自定义模式房间生效——customModeOwner==null(公开/私人房未指定模式)
|
||||
// 时直接返回,不碰任何盾牌。避免误伤私人房间(用户实测:私人房未指定模式也被
|
||||
// 提示「房主禁用盾牌」)。
|
||||
if (customModeOwner == null) return;
|
||||
PVPCustomModeManager.CustomConfig ownerCfg = customCfg.get(customModeOwner);
|
||||
PVPCustomModeManager.ShieldMode mode =
|
||||
(ownerCfg != null) ? ownerCfg.shieldMode : PVPCustomModeManager.ShieldMode.OFF;
|
||||
if (mode != PVPCustomModeManager.ShieldMode.OFF) return; // FREE/ON 交还原版
|
||||
@@ -3555,6 +3587,7 @@ public class PVPArenaManager implements Listener {
|
||||
if (cleared > 0) {
|
||||
p.sendMessage("§c§l[PVP] §f本局禁用盾牌,已没收 " + cleared + " 个盾牌");
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_VILLAGER_NO, 0.8f, 1.0f);
|
||||
registerShieldViolation(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user