Skip to content

Commit

Permalink
添加在线总人数变量到RSNPC
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolMagic233 committed Feb 25, 2023
1 parent 1d5b23f commit 1724c99
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
3 changes: 0 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@
<scope>system</scope>
<systemPath> ${project.basedir}/lib/Tips-2.1.3-MOT-SNAPSHOT.jar</systemPath>
</dependency>



</dependencies>


Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/sobadfish/tntrun/manager/TotalManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/org/sobadfish/tntrun/tools/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());

Expand Down Expand Up @@ -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));
}
}

0 comments on commit 1724c99

Please sign in to comment.