stat
This commit is contained in:
parent
7d69e1db4a
commit
e1f6bfcf0b
3 changed files with 56 additions and 3 deletions
|
@ -3,6 +3,7 @@ package net.pivipi;
|
||||||
|
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.event.GlobalEventHandler;
|
import net.minestom.server.event.GlobalEventHandler;
|
||||||
|
import net.minestom.server.extras.velocity.VelocityProxy;
|
||||||
import net.minestom.server.instance.InstanceContainer;
|
import net.minestom.server.instance.InstanceContainer;
|
||||||
import net.minestom.server.instance.InstanceManager;
|
import net.minestom.server.instance.InstanceManager;
|
||||||
import net.minestom.server.instance.LightingChunk;
|
import net.minestom.server.instance.LightingChunk;
|
||||||
|
@ -23,6 +24,7 @@ public class Main {
|
||||||
|
|
||||||
InstanceManager instanceManager = MinecraftServer.getInstanceManager();
|
InstanceManager instanceManager = MinecraftServer.getInstanceManager();
|
||||||
GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
|
GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
|
||||||
|
SchedulerManager schedulerManager = MinecraftServer.getSchedulerManager();
|
||||||
|
|
||||||
Key<DimensionType> dimension = FancyDimension.create();
|
Key<DimensionType> dimension = FancyDimension.create();
|
||||||
InstanceContainer instanceContainer = instanceManager.createInstanceContainer(dimension);
|
InstanceContainer instanceContainer = instanceManager.createInstanceContainer(dimension);
|
||||||
|
@ -36,14 +38,16 @@ public class Main {
|
||||||
|
|
||||||
WorldConstraints worldConstraints = new WorldConstraints();
|
WorldConstraints worldConstraints = new WorldConstraints();
|
||||||
worldConstraints.setup(globalEventHandler);
|
worldConstraints.setup(globalEventHandler);
|
||||||
|
|
||||||
|
new Stats(instanceManager).start(schedulerManager);
|
||||||
|
|
||||||
/* done */
|
/* done */
|
||||||
|
|
||||||
MinecraftServer.setCompressionThreshold(0);
|
MinecraftServer.setCompressionThreshold(0);
|
||||||
MinecraftServer.setBrandName("PiViPi");
|
MinecraftServer.setBrandName("PiViPi");
|
||||||
|
|
||||||
minecraftServer.start("0.0.0.0", 25565);
|
minecraftServer.start("127.0.0.1", 25565);
|
||||||
System.out.println("started");
|
System.out.println("Listening on port 25565");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
49
src/main/java/net/pivipi/Stats.java
Normal file
49
src/main/java/net/pivipi/Stats.java
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package net.pivipi;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.ComponentBuilder;
|
||||||
|
import net.minestom.server.MinecraftServer;
|
||||||
|
import net.minestom.server.instance.Instance;
|
||||||
|
import net.minestom.server.instance.InstanceManager;
|
||||||
|
import net.minestom.server.monitoring.BenchmarkManager;
|
||||||
|
import net.minestom.server.network.packet.server.play.DeclareRecipesPacket.Ingredient;
|
||||||
|
import net.minestom.server.timer.SchedulerManager;
|
||||||
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
|
|
||||||
|
public class Stats implements Runnable {
|
||||||
|
private int tickDelay = 10;
|
||||||
|
private InstanceManager instanceManager;
|
||||||
|
private BenchmarkManager benchmarkManager;
|
||||||
|
|
||||||
|
private long lastRun;
|
||||||
|
|
||||||
|
public Stats(InstanceManager instanceManager) {
|
||||||
|
this.instanceManager = instanceManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start(SchedulerManager schedulerManager) {
|
||||||
|
this.benchmarkManager = MinecraftServer.getBenchmarkManager();
|
||||||
|
schedulerManager.scheduleTask(this, TaskSchedule.immediate(), TaskSchedule.tick(tickDelay));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
long delay = now - lastRun;
|
||||||
|
lastRun = now;
|
||||||
|
|
||||||
|
double mspt = (double)delay / tickDelay;
|
||||||
|
double tps = 1000 / mspt;
|
||||||
|
long mem = benchmarkManager.getUsedMemory() / 1024 / 1024;
|
||||||
|
|
||||||
|
Component footer = Component.text("MSPT: %f | TPS: %f | Mem: %dMB".formatted(mspt, tps, mem)).appendNewline().append(benchmarkManager.getCpuMonitoringMessage());
|
||||||
|
|
||||||
|
instanceManager.getInstances().forEach(instance -> {
|
||||||
|
instance.getPlayers().forEach(player -> {
|
||||||
|
player.sendPlayerListFooter(footer);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ public class SoccerGenerator implements Generator {
|
||||||
public void generate(@NotNull GenerationUnit unit) {
|
public void generate(@NotNull GenerationUnit unit) {
|
||||||
UnitModifier modifier = unit.modifier();
|
UnitModifier modifier = unit.modifier();
|
||||||
|
|
||||||
modifier.fillBiome(Biome.CRIMSON_FOREST);
|
modifier.fillBiome(Biome.PLAINS);
|
||||||
|
|
||||||
modifier.fillHeight(63, 64, Block.WHITE_WOOL);
|
modifier.fillHeight(63, 64, Block.WHITE_WOOL);
|
||||||
modifier.fill(unit.absoluteStart().withY(63).add(1, 0, 1), unit.absoluteEnd().withY(64), Block.GREEN_CONCRETE_POWDER);
|
modifier.fill(unit.absoluteStart().withY(63).add(1, 0, 1), unit.absoluteEnd().withY(64), Block.GREEN_CONCRETE_POWDER);
|
||||||
|
|
Loading…
Reference in a new issue