mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-09 18:08:37 +01:00
Fix BenchmarkManager not returning a Component
This commit is contained in:
parent
d114f8e61a
commit
6b644d6130
@ -107,7 +107,7 @@ public final class BenchmarkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getCpuMonitoringMessage() {
|
public Component getCpuMonitoringMessage() {
|
||||||
Check.stateCondition(!enabled, "CPU monitoring is only possible when the benchmark manager is enabled.");
|
Check.stateCondition(!enabled, "CPU monitoring is only possible when the benchmark manager is enabled.");
|
||||||
TextComponent.Builder benchmarkMessage = Component.text();
|
TextComponent.Builder benchmarkMessage = Component.text();
|
||||||
for (Map.Entry<String, ThreadResult> resultEntry : resultMap.entrySet()) {
|
for (Map.Entry<String, ThreadResult> resultEntry : resultMap.entrySet()) {
|
||||||
@ -127,7 +127,7 @@ public final class BenchmarkManager {
|
|||||||
benchmarkMessage.append(Component.newline());
|
benchmarkMessage.append(Component.newline());
|
||||||
}
|
}
|
||||||
|
|
||||||
return AdventureSerializer.serialize(benchmarkMessage.build());
|
return benchmarkMessage.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshData() {
|
private void refreshData() {
|
||||||
|
@ -4,6 +4,7 @@ import demo.generator.ChunkGeneratorDemo;
|
|||||||
import demo.generator.NoiseTestGenerator;
|
import demo.generator.NoiseTestGenerator;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
|
import net.minestom.server.adventure.audience.Audiences;
|
||||||
import net.minestom.server.benchmark.BenchmarkManager;
|
import net.minestom.server.benchmark.BenchmarkManager;
|
||||||
import net.minestom.server.chat.ColoredText;
|
import net.minestom.server.chat.ColoredText;
|
||||||
import net.minestom.server.entity.Entity;
|
import net.minestom.server.entity.Entity;
|
||||||
@ -28,9 +29,7 @@ import net.minestom.server.inventory.PlayerInventory;
|
|||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.item.ItemStack;
|
||||||
import net.minestom.server.item.Material;
|
import net.minestom.server.item.Material;
|
||||||
import net.minestom.server.network.ConnectionManager;
|
import net.minestom.server.network.ConnectionManager;
|
||||||
import net.minestom.server.network.packet.server.play.PlayerListHeaderAndFooterPacket;
|
|
||||||
import net.minestom.server.ping.ResponseDataConsumer;
|
import net.minestom.server.ping.ResponseDataConsumer;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
|
||||||
import net.minestom.server.utils.Position;
|
import net.minestom.server.utils.Position;
|
||||||
import net.minestom.server.utils.Vector;
|
import net.minestom.server.utils.Vector;
|
||||||
import net.minestom.server.utils.inventory.PlayerInventoryUtils;
|
import net.minestom.server.utils.inventory.PlayerInventoryUtils;
|
||||||
@ -80,13 +79,8 @@ public class PlayerInit {
|
|||||||
ramUsage /= 1e6; // bytes to MB
|
ramUsage /= 1e6; // bytes to MB
|
||||||
|
|
||||||
final Component header = Component.text("RAM USAGE: " + ramUsage + " MB");
|
final Component header = Component.text("RAM USAGE: " + ramUsage + " MB");
|
||||||
final Component footer = Component.text(benchmarkManager.getCpuMonitoringMessage());
|
final Component footer = benchmarkManager.getCpuMonitoringMessage();
|
||||||
|
Audiences.audiences().players().sendPlayerListHeaderAndFooter(header, footer);
|
||||||
{
|
|
||||||
PlayerListHeaderAndFooterPacket playerListHeaderAndFooterPacket = new PlayerListHeaderAndFooterPacket(header, footer);
|
|
||||||
|
|
||||||
PacketUtils.sendGroupedPacket(players, playerListHeaderAndFooterPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
}).repeat(10, TimeUnit.TICK).schedule();
|
}).repeat(10, TimeUnit.TICK).schedule();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user