9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-23 08:49:25 +00:00

clean up sakura commands

This commit is contained in:
Samsuik
2024-07-27 00:40:26 +01:00
parent c2899aebaf
commit b2777a7c19
3 changed files with 52 additions and 85 deletions

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] TPS Graph Command
diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
index 22676ec7a7ae9494b198e5e65e6be6d32e0feb85..6edc5195c3b496a12b17b2b9b528505d37ffdb12 100644
index 9b550fad76a45fb6ea8d07f75c2ff901d56ae514..14abbe35a401d4d21a13adcbf6afd836a76cb2bd 100644
--- a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
+++ b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
@@ -4,6 +4,7 @@ import io.papermc.paper.command.PaperPluginsCommand;
@@ -3,6 +3,7 @@ package me.samsuik.sakura.command;
import me.samsuik.sakura.command.subcommands.ConfigCommand;
import me.samsuik.sakura.command.subcommands.FPSCommand;
import me.samsuik.sakura.command.subcommands.VisualCommand;
@@ -16,20 +16,20 @@ index 22676ec7a7ae9494b198e5e65e6be6d32e0feb85..6edc5195c3b496a12b17b2b9b528505d
import me.samsuik.sakura.player.visibility.Visibility;
import net.minecraft.server.MinecraftServer;
import org.bukkit.command.Command;
@@ -21,6 +22,7 @@ public final class SakuraCommands {
@@ -19,6 +20,7 @@ public final class SakuraCommands {
COMMANDS.put("tntvisibility", new VisualCommand(Visibility.Setting.TNT_VISIBILITY, "tnttoggle"));
COMMANDS.put("sandvisibility", new VisualCommand(Visibility.Setting.SAND_VISIBILITY, "sandtoggle"));
COMMANDS.put("minimal", new VisualCommand(Visibility.Setting.MINIMAL, "minimaltnt", "tntlag"));
+ COMMANDS.put("tps", new TPSCommand("tps"));
}
public static void registerCommands(final MinecraftServer server) {
public static void registerCommands(MinecraftServer server) {
diff --git a/src/main/java/me/samsuik/sakura/command/subcommands/TPSCommand.java b/src/main/java/me/samsuik/sakura/command/subcommands/TPSCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..7bd4c5696911730170320060c273f3a7f6a610be
index 0000000000000000000000000000000000000000..8e4fa072468d1b6dc9686dcd8a646579c7483fc7
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/command/subcommands/TPSCommand.java
@@ -0,0 +1,67 @@
@@ -0,0 +1,63 @@
+package me.samsuik.sakura.command.subcommands;
+
+import me.samsuik.sakura.command.BaseSubCommand;
@@ -39,15 +39,12 @@ index 0000000000000000000000000000000000000000..7bd4c5696911730170320060c273f3a7
+import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.format.TextDecoration;
+import net.kyori.adventure.text.minimessage.MiniMessage;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.Mth;
+import org.bukkit.command.CommandSender;
+
+public final class TPSCommand extends BaseSubCommand {
+
+ public TPSCommand(String name) {
+ super(name);
+ this.description = "Gets the current ticks per second for the server";
@@ -55,9 +52,9 @@ index 0000000000000000000000000000000000000000..7bd4c5696911730170320060c273f3a7
+
+ @Override
+ public void execute(CommandSender sender, String[] args) {
+ var tracking = MinecraftServer.tickTracking;
+ TickTracking tracking = MinecraftServer.tickTracking;
+
+ var average = tracking.averageTps(10) * 1.75;
+ double average = tracking.averageTps(10) * 1.75;
+ int lines = 10;
+
+ try {
@@ -69,11 +66,11 @@ index 0000000000000000000000000000000000000000..7bd4c5696911730170320060c273f3a7
+ sender.sendMessage(createInformationComponent(tracking));
+
+ // Create the graph
+ var graph = new TPSGraph(tracking, lines, 75, average);
+ TPSGraph graph = new TPSGraph(tracking, lines, 75, average);
+ graph.map();
+
+ // Send the graph to the user
+ for (var component : graph.components()) {
+ for (Component component : graph.components()) {
+ sender.sendMessage(Component.text("| ", NamedTextColor.DARK_PURPLE).append(component));
+ }
+
@@ -95,7 +92,6 @@ index 0000000000000000000000000000000000000000..7bd4c5696911730170320060c273f3a7
+ double alloc = runtime.totalMemory();
+ return (alloc - free) / max;
+ }
+
+}
diff --git a/src/main/java/me/samsuik/sakura/utils/tps/TPSGraph.java b/src/main/java/me/samsuik/sakura/utils/tps/TPSGraph.java
new file mode 100644