mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-19 23:09:32 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@906df69 Prevent internal NPE on ItemStack#damage (#10836) PaperMC/Paper@79e2cb6 Update upstream (Bukkit/CraftBukkit/Spigot) (#10875)
86 lines
4.0 KiB
Diff
86 lines
4.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
|
|
Date: Wed, 2 Aug 2023 18:00:04 +0100
|
|
Subject: [PATCH] Customise Version Command
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
|
index 47039514503d99e84cb99f4941707a7726286516..3e426dc442fd7c82cfd89c4c46290f0c857eddf9 100644
|
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
@@ -124,6 +124,20 @@ public final class Bukkit {
|
|
// Paper end
|
|
}
|
|
|
|
+ // Sakura start - expose git info
|
|
+ @NotNull
|
|
+ public static String getGitInformation() {
|
|
+ final io.papermc.paper.ServerBuildInfo version = io.papermc.paper.ServerBuildInfo.buildInfo();
|
|
+ final String gitBranch = version.gitBranch().orElse("Dev");
|
|
+ final String gitCommit = version.gitCommit().orElse("");
|
|
+ String branchMsg = " on " + gitBranch;
|
|
+ if ("master".equals(gitBranch) || "main".equals(gitBranch)) {
|
|
+ branchMsg = ""; // Don't show branch on main/master
|
|
+ }
|
|
+ return "(Git: " + gitCommit + branchMsg + ")";
|
|
+ }
|
|
+ // Sakura end
|
|
+
|
|
/**
|
|
* Gets the name of this server implementation.
|
|
*
|
|
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
index e64bb57f74e6d6f78927be228825b3e0bdf41f48..019b8abbf69ea0f741e725ae1c965f04604fe16d 100644
|
|
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
@@ -33,6 +33,11 @@ import net.kyori.adventure.text.event.ClickEvent;
|
|
import net.kyori.adventure.text.format.TextDecoration;
|
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|
// Paper end - version command 2.0
|
|
+// Sakura start
|
|
+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
|
|
|
|
public class VersionCommand extends BukkitCommand {
|
|
private VersionFetcher versionFetcher; // Paper - version command 2.0
|
|
@@ -44,6 +49,15 @@ public class VersionCommand extends BukkitCommand {
|
|
return versionFetcher;
|
|
}
|
|
|
|
+ // Sakura start
|
|
+ private static final String VERSION_MESSAGE = """
|
|
+ <dark_purple>.
|
|
+ <dark_purple>| <white>This server is running <gradient:red:light_purple>Sakura</gradient>
|
|
+ <dark_purple>| <white>Commit<dark_gray>: \\<<commit>> <gray>targeting </gray>(<yellow>MC</yellow>: <gray><version></gray>)
|
|
+ <dark_purple>| <white>Github<dark_gray>: \\<<yellow><click:open_url:'https://github.com/Samsuik/Sakura'>link</click></yellow>>
|
|
+ <dark_purple>'""";
|
|
+ // Sakura end
|
|
+
|
|
public VersionCommand(@NotNull String name) {
|
|
super(name);
|
|
|
|
@@ -55,12 +69,18 @@ public class VersionCommand extends BukkitCommand {
|
|
|
|
@Override
|
|
public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) {
|
|
- if (!testPermission(sender)) return true;
|
|
+ // Sakura - move down into else
|
|
|
|
if (args.length == 0) {
|
|
//sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); // Paper - moved to setVersionMessage
|
|
- sendVersion(sender);
|
|
- } else {
|
|
+ // Sakura start
|
|
+ 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())
|
|
+ ));
|
|
+ } else if (testPermission(sender)) {
|
|
+ // Sakura end
|
|
StringBuilder name = new StringBuilder();
|
|
|
|
for (String arg : args) {
|