Compare commits

..

No commits in common. "master" and "WorldBossHurt" have entirely different histories.

22 changed files with 38 additions and 1461 deletions

47
pom.xml
View File

@ -14,47 +14,36 @@
</properties>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>public-rpg</id>
<url>https://repo.aurora-pixels.com/repository/public-rpg/</url>
</repository>
<repository>
<id>public</id>
<url>https://repo.aurora-pixels.com/repository/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2</version>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.Demon.DemonPlugin</groupId>
<artifactId>DemonAPI</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>me.Demon.DemonBank</groupId>
<artifactId>DemonBank</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>io.lumine.xikage.mythicmobs</groupId>
<artifactId>MythicMobs</artifactId>
<version>1.12.2</version>
</dependency>
<dependency>
<groupId>me.Demon.DemonLevels</groupId>
<artifactId>DemonLevels</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>me.Demon.DemonHunHuanSx</groupId>
<artifactId>DemonHunHuanSx</artifactId>
<version>1.12.2</version>
</dependency>
<dependency>
<groupId>com.vexview.api</groupId>
<artifactId>vexview</artifactId>
<version>1.12.2</version>
<groupId>com.fastasyncworldedit.bukkit</groupId>
<artifactId>FastAsyncWorldEdit</artifactId>
<version>2.9.1</version>
<classifier>660</classifier>
</dependency>
</dependencies>

View File

@ -1,97 +0,0 @@
package com.io.yaohun.worldbosshurt;
import com.io.yaohun.worldbosshurt.command.BossSpawnerCmd;
import com.io.yaohun.worldbosshurt.listener.*;
import com.io.yaohun.worldbosshurt.mangage.BossManage;
import com.io.yaohun.worldbosshurt.mangage.RewardManage;
import com.io.yaohun.worldbosshurt.util.BossStack;
import com.io.yaohun.worldbosshurt.util.BossUtil;
import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
public class Main extends JavaPlugin {
public static Main plugin;
public static BossManage bossManage;
public static RewardManage rewardManage;
@Override
public void onEnable() {
plugin = this;
reloadMobDataYml();
getCommand("bossspawner").setExecutor(new BossSpawnerCmd());
getServer().getPluginManager().registerEvents(new BossSpawnLogs(),this);
getServer().getPluginManager().registerEvents(new BossArmor(),this);
getServer().getPluginManager().registerEvents(new BossDamageByPlayer(),this);
getServer().getPluginManager().registerEvents(new BossKillsDeath(),this);
getServer().getPluginManager().registerEvents(new BossDeathEvent(),this);
getServer().getPluginManager().registerEvents(new BossProveEvent(),this);
Bukkit.getConsoleSender().sendMessage("§b[BossHurt] §f插件成功载入Server");
Bukkit.getConsoleSender().sendMessage("§b[BossHurt] §f妖魂QQ:1763917516");
}
public void reloadMobDataYml(){
File Datafile = new File("plugins/WorldBossHurt", "MobData.yml");
bossManage = new BossManage(YamlConfiguration.loadConfiguration(Datafile));
rewardManage = new RewardManage(YamlConfiguration.loadConfiguration(Datafile));
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String Command, String[] args) {
if(Command.equalsIgnoreCase("bossreload") && sender.isOp()){
if(args.length == 1 && args[0].equalsIgnoreCase("test")){
BossUtil.settlementRankingRewards();
return true;
}
reloadMobDataYml();
DemonAPI.sendMessage(sender,"配置文件已重载.");
return true;
}
if(Command.equalsIgnoreCase("bosspz")){ // /bosspz
if(args.length >= 2 && args[0].equalsIgnoreCase("give") && sender.isOp()){
String bossName = args[1];
if(args.length == 2) {
Player player = (Player) sender;
ItemStack pingzheng = BossStack.BossSlashProof(bossName).clone();
DemonAPI.giveItem(player,pingzheng);
DemonAPI.sendMessage(player,"恭喜你获得了 "+pingzheng.getItemMeta().getDisplayName());
}
if(args.length == 3) {
String playName = args[2];
Player player = Bukkit.getPlayer(playName);
if (player == null) {
DemonAPI.sendMessage(sender, "目标玩家不在线无法发送凭证。");
return true;
}
ItemStack pingzheng = BossStack.BossSlashProof(bossName).clone();
DemonAPI.giveItem(player,pingzheng);
DemonAPI.sendMessage(player,"恭喜你获得了 "+pingzheng.getItemMeta().getDisplayName());
}
return true;
}
if(args.length == 2 && args[0].equalsIgnoreCase("tpall") && sender.isOp()){
Player p = (Player) sender;
for (Entity entity : p.getWorld().getEntities()){
if(entity.getCustomName() != null) {
String customName = entity.getCustomName().replaceAll("§[a-zA-Z0-9]", "");
if (customName.contains(args[1])) {
entity.teleport(p.getLocation());
}
}
}
sender.sendMessage("操作执行成功.#"+args[1]);
return true;
}
}
return false;
}
}

View File

@ -1,65 +0,0 @@
package com.io.yaohun.worldbosshurt.api;
import com.io.yaohun.worldbosshurt.Main;
import com.io.yaohun.worldbosshurt.mangage.BossManage;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public abstract class BossHurtAPI {
// 判断这个怪是否是世界boss
public static boolean isBossExist(String customName){
BossManage bossManage = Main.bossManage;
if(bossManage.isCustomNameContains(customName)){
return true;
}
return false;
}
//获取本月猎杀排行榜排行榜
public static void sendTimeMonthTopMessage(Player p){
FileConfiguration yml = Main.plugin.getConfig();
double totalAmount = 0;
HashMap<String, Integer> map = new HashMap<>();
for (String playName : yml.getConfigurationSection("MonthlyKillsTop").getKeys(false)) {
int amount = yml.getInt("MonthlyKillsTop."+playName);
map.put(playName, amount);
totalAmount = totalAmount + amount;
}
List<Map.Entry<String, Integer>> list = new ArrayList<>(map.entrySet());
list.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue()));
int count = Math.min(list.size(), 10);
int rank = 1;
p.sendMessage("§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");
p.sendMessage("§e本月世界级boss猎杀排名如下:");
for (int i = 0; i < count; i++) {
if (rank == 11) {
break;
}
String top_Name = list.get(i).getKey();
p.sendMessage("§e第" + rank + "名 - §c" + top_Name + " §e总计猎杀: §c" + list.get(i).getValue() + "只 §e猎杀占总比: §c" + new DecimalFormat("0.00").format(list.get(i).getValue() / totalAmount * 100) + "%");
++rank;
}
p.sendMessage("§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");
}
public static List<Map.Entry<String, Integer>> getTimeMonthTopHashMap(){
FileConfiguration yml = Main.plugin.getConfig();
double totalAmount = 0;
HashMap<String, Integer> map = new HashMap<>();
for (String playName : yml.getConfigurationSection("MonthlyKillsTop").getKeys(false)) {
int amount = yml.getInt("MonthlyKillsTop."+playName);
map.put(playName, amount);
totalAmount = totalAmount + amount;
}
List<Map.Entry<String, Integer>> list = new ArrayList<>(map.entrySet());
list.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue()));
return list;
}
}

View File

@ -1,122 +0,0 @@
package com.io.yaohun.worldbosshurt.command;
import com.io.yaohun.worldbosshurt.Main;
import com.io.yaohun.worldbosshurt.data.BossData;
import com.io.yaohun.worldbosshurt.event.WorldBossSpawnEvent;
import com.io.yaohun.worldbosshurt.mangage.BossManage;
import com.io.yaohun.worldbosshurt.listener.BossDamageByPlayer;
import com.io.yaohun.worldbosshurt.util.BossSpawnUtil;
import com.io.yaohun.worldbosshurt.util.BossUtil;
import lk.vexview.api.VexViewAPI;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
public class BossSpawnerCmd implements CommandExecutor , TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(BossUtil.isTimeMonthly()){
BossUtil.settlementRankingRewards();
}
if(args.length == 0 && sender.isOp()){
sender.sendMessage("§r");
sender.sendMessage("§e------- ======= §6世界BOSS §e======= -------");
sender.sendMessage("§2/bossspawner §e[代号] §f- §2生成Boss");
sender.sendMessage("§e------- ======= §6世界BOSS §e======= -------");
sender.sendMessage("§r");
return true;
}
if(args.length >= 1 && sender.isOp()){
BossManage bossManage = Main.bossManage;
if(bossManage.isBossSurvive()){
Bukkit.getConsoleSender().sendMessage("[日志-世界Boss] 系统尝试多次执行召唤boss已被拦截.");
return true;
}
BossDamageByPlayer.damageMap.clear(); // 清理之前的伤害数据缓存
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(!antiSpawn){
String bossKey = args[0];
BossData bossData = bossManage.getBossData(bossKey);
if(bossData != null){
Location spawnLoc = bossData.getLocation();// 获取生成点坐标
// 获取坐标周围30格范围内是否存在生物若存在则清除
List<String> stringList = new ArrayList<>();
for (Entity entity : spawnLoc.getWorld().getNearbyEntities(spawnLoc,30,25,30)){
if(!(entity instanceof Item)) {
if(!(entity instanceof Player)){
if(entity.getCustomName() != null) {
stringList.add(entity.getCustomName());
entity.remove();
}
}
}
}
if(stringList.size() >= 1){
Bukkit.getConsoleSender().sendMessage("[日志-世界Boss] 清理周边怪物: "+stringList);
}
bossManage.setBossSurvive(true);
String bossName = bossData.getBossName();// 获取boss的自定义名字
String broadcast = bossData.getBc().replace("%mobs%",bossName); // 获取bc公告信息
Bukkit.broadcastMessage(broadcast);
Bukkit.broadcastMessage(broadcast);
// 发送VexViewAPI的信息
for (Player allp : Bukkit.getOnlinePlayers()) {
if (allp.getLevel() >= 40) {
// 发送Vex信息
String bc_vv = bossData.getBc_vv().replace("%mobs%", bossName);
VexViewAPI.sendFlowView(allp, bc_vv, 16, true);
}
}
new BukkitRunnable() {
private int seconds = 0;
public void run() {
if(seconds == 2){
bossManage.setBossSurvive(false);
}
if(seconds >= 20){
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "mythicmobs mobs spawn " + bossKey + " 1 " + bossData.getLocString());
cancel();
}
seconds++;
}
}.runTaskTimer(Main.plugin,0, 20L);
WorldBossSpawnEvent event = new WorldBossSpawnEvent(bossName);
Bukkit.getPluginManager().callEvent(event);
}
}
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
List<String> completions = new ArrayList<>();
if(args.length == 1){
completions.addAll(Main.bossManage.getBossKeyList());
}
return completions;
}
}

View File

@ -1,68 +0,0 @@
package com.io.yaohun.worldbosshurt.data;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
public class BossData {
private String bossKey;
private String bossName;
private int bossArmor;
private String killsReward;
private String topReward;
private String locString;
private String bc;
private String bc_vv;
public BossData(String bossKey,FileConfiguration yml){
String str = "BossData."+bossKey+".";
this.bossKey = bossKey;
this.bossName = yml.getString(str+"name").replace("&","§");
this.bossArmor = yml.getInt(str+"boss_armor") * 10000;
this.killsReward = null;
if(yml.getString(str+"reward_kills") != null) {
this.killsReward = yml.getString(str + "reward_kills");
}
this.topReward = null;
if(yml.getString(str+"reward_top") != null){
this.topReward = yml.getString(str+"reward_top");
}
this.locString = yml.getString(str+"loc");
this.bc = yml.getString(str+"bc").replace("&","§");
this.bc_vv = yml.getString(str+"bc_vv").replace("&","§");
}
public Location getLocation() {
String[] sp = this.locString.split(",");
String worldName = sp[0];
World world = Bukkit.getWorld(worldName);
int x = Integer.parseInt(sp[1]);
int y = Integer.parseInt(sp[2]);
int z = Integer.parseInt(sp[3]);
return new Location(world,x,y,z);
}
public String getBossKey() {return bossKey;}
public int getBossArmor() {
return bossArmor;
}
public String getKillsReward() {
return killsReward;
}
public String getTopReward() {
return topReward;
}
public String getBossName() {return bossName;}
public String getLocString() {
return locString;
}
public String getBc() {return bc;}
public String getBc_vv() {return bc_vv;}
}

View File

@ -1,90 +0,0 @@
package com.io.yaohun.worldbosshurt.data;
import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
public class RewardData {
private String rewardKey;
private List<String> killsList;
private List<String> damageList;
private HashMap<String,List<String>> topList;
public RewardData(String rewardKey,FileConfiguration yml){
this.rewardKey = rewardKey;
String str = "RewardGroup."+rewardKey+".";
this.killsList = new ArrayList<>();
if(yml.getString(str+"kills") != null){
List<String> stringList = yml.getStringList(str+"kills");
for (String s : stringList){
if(s.contains(";")){
this.killsList.add(s);
}else {
this.killsList.add(s);
this.killsList.add(s);
this.killsList.add(s);
}
}
}
this.damageList = new ArrayList<>();
if(yml.getString(str+"damage") != null){
this.damageList = yml.getStringList(str+"damage");
}
HashMap<String,List<String>> hashMap = new HashMap<>();
if(yml.getConfigurationSection(str+"top") != null) {
for (String top : yml.getConfigurationSection(str + "top").getKeys(false)) {
List<String> stringList = yml.getStringList(str + "top." + top);
hashMap.put(top, stringList);
}
}
this.topList = hashMap;
}
public String getRewardKey() {
if(rewardKey != null) {
return rewardKey;
}
return "无奖励";
}
// 获取最终击杀命令
public List<String> getKillsCmdList(){
int suijishu = (DemonAPI.getRandomInt(killsList.size(), 1) - 1);
String cmdsp = killsList.get(suijishu);
List<String> commands = Collections.singletonList(cmdsp);
if(cmdsp.contains(";")) {
commands = DemonAPI.StringConvertStringList(cmdsp, ";");
}
/*for (String s : commands){
Bukkit.getConsoleSender().sendMessage("#Text = "+s);
}*/
return commands;
}
// 获取排名奖励
public List<String> getTopCmdList(int top){
String topKey = String.valueOf(top);
if(this.topList.get(topKey) != null) {
return this.topList.get(topKey);
}
return new ArrayList<>();
}
// 获取排名奖励数量
public int getTopCmdSize(){
return this.topList.size();
}
// 获取累积伤害奖励
public List<String> getDamageCmdList(){
return this.damageList;
}
}

View File

@ -1,43 +0,0 @@
package com.io.yaohun.worldbosshurt.event;
import com.io.yaohun.worldbosshurt.data.BossData;
import com.io.yaohun.worldbosshurt.data.RewardData;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import java.util.LinkedHashMap;
public class WorldBossDamageEvent extends Event {
private static HandlerList handlers = new HandlerList();
private Player player;
private double damage;
private BossData bossData;
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public WorldBossDamageEvent(Player player,BossData bossData,double damage) {
this.player = player;
this.bossData = bossData;
this.damage = damage;
}
public Player getPlayer() {return player;}
public String getBossKey(){return bossData.getBossKey();}
public String getMobName() {
return bossData.getBossName();
}
public BossData getBossData() {
return bossData;
}
public double getDamage() {
return damage * 1000;
}
}

View File

@ -1,47 +0,0 @@
package com.io.yaohun.worldbosshurt.event;
import com.io.yaohun.worldbosshurt.data.BossData;
import com.io.yaohun.worldbosshurt.data.RewardData;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import java.util.LinkedHashMap;
public class WorldBossDeathEvent extends Event {
private static HandlerList handlers = new HandlerList();
private BossData bossData;
private RewardData rewardData;
private LinkedHashMap<String, Double> sortedMap;
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public WorldBossDeathEvent(BossData bossData,RewardData rewardData,LinkedHashMap<String, Double> sortedMap) {
this.bossData = bossData;
this.rewardData = rewardData;
this.sortedMap = sortedMap;
}
public String getBossKey(){
return bossData.getBossKey();
}
public String getMobName() {
return bossData.getBossName();
}
public BossData getBossData() {
return bossData;
}
public RewardData getRewardData() {
return rewardData;
}
public LinkedHashMap<String, Double> getSortedMap() {
return sortedMap;
}
}

View File

@ -1,25 +0,0 @@
package com.io.yaohun.worldbosshurt.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class WorldBossSpawnEvent extends Event {
private static HandlerList handlers = new HandlerList();
private String mobName;
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public WorldBossSpawnEvent(String mobName) {
this.mobName = mobName;
}
public String getMobName() {
return mobName;
}
}

View File

@ -1,101 +0,0 @@
package com.io.yaohun.worldbosshurt.listener;
import com.io.yaohun.worldbosshurt.Main;
import com.io.yaohun.worldbosshurt.data.BossData;
import com.io.yaohun.worldbosshurt.mangage.BossManage;
import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import java.util.HashMap;
import java.util.UUID;
public class BossArmor implements Listener {
private HashMap<UUID,Double> bossHurtMap = new HashMap<>();
private double getBossHurtDamage(UUID uuid){
if(bossHurtMap.get(uuid) == null){
return 0.0;
}
return bossHurtMap.get(uuid);
}
private void addPlayerDamage(UUID uuid, double damage){
if(bossHurtMap.get(uuid) == null){
bossHurtMap.put(uuid,damage);
return;
}
double newDamage = damage + bossHurtMap.get(uuid);
bossHurtMap.put(uuid,newDamage);
}
public static boolean butt_hurt = false;
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void EntityDamageByEntity(EntityDamageByEntityEvent e) {
if(!(e.getEntity() instanceof Player)) {
Entity entity = e.getEntity(); // 获取受伤生物
String customName = entity.getCustomName(); // 获取生物自定义名
BossManage bossManage = Main.bossManage; // 获取boss管理
if (customName != null && bossManage.isCustomNameContains(customName)) {
BossData bossData = bossManage.getNameToData(customName);
DamageEvent(e, bossData);
}
}
}
public void DamageEvent(EntityDamageByEntityEvent e, BossData dataAPI){
double damage = e.getDamage();
if(butt_hurt){
int start_armor_boss = dataAPI.getBossArmor();
int damage_limit_1 = (int) (start_armor_boss * 0.1); // 200W
int damage_limit_2 = (int) (start_armor_boss * 0.01); // 20W
int damage_limit_3 = (int) (start_armor_boss * 0.001); // 2W
if(damage >= damage_limit_1){
int rand_damage = DemonAPI.getRandomInt((damage_limit_2*5), damage_limit_2);
e.setDamage(rand_damage);
}else if(damage >= damage_limit_2){
int rand_damage = DemonAPI.getRandomInt(damage_limit_2*3, damage_limit_3);
e.setDamage(rand_damage);
}
return;
}
if(damage <= dataAPI.getBossArmor()) {
Entity entity = e.getEntity();
UUID uuid = entity.getUniqueId();
if (bossHurtMap.get(entity.getUniqueId()) != null) {
addPlayerDamage(uuid,damage);
double boss_armonr = getBossHurtDamage(uuid);
if (boss_armonr >= dataAPI.getBossArmor()) {
StartBossArmor("累伤触发");
}
} else {
addPlayerDamage(uuid,damage);
}
} else {
StartBossArmor("瞬伤触发");
e.setCancelled(true);
}
}
public void StartBossArmor(String type){
butt_hurt = true;
int s = DemonAPI.getRandomInt(25, 10);
Bukkit.getConsoleSender().sendMessage("开启保护 开启保护 开启保护 开启保护#"+s+"s || "+type);
Bukkit.getScheduler().runTaskLater(Main.plugin, (Runnable) new Runnable() {
@Override
public void run() {
butt_hurt = false;
bossHurtMap.clear();
Bukkit.getConsoleSender().sendMessage("关闭保护 关闭保护 关闭保护 关闭保护 ");
}
}, (long) 20*s);
}
}

View File

@ -1,96 +0,0 @@
package com.io.yaohun.worldbosshurt.listener;
import com.io.yaohun.worldbosshurt.Main;
import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.UUID;
public class BossDamageByPlayer implements Listener {
public static HashMap<Player,Double> damageMap = new HashMap<>();
private void addPlayerDamage(Player player,double damage){
double newDamage = damage / 1000;
if(damageMap.get(player) == null){
damageMap.put(player,newDamage);
return;
}
double addDamage = newDamage + damageMap.get(player);
damageMap.put(player,addDamage);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onEntityDamageByPlayer(EntityDamageByEntityEvent e) {
if(e.getDamager() instanceof Player){
Entity entity = e.getEntity();
String customName = entity.getCustomName();
if(customName != null && Main.bossManage.isCustomNameContains(customName)){
Player p = (Player) e.getDamager();
String worldName = p.getWorld().getName();
if(!worldName.equalsIgnoreCase("teamDungee")) {
if(customName.contains("§t§e§a§m")){
e.getEntity().remove();
Bukkit.getConsoleSender().sendMessage("[世界boss-日志] 因 "+customName+" §r离开团队副本,此Boss已清理.");
return;
}
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;
}
double damage = e.getDamage();
DemonAPI.sendTitle(p, 5, 20, 5, "", "§c§l造成伤害: §a§l+" + new DecimalFormat("0.00").format(damage));
addPlayerDamage(p,e.getDamage());
}
}
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onEntityDamageByProjectile(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Projectile) {
Projectile projectile = (Projectile) e.getDamager();
if (projectile.getShooter() instanceof Player) {
Entity entity = e.getEntity();
String customName = entity.getCustomName();
if (customName != null && Main.bossManage.isCustomNameContains(customName)) {
Player p = (Player) projectile.getShooter();
String worldName = p.getWorld().getName();
if (!worldName.equalsIgnoreCase("teamDungee")) {
if (customName.contains("§t§e§a§m")) {
e.getEntity().remove();
Bukkit.getConsoleSender().sendMessage("[世界boss-日志] 因 " + customName + " §r离开团队副本,此Boss已清理.");
return;
}
UUID Mob_uuid = e.getEntity().getUniqueId();
if (!BossSpawnLogs.WhiteBossList.contains(Mob_uuid)) {
e.getEntity().remove();
Bukkit.broadcastMessage("§6[§4公告§6] §a" + customName + "§a被卷入了异次元时空.");
return;
}
double damage = e.getDamage();
DemonAPI.sendTitle(p, 5, 20, 5, "", "§c§l造成伤害: §a§l+" + new DecimalFormat("0.00").format(damage));
addPlayerDamage(p, e.getDamage());
}
}
}
}
}
}

View File

@ -1,35 +0,0 @@
package com.io.yaohun.worldbosshurt.listener;
import com.io.yaohun.worldbosshurt.data.RewardData;
import com.io.yaohun.worldbosshurt.event.WorldBossDeathEvent;
import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.LinkedHashMap;
import java.util.List;
public class BossDeathEvent implements Listener {
@EventHandler
public void onBossDeath(WorldBossDeathEvent e){
RewardData rewardData = e.getRewardData();
LinkedHashMap<String, Double> hashMap = e.getSortedMap();
int rank = 1;
for (String name : hashMap.keySet()) {
if (rank >= 6) {
break;
}
List<String> rankRewardList = rewardData.getTopCmdList(rank);
if (rankRewardList.size() >= 1) {
Player onlinePlayer = Bukkit.getPlayer(name);
if (onlinePlayer != null && onlinePlayer.isOnline()) {
DemonAPI.ConsoleOutCommandList(onlinePlayer, rankRewardList);
}
}
rank++;
}
}
}

View File

@ -1,156 +0,0 @@
package com.io.yaohun.worldbosshurt.listener;
import com.io.yaohun.worldbosshurt.Main;
import com.io.yaohun.worldbosshurt.data.BossData;
import com.io.yaohun.worldbosshurt.data.RewardData;
import com.io.yaohun.worldbosshurt.event.WorldBossDamageEvent;
import com.io.yaohun.worldbosshurt.event.WorldBossDeathEvent;
import com.io.yaohun.worldbosshurt.mangage.BossManage;
import com.io.yaohun.worldbosshurt.util.BossStack;
import com.io.yaohun.worldbosshurt.util.BossUtil;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitRunnable;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
public class BossKillsDeath implements Listener {
@EventHandler
public void onkilldrop(MythicMobDeathEvent e){
if(e.getKiller() instanceof Player) { // 判断斩杀者是玩家
Entity entity = e.getEntity();
BossManage bossManage = Main.bossManage;
String customName = entity.getCustomName();
if(customName != null && bossManage.isCustomNameContains(customName)){
BossData bossData = bossManage.getNameToData(customName);
if(bossData == null){return;}
String worldName = entity.getWorld().getName();
if (!worldName.equalsIgnoreCase("teamDungee")) {
Player player = ((Player) e.getKiller()).getPlayer();
String message = BossUtil.getFinallyKills().replace("%p%", player.getName()); // 获取最终击杀提示
Bukkit.broadcastMessage(message.replace("%mobs%",bossData.getBossName())); // 发送最终击杀提示
BossUtil.addMonthlyKillBoss(player.getName()); // 为玩家累积最终斩杀次数
String Kills_Group_Key = bossData.getKillsReward(); // 获取击杀奖励组名
RewardData killsRewardData = Main.rewardManage.getRewardData(Kills_Group_Key);
// 执行命令并发放奖励
if(bossData.getKillsReward() != null){
if (!Kills_Group_Key.equalsIgnoreCase("魂环")) {
List<String> commands = killsRewardData.getKillsCmdList();
DemonAPI.ConsoleOutCommandList(player, commands);
}else{
sendRingRewards(player,bossData,killsRewardData);
}
}
new BukkitRunnable() {
public void run() {
statisticalSettlementOfDamages(bossData,Main.rewardManage.getRewardData(bossData.getTopReward()));
cancel();
}
}.runTaskLater(Main.plugin, 20L);
}
}
}
}
/*
* 将对boss造成伤害的存进Hash
* 并进行排序随后发送全服公告
* */
public static void statisticalSettlementOfDamages(BossData bossData,RewardData rewardData) {
double totalDamage = 0; // 获取本次造成总伤害
HashMap<String, Double> hashMap = new HashMap<>();
Map<Player, Double> damageMap = BossDamageByPlayer.damageMap;
List<Player> playerList = new ArrayList<>();
for (Player player : damageMap.keySet()) {
if (player != null && player.isOnline()) {
double damage = damageMap.get(player); // 获取该玩家造成伤害
totalDamage += damage; // 统计玩家造成总计伤害
hashMap.put(player.getName(), damage); // 将玩家名和伤害存储
playerList.add(player); // 将玩家存入在线玩家列表
WorldBossDamageEvent worldBossDamageEvent = new WorldBossDamageEvent(player,bossData,damage);
Bukkit.getPluginManager().callEvent(worldBossDamageEvent);
}
}
if (hashMap.size() < 1) { return; }
LinkedHashMap<String, Double> sortedMap = hashMap.entrySet()
.stream()
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
.collect(Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue,
(e1, e2) -> e1,
LinkedHashMap::new
));
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");
Bukkit.broadcastMessage("§e世界级Boss: "+bossData.getBossName()+" §e伤害排名如下:");
int rank = 1;
for (String top_Name : sortedMap.keySet()){
if(rank == 6){break;}
double damage = sortedMap.get(top_Name);
Bukkit.broadcastMessage("§e第" + rank + "名 - §c" + top_Name + " §e总计伤害: §c" + new DecimalFormat("00.00").format(damage) + "k §e伤害占总比: §c" + new DecimalFormat("0.00").format(damage / totalDamage * 100) + "%");
rank++;
}
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){
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<String> damageRewardList = rewardData.getDamageCmdList();
DemonAPI.ConsoleOutCommandList(player, damageRewardList);
} else {
DemonAPI.sendMessage(player, "你造成的总伤害不足§4100,000§a无法获得参与奖。");
}
}
}
}
WorldBossDeathEvent worldBossDeathEvent = new WorldBossDeathEvent(bossData,rewardData,sortedMap);
Bukkit.getPluginManager().callEvent(worldBossDeathEvent);
}
public void sendRingRewards(Player player,BossData bossData,RewardData rewardData) {
String name = player.getName();
if(DemonAPI.getRandomInt(100,1) >= 10){
DemonAPI.sendMessage(player,"很遗憾,这只灵兽的最终一击并未掉落任何奖励。");
}else{
String bossKey = bossData.getBossKey();
if (DemonAPI.getRandomInt(100,1) >= 2) {
if (DemonAPI.getRandomInt(100, 1) > 10) {
player.getInventory().addItem(BossStack.BossSlashProof(bossKey));
Bukkit.broadcastMessage("§6[§4公告§6] §e"+name+" §a通过最终一击获得了 §c§l猎杀凭证 §f("+bossKey+")");
} else {
if(rewardData.getRewardKey().contains("百万年")){
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "mythicmobs items give " + name + " 百万年" + bossKey + "灵环无献祭");
DemonAPI.sendMessage(player,"恭喜你获得了 §6§l百万年灵环 §f(" + bossKey + ")");
Bukkit.broadcastMessage("§6[§4公告§6] §e" + name + " §a通过最终一击获得了 §6§l百万年灵环 §f(" + bossKey + ")");
} else {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "mythicmobs items give " + name + " 十万年" + bossKey + "灵环无献祭");
DemonAPI.sendMessage(player,"恭喜你获得了 §c§l十万年灵环 §f(" + bossKey + ")");
Bukkit.broadcastMessage("§6[§4公告§6] §e" + name + " §a通过最终一击获得了 §c§l十万年灵环 §f(" + bossKey + ")");
}
}
} else {
if(rewardData.getRewardKey().contains("百万年")){
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "mythicmobs items give " + name + " 百万年" + bossKey + "灵环");
DemonAPI.sendMessage(player,"恭喜你获得了 §6§l百万年灵环 §f(" + bossKey + ")§d[含献祭]");
Bukkit.broadcastMessage("§6[§4公告§6] §e" + name + " §a通过最终一击获得了 §6§l百万年灵环 §f(" + bossKey + ")§d[含献祭]");
}else {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "mythicmobs items give " + name + " 十万年" + bossKey + "灵环");
DemonAPI.sendMessage(player,"恭喜你获得了 §c§l十万年灵环 §f(" + bossKey + ")§d[含献祭]");
Bukkit.broadcastMessage("§6[§4公告§6] §e" + name + " §a通过最终一击获得了 §c§l十万年灵环 §f(" + bossKey + ")§d[含献祭]");
}
}
}
}
}

View File

@ -1,164 +0,0 @@
package com.io.yaohun.worldbosshurt.listener;
import com.io.yaohun.worldbosshurt.util.BossStack;
import me.Demon.DemonHunHuanSX.HunHuanAPI;
import me.Demon.DemonHunHuanSX.Main;
import me.Demon.DemonPlugin.DemonAPI;
import me.Demon.ItemKuAPI;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class BossProveEvent implements Listener {
public static String invTitle = "斗魂偙国 - 十万年凭证兑换";
/*
* 交换兑换十万年魂环
* */
@EventHandler
public void onclick(InventoryClickEvent e){
int rawSlot = e.getRawSlot();
Player p = (Player) e.getWhoClicked();
Inventory inv = e.getInventory();
ItemStack item = e.getCurrentItem();
if(inv != null && invTitle.equalsIgnoreCase(inv.getTitle())){
e.setCancelled(true);
if(!DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)){
p.playSound(p.getLocation(),Sound.BLOCK_COMPARATOR_CLICK,1.6F,1.8F);
NBTTagCompound nbt = BossStack.getNBT(item);
if(nbt.hasKey("hhkey")){
String hhkey = nbt.getString("hhkey");
p.closeInventory(); // 关闭界面
ItemStack needStack = BossStack.BossSlashProof(hhkey);
if(!DemonAPI.isPlayerItemsLore(p,needStack,8)){
DemonAPI.sendMessage(p,"兑换失败,缺少该十万年灵兽的猎杀凭证。",Sound.ENTITY_VILLAGER_NO);
return;
}
ItemStack laborStack = ItemKuAPI.getItems("劳动者结晶",1);
if(!DemonAPI.isPlayerItemsLore(p,laborStack,2)){
DemonAPI.sendMessage(p,"兑换失败,缺少劳动者结晶。",Sound.ENTITY_VILLAGER_NO);
return;
}
DemonAPI.removePlayerItemsLore(p,needStack,8); // 扣除凭证
DemonAPI.removePlayerItemsLore(p,laborStack,2); // 扣除劳动者结晶
ItemStack hh_item = HunHuanAPI.getHHItems("十万年_"+hhkey+"灵环");
p.getInventory().addItem(hh_item);
p.sendMessage(Main.prefix+"兑换成功,你获得了 "+hh_item.getItemMeta().getDisplayName());
return;
}
if(nbt.hasKey("hhkeypro")){
String hhkey = nbt.getString("hhkeypro");
p.closeInventory(); // 关闭界面
ItemStack needStack = BossStack.BossSlashProof(hhkey);
if(!DemonAPI.isPlayerItemsLore(p,needStack,12)){
DemonAPI.sendMessage(p,"兑换失败,缺少该十万年灵兽的猎杀凭证。",Sound.ENTITY_VILLAGER_NO);
return;
}
// 获取灵环精片
ItemStack spermTablets = ItemKuAPI.getItems("灵环精片",1);
if(!DemonAPI.isPlayerItemsLore(p,spermTablets,64)){
DemonAPI.sendMessage(p,"兑换失败,缺少灵环精片。",Sound.ENTITY_VILLAGER_NO);
return;
}
ItemStack laborStack = ItemKuAPI.getItems("劳动者结晶",1);
if(!DemonAPI.isPlayerItemsLore(p,laborStack,10)){
DemonAPI.sendMessage(p,"兑换失败,缺少劳动者结晶。",Sound.ENTITY_VILLAGER_NO);
return;
}
DemonAPI.removePlayerItemsLore(p,needStack,12); // 扣除凭证
DemonAPI.removePlayerItemsLore(p,laborStack,10); // 扣除劳动者结晶
DemonAPI.removePlayerItemsLore(p,spermTablets,64); // 扣除灵环精片
ItemStack hh_item = HunHuanAPI.getHHItems("十万年_"+hhkey+"灵环");
ItemMeta meta = hh_item.getItemMeta();
List<String> lore = meta.getLore();
lore.add("§d十万年灵兽自愿献祭标识");
meta.setLore(lore);
hh_item.setItemMeta(meta);
p.getInventory().addItem(hh_item);
p.sendMessage(Main.prefix+"兑换成功,你获得了 "+hh_item.getItemMeta().getDisplayName());
}
}
}
}
/*
* 玩家手持凭证打开兑换界面
* */
@EventHandler
public void onUse(PlayerInteractEvent e){
Player player = e.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
if(e.getHand() == EquipmentSlot.HAND){
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
if(BossStack.isItemBossProve(item)){
e.setCancelled(true);
BossProveEvent.OpenGui(player);
player.playSound(player.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1.6F,1.8F);
}
}
}
}
public static void OpenGui(Player p){
Inventory inv = Bukkit.createInventory(null,27,invTitle);
inv.setItem(0,Show_Items("巨兽泰坦"));
inv.setItem(1,Show_Items("青天牛马"));
inv.setItem(2,Show_Items("奇灵舞魅兔"));
inv.setItem(3,Show_Items("冰封魔焰虎"));
inv.setItem(4,Show_Items("噬魂蛛皇"));
inv.setItem(5,Show_Items("雷暴狮王"));
inv.setItem(18,Hd_Items("巨兽泰坦"));
inv.setItem(19,Hd_Items("青天牛马"));
inv.setItem(20,Hd_Items("奇灵舞魅兔"));
inv.setItem(21,Hd_Items("冰封魔焰虎"));
inv.setItem(22,Hd_Items("噬魂蛛皇"));
inv.setItem(23,Hd_Items("雷暴狮王"));
p.openInventory(inv);
}
public static ItemStack Show_Items(String keyName){
ItemStack item = HunHuanAPI.getHHItems("十万年_"+keyName+"灵环");
ItemMeta meta = item.getItemMeta();
List<String> lore = meta.getLore();
lore.add(" ");
lore.add("§7-----[兑换需求材料]-----");
lore.add("§c§l猎杀凭证 §f("+keyName+") §7x 8");
lore.add("§2§l劳动者结晶 §7x 2");
lore.add("§a§l✔§f左键点击兑换");
meta.setLore(lore);
item.setItemMeta(meta);
NBTTagCompound nbt = BossStack.getNBT(item);
nbt.setString("hhkey",keyName);
return BossStack.setNBT(item,nbt);
}
public static ItemStack Hd_Items(String keyName){
ItemStack item = HunHuanAPI.getHHItems("十万年_"+keyName+"灵环");
ItemMeta meta = item.getItemMeta();
List<String> lore = meta.getLore();
lore.add("§d十万年灵兽自愿献祭标识");
lore.add(" ");
lore.add("§7-----[兑换需求材料]-----");
lore.add("§c§l猎杀凭证 §f("+keyName+") §7x 12");
lore.add("§b§l灵环精片 §7x 64");
lore.add("§2§l劳动者结晶 §7x 10");
lore.add("§a§l✔§f左键点击兑换");
lore.add("§b#活动期间限时开放");
meta.setLore(lore);
item.setItemMeta(meta);
NBTTagCompound nbt = BossStack.getNBT(item);
nbt.setString("hhkeypro",keyName);
return BossStack.setNBT(item,nbt);
}
}

View File

@ -1,21 +0,0 @@
package com.io.yaohun.worldbosshurt.listener;
import com.io.yaohun.worldbosshurt.event.WorldBossSpawnEvent;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.ArrayList;
import java.util.List;
public class BossSpawnLogs implements Listener {
public static List<String> WhiteBossList = new ArrayList<>();
@EventHandler
public void onSpawnBlockEvent(WorldBossSpawnEvent e) {
String customName = e.getMobName();
WhiteBossList.add(customName);
Bukkit.getConsoleSender().sendMessage("[日志-UUID导入] Boss "+customName+" §r已被录入List");
}
}

View File

@ -0,0 +1,18 @@
package com.io.yaohun.worldbosshurt;
import org.bukkit.plugin.java.JavaPlugin;
public class main extends JavaPlugin {
private static main instance;
@Override
public void onEnable() {
instance = this;
}
public static main getInstance() {
return instance;
}
}

View File

@ -1,74 +0,0 @@
package com.io.yaohun.worldbosshurt.mangage;
import com.io.yaohun.worldbosshurt.Main;
import com.io.yaohun.worldbosshurt.data.BossData;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class BossManage {
private boolean bossSurvive;
private final List<String> bossKeyList = new ArrayList<>(); // 获取boss名列表
private final List<String> customNameList = new ArrayList<>(); // 获取boss名列表
private final HashMap<String, BossData> bossDataMap = new HashMap<>();
public BossManage(FileConfiguration yml) {
this.bossSurvive = false;
for (String bossKey : yml.getConfigurationSection("BossData").getKeys(false)) {
bossDataMap.put(bossKey, new BossData(bossKey, yml));
String customName = yml.getString("BossData." + bossKey + ".name");
customNameList.add(customName);
bossKeyList.add(bossKey);
}
Bukkit.getConsoleSender().sendMessage("§b[BossHurt] §f已导入Boss: §a" + customNameList.size() + "");
}
public BossData getBossData(String bossKey) {
if (bossDataMap.get(bossKey) == null) {
return null;
}
return bossDataMap.get(bossKey);
}
public BossData getNameToData(String customName) {
for (String bossKey : bossDataMap.keySet()) {
BossData data = bossDataMap.get(bossKey);
String bossName = data.getBossName();
if (customName.contains(bossName)) {
return data;
}
}
return null;
}
public boolean isBossSurvive() {
return bossSurvive;
}
public void setBossSurvive(boolean butt) {
bossSurvive = butt;
}
public List<String> getBossKeyList() {
return bossKeyList;
}
public boolean isCustomNameContains(String customName) {
// 检查 customName 是否为 null
if (customName == null) {
return false;
}
// 遍历 customNameList 检查是否有任何名称包含 customName
for (String name : this.customNameList) {
// 检查 name 是否为 null
if (name != null && customName.contains(name)) {
return true;
}
}
return false;
}
}

View File

@ -1,27 +0,0 @@
package com.io.yaohun.worldbosshurt.mangage;
import com.io.yaohun.worldbosshurt.data.RewardData;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.HashMap;
public class RewardManage {
private final HashMap<String, RewardData> rewardDataMap = new HashMap<>();
public RewardManage(FileConfiguration yml) {
if(yml.getConfigurationSection("RewardGroup") != null) {
for (String rewardKey : yml.getConfigurationSection("RewardGroup").getKeys(false)){
rewardDataMap.put(rewardKey,new RewardData(rewardKey,yml));
}
}
Bukkit.getConsoleSender().sendMessage("§b[BossHurt] §f已导入奖励方案: §a" + rewardDataMap.size() + "");
}
public RewardData getRewardData(String string) {
if(rewardDataMap.get(string) != null){
return rewardDataMap.get(string);
}
return null;
}
}

View File

@ -1,31 +0,0 @@
package com.io.yaohun.worldbosshurt.util;
import me.Demon.DemonLevels.api.DLevelAPI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class BossSpawnUtil {
public static String getTheCurrentServerPlayerStatus(){
// 如果服务器没有玩家在线则无法召唤
int online_size = Bukkit.getOnlinePlayers().size();
if(online_size <= 0){
return "NoPlayer";
}
// 在线人数小于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级");
if(level >= 90) {
return "Start";
}
}
}
// 在线人数大于15人 可召唤
if (online_size >= 15) {
return "Start";
}
return "NoLevel";
}
}

View File

@ -1,61 +0,0 @@
package com.io.yaohun.worldbosshurt.util;
import com.io.yaohun.worldbosshurt.Main;
import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import java.util.*;
import java.util.stream.Collectors;
public class BossStack {
public static NBTTagCompound getNBT(ItemStack Equipment) {
net.minecraft.server.v1_12_R1.ItemStack nmsEquipment = CraftItemStack.asNMSCopy(Equipment);
return nmsEquipment.hasTag() && nmsEquipment.getTag() != null ? nmsEquipment.getTag() : new NBTTagCompound();
}
public static ItemStack setNBT(ItemStack item, NBTTagCompound nbtEquipment) {
net.minecraft.server.v1_12_R1.ItemStack nmsEquipment = CraftItemStack.asNMSCopy(item);
nmsEquipment.setTag(nbtEquipment);
return CraftItemStack.asBukkitCopy(nmsEquipment);
}
/*
* 增加玩家每月Boss击杀数
* */
public static ItemStack BossSlashProof(String bossName){
ItemStack item = new ItemStack(Material.PAPER,1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§c§l猎杀凭证 §f("+bossName+")");
List<String> lore = new ArrayList<>();
lore.add("§c§l★§7通过猎杀§c十万年级§7以上");
lore.add("§7灵兽§a掉落§7的凭证,§a集齐多张");
lore.add("§7可兑换§c十万年级§7以上灵环!");
lore.add("§b§l✪§7务必要妥善保管此凭证!");
meta.setLore(lore);
item.setItemMeta(meta);
NBTTagCompound nbt = getNBT(item);
nbt.setString("stex","cailiao_68");
return setNBT(item,nbt);
}
public static boolean isItemBossProve(ItemStack item){
if(DemonAPI.itemIsNull(item) || DemonAPI.itemIsLore(item)){
return false;
}
ItemMeta meta = item.getItemMeta();
if(meta.getDisplayName().contains("§c§l猎杀凭证")){
if(meta.getLore().contains("§7灵兽§a掉落§7的凭证,§a集齐多张")){
return true;
}
}
return false;
}
}

View File

@ -1,106 +0,0 @@
package com.io.yaohun.worldbosshurt.util;
import com.io.yaohun.worldbosshurt.Main;
import me.Demon.DemonBanK.BankAPI;
import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class BossUtil {
public static String finallyKills = "§6[§4公告§6] §a玩家 §c%p% §a夺取了 §r%mobs% §6§l最终一击!";
public static String getFinallyKills() {
return finallyKills;
}
/*
* 增加玩家每月Boss击杀数
* */
public static void addMonthlyKillBoss(String name){
FileConfiguration yml = Main.plugin.getConfig();
int killAmount = yml.getInt("MonthlyKillsTop."+name);
yml.set("MonthlyKillsTop."+name,(killAmount+1));
Main.plugin.saveConfig();
}
/*
* 获取每月数据刷新时间
* */
public static String getTimeMonthly(){
FileConfiguration yml = Main.plugin.getConfig();
if(yml.getString("TimeMonth") != null){
return yml.getString("TimeMonth");
}
return "2022/04";
}
/*
* 判断本月数据是否刷新
* */
public static boolean isTimeMonthly(){
if(!getTimeMonthly().equalsIgnoreCase(DemonAPI.getTime("yyyy/MM"))){
return true;
}
return false;
}
/*
* 结算上月累积击杀十万年次数排行
* */
public static void settlementRankingRewards() {
FileConfiguration yml = Main.plugin.getConfig();
yml.set("TimeMonth", DemonAPI.getTime("yyyy/MM")); // 设置本月时间
HashMap<String, Integer> hashMap = new HashMap<>(); // 统计击杀boss次数
if (yml.getConfigurationSection("MonthlyKillsTop") != null) {
for (String name : yml.getConfigurationSection("MonthlyKillsTop").getKeys(false)){
int killAmount = yml.getInt("MonthlyKillsTop."+name); // 获取击杀boss次数
hashMap.put(name,killAmount); // put次数
}
yml.set("MonthlyKillsTop",null); // 清理本地数据
}
if(hashMap.size() >= 1){
// 为HashMap中数值进行降序排序
LinkedHashMap<String, Integer> sortedMap = hashMap.entrySet()
.stream()
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
.collect(Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue,
(e1, e2) -> e1,
LinkedHashMap::new
));
// 遍历sortedMap中的数据
int rank = 1;
for (String name : sortedMap.keySet()){
int kill_amount = sortedMap.get(name);
if(rank == 1) {
Bukkit.broadcastMessage("§6[§4灵兽猎杀排行§6] §a玩家 §e" + name + " §a上月总计猎杀: §6" + kill_amount + "只 §a获得奖励: §d§l点券§fx1000");
BankAPI.addPoints(name,1000);
}else if(rank == 2){
Bukkit.broadcastMessage("§6[§4灵兽猎杀排行§6] §a玩家 §e" + name + " §a上月总计猎杀: §6" + kill_amount + "只 §a获得奖励: §d§l点券§fx750");
BankAPI.addPoints(name,750);
}else if(rank == 3){
Bukkit.broadcastMessage("§6[§4灵兽猎杀排行§6] §a玩家 §e" + name + " §a上月总计猎杀: §6" + kill_amount + "只 §a获得奖励: §d§l点券§fx500");
BankAPI.addPoints(name,500);
}else if(rank == 4){
Bukkit.broadcastMessage("§6[§4灵兽猎杀排行§6] §a玩家 §e" + name + " §a上月总计猎杀: §6" + kill_amount + "只 §a获得奖励: §d§l点券§fx250");
BankAPI.addPoints(name,250);
}else if(rank == 5){
Bukkit.broadcastMessage("§6[§4灵兽猎杀排行§6] §a玩家 §e" + name + " §a上月总计猎杀: §6" + kill_amount + "只 §a获得奖励: §d§l点券§fx100");
BankAPI.addPoints(name,100);
break;
}
rank++;
}
}
Main.plugin.saveConfig(); // 保存本地数据
Bukkit.getConsoleSender().sendMessage("[日志 - 世界BOSS] 成功结算上月玩家的Boss总击杀榜.");
}
}

View File

@ -1,7 +1,6 @@
name: WorldBossHurt
main: com.io.yaohun.worldbosshurt.Main
version: 1.0.2
main: com.io.yaohun.worldbosshurt.main
version: 1.0.0
commands:
bosspz:
bossreload:
bossspawner: