测试版1.0.2
This commit is contained in:
parent
4d184bb239
commit
68fb33528f
17
pom.xml
17
pom.xml
|
@ -26,21 +26,26 @@
|
|||
<id>public-rpg</id>
|
||||
<url>https://repo.aurora-pixels.com/repository/public-rpg/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigotmc-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>fastasyncworldedit</artifactId>
|
||||
<version>2.11.1</version>
|
||||
<classifier>857</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
|
@ -1,27 +0,0 @@
|
|||
package com.yaohun.enderdragonWars;
|
||||
|
||||
import com.yaohun.enderdragonWars.game.Game;
|
||||
import com.yaohun.enderdragonWars.manage.GameManage;
|
||||
import com.yaohun.enderdragonWars.manage.GiftEffectManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
|
||||
public static Main plugin;
|
||||
public static GameManage gameManage;
|
||||
public static Game game;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
GiftEffectManager.registerAll();
|
||||
gameManage = new GameManage();
|
||||
game = new Game();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
GiftEffectManager.stopQueue();
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package com.yaohun.enderdragonWars.data;
|
||||
|
||||
import com.yaohun.enderdragonWars.util.GameUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public class GiftData {
|
||||
private String giftName; // 礼物名
|
||||
private String event; // 效果名
|
||||
private int minutes; // 加播或减播
|
||||
private String sounds; // 自定义音效
|
||||
|
||||
public GiftData(String giftName, FileConfiguration yml) {
|
||||
this.giftName = giftName;
|
||||
String str = "礼物设置." + giftName + ".";
|
||||
if (yml.getString(str + "声音") != null) {
|
||||
this.sounds = yml.getString(str + "声音");
|
||||
}
|
||||
this.event = yml.getString(str + "效果");
|
||||
this.minutes = yml.getInt(str + "加播");
|
||||
if (this.minutes >= 1) {
|
||||
Bukkit.getConsoleSender().sendMessage("事件: " + this.event + " 条件: " + giftName + " 加播: +" + minutes + "分钟");
|
||||
} else {
|
||||
Bukkit.getConsoleSender().sendMessage("事件: " + this.event + " 条件: " + giftName + " 减播: -" + minutes + "分钟");
|
||||
}
|
||||
}
|
||||
|
||||
public String getGiftName() {
|
||||
return giftName;
|
||||
}
|
||||
|
||||
public String getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public void OutPlaySoundsEvent() {
|
||||
if(!sounds.equalsIgnoreCase("NULL")) {
|
||||
GameUtil.SendAllSounds(sounds);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package com.yaohun.enderdragonWars.effect;
|
||||
|
||||
import com.yaohun.enderdragonWars.game.Game;
|
||||
|
||||
public abstract class GiftEffect {
|
||||
private String audience;
|
||||
|
||||
public GiftEffect(String audience) {
|
||||
this.audience = audience;
|
||||
}
|
||||
|
||||
public String getAudience() {
|
||||
return audience;
|
||||
}
|
||||
|
||||
public abstract void apply(Game game);
|
||||
|
||||
public int getQueueTime() {
|
||||
return 20;
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package com.yaohun.enderdragonWars.effect;
|
||||
|
||||
import com.yaohun.enderdragonWars.Main;
|
||||
import com.yaohun.enderdragonWars.game.Game;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
public class GiftQueue {
|
||||
|
||||
private Queue<GiftEffect> effectQueue = new LinkedList<>();
|
||||
|
||||
private BukkitTask task;
|
||||
|
||||
public GiftQueue(int waitTime) {
|
||||
task = Bukkit.getScheduler().runTaskTimer(Main.plugin, new Runnable() {
|
||||
private int timer = 0;
|
||||
private boolean running = false;
|
||||
@Override
|
||||
public void run() {
|
||||
timer++;
|
||||
if (!running) {
|
||||
timer = waitTime;
|
||||
running = true;
|
||||
}
|
||||
if (timer >= waitTime) {
|
||||
timer = 0;
|
||||
if (effectQueue.isEmpty()) {
|
||||
running = false;
|
||||
return;
|
||||
}
|
||||
Game game = Main.game;
|
||||
GiftEffect effect = effectQueue.poll();
|
||||
effect.apply(game);
|
||||
}
|
||||
}
|
||||
}, 0L, 1L);
|
||||
}
|
||||
|
||||
public void addEffect(GiftEffect effect) {
|
||||
effectQueue.add(effect);
|
||||
}
|
||||
|
||||
public Queue<GiftEffect> getEffectQueue() {
|
||||
return effectQueue;
|
||||
}
|
||||
|
||||
public BukkitTask getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package com.yaohun.enderdragonWars.game;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Game {
|
||||
|
||||
private Player player;
|
||||
private World world;
|
||||
private boolean startd;
|
||||
public Game(){
|
||||
|
||||
}
|
||||
|
||||
public void startGame(Player player){
|
||||
if(startd){return;}
|
||||
this.player = player;
|
||||
this.startd = true;
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.yaohun.enderdragonWars.liveevent;
|
||||
|
||||
import com.yaohun.enderdragonWars.manage.GiftEffectManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GiftEventHandler {
|
||||
|
||||
public static void SendHandLer(Player zhubo, String hideName, String eventName){
|
||||
if(eventName.equalsIgnoreCase("清空背包")){
|
||||
GiftEffectManager.addGiftEffect(hideName,eventName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package com.yaohun.enderdragonWars.util;
|
||||
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class GameUtil {
|
||||
|
||||
public static String HideName(String audience){
|
||||
if(audience.length() <= 2){
|
||||
return "**";
|
||||
}
|
||||
// 获取第一个和第二个字符
|
||||
char firstChar = audience.charAt(0);
|
||||
char lastChar = audience.charAt(audience.length() - 1);
|
||||
// 构建屏蔽后的字符串
|
||||
StringBuilder maskedString = new StringBuilder();
|
||||
for (int i = 1; i < audience.length() - 1; i++) {
|
||||
maskedString.append('*');
|
||||
}
|
||||
return String.valueOf(firstChar) + maskedString + lastChar;
|
||||
}
|
||||
|
||||
public static void SendAllSounds(String sound){
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!sound.contains("_")) {
|
||||
player.playSound(player.getLocation(), sound, 0.5F, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package com.yaohun.enderdragonWars.util;
|
||||
|
||||
import com.yaohun.enderdragonWars.Main;
|
||||
import com.yaohun.enderdragonWars.data.GiftData;
|
||||
import com.yaohun.enderdragonWars.liveevent.GiftEventHandler;
|
||||
import com.yaohun.enderdragonWars.manage.GameManage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GiftUtil {
|
||||
|
||||
// 执行礼物效果
|
||||
public static void executeGiftEffect(Player zhubo,String userName,String giftName,int giftAmount){
|
||||
GameManage gameManage = Main.gameManage;
|
||||
if(gameManage.getGiftData(giftName) == null){
|
||||
zhubo.sendMessage("§c[系统]§a礼物 "+giftName+" 的未设置任何礼物效果.");
|
||||
return;
|
||||
}
|
||||
// 获取礼物数据
|
||||
GiftData giftData = gameManage.getGiftData(giftName);
|
||||
// 获取隐藏名字后的观众名
|
||||
String hide_name = GameUtil.HideName(userName);
|
||||
// 获取效果名
|
||||
String eventName = giftData.getEvent();
|
||||
if(giftAmount <= 1){
|
||||
giftData.OutPlaySoundsEvent();
|
||||
GiftEventHandler.SendHandLer(zhubo, userName, eventName);
|
||||
}else{
|
||||
long dadey = 5L;
|
||||
for (int i = 0; i < giftAmount; i++) {
|
||||
Bukkit.getScheduler().runTaskLater(Main.plugin, () -> {
|
||||
giftData.OutPlaySoundsEvent();
|
||||
GiftEventHandler.SendHandLer(zhubo, userName, eventName);
|
||||
}, (long) i * dadey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package com.yaohun.enderdragonWars.util;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import javax.swing.plaf.synth.Region;
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class RandomUtil {
|
||||
|
||||
public static boolean random(double d) {
|
||||
return d >= new Random().nextFloat();
|
||||
}
|
||||
|
||||
public static int getRandomInt(int min, int max) {
|
||||
if (min == max) {
|
||||
return max;
|
||||
}
|
||||
Random r = new Random();
|
||||
int i = min < max ? min : max;
|
||||
int a = min < max ? max : min;
|
||||
return r.nextInt(a - i + 1) + i;
|
||||
}
|
||||
|
||||
public static double getRandomDouble(double min, double max, int scl) {
|
||||
int pow = (int) Math.pow(10, scl);
|
||||
return Math.floor((Math.random() * (max - min) + min) * pow) / pow;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.yaohun.enderdragonwars;
|
|||
|
||||
import com.yaohun.enderdragonwars.effect.types.*;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.listener.GameListener;
|
||||
import com.yaohun.enderdragonwars.listener.PlayerListener;
|
||||
import com.yaohun.enderdragonwars.manager.GameManager;
|
||||
import com.yaohun.enderdragonwars.manager.GiftEffectManager;
|
||||
|
@ -26,10 +27,16 @@ public class Main extends JavaPlugin {
|
|||
game = new Game();
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new GameListener(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public boolean onCommand(CommandSender sender, Command command, String Command, String[] args) {
|
||||
if(args.length == 1 && args[0].equalsIgnoreCase("start")){
|
||||
Player player = (Player) sender;
|
||||
game.startGame(player);
|
||||
return true;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
String subCommand = args[0];
|
||||
Player player = (Player) sender;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.effect.GiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
|
@ -1,26 +1,96 @@
|
|||
package com.yaohun.enderdragonwars.game;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.util.BossBarUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class Game {
|
||||
|
||||
private Player player;
|
||||
private World world;
|
||||
private BossBar bossBar1;
|
||||
private BossBar bossBar2;
|
||||
private boolean startd;
|
||||
|
||||
private int remainTime;
|
||||
|
||||
private long liveTime;
|
||||
private List<BukkitTask> tasks = new ArrayList<>();
|
||||
public Game(){
|
||||
bossBar1 = Bukkit.createBossBar("下播时间", BarColor.WHITE, BarStyle.SEGMENTED_20);
|
||||
bossBar2 = Bukkit.createBossBar("挑战目标", BarColor.WHITE, BarStyle.SOLID);
|
||||
}
|
||||
|
||||
public void updateBossBar() {
|
||||
// 击败末影龙提示
|
||||
targetCueBossBar();
|
||||
// 获取最大时间
|
||||
long maxLiveTime = 1000 * 60 * 60 * 6;
|
||||
double d = (double) getLiveTime() / (double)maxLiveTime;
|
||||
d = Math.max(0, Math.min(d, 1));
|
||||
long liveTimeInSeconds = getLiveTime() / 1000;
|
||||
long hours = liveTimeInSeconds / 3600;
|
||||
long minutes = (liveTimeInSeconds % 3600) / 60;
|
||||
long seconds = liveTimeInSeconds % 60;
|
||||
if (hours >= 1) {
|
||||
bossBar1.setTitle("§6§l距离下播还有§f§l: §a" + hours + "小时" + minutes + "分" + seconds + "秒");
|
||||
} else if (minutes >= 1) {
|
||||
bossBar1.setTitle("§6§l距离下播还有§f§l: §a" + minutes + "分" + seconds + "秒");
|
||||
} else if (seconds >= 1) {
|
||||
bossBar1.setTitle("§6§l距离下播还有§f§l: §a" + seconds + "秒");
|
||||
} else {
|
||||
bossBar1.setTitle("§a§l恭喜您完成挑战!下播吧!");
|
||||
}
|
||||
BossBarUtil.setBarProgress(bossBar1,d);
|
||||
BossBarUtil.setBarColor(bossBar1,d);
|
||||
}
|
||||
|
||||
private int tragetCueI = 0;
|
||||
public void targetCueBossBar(){
|
||||
tragetCueI--;
|
||||
if(tragetCueI <= 0) {
|
||||
bossBar2.addPlayer(player);
|
||||
List<String> stringList = new ArrayList<>();
|
||||
stringList.add("§c§l击败末影龙 §b§l减播1小时!");
|
||||
Collections.shuffle(stringList);
|
||||
Random random = new Random();
|
||||
String titleShow = stringList.get(random.nextInt(stringList.size()));
|
||||
bossBar2.setTitle(titleShow);
|
||||
BossBarUtil.setBarColor(bossBar2);
|
||||
tragetCueI = 20;
|
||||
}else{
|
||||
if(tragetCueI == 16) {
|
||||
if (bossBar2.getPlayers().contains(player)) {
|
||||
bossBar2.removePlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startGame(Player player) {
|
||||
if (startd) {
|
||||
return;
|
||||
}
|
||||
if(startd){return;}
|
||||
this.player = player;
|
||||
this.world = player.getWorld();
|
||||
this.startd = true;
|
||||
this.liveTime = 1000 * 60 * 60 * 3; // 默认下播时间 60秒x60分钟x2小时
|
||||
// 添加boss血条
|
||||
updataPlayerData(player);
|
||||
tasks.add(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
liveTime = liveTime - 500;
|
||||
updateBossBar();
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 10L));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
|
@ -30,9 +100,47 @@ public class Game {
|
|||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
public void updataPlayerData(Player player){
|
||||
player.setFoodLevel(20);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
bossBar1.addPlayer(player);
|
||||
bossBar2.addPlayer(player);
|
||||
}
|
||||
|
||||
public int getRemainTime() {
|
||||
return remainTime;
|
||||
public void removePlayerDataBossBar(){
|
||||
bossBar1.removeAll();
|
||||
bossBar2.removeAll();
|
||||
bossBar1 = Bukkit.createBossBar("下播时间", BarColor.WHITE, BarStyle.SEGMENTED_20);
|
||||
bossBar2 = Bukkit.createBossBar("挑战目标", BarColor.WHITE, BarStyle.SOLID);
|
||||
}
|
||||
|
||||
public boolean isStartd() {
|
||||
return startd;
|
||||
}
|
||||
|
||||
public long getLiveTime() {
|
||||
return liveTime;
|
||||
}
|
||||
public void setLiveTime(long liveTime) {
|
||||
this.liveTime = liveTime;
|
||||
}
|
||||
|
||||
public void takeLiveTime(long minutes){
|
||||
long minutesTime = 1000 * 60 * minutes;
|
||||
long newTime = getLiveTime() - minutesTime;
|
||||
if(newTime < 0){
|
||||
newTime = 0;
|
||||
}
|
||||
setLiveTime(newTime);
|
||||
}
|
||||
|
||||
public void addLiveTime(long minutes){
|
||||
long minutesTime = 1000 * 60 * minutes;
|
||||
long newTime = getLiveTime() + minutesTime;
|
||||
if(newTime < 0){
|
||||
newTime = 0;
|
||||
}
|
||||
setLiveTime(newTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package com.yaohun.enderdragonwars.listener;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class GameListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPing(ServerListPingEvent e){
|
||||
e.setMotd("§a整蛊模式: §6生存挑战 §a当前版本: §6常规版 §b运行中");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoinItems(PlayerJoinEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
if (!Main.game.isStartd()) {
|
||||
p.performCommand("game start");
|
||||
}
|
||||
Main.game.updataPlayerData(p);
|
||||
cancel();
|
||||
}
|
||||
}.runTaskLater(Main.plugin, 20L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e){
|
||||
Player p = e.getPlayer();
|
||||
Main.game.removePlayerDataBossBar();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKick(PlayerKickEvent e){
|
||||
Player p = e.getPlayer();
|
||||
Main.game.removePlayerDataBossBar( );
|
||||
}
|
||||
|
||||
/*
|
||||
* 死亡后游戏时间 +5分钟
|
||||
* */
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e){
|
||||
e.setDeathMessage(null);
|
||||
Player p = e.getEntity();
|
||||
new BukkitRunnable() {
|
||||
private int i = 0;
|
||||
public void run() {
|
||||
if (i == 1) {
|
||||
p.spigot().respawn();
|
||||
}
|
||||
// 增加游戏时间5分钟
|
||||
if(i == 3) {
|
||||
Main.game.addLiveTime(5);
|
||||
p.sendTitle("§4你嘎了", "§e加播5分钟!");
|
||||
cancel();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin,0L, 2L);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.yaohun.enderdragonwars.util;
|
||||
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BossBarUtil {
|
||||
|
||||
public static void setBarColor(BossBar bossBar){
|
||||
double random = RandomUtil.getRandomDouble(0,1,1);
|
||||
if (random >= 0 && random <= 0.2) {
|
||||
bossBar.setColor(BarColor.RED);
|
||||
} else if (random <= 0.4) {
|
||||
bossBar.setColor(BarColor.YELLOW);
|
||||
} else if (random <= 0.6) {
|
||||
bossBar.setColor(BarColor.GREEN);
|
||||
} else if (random <= 0.8) {
|
||||
bossBar.setColor(BarColor.BLUE);
|
||||
} else {
|
||||
bossBar.setColor(BarColor.PURPLE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBarColor(BossBar bossBar,double percent){
|
||||
if (percent >= 0 && percent <= 0.3333) {
|
||||
bossBar.setColor(BarColor.RED);
|
||||
} else if (percent <= 0.6666) {
|
||||
bossBar.setColor(BarColor.YELLOW);
|
||||
} else {
|
||||
bossBar.setColor(BarColor.GREEN);
|
||||
}
|
||||
}
|
||||
public static void setBarProgress(BossBar bossBar,double percent){
|
||||
if (percent <= 0) {
|
||||
percent = 0;
|
||||
} else if (percent >= 1) {
|
||||
percent = 1;
|
||||
}
|
||||
bossBar.setProgress(percent);
|
||||
}
|
||||
|
||||
public static void addBossBar(Player player, List<BossBar> bossBarList){
|
||||
for (BossBar bossBar : bossBarList) {
|
||||
bossBar.addPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeBossBar(Player player,List<BossBar> bossBarList){
|
||||
for (BossBar bossBar : bossBarList) {
|
||||
bossBar.removePlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user