mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-22 08:19:26 +00:00
clean up sakura commands
This commit is contained in:
@@ -41,10 +41,10 @@ index 83a726bcf8b7dce73a361b0d79dbd63a0afc7a12..6efe0ed8600e3703bd83d46545bba887
|
||||
}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/command/BaseSubCommand.java b/src/main/java/me/samsuik/sakura/command/BaseSubCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9b5af05f7a4593eb44f36fff90d94e98d6999c7f
|
||||
index 0000000000000000000000000000000000000000..87d8fd1fe60dfea4ce697048a34d9bb888cb6d4b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/command/BaseSubCommand.java
|
||||
@@ -0,0 +1,47 @@
|
||||
@@ -0,0 +1,45 @@
|
||||
+package me.samsuik.sakura.command;
|
||||
+
|
||||
+import org.bukkit.command.Command;
|
||||
@@ -58,7 +58,6 @@ index 0000000000000000000000000000000000000000..9b5af05f7a4593eb44f36fff90d94e98
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public abstract class BaseSubCommand extends Command {
|
||||
+
|
||||
+ public BaseSubCommand(String name) {
|
||||
+ super(name);
|
||||
+ this.description = "Sakura Command " + name;
|
||||
@@ -72,8 +71,8 @@ index 0000000000000000000000000000000000000000..9b5af05f7a4593eb44f36fff90d94e98
|
||||
+ @Override
|
||||
+ @Deprecated
|
||||
+ public final boolean execute(CommandSender sender, String label, String[] args) {
|
||||
+ if (testPermission(sender)) {
|
||||
+ execute(sender, args);
|
||||
+ if (this.testPermission(sender)) {
|
||||
+ this.execute(sender, args);
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
@@ -82,29 +81,27 @@ index 0000000000000000000000000000000000000000..9b5af05f7a4593eb44f36fff90d94e98
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||
+ var completions = new ArrayList<String>(0);
|
||||
+ List<String> completions = new ArrayList<>(0);
|
||||
+
|
||||
+ if (testPermissionSilent(sender)) {
|
||||
+ tabComplete(completions, args);
|
||||
+ if (this.testPermissionSilent(sender)) {
|
||||
+ this.tabComplete(completions, args);
|
||||
+ }
|
||||
+
|
||||
+ return completions;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommand.java b/src/main/java/me/samsuik/sakura/command/SakuraCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2b145614bf189ae56622016436bfefd63f5271eb
|
||||
index 0000000000000000000000000000000000000000..18c74437018ff4c0935242f6002083edb1282a01
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/command/SakuraCommand.java
|
||||
@@ -0,0 +1,93 @@
|
||||
@@ -0,0 +1,86 @@
|
||||
+package me.samsuik.sakura.command;
|
||||
+
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
@@ -112,15 +109,14 @@ index 0000000000000000000000000000000000000000..2b145614bf189ae56622016436bfefd6
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import javax.annotation.Nullable;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+import java.util.stream.Stream;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class SakuraCommand extends Command {
|
||||
+
|
||||
+ private static final Component INFORMATION_MESSAGE = MiniMessage.miniMessage().deserialize("""
|
||||
+ <dark_purple>.</dark_purple>
|
||||
+ <dark_purple>| <white>This is the main command for <gradient:red:light_purple:0.5>Sakura</gradient>.
|
||||
@@ -131,7 +127,6 @@ index 0000000000000000000000000000000000000000..2b145614bf189ae56622016436bfefd6
|
||||
+
|
||||
+ public SakuraCommand(String name) {
|
||||
+ super(name);
|
||||
+
|
||||
+ this.description = "";
|
||||
+ this.usageMessage = "/sakura";
|
||||
+ this.setPermission("bukkit.command.sakura");
|
||||
@@ -140,37 +135,34 @@ index 0000000000000000000000000000000000000000..2b145614bf189ae56622016436bfefd6
|
||||
+ @Override
|
||||
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||
+ if (args.length > 0) {
|
||||
+ var commands = new ArrayList<>(SakuraCommands.COMMANDS.values());
|
||||
+ List<Command> commands = new ArrayList<>(SakuraCommands.COMMANDS.values());
|
||||
+
|
||||
+ // This part is copied from the VersionCommand SubCommand in paper
|
||||
+ @Nullable
|
||||
+ var internalVersion = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
|
||||
+ Command internalVersion = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
|
||||
+ if (internalVersion != null) {
|
||||
+ commands.add(internalVersion);
|
||||
+ }
|
||||
+
|
||||
+ for (var base : commands) {
|
||||
+ for (Command base : commands) {
|
||||
+ if (base.getName().equalsIgnoreCase(args[0])) {
|
||||
+ return base.execute(sender, commandLabel, Arrays.copyOfRange(args, 1, args.length));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ sendHelpMessage(sender);
|
||||
+ this.sendHelpMessage(sender);
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ private void sendHelpMessage(CommandSender sender) {
|
||||
+ sender.sendMessage(INFORMATION_MESSAGE);
|
||||
+
|
||||
+ var uniqueCommands = SakuraCommands.COMMANDS.values()
|
||||
+ Stream<Command> uniqueCommands = SakuraCommands.COMMANDS.values()
|
||||
+ .stream()
|
||||
+ .filter(command -> command != this);
|
||||
+
|
||||
+ uniqueCommands.forEach((command) -> {
|
||||
+ sender.sendMessage(MiniMessage.miniMessage().deserialize(COMMAND_MSG,
|
||||
+ Placeholder.unparsed("command", command.getName()))
|
||||
+ );
|
||||
+ sender.sendRichMessage(COMMAND_MSG, Placeholder.unparsed("command", command.getName()));
|
||||
+ });
|
||||
+
|
||||
+ sender.sendMessage(Component.text("'", NamedTextColor.DARK_PURPLE));
|
||||
@@ -179,27 +171,25 @@ index 0000000000000000000000000000000000000000..2b145614bf189ae56622016436bfefd6
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||
+ if (!testPermissionSilent(sender)) {
|
||||
+ if (!this.testPermissionSilent(sender)) {
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+ return SakuraCommands.COMMANDS.values().stream()
|
||||
+ .filter(command -> command != this) // ahem
|
||||
+ .filter(command -> command != this)
|
||||
+ .map(Command::getName)
|
||||
+ .filter(name -> args.length <= 1 || name.startsWith(args[args.length - 1]))
|
||||
+ .toList();
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3b08454cf7411d12bb33225df59800bd73312123
|
||||
index 0000000000000000000000000000000000000000..3e85c19db0655034c203eaab8d2e6b5504da5da8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
|
||||
@@ -0,0 +1,26 @@
|
||||
@@ -0,0 +1,22 @@
|
||||
+package me.samsuik.sakura.command;
|
||||
+
|
||||
+import io.papermc.paper.command.PaperPluginsCommand;
|
||||
+import me.samsuik.sakura.command.subcommands.ConfigCommand;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.command.Command;
|
||||
@@ -208,27 +198,24 @@ index 0000000000000000000000000000000000000000..3b08454cf7411d12bb33225df59800bd
|
||||
+import java.util.Map;
|
||||
+
|
||||
+public final class SakuraCommands {
|
||||
+
|
||||
+ static final Map<String, Command> COMMANDS = new HashMap<>();
|
||||
+ static {
|
||||
+ COMMANDS.put("sakura", new SakuraCommand("sakura"));
|
||||
+ COMMANDS.put("config", new ConfigCommand("config"));
|
||||
+ }
|
||||
+
|
||||
+ public static void registerCommands(final MinecraftServer server) {
|
||||
+ public static void registerCommands(MinecraftServer server) {
|
||||
+ COMMANDS.forEach((s, command) -> {
|
||||
+ server.server.getCommandMap().register(s, "sakura", command);
|
||||
+ });
|
||||
+ server.server.getCommandMap().register("bukkit", new PaperPluginsCommand());
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java b/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..75febc3f40910a27a9fc651dac9697da48338cc1
|
||||
index 0000000000000000000000000000000000000000..c41f188fdaf510a127771b1782e957058b8cc355
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java
|
||||
@@ -0,0 +1,45 @@
|
||||
@@ -0,0 +1,33 @@
|
||||
+package me.samsuik.sakura.command.subcommands;
|
||||
+
|
||||
+import me.samsuik.sakura.command.BaseSubCommand;
|
||||
@@ -238,10 +225,6 @@ index 0000000000000000000000000000000000000000..75febc3f40910a27a9fc651dac9697da
|
||||
+import org.bukkit.craftbukkit.CraftServer;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+
|
||||
+import static net.kyori.adventure.text.Component.text;
|
||||
+import static net.kyori.adventure.text.format.NamedTextColor.GREEN;
|
||||
@@ -249,7 +232,6 @@ index 0000000000000000000000000000000000000000..75febc3f40910a27a9fc651dac9697da
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class ConfigCommand extends BaseSubCommand {
|
||||
+
|
||||
+ public ConfigCommand(String name) {
|
||||
+ super(name);
|
||||
+ this.description = "Command for reloading the sakura configuration file";
|
||||
@@ -266,13 +248,6 @@ index 0000000000000000000000000000000000000000..75febc3f40910a27a9fc651dac9697da
|
||||
+
|
||||
+ Command.broadcastCommandMessage(sender, text("Sakura config reload complete.", GREEN));
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java
|
||||
new file mode 100644
|
||||
@@ -1121,7 +1096,7 @@ index e2a0487089eb5a7bdc1433e4c75f69d8e9f9d5f9..7da2fc17f6e7bf888ef0c2a8eba0fc3b
|
||||
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index c8b82bc41f2042bb4b067f06265a3a22e51f7629..e95957d6e6ceb29851e1e52226534dd058ca1409 100644
|
||||
index c8b82bc41f2042bb4b067f06265a3a22e51f7629..bc85cb49643f053f567a36174a8b8f6809559061 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1070,6 +1070,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1136,7 +1111,7 @@ index c8b82bc41f2042bb4b067f06265a3a22e51f7629..e95957d6e6ceb29851e1e52226534dd0
|
||||
this.reloadData();
|
||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||
+ me.samsuik.sakura.command.SakuraCommands.registerCommands(this.console); // Sakura
|
||||
+ me.samsuik.sakura.command.SakuraCommands.registerCommands(this.console); // Sakura - sakura configuration files
|
||||
this.spark.registerCommandBeforePlugins(this); // Paper - spark
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
|
||||
@@ -5,12 +5,12 @@ Subject: [PATCH] Visibility API and Command
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
|
||||
index 3b08454cf7411d12bb33225df59800bd73312123..22676ec7a7ae9494b198e5e65e6be6d32e0feb85 100644
|
||||
index 3e85c19db0655034c203eaab8d2e6b5504da5da8..9b550fad76a45fb6ea8d07f75c2ff901d56ae514 100644
|
||||
--- a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
|
||||
+++ b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
|
||||
@@ -2,6 +2,9 @@ package me.samsuik.sakura.command;
|
||||
@@ -1,6 +1,9 @@
|
||||
package me.samsuik.sakura.command;
|
||||
|
||||
import io.papermc.paper.command.PaperPluginsCommand;
|
||||
import me.samsuik.sakura.command.subcommands.ConfigCommand;
|
||||
+import me.samsuik.sakura.command.subcommands.FPSCommand;
|
||||
+import me.samsuik.sakura.command.subcommands.VisualCommand;
|
||||
@@ -18,7 +18,7 @@ index 3b08454cf7411d12bb33225df59800bd73312123..22676ec7a7ae9494b198e5e65e6be6d3
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.bukkit.command.Command;
|
||||
|
||||
@@ -14,6 +17,10 @@ public final class SakuraCommands {
|
||||
@@ -12,6 +15,10 @@ public final class SakuraCommands {
|
||||
static {
|
||||
COMMANDS.put("sakura", new SakuraCommand("sakura"));
|
||||
COMMANDS.put("config", new ConfigCommand("config"));
|
||||
@@ -28,13 +28,13 @@ index 3b08454cf7411d12bb33225df59800bd73312123..22676ec7a7ae9494b198e5e65e6be6d3
|
||||
+ COMMANDS.put("minimal", new VisualCommand(Visibility.Setting.MINIMAL, "minimaltnt", "tntlag"));
|
||||
}
|
||||
|
||||
public static void registerCommands(final MinecraftServer server) {
|
||||
public static void registerCommands(MinecraftServer server) {
|
||||
diff --git a/src/main/java/me/samsuik/sakura/command/subcommands/FPSCommand.java b/src/main/java/me/samsuik/sakura/command/subcommands/FPSCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..aa5ddf696b09226a0bd3d967d2ac2b11fc2deb32
|
||||
index 0000000000000000000000000000000000000000..65f7f7dee78e352bdc88ff42714d10585aa25e21
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/command/subcommands/FPSCommand.java
|
||||
@@ -0,0 +1,26 @@
|
||||
@@ -0,0 +1,24 @@
|
||||
+package me.samsuik.sakura.command.subcommands;
|
||||
+
|
||||
+import me.samsuik.sakura.command.BaseSubCommand;
|
||||
@@ -46,8 +46,7 @@ index 0000000000000000000000000000000000000000..aa5ddf696b09226a0bd3d967d2ac2b11
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class FPSCommand extends BaseSubCommand {
|
||||
+
|
||||
+ private final VisibilityGUI VISIBILITY_GUI = new VisibilityGUI();
|
||||
+ private final VisibilityGUI gui = new VisibilityGUI();
|
||||
+
|
||||
+ public FPSCommand(String name) {
|
||||
+ super(name);
|
||||
@@ -56,17 +55,16 @@ index 0000000000000000000000000000000000000000..aa5ddf696b09226a0bd3d967d2ac2b11
|
||||
+ @Override
|
||||
+ public void execute(CommandSender sender, String[] args) {
|
||||
+ if (sender instanceof Player player) {
|
||||
+ VISIBILITY_GUI.showTo(player);
|
||||
+ this.gui.showTo(player);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/command/subcommands/VisualCommand.java b/src/main/java/me/samsuik/sakura/command/subcommands/VisualCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..148a583279333eeb3e5db16652623082cd5e0e60
|
||||
index 0000000000000000000000000000000000000000..edb3733a15687fadbf25e6f69274fab6b91508c3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/command/subcommands/VisualCommand.java
|
||||
@@ -0,0 +1,45 @@
|
||||
@@ -0,0 +1,43 @@
|
||||
+package me.samsuik.sakura.command.subcommands;
|
||||
+
|
||||
+import me.samsuik.sakura.command.BaseSubCommand;
|
||||
@@ -83,7 +81,6 @@ index 0000000000000000000000000000000000000000..148a583279333eeb3e5db16652623082
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class VisualCommand extends BaseSubCommand {
|
||||
+
|
||||
+ private final Visibility.Setting type;
|
||||
+
|
||||
+ public VisualCommand(Visibility.Setting type, String... aliases) {
|
||||
@@ -98,19 +95,18 @@ index 0000000000000000000000000000000000000000..148a583279333eeb3e5db16652623082
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ var visibility = player.getVisibility();
|
||||
+ Visibility visibility = player.getVisibility();
|
||||
+
|
||||
+ // Toggle clicked setting visibility
|
||||
+ visibility.toggle(type);
|
||||
+ visibility.toggle(this.type);
|
||||
+
|
||||
+ // Send message to player
|
||||
+ var state = visibility.isEnabled(type) ? "Enabled" : "Disabled";
|
||||
+ player.sendMessage(MiniMessage.miniMessage().deserialize(GlobalConfiguration.get().fps.message,
|
||||
+ Placeholder.unparsed("name", type.friendlyName()),
|
||||
+ Placeholder.unparsed("state", state))
|
||||
+ String state = visibility.isEnabled(this.type) ? "Enabled" : "Disabled";
|
||||
+ player.sendRichMessage(GlobalConfiguration.get().fps.message,
|
||||
+ Placeholder.unparsed("name", this.type.friendlyName()),
|
||||
+ Placeholder.unparsed("state", state)
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java
|
||||
new file mode 100644
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user