From ddbd2b4d4c2163606dd2e4e956e7c4697ff82dbf Mon Sep 17 00:00:00 2001 From: yaohunya <31456652@qq.com> Date: Sat, 3 Aug 2024 11:24:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/me/Demon/DemonLevels/data/PlayerData.java | 1 + .../java/me/Demon/DemonLevels/listener/JoinEvent.java | 8 +++++--- src/main/resources/plugin.yml | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/Demon/DemonLevels/data/PlayerData.java b/src/main/java/me/Demon/DemonLevels/data/PlayerData.java index 6d4ed55..68450d1 100644 --- a/src/main/java/me/Demon/DemonLevels/data/PlayerData.java +++ b/src/main/java/me/Demon/DemonLevels/data/PlayerData.java @@ -64,6 +64,7 @@ public class PlayerData { yml.set("exp",this.exp.toString()); yml.set("totalExp",this.totalExp.toString()); saveFile(); + System.out.println("[调试 - 等级保存] level = "+this.level+" exp = "+this.exp+" totalExp = "+this.totalExp); } public void saveFile(){ diff --git a/src/main/java/me/Demon/DemonLevels/listener/JoinEvent.java b/src/main/java/me/Demon/DemonLevels/listener/JoinEvent.java index 7843314..1af4497 100644 --- a/src/main/java/me/Demon/DemonLevels/listener/JoinEvent.java +++ b/src/main/java/me/Demon/DemonLevels/listener/JoinEvent.java @@ -26,9 +26,10 @@ public class JoinEvent implements Listener { public void run() { FileConfiguration yml = Main.plugin.getConfig(); int totalExp = yml.getInt("levelstats."+name+".totalExp"); - if(totalExp > playerData.getTotalExp().intValue()){ - DLevelAPI.setTotalExp(p,new BigInteger(yml.getString("levelstats."+name+".totalExp"))); - System.out.println("[调试 - 修正] 玩家 "+name+" 经验出现错误,已被纠正."); + BigInteger bigInteger = BigInteger.valueOf(totalExp); + if(bigInteger.compareTo(playerData.getTotalExp()) > 0){ + System.out.println("[调试 - 修正] 玩家 "+name+" 经验出现错误,已被纠正. YmlExp = "+bigInteger.toString()+" playerdata = "+playerData.getTotalExp().toString()); + DLevelAPI.setTotalExp(p,bigInteger); } } }.runTaskLater(Main.plugin,100L); @@ -41,5 +42,6 @@ public class JoinEvent implements Listener { String uuid = p.getUniqueId().toString(); PlayerData playerData = Main.serverManage.getPlayerData(uuid); // 读取玩家的等级数据 playerData.savePlayerData(); + Main.serverManage.getDataHashMap().remove(p.getUniqueId().toString()); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c8b36e3..2e72ad6 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: DemonLevels main: me.Demon.DemonLevels.Main -version: 2.1.9 +version: 2.2.0 depend: [DemonTeam] commands: dlevel: \ No newline at end of file