From 1724c9960c9951ca2f84c02f66437adeb5711b52 Mon Sep 17 00:00:00 2001 From: zfxzs250 <3078023566@qq.com> Date: Sat, 25 Feb 2023 14:57:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9C=A8=E7=BA=BF=E6=80=BB?= =?UTF-8?q?=E4=BA=BA=E6=95=B0=E5=8F=98=E9=87=8F=E5=88=B0RSNPC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 3 --- .../org/sobadfish/tntrun/manager/TotalManager.java | 8 ++++++++ .../java/org/sobadfish/tntrun/tools/Utils.java | 14 +++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index ef372a3..64f884c 100644 --- a/pom.xml +++ b/pom.xml @@ -59,9 +59,6 @@ system ${project.basedir}/lib/Tips-2.1.3-MOT-SNAPSHOT.jar - - - diff --git a/src/main/java/org/sobadfish/tntrun/manager/TotalManager.java b/src/main/java/org/sobadfish/tntrun/manager/TotalManager.java index f7a5547..7bb2a2e 100644 --- a/src/main/java/org/sobadfish/tntrun/manager/TotalManager.java +++ b/src/main/java/org/sobadfish/tntrun/manager/TotalManager.java @@ -4,10 +4,12 @@ import cn.nukkit.plugin.PluginBase; import cn.nukkit.utils.Config; import cn.nukkit.utils.TextFormat; +import com.smallaswater.npc.variable.VariableManage; import org.sobadfish.tntrun.manager.data.PlayerDataManager; import org.sobadfish.tntrun.manager.data.PlayerTopManager; import org.sobadfish.tntrun.panel.lib.AbstractFakeInventory; import org.sobadfish.tntrun.room.config.GameRoomConfig; +import org.sobadfish.tntrun.tools.Utils; import java.io.File; @@ -55,6 +57,12 @@ public static void init(PluginBase pluginBase){ TotalManager.plugin = pluginBase; checkServer(); loadConfig(); + try { + Class.forName("com.smallaswater.npc.variable.BaseVariableV2"); + VariableManage.addVariableV2("TntRun", Utils.class); + } catch (Exception ignored) { + + } ThreadManager.init(); } diff --git a/src/main/java/org/sobadfish/tntrun/tools/Utils.java b/src/main/java/org/sobadfish/tntrun/tools/Utils.java index 65468d2..5e6df4e 100644 --- a/src/main/java/org/sobadfish/tntrun/tools/Utils.java +++ b/src/main/java/org/sobadfish/tntrun/tools/Utils.java @@ -15,7 +15,11 @@ import cn.nukkit.nbt.tag.FloatTag; import cn.nukkit.nbt.tag.ListTag; import cn.nukkit.utils.DyeColor; +import com.smallaswater.npc.data.RsNpcConfig; +import com.smallaswater.npc.variable.BaseVariableV2; import org.sobadfish.tntrun.manager.TotalManager; +import org.sobadfish.tntrun.room.GameRoom; +import org.sobadfish.tntrun.room.config.GameRoomConfig; import java.io.*; import java.nio.channels.FileChannel; @@ -25,7 +29,7 @@ import java.util.SplittableRandom; -public class Utils { +public class Utils extends BaseVariableV2 { private static final SplittableRandom RANDOM = new SplittableRandom(System.currentTimeMillis()); @@ -284,4 +288,12 @@ private static void copyDirectiory(String sourceDir, String targetDir) } + @Override + public void onUpdate(Player player, RsNpcConfig rsNpcConfig) { + int a = 0; + for(GameRoom room: TotalManager.getRoomManager().getRooms().values()){ + a += room.getInRoomPlayers().size(); + } + addVariable("{TntrunPlayers}", String.valueOf(a)); + } }