- 新增 applyShieldCooldownToAll:扫玩家背包+副手+盔甲栏,给所有盾牌写 SHIELD_OFF_COOLDOWN_SECONDS(86400s=24h) 超冷。 - 触发点:onPlayerChangedWorld 进 PVP 世界 + onPlayerEnterPVPWorld 清空后兜底, 仅 OFF 模式 + isPVPWorld 判定,非 OFF 直接跳过,不误伤其他世界/其他模式。 - 覆盖创造模式直接拿盾(/give、创造物品栏、别地图带进来)。 Co-Authored-By: WorkBuddy <noreply@workbuddy.cn>
This commit is contained in:
co-authored by
WorkBuddy
parent
d088dc1151
commit
643a515597
@@ -1583,6 +1583,16 @@ public class PVPArenaManager implements Listener {
|
|||||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.0f);
|
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.0f);
|
||||||
|
|
||||||
plugin.getLogger().info("[PVP] 玩家 " + playerName + " 进入PVP竞技场(已备份清空原背包,等待选装备)");
|
plugin.getLogger().info("[PVP] 玩家 " + playerName + " 进入PVP竞技场(已备份清空原背包,等待选装备)");
|
||||||
|
|
||||||
|
// ★ 第121批续5:自定义模式强制关(盾模式=OFF)时,清空背包后仍兜底扫一次——
|
||||||
|
// 覆盖玩家从创造物品栏/别地图带盾进来的场景(清背包前的盾已不在,
|
||||||
|
// 但若 clearInventory 未覆盖盔甲栏/副手残余,这里兜底写超冷)。
|
||||||
|
PVPCustomModeManager.CustomConfig eCfg = customCfg.get(playerName);
|
||||||
|
PVPCustomModeManager.ShieldMode eMode =
|
||||||
|
(eCfg != null) ? eCfg.shieldMode : PVPCustomModeManager.ShieldMode.OFF;
|
||||||
|
if (eMode == PVPCustomModeManager.ShieldMode.OFF) {
|
||||||
|
applyShieldCooldownToAll(player, SHIELD_OFF_COOLDOWN_SECONDS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1775,6 +1785,17 @@ public class PVPArenaManager implements Listener {
|
|||||||
boolean toIsPVP = isPVPWorld(player.getWorld());
|
boolean toIsPVP = isPVPWorld(player.getWorld());
|
||||||
boolean fromIsPVP = isPVPWorld(Bukkit.getWorld(from));
|
boolean fromIsPVP = isPVPWorld(Bukkit.getWorld(from));
|
||||||
if (toIsPVP && !fromIsPVP) {
|
if (toIsPVP && !fromIsPVP) {
|
||||||
|
// ★ 第121批续5:自定义模式强制关(盾模式=OFF)时,进世界即给该玩家所有盾牌
|
||||||
|
// 写 24h 超长冷却——覆盖创造模式直接拿盾(/give、创造物品栏、别地图带进来)。
|
||||||
|
// 仅对 PVP 世界生效(isPVPWorld 判定),非 OFF 模式直接跳过,不误伤其他世界。
|
||||||
|
PVPCustomModeManager.CustomConfig wCfg = customCfg.get(player.getName());
|
||||||
|
PVPCustomModeManager.ShieldMode wMode =
|
||||||
|
(wCfg != null) ? wCfg.shieldMode : PVPCustomModeManager.ShieldMode.OFF;
|
||||||
|
if (wMode == PVPCustomModeManager.ShieldMode.OFF) {
|
||||||
|
applyShieldCooldownToAll(player, SHIELD_OFF_COOLDOWN_SECONDS);
|
||||||
|
plugin.getLogger().info("[PVP] 玩家 " + player.getName()
|
||||||
|
+ " 进入PVP世界:盾牌模式=OFF,已给全部盾牌写 24h 超冷(含创造模式拿盾)");
|
||||||
|
}
|
||||||
// 进入PVP世界 → 打开装备选择GUI(此时玩家仍持有原背包)
|
// 进入PVP世界 → 打开装备选择GUI(此时玩家仍持有原背包)
|
||||||
onPlayerEnterPVPWorld(player);
|
onPlayerEnterPVPWorld(player);
|
||||||
} else if (fromIsPVP && !toIsPVP) {
|
} else if (fromIsPVP && !toIsPVP) {
|
||||||
@@ -3515,6 +3536,34 @@ public class PVPArenaManager implements Listener {
|
|||||||
shield.setData(io.papermc.paper.datacomponent.DataComponentTypes.USE_COOLDOWN, cooldown);
|
shield.setData(io.papermc.paper.datacomponent.DataComponentTypes.USE_COOLDOWN, cooldown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第121批续5:自定义模式强制关(盾模式=OFF)时,给该玩家【背包+副手+盔甲】里
|
||||||
|
* 的任何一个盾牌写 24h 超长冷却。覆盖创造模式直接拿盾(/give、创造物品栏、从别的地图带进来等),
|
||||||
|
* 仅对当前 PVP 世界生效(调用点已用 isPVPWorld 判定),离开 PVP 世界后背包还原自动失效,
|
||||||
|
* 不误伤其他世界。
|
||||||
|
*/
|
||||||
|
private void applyShieldCooldownToAll(Player player, float seconds) {
|
||||||
|
if (player == null) return;
|
||||||
|
for (int i = 0; i < player.getInventory().getSize(); i++) {
|
||||||
|
ItemStack it = player.getInventory().getItem(i);
|
||||||
|
if (it != null && it.getType() == Material.SHIELD) {
|
||||||
|
applyShieldUseCooldown(it, seconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ItemStack off = player.getInventory().getItemInOffHand();
|
||||||
|
if (off != null && off.getType() == Material.SHIELD) {
|
||||||
|
applyShieldUseCooldown(off, seconds);
|
||||||
|
}
|
||||||
|
ItemStack[] arm = player.getInventory().getArmorContents();
|
||||||
|
if (arm != null) {
|
||||||
|
for (ItemStack a : arm) {
|
||||||
|
if (a != null && a.getType() == Material.SHIELD) {
|
||||||
|
applyShieldUseCooldown(a, seconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== 命令入口 ====================
|
// ==================== 命令入口 ====================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user