File tree Expand file tree Collapse file tree 3 files changed +39
-4
lines changed
src/main/java/monkey/info/command Expand file tree Collapse file tree 3 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 5
5
import io .prometheus .metrics .model .registry .PrometheusRegistry ;
6
6
import monkey .info .command .metrics .Metric ;
7
7
import monkey .info .command .metrics .Mobcaps ;
8
+ import monkey .info .command .metrics .Player ;
8
9
import monkey .info .command .metrics .Tick ;
9
10
import org .jetbrains .annotations .Nullable ;
10
11
@@ -39,8 +40,9 @@ public void run() {
39
40
40
41
public void start () {
41
42
this .stop ();
42
- this .registerMetric (new Tick ());
43
43
this .registerMetric (new Mobcaps ());
44
+ this .registerMetric (new Player ());
45
+ this .registerMetric (new Tick ());
44
46
45
47
if (metricUpdateLoop == null ) metricUpdateLoop = new Timer ("Metric Update Loop" );
46
48
metricUpdateLoop .scheduleAtFixedRate (new TimerTask () {
Original file line number Diff line number Diff line change @@ -18,15 +18,16 @@ public Mobcaps() {
18
18
public void update (MinecraftServer server ) {
19
19
// edit from: https://github.com/gnembon/fabric-carpet/blob/7486670918f733aaf6ae3b595290947802024d02/src/main/java/carpet/utils/SpawnReporter.java#L105
20
20
for (ServerWorld world : server .getWorlds ()) {
21
- RegistryKey <World > dim = world .getRegistryKey ();
22
21
SpawnHelper .Info lastSpawner = world .getChunkManager ().getSpawnInfo ();
23
- int chunkcount = SpawnReporter .chunkCounts .getOrDefault (dim , -1 );
24
22
25
23
if (lastSpawner != null ) {
24
+ RegistryKey <World > dim = world .getRegistryKey ();
25
+ String worldName = world .getRegistryKey ().getValue ().toString ();
26
+ int chunkcount = SpawnReporter .chunkCounts .getOrDefault (dim , -1 );
27
+
26
28
for (SpawnGroup enumcreaturetype : SpawnGroup .values ()) {
27
29
Object2IntMap <SpawnGroup > dimCounts = lastSpawner .getGroupToCount ();
28
30
String enumcreature = enumcreaturetype .toString ();
29
- String worldName = world .getRegistryKey ().getValue ().toString ();
30
31
31
32
int cur = dimCounts .getOrDefault (enumcreaturetype , -1 );
32
33
int max = (int ) (chunkcount * ((double ) enumcreaturetype .getCapacity () / SpawnReporter .currentMagicNumber ()));
Original file line number Diff line number Diff line change
1
+ package monkey .info .command .metrics ;
2
+
3
+ import carpet .patches .EntityPlayerMPFake ;
4
+ import net .minecraft .server .MinecraftServer ;
5
+ import net .minecraft .server .network .ServerPlayerEntity ;
6
+ import net .minecraft .server .world .ServerWorld ;
7
+ import net .minecraft .util .registry .RegistryKey ;
8
+ import net .minecraft .world .World ;
9
+
10
+ import java .util .List ;
11
+
12
+ public class Player extends Metric {
13
+ public Player () {
14
+ super ("players_online" , "Online players" , "type" , "world" );
15
+ }
16
+
17
+ @ Override
18
+ public void update (MinecraftServer server ) {
19
+ // edit from: https://github.com/gnembon/fabric-carpet/blob/7486670918f733aaf6ae3b595290947802024d02/src/main/java/carpet/utils/SpawnReporter.java#L105
20
+ for (ServerWorld world : server .getWorlds ()) {
21
+ RegistryKey <World > dim = world .getRegistryKey ();
22
+ List <ServerPlayerEntity > players = world .getPlayers ();
23
+ String worldName = world .getRegistryKey ().getValue ().toString ();
24
+
25
+ long fakePlayers = players .stream ().filter (player -> player instanceof EntityPlayerMPFake ).count ();
26
+ long realPlayers = players .size () - fakePlayers ;
27
+
28
+ this .getGauge ().labelValues ("FAKE" , worldName ).set (fakePlayers );
29
+ this .getGauge ().labelValues ("REAL" , worldName ).set (realPlayers );
30
+ }
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments