From e0ccdfc87126f1f120b7c10dbc462927ed4b4a38 Mon Sep 17 00:00:00 2001 From: yaohunya <31456652@qq.com> Date: Fri, 2 Aug 2024 12:11:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=96=E7=95=8CBOSS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../worldbosshurt/command/BossSpawnerCmd.java | 23 +++++++------ .../listener/BossDamageByPlayer.java | 10 ++++-- .../listener/BossDeathEvent.java | 12 ++++--- .../listener/BossKillsDeath.java | 33 +++++++++++-------- .../worldbosshurt/util/BossSpawnUtil.java | 12 +++---- .../yaohun/worldbosshurt/util/BossUtil.java | 4 +-- src/main/resources/plugin.yml | 2 +- 7 files changed, 56 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/io/yaohun/worldbosshurt/command/BossSpawnerCmd.java b/src/main/java/com/io/yaohun/worldbosshurt/command/BossSpawnerCmd.java index 1d6bf73..a16d4c0 100644 --- a/src/main/java/com/io/yaohun/worldbosshurt/command/BossSpawnerCmd.java +++ b/src/main/java/com/io/yaohun/worldbosshurt/command/BossSpawnerCmd.java @@ -37,7 +37,7 @@ public class BossSpawnerCmd implements CommandExecutor , TabCompleter { sender.sendMessage("§r"); return true; } - if(args.length == 1){ + if(args.length >= 1 && sender.isOp()){ BossManage bossManage = Main.bossManage; if(bossManage.isBossSurvive()){ Bukkit.getConsoleSender().sendMessage("[日志-世界Boss] 系统尝试多次执行召唤boss已被拦截."); @@ -45,16 +45,19 @@ public class BossSpawnerCmd implements CommandExecutor , TabCompleter { } BossDamageByPlayer.damageMap.clear(); // 清理之前的伤害数据缓存 - String stats_type = BossSpawnUtil.getTheCurrentServerPlayerStatus(); - if(stats_type.equalsIgnoreCase("NoPlayer")){ - Bukkit.broadcastMessage("§6[§4公告§6] §a世界BOSS召唤失败,在线器师人数过低无法挑战."); - return true; + boolean antiSpawn = false; + if(args.length == 1) { + String stats_type = BossSpawnUtil.getTheCurrentServerPlayerStatus(); + if (stats_type.equalsIgnoreCase("NoPlayer")) { + Bukkit.broadcastMessage("§6[§4公告§6] §a世界BOSS召唤失败,在线器师人数过低无法挑战."); + antiSpawn = true; + } + if (stats_type.equalsIgnoreCase("NoLevel")) { + Bukkit.broadcastMessage("§6[§4公告§6] §a世界BOSS召唤失败,在线器师无一人达到90级封号斗魂."); + antiSpawn = true; + } } - if(stats_type.equalsIgnoreCase("NoLevel")){ - Bukkit.broadcastMessage("§6[§4公告§6] §a世界BOSS召唤失败,在线器师无一人达到90级封号斗魂."); - return true; - } - if(stats_type.equalsIgnoreCase("Start")) { + if(!antiSpawn){ String bossKey = args[0]; BossData bossData = bossManage.getBossData(bossKey); if(bossData != null){ diff --git a/src/main/java/com/io/yaohun/worldbosshurt/listener/BossDamageByPlayer.java b/src/main/java/com/io/yaohun/worldbosshurt/listener/BossDamageByPlayer.java index 00d16be..e1b5fc6 100644 --- a/src/main/java/com/io/yaohun/worldbosshurt/listener/BossDamageByPlayer.java +++ b/src/main/java/com/io/yaohun/worldbosshurt/listener/BossDamageByPlayer.java @@ -43,8 +43,14 @@ public class BossDamageByPlayer implements Listener { Bukkit.getConsoleSender().sendMessage("[世界boss-日志] 因 "+customName+" §r离开团队副本,此Boss已清理."); return; } - UUID Mob_uuid = e.getEntity().getUniqueId(); - if(!BossSpawnLogs.WhiteBossList.contains(Mob_uuid)){ + boolean isBossName = false; + for (String bossName : BossSpawnLogs.WhiteBossList){ + if(customName.contains(bossName)){ + isBossName = true; + break; + } + } + if(!isBossName){ e.getEntity().remove(); Bukkit.broadcastMessage("§6[§4公告§6] §a"+customName+"§a被卷入了异次元时空."); return; diff --git a/src/main/java/com/io/yaohun/worldbosshurt/listener/BossDeathEvent.java b/src/main/java/com/io/yaohun/worldbosshurt/listener/BossDeathEvent.java index b4acedc..0b2fbfb 100644 --- a/src/main/java/com/io/yaohun/worldbosshurt/listener/BossDeathEvent.java +++ b/src/main/java/com/io/yaohun/worldbosshurt/listener/BossDeathEvent.java @@ -18,13 +18,15 @@ public class BossDeathEvent implements Listener { RewardData rewardData = e.getRewardData(); LinkedHashMap hashMap = e.getSortedMap(); int rank = 1; - for (String name : hashMap.keySet()){ - if(rank >= 6){break;} + for (String name : hashMap.keySet()) { + if (rank >= 6) { + break; + } List rankRewardList = rewardData.getTopCmdList(rank); - if(rankRewardList.size() >= 1){ + if (rankRewardList.size() >= 1) { Player onlinePlayer = Bukkit.getPlayer(name); - if(onlinePlayer != null && onlinePlayer.isOnline()){ - DemonAPI.ConsoleOutCommandList(onlinePlayer,rankRewardList); + if (onlinePlayer != null && onlinePlayer.isOnline()) { + DemonAPI.ConsoleOutCommandList(onlinePlayer, rankRewardList); } } rank++; diff --git a/src/main/java/com/io/yaohun/worldbosshurt/listener/BossKillsDeath.java b/src/main/java/com/io/yaohun/worldbosshurt/listener/BossKillsDeath.java index 346ac0e..5150166 100644 --- a/src/main/java/com/io/yaohun/worldbosshurt/listener/BossKillsDeath.java +++ b/src/main/java/com/io/yaohun/worldbosshurt/listener/BossKillsDeath.java @@ -30,7 +30,7 @@ public class BossKillsDeath implements Listener { BossManage bossManage = Main.bossManage; String customName = entity.getCustomName(); if(customName != null && bossManage.isCustomNameContains(customName)){ - BossData bossData = bossManage.getBossData(customName); + BossData bossData = bossManage.getNameToData(customName); if(bossData == null){return;} String worldName = entity.getWorld().getName(); if (!worldName.equalsIgnoreCase("teamDungee")) { @@ -39,21 +39,22 @@ public class BossKillsDeath implements Listener { Bukkit.broadcastMessage(message.replace("%mobs%",bossData.getBossName())); // 发送最终击杀提示 BossUtil.addMonthlyKillBoss(player.getName()); // 为玩家累积最终斩杀次数 String Kills_Group_Key = bossData.getKillsReward(); // 获取击杀奖励组名 - RewardData rewardData = Main.rewardManage.getRewardData(Kills_Group_Key); + RewardData killsRewardData = Main.rewardManage.getRewardData(Kills_Group_Key); // 执行命令并发放奖励 if(bossData.getKillsReward() != null){ if (!Kills_Group_Key.equalsIgnoreCase("魂环")) { - List commands = rewardData.getKillsCmdList(); + List commands = killsRewardData.getKillsCmdList(); DemonAPI.ConsoleOutCommandList(player, commands); }else{ - sendRingRewards(player,bossData,rewardData); + sendRingRewards(player,bossData,killsRewardData); } } new BukkitRunnable() { public void run() { - statisticalSettlementOfDamages(bossData,rewardData); + statisticalSettlementOfDamages(bossData,Main.rewardManage.getRewardData(bossData.getTopReward())); + cancel(); } - }.runTaskLater(Main.plugin, 10L); + }.runTaskLater(Main.plugin, 20L); } } } @@ -99,14 +100,18 @@ public class BossKillsDeath implements Listener { } Bukkit.broadcastMessage("§c§M §6§m §e§m §a§m §b§m §C§L▍ §c§l伤§6§l害§E§L统§A§l计§B§L表 §C§l▍§b§M §a§M §e§M §6§m §c§m §r"); for (Player player : playerList){ - double damage = BossDamageByPlayer.damageMap.get(player); // 获取玩家造成伤害 - player.sendMessage("§e您造成的总伤害: §c" + new DecimalFormat(",###.00").format(damage) + "k §e伤害占总比: §c" + new DecimalFormat("0.00").format(damage / totalDamage * 100) + "%"); - // 判断玩家造成伤害是否达到100K并发放奖励 - if(damage >= 100){ - List damageRewardList = rewardData.getDamageCmdList(); - DemonAPI.ConsoleOutCommandList(player,damageRewardList); - }else{ - DemonAPI.sendMessage(player,"你造成的总伤害不足§4100,000§a无法获得参与奖。"); + if(BossDamageByPlayer.damageMap.get(player) != null) { + double damage = BossDamageByPlayer.damageMap.get(player); // 获取玩家造成伤害 + player.sendMessage("§e您造成的总伤害: §c" + new DecimalFormat(",###.00").format(damage) + "k §e伤害占总比: §c" + new DecimalFormat("0.00").format(damage / totalDamage * 100) + "%"); + if(rewardData != null) { + // 判断玩家造成伤害是否达到100K并发放奖励 + if (damage >= 10) { + List damageRewardList = rewardData.getDamageCmdList(); + DemonAPI.ConsoleOutCommandList(player, damageRewardList); + } else { + DemonAPI.sendMessage(player, "你造成的总伤害不足§4100,000§a无法获得参与奖。"); + } + } } } WorldBossDeathEvent worldBossDeathEvent = new WorldBossDeathEvent(bossData,rewardData,sortedMap); diff --git a/src/main/java/com/io/yaohun/worldbosshurt/util/BossSpawnUtil.java b/src/main/java/com/io/yaohun/worldbosshurt/util/BossSpawnUtil.java index b441fd9..0d9abba 100644 --- a/src/main/java/com/io/yaohun/worldbosshurt/util/BossSpawnUtil.java +++ b/src/main/java/com/io/yaohun/worldbosshurt/util/BossSpawnUtil.java @@ -12,12 +12,8 @@ public class BossSpawnUtil { if(online_size <= 0){ return "NoPlayer"; } - // 在线人数大于15人 可召唤 - if (online_size > 15) { - return "Start"; - } - // 在线人数小于5人 但有90级玩家 可召唤 - if (online_size < 15) { + // 在线人数小于15人 但有90级玩家 可召唤 + if (online_size <= 14) { for (Player p : Bukkit.getOnlinePlayers()){ double level = DLevelAPI.getOffPlayer_Level(p.getName()); Bukkit.getConsoleSender().sendMessage("[世界BOSS-输出日志] 玩家 "+p.getName()+" 等级: "+level+" 需求等级: 90级"); @@ -26,6 +22,10 @@ public class BossSpawnUtil { } } } + // 在线人数大于15人 可召唤 + if (online_size >= 15) { + return "Start"; + } return "NoLevel"; } } diff --git a/src/main/java/com/io/yaohun/worldbosshurt/util/BossUtil.java b/src/main/java/com/io/yaohun/worldbosshurt/util/BossUtil.java index bd2bcf1..048e7ee 100644 --- a/src/main/java/com/io/yaohun/worldbosshurt/util/BossUtil.java +++ b/src/main/java/com/io/yaohun/worldbosshurt/util/BossUtil.java @@ -35,8 +35,8 @@ public class BossUtil { * */ public static String getTimeMonthly(){ FileConfiguration yml = Main.plugin.getConfig(); - if(yml.getString("Timemonth") != null){ - return yml.getString("Timemonth"); + if(yml.getString("TimeMonth") != null){ + return yml.getString("TimeMonth"); } return "2022/04"; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7648fcb..d3df1a3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: WorldBossHurt main: com.io.yaohun.worldbosshurt.Main -version: 1.0.0 +version: 1.0.2 commands: bosspz: bossreload: