diff --git a/lib/DemonVipSystem.jar b/lib/DemonVipSystem.jar new file mode 100644 index 0000000..acc9522 Binary files /dev/null and b/lib/DemonVipSystem.jar differ diff --git a/src/main/java/me/Demon/DemonLevels/LevelExpansion.java b/src/main/java/me/Demon/DemonLevels/LevelExpansion.java index 7db3180..a71434a 100644 --- a/src/main/java/me/Demon/DemonLevels/LevelExpansion.java +++ b/src/main/java/me/Demon/DemonLevels/LevelExpansion.java @@ -1,6 +1,7 @@ package me.Demon.DemonLevels; import me.Demon.DemonLevels.api.DLevelAPI; +import me.Demon.DemonLevels.manage.ServerManage; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -44,7 +45,9 @@ public class LevelExpansion extends PlaceholderExpansion { @Override public String onPlaceholderRequest(Player player, String indentifier) { - if (indentifier.equalsIgnoreCase("expbl")) { + if (indentifier.equalsIgnoreCase("prefix")) { + return DLevelAPI.getRankTitle(player.getLevel()); + }else if (indentifier.equalsIgnoreCase("expbl")) { if(Main.serverManage.getExpMultiplicity() <= 1.0){ return "0.00"; } @@ -96,6 +99,9 @@ public class LevelExpansion extends PlaceholderExpansion { } // 如果剩余经验小于 1,000,000,直接格式化为 "x.xxx" return new DecimalFormat(",###.##").format(remainingExp); + }else if(indentifier.equalsIgnoreCase("dexp")){ + ServerManage serverManage = Main.serverManage; + return String.format("%.1f", serverManage.getExpMultiplicity() * 100)+"%"; } return ""; } diff --git a/src/main/java/me/Demon/DemonLevels/Main.java b/src/main/java/me/Demon/DemonLevels/Main.java index 685b445..81f9449 100644 --- a/src/main/java/me/Demon/DemonLevels/Main.java +++ b/src/main/java/me/Demon/DemonLevels/Main.java @@ -41,6 +41,7 @@ public class Main extends JavaPlugin { } DemonAPI.sendConsoleMessage("§f[§6!§f] §aDemonLevels §f加载完成,祝你使用愉快!"); DemonAPI.sendConsoleMessage("§f[§6!§f] §b极光像素工作室出品"); + } diff --git a/src/main/java/me/Demon/DemonLevels/command/MainCmd.java b/src/main/java/me/Demon/DemonLevels/command/MainCmd.java index 3d7e430..32910fa 100644 --- a/src/main/java/me/Demon/DemonLevels/command/MainCmd.java +++ b/src/main/java/me/Demon/DemonLevels/command/MainCmd.java @@ -5,7 +5,7 @@ import me.Demon.DemonLevels.Main; import me.Demon.DemonLevels.api.DLevelAPI; import me.Demon.DemonLevels.data.PlayerData; import me.Demon.DemonLevels.manage.ServerManage; -import me.Demon.DemonLevels.util.GameUtil; +import me.Demon.DemonLevels.util.ConvertUtil; import me.Demon.DemonPlugin.DemonAPI; import org.bukkit.Bukkit; import org.bukkit.Sound; @@ -14,8 +14,6 @@ import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import java.math.BigInteger; -import java.time.*; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -56,17 +54,17 @@ public class MainCmd implements CommandExecutor , TabCompleter { } if(args[0].equalsIgnoreCase("dexp")){ if(args.length >= 2){ - double doubleExp = GameUtil.convertDouble(args[1]); + double doubleExp = ConvertUtil.convertDouble(args[1]); long defaultTime = 7 * 24 * 60 * 60 * 1000L; // 默认开启经验倍率时间7天 if(args.length >= 3){ - defaultTime = GameUtil.convertInt(args[2]) * 60 * 60 * 1000L; + defaultTime = ConvertUtil.convertInt(args[2]) * 60 * 60 * 1000L; } long expMultipleTime = System.currentTimeMillis() + defaultTime; // 本次经验倍率持续时间 if(doubleExp >= 1.1) { Main.serverManage.setExpMultiplicity(doubleExp,expMultipleTime); for (Player p : Bukkit.getOnlinePlayers()) { DemonAPI.sendMessage(p, "当前经验获取倍率为: §e§l"+doubleExp*100+"%"); - p.sendTitle("§d§l"+doubleExp*100+"%","§f持续时间: §a"+GameUtil.formatTime(defaultTime)); + p.sendTitle("§d§l"+doubleExp*100+"%","§f持续时间: §a"+ ConvertUtil.formatTime(defaultTime)); p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); } } @@ -76,10 +74,10 @@ public class MainCmd implements CommandExecutor , TabCompleter { if(args[0].equalsIgnoreCase("kmob")){ if(args.length >= 3){ String mobKey = args[1]; - int min = GameUtil.convertInt(args[2]); + int min = ConvertUtil.convertInt(args[2]); int max = min; if(args.length == 4){ - max = GameUtil.convertInt(args[3]); + max = ConvertUtil.convertInt(args[3]); Main.configYml.setKillsExp(mobKey,min,max); DemonAPI.sendMessage(sender,"成功设置 §6"+mobKey+" §a经验掉落为: §d"+min+"§a~§d"+max); }else{ @@ -97,7 +95,7 @@ public class MainCmd implements CommandExecutor , TabCompleter { return true; } Player player = Bukkit.getPlayer(name); - int value = GameUtil.convertInt(args[2]); + int value = ConvertUtil.convertInt(args[2]); if(args[0].equalsIgnoreCase("give")){ if(player == null) { DemonAPI.sendMessage(sender,"目标玩家不在线."); diff --git a/src/main/java/me/Demon/DemonLevels/data/PlayerData.java b/src/main/java/me/Demon/DemonLevels/data/PlayerData.java index 68450d1..fc780ea 100644 --- a/src/main/java/me/Demon/DemonLevels/data/PlayerData.java +++ b/src/main/java/me/Demon/DemonLevels/data/PlayerData.java @@ -27,7 +27,6 @@ public class PlayerData { this.exp = new BigInteger(expString); String totalExpString = fileConfiguration.getString("totalExp"); this.totalExp = new BigInteger(totalExpString); - } public String getUuid() { diff --git a/src/main/java/me/Demon/DemonLevels/listener/JoinEvent.java b/src/main/java/me/Demon/DemonLevels/listener/JoinEvent.java index 9ee3d46..d3b6860 100644 --- a/src/main/java/me/Demon/DemonLevels/listener/JoinEvent.java +++ b/src/main/java/me/Demon/DemonLevels/listener/JoinEvent.java @@ -32,7 +32,7 @@ public class JoinEvent implements Listener { DLevelAPI.setTotalExp(p,bigInteger); } } - }.runTaskLater(Main.plugin,100L); + }.runTaskLater(Main.plugin,40L); } @EventHandler diff --git a/src/main/java/me/Demon/DemonLevels/manage/MobsManage.java b/src/main/java/me/Demon/DemonLevels/manage/MobsManage.java index db5b92c..bb96f42 100644 --- a/src/main/java/me/Demon/DemonLevels/manage/MobsManage.java +++ b/src/main/java/me/Demon/DemonLevels/manage/MobsManage.java @@ -1,7 +1,7 @@ package me.Demon.DemonLevels.manage; import me.Demon.DemonLevels.Main; -import me.Demon.DemonLevels.util.GameUtil; +import me.Demon.DemonLevels.util.ConvertUtil; import me.Demon.DemonLevels.util.RandomUtil; import org.bukkit.configuration.file.FileConfiguration; @@ -16,12 +16,12 @@ public class MobsManage { String expString = yml.getString("MobKillExp."+mmKey); if(expString.contains("~")){ String[] strings = expString.split("~"); - minExp = GameUtil.convertInt(strings[0]); - maxExp = GameUtil.convertInt(strings[1]); + minExp = ConvertUtil.convertInt(strings[0]); + maxExp = ConvertUtil.convertInt(strings[1]); randomModel = true; }else{ - minExp = GameUtil.convertInt(expString); - maxExp = GameUtil.convertInt(expString); + minExp = ConvertUtil.convertInt(expString); + maxExp = ConvertUtil.convertInt(expString); } if(Main.Debug){ System.out.println("[调试 - 等级] MM生物: "+mmKey+" Min: "+this.minExp+" Max: "+this.maxExp); diff --git a/src/main/java/me/Demon/DemonLevels/util/GameUtil.java b/src/main/java/me/Demon/DemonLevels/util/GameUtil.java deleted file mode 100644 index 40200b9..0000000 --- a/src/main/java/me/Demon/DemonLevels/util/GameUtil.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.Demon.DemonLevels.util; - -import me.Demon.DemonLevels.Main; -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; - -import java.io.File; -import java.io.IOException; -import java.util.UUID; - -public abstract class GameUtil { - - public static int convertInt(String string){ - try { - return Integer.parseInt(string); - } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { - return 1; - } - } - - public static double convertDouble(String string){ - try { - return Double.parseDouble(string); - } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { - return 1.0; - } - } - - public static String formatTime(long millis) { - // 转换毫秒为秒 - long seconds = millis / 1000; - - // 计算天、小时和分钟 - long days = seconds / (24 * 3600); - long hours = (seconds % (24 * 3600)) / 3600; - long minutes = (seconds % 3600) / 60; - - // 判断时间长度的范围,并格式化输出 - if (days > 0) { - return String.format("%d天%d小时", days, hours); - } else if (hours > 0) { - return String.format("%d小时%d分钟", hours, minutes); - } else { - return String.format("%d分钟", minutes); - } - } -}