124批续21:①测试场敌对生物打不到玩家(onEntityDamage选装无敌误拦pvp_test) ②退场床优先世界出生点兜底
Auto Release / build (push) Successful in 2m58s

This commit is contained in:
youpaishidifu
2026-11-17 21:16:19 +08:00
parent 6d5127d19e
commit b4de14d821
2 changed files with 27 additions and 14 deletions
@@ -2218,7 +2218,14 @@ public class PVPArenaManager implements Listener {
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
String name = player.getName(); String name = player.getName();
// 在PVP世界中但未确认装备 → 取消所有伤害 // 在PVP世界中但未确认装备 → 取消所有伤害
if (inPVPArena.contains(name) && !equipmentConfirmed.contains(name)) { // ★ 第124批续21:pvp_test(PVPTestManager 固定靶场)排除在外——靶场是「练习生物打玩家」
// 的专属场景,伤害完全交给 PVPTestManager 的固定伤害逻辑;若此处也对靶场取消,
// 玩家操作的是 PVPTestManager 的练习 GUI(非 PVP 选装 GUI),PVP 侧 equipmentConfirmed
// 恒 false,会把练习生物对玩家的伤害也全取消 → 敌对生物打不到玩家、kill 不了。
World curWorld = player.getWorld();
boolean inTestWorld = curWorld != null
&& curWorld.getName().equals(PVPTestManager.PVP_TEST_WORLD_NAME);
if (inPVPArena.contains(name) && !equipmentConfirmed.contains(name) && !inTestWorld) {
event.setCancelled(true); event.setCancelled(true);
} }
+19 -13
View File
@@ -811,6 +811,17 @@ public class PVPTestManager implements Listener {
} }
} }
/**
* ★ 第124批续21:退场传送目标统一口径——优先玩家床(出生点),无床则回主世界出生点兜底。
* 用户定调:「退场应当优先退玩家出生点,世界出生点兜底」。
* handleBack/leaveTest/onRespawn/onPlayerJoin/选装GUI遣返 全部走这里,避免各自写死世界出生点。
*/
private Location getBedOrSpawnLocation(Player p) {
Location bed = p.getBedSpawnLocation();
if (bed != null) return bed;
return Bukkit.getWorlds().get(0).getSpawnLocation();
}
/** /**
* 返回出生点(床):若在测试场则先清理并还原背包,再传送至床(无床则主世界出生点)。 * 返回出生点(床):若在测试场则先清理并还原背包,再传送至床(无床则主世界出生点)。
* 供可点击超链接 /pvp back 调用。 * 供可点击超链接 /pvp back 调用。
@@ -830,8 +841,7 @@ public class PVPTestManager implements Listener {
checkAllLeft(); checkAllLeft();
} }
Location bed = p.getBedSpawnLocation(); Location bed = p.getBedSpawnLocation();
World main = Bukkit.getWorlds().get(0); Location dest = getBedOrSpawnLocation(p);
Location dest = (bed != null) ? bed : main.getSpawnLocation();
p.teleport(dest); p.teleport(dest);
if (bed != null) { if (bed != null) {
p.sendMessage("§a§l[PVP测试] 已传送回你的床(出生点)"); p.sendMessage("§a§l[PVP测试] 已传送回你的床(出生点)");
@@ -923,8 +933,7 @@ public class PVPTestManager implements Listener {
chosenEquip.remove(p.getUniqueId()); chosenEquip.remove(p.getUniqueId());
pendingRespawn.remove(p.getUniqueId()); pendingRespawn.remove(p.getUniqueId());
restoreInventory(p); restoreInventory(p);
World main = Bukkit.getWorlds().get(0); p.teleport(getBedOrSpawnLocation(p)); // ★ 续21:床优先,世界出生点兜底
p.teleport(main.getSpawnLocation());
p.sendMessage("§a§l[PVP测试] 已离开测试场,背包已还原"); p.sendMessage("§a§l[PVP测试] 已离开测试场,背包已还原");
checkAllLeft(); checkAllLeft();
} }
@@ -1174,8 +1183,7 @@ public class PVPTestManager implements Listener {
chosenDiff.remove(uid); chosenDiff.remove(uid);
chosenEquip.remove(uid); chosenEquip.remove(uid);
pendingRespawn.remove(uid); pendingRespawn.remove(uid);
World main = Bukkit.getWorlds().get(0); e.setRespawnLocation(getBedOrSpawnLocation(p)); // ★ 续21:床优先,世界出生点兜底
e.setRespawnLocation(main.getSpawnLocation());
// 复活瞬间立即还原原背包,杜绝利用快速重进保留/携带测试场装备 // 复活瞬间立即还原原背包,杜绝利用快速重进保留/携带测试场装备
restoreInventory(p); restoreInventory(p);
checkAllLeft(); checkAllLeft();
@@ -1222,9 +1230,8 @@ public class PVPTestManager implements Listener {
pendingRespawn.remove(uid); pendingRespawn.remove(uid);
if (inTestWorld) { if (inTestWorld) {
World main = Bukkit.getWorlds().get(0); p.teleport(getBedOrSpawnLocation(p)); // ★ 续21:床优先,世界出生点兜底
p.teleport(main.getSpawnLocation()); p.sendMessage("§c§l[PVP测试] 检测到你在测试场非正常断线,已送你回出生点并恢复背包");
p.sendMessage("§c§l[PVP测试] 检测到你在测试场非正常断线,已送你回主世界并恢复背包");
} }
checkAllLeft(); checkAllLeft();
} }
@@ -1267,12 +1274,11 @@ public class PVPTestManager implements Listener {
int count = guiCloseCount.getOrDefault(uid, 0) + 1; int count = guiCloseCount.getOrDefault(uid, 0) + 1;
guiCloseCount.put(uid, count); guiCloseCount.put(uid, count);
if (count >= 2) { if (count >= 2) {
// 遣返主世界 // 遣返(★续21:床优先,世界出生点兜底)
pendingEquipSelect.remove(uid); pendingEquipSelect.remove(uid);
guiCloseCount.remove(uid); guiCloseCount.remove(uid);
World main = Bukkit.getWorlds().get(0); p.teleport(getBedOrSpawnLocation(p));
p.teleport(main.getSpawnLocation()); p.sendMessage("§c§l[PVP测试] 你多次关闭选装界面,已被遣返出生点。");
p.sendMessage("§c§l[PVP测试] 你多次关闭选装界面,已被遣返主世界。");
} else { } else {
p.sendMessage("§e§l[PVP测试] 还需选择装备!再关闭 " + (2 - count) + " 次将被遣返。"); p.sendMessage("§e§l[PVP测试] 还需选择装备!再关闭 " + (2 - count) + " 次将被遣返。");
} }