diff --git a/sakura-api/paper-patches/files/src/main/java/org/bukkit/command/defaults/VersionCommand.java.patch b/sakura-api/paper-patches/files/src/main/java/org/bukkit/command/defaults/VersionCommand.java.patch deleted file mode 100644 index 8b38c85..0000000 --- a/sakura-api/paper-patches/files/src/main/java/org/bukkit/command/defaults/VersionCommand.java.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java -+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java -@@ -31,6 +_,11 @@ - import net.kyori.adventure.text.event.ClickEvent; - import net.kyori.adventure.text.format.TextDecoration; - import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; -+// Sakura start - customise version command -+import net.kyori.adventure.text.event.HoverEvent; -+import net.kyori.adventure.text.minimessage.MiniMessage; -+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -+// Sakura end - customise version command - - @Deprecated(forRemoval = true) - public class VersionCommand extends BukkitCommand { -@@ -43,6 +_,15 @@ - return versionFetcher; - } - -+ // Sakura start - customise version command -+ private static final String VERSION_MESSAGE = """ -+ . -+ | This server is running Sakura -+ | Commit: \\<> targeting (MC: ) -+ | Github: \\<link> -+ '"""; -+ // Sakura end - customise version command -+ - public VersionCommand(@NotNull String name) { - super(name); - -@@ -54,11 +_,16 @@ - - @Override - public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { -- if (!testPermission(sender)) return true; -- -- if (args.length == 0) { -+ // Sakura start - customise version command -+ if (args.length == 0 || !this.testPermission(sender)) { -+ sender.sendMessage(MiniMessage.miniMessage().deserialize(VERSION_MESSAGE, -+ Placeholder.component("commit", Component.text("hover", NamedTextColor.YELLOW) -+ .hoverEvent(HoverEvent.showText(Component.text(Bukkit.getGitInformation())))), -+ Placeholder.unparsed("version", Bukkit.getMinecraftVersion()) -+ )); - //sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); // Paper - moved to setVersionMessage -- sendVersion(sender); -+ //sendVersion(sender); -+ // Sakura end - customise version command - } else { - StringBuilder name = new StringBuilder(); - diff --git a/sakura-server/build.gradle.kts.patch b/sakura-server/build.gradle.kts.patch index 2c0bb8c..0c58ef9 100644 --- a/sakura-server/build.gradle.kts.patch +++ b/sakura-server/build.gradle.kts.patch @@ -57,6 +57,15 @@ implementation("ca.spottedleaf:concurrentutil:0.0.3") implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+ implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21 +@@ -213,7 +_,7 @@ + "Specification-Version" to project.version, + "Specification-Vendor" to "Paper Team", + "Brand-Id" to "papermc:paper", +- "Brand-Name" to "Paper", ++ "Brand-Name" to serverBrand, + "Build-Number" to (build ?: ""), + "Build-Time" to buildTime.toString(), + "Git-Branch" to gitBranch, @@ -267,7 +_,7 @@ jvmArgumentProviders.add(provider) } diff --git a/sakura-server/paper-patches/files/src/main/java/io/papermc/paper/command/PaperVersionCommand.java.patch b/sakura-server/paper-patches/files/src/main/java/io/papermc/paper/command/PaperVersionCommand.java.patch new file mode 100644 index 0000000..abe1beb --- /dev/null +++ b/sakura-server/paper-patches/files/src/main/java/io/papermc/paper/command/PaperVersionCommand.java.patch @@ -0,0 +1,29 @@ +--- a/src/main/java/io/papermc/paper/command/PaperVersionCommand.java ++++ b/src/main/java/io/papermc/paper/command/PaperVersionCommand.java +@@ -52,8 +_,10 @@ + final PaperVersionCommand command = new PaperVersionCommand(); + + return Commands.literal("version") +- .requires(source -> source.getSender().hasPermission("bukkit.command.version")) ++ // Sakura start - customise version command + .then(Commands.argument("plugin", StringArgumentType.word()) ++ .requires(source -> source.getSender().hasPermission("bukkit.command.version")) ++ // Sakura end - customise version command + .suggests(command::suggestPlugins) + .executes(command::pluginVersion)) + .executes(command::serverVersion) +@@ -130,7 +_,13 @@ + } + + private int serverVersion(CommandContext context) { +- sendVersion(context.getSource().getSender()); ++ // Sakura start - customise version command ++ final CommandSender sender = context.getSource().getSender(); ++ if (sender.hasPermission("bukkit.command.version")) { ++ sendVersion(sender); ++ } ++ me.samsuik.sakura.configuration.SakuraBrandInformation.sendBrandToPlayer(sender); ++ // Sakura end - customise version command + return Command.SINGLE_SUCCESS; + } + diff --git a/sakura-server/src/main/java/me/samsuik/sakura/configuration/SakuraBrandInformation.java b/sakura-server/src/main/java/me/samsuik/sakura/configuration/SakuraBrandInformation.java new file mode 100644 index 0000000..8c2df67 --- /dev/null +++ b/sakura-server/src/main/java/me/samsuik/sakura/configuration/SakuraBrandInformation.java @@ -0,0 +1,30 @@ +package me.samsuik.sakura.configuration; + +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.event.HoverEvent; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; + +public final class SakuraBrandInformation { + private static final String VERSION_MESSAGE = """ + . + | This server is running Sakura + | Commit: \\<> targeting (MC: ) + | Github: \\<link> + '"""; + + public static void sendBrandToPlayer(final CommandSender sender) { + sender.sendMessage(MiniMessage.miniMessage().deserialize(VERSION_MESSAGE, + Placeholder.component("commit", gitCommit()), + Placeholder.unparsed("version", Bukkit.getMinecraftVersion()) + )); + } + + private static Component gitCommit() { + return Component.text("hover", NamedTextColor.YELLOW) + .hoverEvent(HoverEvent.showText(Component.text(Bukkit.getGitInformation()))); + } +}