测试版
This commit is contained in:
parent
8b7880a1b0
commit
242a88c99d
10
pom.xml
10
pom.xml
|
@ -41,6 +41,16 @@
|
||||||
<artifactId>MythicMobs</artifactId>
|
<artifactId>MythicMobs</artifactId>
|
||||||
<version>1.12.2</version>
|
<version>1.12.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.Demon.DemonLevels</groupId>
|
||||||
|
<artifactId>DemonLevels</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vexview.api</groupId>
|
||||||
|
<artifactId>vexview</artifactId>
|
||||||
|
<version>1.12.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -1,27 +1,124 @@
|
||||||
package com.io.yaohun.worldbosshurt.command;
|
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.mangage.DamageManage;
|
||||||
|
import com.io.yaohun.worldbosshurt.util.BossSpawnUtil;
|
||||||
import com.io.yaohun.worldbosshurt.util.BossUtil;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
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 org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.minecraft.server.v1_12_R1.SoundEffects.bc;
|
||||||
|
import static net.minecraft.server.v1_12_R1.SoundEffects.fa;
|
||||||
|
|
||||||
public class BossSpawnerCmd implements CommandExecutor , TabCompleter {
|
public class BossSpawnerCmd implements CommandExecutor , TabCompleter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] arge) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(BossUtil.isTimeMonthly()){
|
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){
|
||||||
|
BossManage bossManage = Main.bossManage;
|
||||||
|
if(bossManage.isBossSurvive()){
|
||||||
|
Bukkit.getConsoleSender().sendMessage("[日志-世界Boss] 系统尝试多次执行召唤boss已被拦截.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
DamageManage.damageMap.clear(); // 清理之前的伤害数据缓存
|
||||||
|
|
||||||
|
String stats_type = BossSpawnUtil.getTheCurrentServerPlayerStatus();
|
||||||
|
if(stats_type.equalsIgnoreCase("NoPlayer")){
|
||||||
|
Bukkit.broadcastMessage("§6[§4公告§6] §a世界BOSS召唤失败,在线器师人数过低无法挑战.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(stats_type.equalsIgnoreCase("NoLevel")){
|
||||||
|
Bukkit.broadcastMessage("§6[§4公告§6] §a世界BOSS召唤失败,在线器师无一人达到90级封号斗魂.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(stats_type.equalsIgnoreCase("Start")) {
|
||||||
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] arge) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
List<String> stringList = new ArrayList<>();
|
List<String> completions = new ArrayList<>();
|
||||||
return null;
|
if(args.length == 1){
|
||||||
|
completions.addAll(Main.bossManage.getBossKeyList());
|
||||||
|
}
|
||||||
|
return completions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,23 +5,45 @@ import com.io.yaohun.worldbosshurt.data.BossData;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BossManage {
|
public class BossManage {
|
||||||
|
|
||||||
private List<String> customNameList; // 获取boss名列表
|
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<>();
|
private final HashMap<String,BossData> bossDataMap = new HashMap<>();
|
||||||
|
|
||||||
public BossManage(FileConfiguration yml) {
|
public BossManage(FileConfiguration yml) {
|
||||||
|
this.bossSurvive = false;
|
||||||
for (String bossKey : yml.getConfigurationSection("BossData").getKeys(false)){
|
for (String bossKey : yml.getConfigurationSection("BossData").getKeys(false)){
|
||||||
bossDataMap.put(bossKey,new BossData(bossKey,yml));
|
bossDataMap.put(bossKey,new BossData(bossKey,yml));
|
||||||
String customName = yml.getString("BossData."+bossKey+".name");
|
String customName = yml.getString("BossData."+bossKey+".name");
|
||||||
customNameList.add(customName);
|
customNameList.add(customName);
|
||||||
|
bossKeyList.add(bossKey);
|
||||||
}
|
}
|
||||||
Bukkit.getConsoleSender().sendMessage("§b[BossHurt] §f已导入Boss: §a" + customNameList.size() + "只");
|
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 boolean isBossSurvive() {
|
||||||
|
return bossSurvive;
|
||||||
|
}
|
||||||
|
public void setBossSurvive(boolean butt){
|
||||||
|
bossSurvive = butt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getBossKeyList() {
|
||||||
|
return bossKeyList;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCustomNameContains(String customName){
|
public boolean isCustomNameContains(String customName){
|
||||||
for (String name : this.customNameList){
|
for (String name : this.customNameList){
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class DamageManage implements Listener {
|
public class DamageManage implements Listener {
|
||||||
|
|
||||||
private HashMap<Player,Double> damageMap = new HashMap<>();
|
public static HashMap<Player,Double> damageMap = new HashMap<>();
|
||||||
|
|
||||||
private void addPlayerDamage(Player player,double damage){
|
private void addPlayerDamage(Player player,double damage){
|
||||||
double newDamage = damage / 1000;
|
double newDamage = damage / 1000;
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
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人 可召唤
|
||||||
|
if (online_size > 15) {
|
||||||
|
return "Start";
|
||||||
|
}
|
||||||
|
// 在线人数小于5人 但有90级玩家 可召唤
|
||||||
|
if (online_size < 15) {
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "NoLevel";
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,7 +39,6 @@ public class BossUtil {
|
||||||
* 判断本月数据是否刷新
|
* 判断本月数据是否刷新
|
||||||
* */
|
* */
|
||||||
public static boolean isTimeMonthly(){
|
public static boolean isTimeMonthly(){
|
||||||
FileConfiguration yml = Main.plugin.getConfig();
|
|
||||||
if(!getTimeMonthly().equalsIgnoreCase(DemonAPI.getTime("yyyy/MM"))){
|
if(!getTimeMonthly().equalsIgnoreCase(DemonAPI.getTime("yyyy/MM"))){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user