修复竞技场断线重进绕过公平限制(上线遣返出生点);backup命令放开控制台执行(支持指定玩家);测试场装备自由选武器/护甲档位;食物shift点击±16
This commit is contained in:
@@ -2049,6 +2049,34 @@ public class Main extends JavaPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===== 竞技场/测试场断线重进防绕过:上线若仍在竞技场/测试场,强制离场遣返出生点 =====
|
||||||
|
// 防止玩家在竞技场退出重进,让系统回收公平装备、发放自己背包装备从而绕过公平限制
|
||||||
|
if (pvPArenaManager != null) {
|
||||||
|
World arenaW = pvPArenaManager.getPVPWorld();
|
||||||
|
boolean inArena = (arenaW != null && p.getWorld().equals(arenaW))
|
||||||
|
|| pvPArenaManager.isInPVPArena(name);
|
||||||
|
if (!inArena && db != null) {
|
||||||
|
// 兜底:断线时未还原的竞技场背包备份仍存在(说明上次在竞技场掉线)
|
||||||
|
try {
|
||||||
|
if (db.getPvpInventoryBackup(name) != null) inArena = true;
|
||||||
|
} catch (Exception ignore) {}
|
||||||
|
}
|
||||||
|
if (inArena) {
|
||||||
|
pvPArenaManager.forceLeaveArena(p, false);
|
||||||
|
World main = Bukkit.getWorlds().get(0);
|
||||||
|
if (main != null) p.teleport(main.getSpawnLocation());
|
||||||
|
p.sendMessage("§e§l[PVP] 检测到你上次在竞技场掉线,已遣返主世界并恢复背包");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pvpTestManager != null
|
||||||
|
&& p.getWorld().getName().equals(PVPTestManager.PVP_TEST_WORLD_NAME)
|
||||||
|
&& !pvpTestManager.isInTest(p)) {
|
||||||
|
// 掉线重进落在测试场世界但状态已清:直接遣返主世界(背包已在断线时还原)
|
||||||
|
World main = Bukkit.getWorlds().get(0);
|
||||||
|
if (main != null) p.teleport(main.getSpawnLocation());
|
||||||
|
p.sendMessage("§e§l[PVP测试] 检测到你上次在测试场掉线,已遣返主世界");
|
||||||
|
}
|
||||||
|
|
||||||
// ===== 异地登录检测:异步通知PHP比较IP归属并发提醒邮件 =====
|
// ===== 异地登录检测:异步通知PHP比较IP归属并发提醒邮件 =====
|
||||||
if (webManager != null && ip != null
|
if (webManager != null && ip != null
|
||||||
&& !ip.isEmpty()) {
|
&& !ip.isEmpty()) {
|
||||||
@@ -3570,7 +3598,7 @@ public class Main extends JavaPlugin
|
|||||||
if (title.equals("§6§lPVP测试场")) {
|
if (title.equals("§6§lPVP测试场")) {
|
||||||
if (pvpTestManager != null) {
|
if (pvpTestManager != null) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
pvpTestManager.handleClick(p, e.getRawSlot());
|
pvpTestManager.handleClick(p, e.getRawSlot(), e.isShiftClick());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -6135,104 +6163,110 @@ public class Main extends JavaPlugin
|
|||||||
|
|
||||||
// ===== backup(玩家自助还原主背包,最近3份任选)=====
|
// ===== backup(玩家自助还原主背包,最近3份任选)=====
|
||||||
if (sub.equals("backup")) {
|
if (sub.equals("backup")) {
|
||||||
if (!(sender instanceof Player)) {
|
// 解析目标玩家:玩家自助用自己;控制台/命令方块必须指定玩家名
|
||||||
sender.sendMessage("§c仅玩家可用");
|
Player self = (sender instanceof Player) ? (Player) sender : null;
|
||||||
|
String targetName;
|
||||||
|
Player targetPlayer = self;
|
||||||
|
if (self == null) {
|
||||||
|
// 控制台:第一个参数必须是玩家名(不能以 # 开头)
|
||||||
|
if (args.length < 2 || args[1].startsWith("#")) {
|
||||||
|
sender.sendMessage(
|
||||||
|
"§c用法: /sdf1_login backup <玩家名> [#编号]");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player self = (Player) sender;
|
targetName = args[1];
|
||||||
|
targetPlayer = Bukkit.getPlayerExact(targetName);
|
||||||
|
} else {
|
||||||
|
targetName = self.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 场内拦截(仅对在线目标生效)
|
||||||
|
if (targetPlayer != null) {
|
||||||
if (pvPArenaManager != null
|
if (pvPArenaManager != null
|
||||||
&& pvPArenaManager.isInPVPArena(
|
&& pvPArenaManager.isInPVPArena(targetName)) {
|
||||||
self.getName())) {
|
sender.sendMessage("§c" + targetName
|
||||||
sender.sendMessage(
|
+ " 在竞技场内,无法还原主背包,请先 /pvp leave");
|
||||||
"§c竞技场内无法还原主背包,请先 /pvp leave");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (pvpTestManager != null
|
if (pvpTestManager != null
|
||||||
&& pvpTestManager.isInTest(self)) {
|
&& pvpTestManager.isInTest(targetPlayer)) {
|
||||||
sender.sendMessage(
|
sender.sendMessage("§c" + targetName
|
||||||
"§c测试场内无法还原主背包,请先 /pvp leave");
|
+ " 在测试场内,无法还原主背包,请先 /pvp leave");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 带 #编号 → 还原指定备份到自己的背包
|
}
|
||||||
if (args.length >= 2
|
|
||||||
&& args[1].startsWith("#")) {
|
// 解析 #编号(玩家自助时为 args[1];控制台时为玩家名之后的参数)
|
||||||
int bid;
|
Integer bid = null;
|
||||||
|
for (int i = 1; i < args.length; i++) {
|
||||||
|
if (args[i].startsWith("#")) {
|
||||||
try {
|
try {
|
||||||
bid = Integer.parseInt(
|
bid = Integer.parseInt(
|
||||||
args[1].replace("#", ""));
|
args[i].replace("#", ""));
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
sender.sendMessage("§c无效编号");
|
sender.sendMessage("§c无效编号");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String[] bk =
|
}
|
||||||
db.getInventoryBackupById(bid);
|
}
|
||||||
|
|
||||||
|
// 带编号 → 还原
|
||||||
|
if (bid != null) {
|
||||||
|
if (targetPlayer == null) {
|
||||||
|
sender.sendMessage("§c玩家 " + targetName
|
||||||
|
+ " 当前不在线,无法还原实时背包");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
String[] bk = db.getInventoryBackupById(bid);
|
||||||
if (bk == null) {
|
if (bk == null) {
|
||||||
sender.sendMessage("§c备份 #" + bid
|
sender.sendMessage("§c备份 #" + bid + " 不存在");
|
||||||
+ " 不存在");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
self.getInventory().setContents(
|
targetPlayer.getInventory().setContents(
|
||||||
InventorySerializer.fromBase64(
|
InventorySerializer.fromBase64(bk[0]));
|
||||||
bk[0]));
|
if (bk[1] != null && !bk[1].isEmpty())
|
||||||
if (bk[1] != null
|
targetPlayer.getInventory().setArmorContents(
|
||||||
&& !bk[1].isEmpty())
|
InventorySerializer.fromBase64(bk[1]));
|
||||||
self.getInventory()
|
if (bk[2] != null && !bk[2].isEmpty())
|
||||||
.setArmorContents(
|
targetPlayer.getInventory().setExtraContents(
|
||||||
InventorySerializer
|
InventorySerializer.fromBase64(bk[2]));
|
||||||
.fromBase64(
|
|
||||||
bk[1]));
|
|
||||||
if (bk[2] != null
|
|
||||||
&& !bk[2].isEmpty())
|
|
||||||
self.getInventory()
|
|
||||||
.setExtraContents(
|
|
||||||
InventorySerializer
|
|
||||||
.fromBase64(
|
|
||||||
bk[2]));
|
|
||||||
int lv = Integer.parseInt(bk[3]);
|
int lv = Integer.parseInt(bk[3]);
|
||||||
if (lv > 0) self.setLevel(lv);
|
if (lv > 0) targetPlayer.setLevel(lv);
|
||||||
self.setExp((float) Double
|
targetPlayer.setExp((float) Double.parseDouble(bk[4]));
|
||||||
.parseDouble(bk[4]));
|
sender.sendMessage("§a已为 " + targetName
|
||||||
sender.sendMessage(
|
+ " 还原主背包备份 #" + bid);
|
||||||
"§a已还原主背包备份 #" + bid);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage("§c还原失败: "
|
sender.sendMessage("§c还原失败: " + e.getMessage());
|
||||||
+ e.getMessage());
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 不带编号 → 列出最近 3 份供选择
|
|
||||||
|
// 不带编号 → 列出最近 3 份
|
||||||
List<Map<String, Object>> myList =
|
List<Map<String, Object>> myList =
|
||||||
db.getInventoryBackups(
|
db.getInventoryBackups(targetName, 3);
|
||||||
self.getName(), 3);
|
|
||||||
if (myList.isEmpty()) {
|
if (myList.isEmpty()) {
|
||||||
sender.sendMessage(
|
sender.sendMessage("§c" + targetName + " 没有任何背包备份");
|
||||||
"§c你没有任何背包备份");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
sender.sendMessage(
|
sender.sendMessage("§e§l=== " + targetName
|
||||||
"§e§l=== 你的背包备份(最近3份)===");
|
+ " 的背包备份(最近3份)===");
|
||||||
java.text.SimpleDateFormat sdf =
|
java.text.SimpleDateFormat sdf =
|
||||||
new java.text.SimpleDateFormat(
|
new java.text.SimpleDateFormat("MM-dd HH:mm:ss");
|
||||||
"MM-dd HH:mm:ss");
|
|
||||||
for (Map<String, Object> b : myList) {
|
for (Map<String, Object> b : myList) {
|
||||||
int bid = ((Number) b.get("id"))
|
int bidi = ((Number) b.get("id")).intValue();
|
||||||
.intValue();
|
|
||||||
Object stObj = b.get("save_time");
|
Object stObj = b.get("save_time");
|
||||||
long st = stObj != null
|
long st = stObj != null ? ((Number) stObj).longValue() : 0;
|
||||||
? ((Number) stObj)
|
String time = st > 0 ? sdf.format(new java.util.Date(st))
|
||||||
.longValue()
|
|
||||||
: 0;
|
|
||||||
String time = st > 0
|
|
||||||
? sdf.format(
|
|
||||||
new java.util.Date(st))
|
|
||||||
: "未知时间";
|
: "未知时间";
|
||||||
sender.sendMessage("§7#" + bid + " §f"
|
sender.sendMessage("§7#" + bidi + " §f" + time + " §7: "
|
||||||
+ time + " §7: "
|
+ getBackupItemPreview(bidi));
|
||||||
+ getBackupItemPreview(bid));
|
|
||||||
}
|
}
|
||||||
sender.sendMessage(
|
if (self != null)
|
||||||
"§7使用 §e/sdf1_login backup #编号 §7还原对应备份");
|
sender.sendMessage("§7使用 §e/sdf1_login backup #编号 §7还原对应备份");
|
||||||
|
else
|
||||||
|
sender.sendMessage("§7使用 §e/sdf1_login backup "
|
||||||
|
+ targetName + " #编号 §7还原对应备份");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,22 @@ public class PVPTestManager implements Listener {
|
|||||||
private final Map<UUID, Boolean> testEnchant = new HashMap<>(); // 主武器是否附魔(锋利V+击退II)
|
private final Map<UUID, Boolean> testEnchant = new HashMap<>(); // 主武器是否附魔(锋利V+击退II)
|
||||||
private final Map<UUID, Boolean> testShield = new HashMap<>(); // 是否拿盾牌
|
private final Map<UUID, Boolean> testShield = new HashMap<>(); // 是否拿盾牌
|
||||||
private final Map<UUID, Integer> testFood = new HashMap<>(); // 熟牛肉数量(1~64,与主场一致)
|
private final Map<UUID, Integer> testFood = new HashMap<>(); // 熟牛肉数量(1~64,与主场一致)
|
||||||
|
/** 自由装备档位(测试世界跳过公平锁定,全员自由选武器/护甲材质) */
|
||||||
|
private final Map<UUID, Integer> testWeaponTier = new HashMap<>(); // 0铁 1金 2钻 3下界合金
|
||||||
|
private final Map<UUID, Integer> testArmorTier = new HashMap<>(); // 0无 1铁 2金 3钻 4下界合金
|
||||||
|
|
||||||
|
private static final Material[] SWORD_TIERS = {
|
||||||
|
Material.IRON_SWORD, Material.GOLDEN_SWORD, Material.DIAMOND_SWORD, Material.NETHERITE_SWORD };
|
||||||
|
private static final Material[] AXE_TIERS = {
|
||||||
|
Material.IRON_AXE, Material.GOLDEN_AXE, Material.DIAMOND_AXE, Material.NETHERITE_AXE };
|
||||||
|
private static final String[] WEAPON_TIER_NAMES = { "§7铁", "§e金", "§b钻石", "§8下界合金" };
|
||||||
|
private static final Material[][] ARMOR_SETS = {
|
||||||
|
null,
|
||||||
|
{ Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS },
|
||||||
|
{ Material.GOLDEN_HELMET, Material.GOLDEN_CHESTPLATE, Material.GOLDEN_LEGGINGS, Material.GOLDEN_BOOTS },
|
||||||
|
{ Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS },
|
||||||
|
{ Material.NETHERITE_HELMET, Material.NETHERITE_CHESTPLATE, Material.NETHERITE_LEGGINGS, Material.NETHERITE_BOOTS } };
|
||||||
|
private static final String[] ARMOR_TIER_NAMES = { "§7无", "§7铁", "§e金", "§b钻石", "§8下界合金" };
|
||||||
/** 每个练习生物对应的难度(用于固定伤害 + 噩梦走位判定) */
|
/** 每个练习生物对应的难度(用于固定伤害 + 噩梦走位判定) */
|
||||||
private final Map<UUID, TestDifficulty> mobDifficulty = new HashMap<>();
|
private final Map<UUID, TestDifficulty> mobDifficulty = new HashMap<>();
|
||||||
/** 互殴拦截提示节流(玩家UUID→上次提示时间戳) */
|
/** 互殴拦截提示节流(玩家UUID→上次提示时间戳) */
|
||||||
@@ -216,9 +232,13 @@ public class PVPTestManager implements Listener {
|
|||||||
testEnchant.putIfAbsent(p.getUniqueId(), false);
|
testEnchant.putIfAbsent(p.getUniqueId(), false);
|
||||||
testShield.putIfAbsent(p.getUniqueId(), true);
|
testShield.putIfAbsent(p.getUniqueId(), true);
|
||||||
testFood.putIfAbsent(p.getUniqueId(), 16);
|
testFood.putIfAbsent(p.getUniqueId(), 16);
|
||||||
|
testWeaponTier.putIfAbsent(p.getUniqueId(), 0);
|
||||||
|
testArmorTier.putIfAbsent(p.getUniqueId(), 0);
|
||||||
boolean enchant = testEnchant.get(p.getUniqueId());
|
boolean enchant = testEnchant.get(p.getUniqueId());
|
||||||
boolean shield = testShield.get(p.getUniqueId());
|
boolean shield = testShield.get(p.getUniqueId());
|
||||||
int food = testFood.get(p.getUniqueId());
|
int food = testFood.get(p.getUniqueId());
|
||||||
|
int weaponTier = testWeaponTier.get(p.getUniqueId());
|
||||||
|
int armorTier = testArmorTier.get(p.getUniqueId());
|
||||||
|
|
||||||
// 顶部信息
|
// 顶部信息
|
||||||
ItemStack info = new ItemStack(Material.PAPER);
|
ItemStack info = new ItemStack(Material.PAPER);
|
||||||
@@ -230,7 +250,8 @@ public class PVPTestManager implements Listener {
|
|||||||
"",
|
"",
|
||||||
"§e当前难度: " + diff.display,
|
"§e当前难度: " + diff.display,
|
||||||
"§e练习场景: " + equip.display,
|
"§e练习场景: " + equip.display,
|
||||||
"§e主武器: §b铁剑 + 铁斧 §7(必发)",
|
"§e主武器: " + WEAPON_TIER_NAMES[weaponTier] + "§b剑 + " + WEAPON_TIER_NAMES[weaponTier] + "§b斧",
|
||||||
|
"§e护甲: " + ARMOR_TIER_NAMES[armorTier],
|
||||||
"§e附魔: " + (enchant ? "§a开启" : "§c关闭"),
|
"§e附魔: " + (enchant ? "§a开启" : "§c关闭"),
|
||||||
"§e盾牌: " + (shield ? "§a装备" : "§c不装备")));
|
"§e盾牌: " + (shield ? "§a装备" : "§c不装备")));
|
||||||
info.setItemMeta(im);
|
info.setItemMeta(im);
|
||||||
@@ -270,7 +291,7 @@ public class PVPTestManager implements Listener {
|
|||||||
ItemMeta fm = foodMinus.getItemMeta();
|
ItemMeta fm = foodMinus.getItemMeta();
|
||||||
if (fm != null) {
|
if (fm != null) {
|
||||||
fm.setDisplayName("§c§l熟牛肉 -1");
|
fm.setDisplayName("§c§l熟牛肉 -1");
|
||||||
fm.setLore(Arrays.asList("§7当前: " + food + " 个", "§7范围 1~64"));
|
fm.setLore(Arrays.asList("§7当前: " + food + " 个", "§7范围 1~64", "§bShift点击 -16"));
|
||||||
foodMinus.setItemMeta(fm);
|
foodMinus.setItemMeta(fm);
|
||||||
}
|
}
|
||||||
gui.setItem(47, foodMinus);
|
gui.setItem(47, foodMinus);
|
||||||
@@ -279,7 +300,7 @@ public class PVPTestManager implements Listener {
|
|||||||
ItemMeta fmi = foodInfo.getItemMeta();
|
ItemMeta fmi = foodInfo.getItemMeta();
|
||||||
if (fmi != null) {
|
if (fmi != null) {
|
||||||
fmi.setDisplayName("§6§l熟牛肉: " + food + " 个");
|
fmi.setDisplayName("§6§l熟牛肉: " + food + " 个");
|
||||||
fmi.setLore(Arrays.asList("§7补血普通食物", "§7点击两侧 ±1"));
|
fmi.setLore(Arrays.asList("§7补血普通食物", "§7左键±1,§bShift±16"));
|
||||||
foodInfo.setItemMeta(fmi);
|
foodInfo.setItemMeta(fmi);
|
||||||
}
|
}
|
||||||
gui.setItem(48, foodInfo);
|
gui.setItem(48, foodInfo);
|
||||||
@@ -288,11 +309,67 @@ public class PVPTestManager implements Listener {
|
|||||||
ItemMeta fp = foodPlus.getItemMeta();
|
ItemMeta fp = foodPlus.getItemMeta();
|
||||||
if (fp != null) {
|
if (fp != null) {
|
||||||
fp.setDisplayName("§a§l熟牛肉 +1");
|
fp.setDisplayName("§a§l熟牛肉 +1");
|
||||||
fp.setLore(Arrays.asList("§7当前: " + food + " 个", "§7范围 1~64"));
|
fp.setLore(Arrays.asList("§7当前: " + food + " 个", "§7范围 1~64", "§bShift点击 +16"));
|
||||||
foodPlus.setItemMeta(fp);
|
foodPlus.setItemMeta(fp);
|
||||||
}
|
}
|
||||||
gui.setItem(50, foodPlus);
|
gui.setItem(50, foodPlus);
|
||||||
|
|
||||||
|
// ★ 武器档位(11/-1,12/显示,13/+1):自由选主武器材质(剑+斧)
|
||||||
|
ItemStack wMinus = new ItemStack(SWORD_TIERS[weaponTier]);
|
||||||
|
ItemMeta wm = wMinus.getItemMeta();
|
||||||
|
if (wm != null) {
|
||||||
|
wm.setDisplayName("§c§l武器档位 -");
|
||||||
|
wm.setLore(Arrays.asList("§7当前: " + WEAPON_TIER_NAMES[weaponTier], "§7剑+斧材质"));
|
||||||
|
wMinus.setItemMeta(wm);
|
||||||
|
}
|
||||||
|
gui.setItem(11, wMinus);
|
||||||
|
|
||||||
|
ItemStack wInfo = new ItemStack(Material.PAPER);
|
||||||
|
ItemMeta wmi = wInfo.getItemMeta();
|
||||||
|
if (wmi != null) {
|
||||||
|
wmi.setDisplayName("§6§l武器: " + WEAPON_TIER_NAMES[weaponTier]);
|
||||||
|
wmi.setLore(Arrays.asList("§7主武器材质(剑+斧)", "§7点击两侧切换"));
|
||||||
|
wInfo.setItemMeta(wmi);
|
||||||
|
}
|
||||||
|
gui.setItem(12, wInfo);
|
||||||
|
|
||||||
|
ItemStack wPlus = new ItemStack(SWORD_TIERS[weaponTier]);
|
||||||
|
ItemMeta wp = wPlus.getItemMeta();
|
||||||
|
if (wp != null) {
|
||||||
|
wp.setDisplayName("§a§l武器档位 +");
|
||||||
|
wp.setLore(Arrays.asList("§7当前: " + WEAPON_TIER_NAMES[weaponTier], "§7剑+斧材质"));
|
||||||
|
wPlus.setItemMeta(wp);
|
||||||
|
}
|
||||||
|
gui.setItem(13, wPlus);
|
||||||
|
|
||||||
|
// ★ 护甲档位(14/-1,15/显示,16/+1):自由选全套护甲材质
|
||||||
|
ItemStack aMinus = new ItemStack(armorTier > 0 ? ARMOR_SETS[armorTier][1] : Material.LEATHER_CHESTPLATE);
|
||||||
|
ItemMeta am = aMinus.getItemMeta();
|
||||||
|
if (am != null) {
|
||||||
|
am.setDisplayName("§c§l护甲档位 -");
|
||||||
|
am.setLore(Arrays.asList("§7当前: " + ARMOR_TIER_NAMES[armorTier], "§7无=不穿护甲"));
|
||||||
|
aMinus.setItemMeta(am);
|
||||||
|
}
|
||||||
|
gui.setItem(14, aMinus);
|
||||||
|
|
||||||
|
ItemStack aInfo = new ItemStack(Material.PAPER);
|
||||||
|
ItemMeta ami = aInfo.getItemMeta();
|
||||||
|
if (ami != null) {
|
||||||
|
ami.setDisplayName("§6§l护甲: " + ARMOR_TIER_NAMES[armorTier]);
|
||||||
|
ami.setLore(Arrays.asList("§7全套护甲材质", "§7点击两侧切换"));
|
||||||
|
aInfo.setItemMeta(ami);
|
||||||
|
}
|
||||||
|
gui.setItem(15, aInfo);
|
||||||
|
|
||||||
|
ItemStack aPlus = new ItemStack(armorTier > 0 ? ARMOR_SETS[armorTier][1] : Material.LEATHER_CHESTPLATE);
|
||||||
|
ItemMeta ap = aPlus.getItemMeta();
|
||||||
|
if (ap != null) {
|
||||||
|
ap.setDisplayName("§a§l护甲档位 +");
|
||||||
|
ap.setLore(Arrays.asList("§7当前: " + ARMOR_TIER_NAMES[armorTier], "§7无=不穿护甲"));
|
||||||
|
aPlus.setItemMeta(ap);
|
||||||
|
}
|
||||||
|
gui.setItem(16, aPlus);
|
||||||
|
|
||||||
// 确认开始按钮
|
// 确认开始按钮
|
||||||
ItemStack start = new ItemStack(Material.LIME_STAINED_GLASS_PANE);
|
ItemStack start = new ItemStack(Material.LIME_STAINED_GLASS_PANE);
|
||||||
ItemMeta sm = start.getItemMeta();
|
ItemMeta sm = start.getItemMeta();
|
||||||
@@ -353,7 +430,7 @@ public class PVPTestManager implements Listener {
|
|||||||
gui.setItem(slot, btn);
|
gui.setItem(slot, btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleClick(Player p, int slot) {
|
public void handleClick(Player p, int slot, boolean shift) {
|
||||||
if (!p.getOpenInventory().getTitle().equals(TEST_GUI_TITLE)) return;
|
if (!p.getOpenInventory().getTitle().equals(TEST_GUI_TITLE)) return;
|
||||||
|
|
||||||
if (slot == 19) { chosenDiff.put(p.getUniqueId(), TestDifficulty.EASY); openGUI(p); return; }
|
if (slot == 19) { chosenDiff.put(p.getUniqueId(), TestDifficulty.EASY); openGUI(p); return; }
|
||||||
@@ -373,16 +450,40 @@ public class PVPTestManager implements Listener {
|
|||||||
testShield.put(id, !testShield.getOrDefault(id, true));
|
testShield.put(id, !testShield.getOrDefault(id, true));
|
||||||
openGUI(p); return;
|
openGUI(p); return;
|
||||||
}
|
}
|
||||||
|
// ★ 武器档位(11/-1,12/显示,13/+1)
|
||||||
|
if (slot == 11) {
|
||||||
|
UUID id = p.getUniqueId();
|
||||||
|
testWeaponTier.put(id, Math.max(0, testWeaponTier.getOrDefault(id, 0) - 1));
|
||||||
|
openGUI(p); return;
|
||||||
|
}
|
||||||
|
if (slot == 12) { openGUI(p); return; }
|
||||||
|
if (slot == 13) {
|
||||||
|
UUID id = p.getUniqueId();
|
||||||
|
testWeaponTier.put(id, Math.min(WEAPON_TIER_NAMES.length - 1, testWeaponTier.getOrDefault(id, 0) + 1));
|
||||||
|
openGUI(p); return;
|
||||||
|
}
|
||||||
|
// ★ 护甲档位(14/-1,15/显示,16/+1)
|
||||||
|
if (slot == 14) {
|
||||||
|
UUID id = p.getUniqueId();
|
||||||
|
testArmorTier.put(id, Math.max(0, testArmorTier.getOrDefault(id, 0) - 1));
|
||||||
|
openGUI(p); return;
|
||||||
|
}
|
||||||
|
if (slot == 15) { openGUI(p); return; }
|
||||||
|
if (slot == 16) {
|
||||||
|
UUID id = p.getUniqueId();
|
||||||
|
testArmorTier.put(id, Math.min(ARMOR_TIER_NAMES.length - 1, testArmorTier.getOrDefault(id, 0) + 1));
|
||||||
|
openGUI(p); return;
|
||||||
|
}
|
||||||
// ★ 熟牛肉数量 ±1(47/-1,50/+1,48仅显示)
|
// ★ 熟牛肉数量 ±1(47/-1,50/+1,48仅显示)
|
||||||
if (slot == 47) {
|
if (slot == 47) {
|
||||||
UUID id = p.getUniqueId();
|
UUID id = p.getUniqueId();
|
||||||
testFood.put(id, Math.max(1, testFood.getOrDefault(id, 16) - 1));
|
testFood.put(id, Math.max(1, testFood.getOrDefault(id, 16) - (shift ? 16 : 1)));
|
||||||
openGUI(p); return;
|
openGUI(p); return;
|
||||||
}
|
}
|
||||||
if (slot == 48) { openGUI(p); return; }
|
if (slot == 48) { openGUI(p); return; }
|
||||||
if (slot == 50) {
|
if (slot == 50) {
|
||||||
UUID id = p.getUniqueId();
|
UUID id = p.getUniqueId();
|
||||||
testFood.put(id, Math.min(64, testFood.getOrDefault(id, 16) + 1));
|
testFood.put(id, Math.min(64, testFood.getOrDefault(id, 16) + (shift ? 16 : 1)));
|
||||||
openGUI(p); return;
|
openGUI(p); return;
|
||||||
}
|
}
|
||||||
if (slot == 49) {
|
if (slot == 49) {
|
||||||
@@ -405,6 +506,8 @@ public class PVPTestManager implements Listener {
|
|||||||
|
|
||||||
boolean enchant = testEnchant.getOrDefault(p.getUniqueId(), false);
|
boolean enchant = testEnchant.getOrDefault(p.getUniqueId(), false);
|
||||||
boolean shield = testShield.getOrDefault(p.getUniqueId(), true);
|
boolean shield = testShield.getOrDefault(p.getUniqueId(), true);
|
||||||
|
int wt = testWeaponTier.getOrDefault(p.getUniqueId(), 0);
|
||||||
|
int at = testArmorTier.getOrDefault(p.getUniqueId(), 0);
|
||||||
|
|
||||||
// 清掉该玩家之前的练习生物(支持重新配置)
|
// 清掉该玩家之前的练习生物(支持重新配置)
|
||||||
removePlayerMobs(p);
|
removePlayerMobs(p);
|
||||||
@@ -431,8 +534,11 @@ public class PVPTestManager implements Listener {
|
|||||||
|
|
||||||
int beef = testFood.getOrDefault(p.getUniqueId(), 16);
|
int beef = testFood.getOrDefault(p.getUniqueId(), 16);
|
||||||
p.sendMessage("§a§l[PVP测试] 已进入测试场! 难度: " + diff.display + " 场景: " + equip.display
|
p.sendMessage("§a§l[PVP测试] 已进入测试场! 难度: " + diff.display + " 场景: " + equip.display
|
||||||
|
+ " 武器:" + WEAPON_TIER_NAMES[wt] + " 护甲:" + ARMOR_TIER_NAMES[at]
|
||||||
+ " 附魔:" + (enchant ? "§d开" : "§7关") + " 盾牌:" + (shield ? "§a有" : "§7无") + " 熟牛肉:" + beef);
|
+ " 附魔:" + (enchant ? "§d开" : "§7关") + " 盾牌:" + (shield ? "§a有" : "§7无") + " 熟牛肉:" + beef);
|
||||||
p.sendMessage("§7主武器: 铁剑 + 铁斧" + (enchant ? "(附魔)" : "(未附魔)") + (shield ? " +盾牌" : ""));
|
p.sendMessage("§7主武器: " + WEAPON_TIER_NAMES[wt] + "§b剑 + " + WEAPON_TIER_NAMES[wt] + "§b斧"
|
||||||
|
+ (at > 0 ? " + " + ARMOR_TIER_NAMES[at] + "§b护甲" : "")
|
||||||
|
+ (enchant ? "(附魔)" : "(未附魔)") + (shield ? " +盾牌" : ""));
|
||||||
p.sendMessage("§7练习生物血量统一为40。敌对生物互不攻击(友伤免疫)。");
|
p.sendMessage("§7练习生物血量统一为40。敌对生物互不攻击(友伤免疫)。");
|
||||||
p.sendMessage("§7清空当前波次后,每10秒刷新下一波;背包已附熟牛肉回血。测试场内不可互殴,只能打练习生物。输入 /pvp leave 离开。");
|
p.sendMessage("§7清空当前波次后,每10秒刷新下一波;背包已附熟牛肉回血。测试场内不可互殴,只能打练习生物。输入 /pvp leave 离开。");
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.0f);
|
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.0f);
|
||||||
@@ -442,12 +548,30 @@ public class PVPTestManager implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void giveEquip(Player p, TestEquip equip) {
|
private void giveEquip(Player p, TestEquip equip) {
|
||||||
// ★ 2026-07-09 改版:主武器 = 铁剑 + 铁斧(都给);附魔=锋利V+击退II;盾牌可选;无护甲(与PVP竞技场一致)。
|
// ★ 2026-07-09 改版:主武器 = 剑 + 斧(都给,材质按所选档位);附魔=锋利V+击退II;盾牌可选;护甲按所选档位(可为无)。
|
||||||
boolean enchant = testEnchant.getOrDefault(p.getUniqueId(), false);
|
boolean enchant = testEnchant.getOrDefault(p.getUniqueId(), false);
|
||||||
boolean shield = testShield.getOrDefault(p.getUniqueId(), true);
|
boolean shield = testShield.getOrDefault(p.getUniqueId(), true);
|
||||||
|
int wt = testWeaponTier.getOrDefault(p.getUniqueId(), 0);
|
||||||
|
int at = testArmorTier.getOrDefault(p.getUniqueId(), 0);
|
||||||
|
|
||||||
p.getInventory().addItem(makeTestWeapon(Material.IRON_SWORD, "§b§l练习铁剑", enchant));
|
p.getInventory().addItem(makeTestWeapon(SWORD_TIERS[wt], "§b§l练习剑", enchant));
|
||||||
p.getInventory().addItem(makeTestWeapon(Material.IRON_AXE, "§b§l练习铁斧", enchant));
|
p.getInventory().addItem(makeTestWeapon(AXE_TIERS[wt], "§b§l练习斧", enchant));
|
||||||
|
|
||||||
|
if (at > 0 && ARMOR_SETS[at] != null) {
|
||||||
|
Material[] set = ARMOR_SETS[at];
|
||||||
|
ItemStack[] armor = new ItemStack[4];
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
ItemStack piece = new ItemStack(set[i]);
|
||||||
|
ItemMeta m = piece.getItemMeta();
|
||||||
|
if (m != null) {
|
||||||
|
m.setDisplayName("§a§l练习护甲");
|
||||||
|
m.setLore(Arrays.asList("§7" + ARMOR_TIER_NAMES[at].replace("§", "") + "套装"));
|
||||||
|
piece.setItemMeta(m);
|
||||||
|
}
|
||||||
|
armor[i] = piece;
|
||||||
|
}
|
||||||
|
p.getInventory().setArmorContents(armor);
|
||||||
|
}
|
||||||
|
|
||||||
if (shield) {
|
if (shield) {
|
||||||
ItemStack sh = new ItemStack(Material.SHIELD);
|
ItemStack sh = new ItemStack(Material.SHIELD);
|
||||||
|
|||||||
Reference in New Issue
Block a user