Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
26734e83b0
* Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 8085edde SPIGOT-6918: Add SpawnCategory API and configurations for Axolotls 04c7e13c PR-719: Add Player Profile API 71564210 SPIGOT-6910: Add BlockDamageAbortEvent CraftBukkit Changes: febaa1c6 SPIGOT-6918: Add SpawnCategory API and configurations for Axolotls 9dafd109 Don't send updates over large distances bdac46b0 SPIGOT-6782: EntityPortalEvent should not destroy entity when setTo() uses same world as getFrom() 8f361ece PR-1002: Add Player Profile API 911875d4 Increase outdated build delay e5f8a767 SPIGOT-6917: Use main scoreboard for /trigger a672a531 Clean up callBlockDamageEvent 8e1bdeef SPIGOT-6910: Add BlockDamageAbortEvent Spigot Changes: 6edb62f3 Rebuild patches 7fbc6a1e Rebuild patches * Updated Upstream (CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing CraftBukkit Changes: de951355 SPIGOT-6927: Fix default value of spawn-limits in Worlds
102 Zeilen
4.8 KiB
Diff
102 Zeilen
4.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Professor Bloodstone <git@bloodstone.dev>
|
|
Date: Sun, 20 Jun 2021 01:48:31 +0200
|
|
Subject: [PATCH] Add Git information to version command/on startup
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/util/JarManifests.java b/src/main/java/io/papermc/paper/util/JarManifests.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..909617079db61b675cc7b60b44ef96b306076343
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/util/JarManifests.java
|
|
@@ -0,0 +1,37 @@
|
|
+package io.papermc.paper.util;
|
|
+
|
|
+import java.io.IOException;
|
|
+import java.io.InputStream;
|
|
+import java.net.URL;
|
|
+import java.util.Collections;
|
|
+import java.util.Map;
|
|
+import java.util.WeakHashMap;
|
|
+import java.util.jar.Manifest;
|
|
+import org.jetbrains.annotations.ApiStatus;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+import org.jetbrains.annotations.Nullable;
|
|
+
|
|
+@ApiStatus.Internal
|
|
+public final class JarManifests {
|
|
+ private JarManifests() {
|
|
+ }
|
|
+
|
|
+ private static final Map<ClassLoader, Manifest> MANIFESTS = Collections.synchronizedMap(new WeakHashMap<>());
|
|
+
|
|
+ public static @Nullable Manifest manifest(final @NotNull Class<?> clazz) {
|
|
+ return MANIFESTS.computeIfAbsent(clazz.getClassLoader(), classLoader -> {
|
|
+ final String classLocation = "/" + clazz.getName().replace(".", "/") + ".class";
|
|
+ final URL resource = clazz.getResource(classLocation);
|
|
+ if (resource == null) {
|
|
+ return null;
|
|
+ }
|
|
+ final String classFilePath = resource.toString().replace("\\", "/");
|
|
+ final String archivePath = classFilePath.substring(0, classFilePath.length() - classLocation.length());
|
|
+ try (final InputStream stream = new URL(archivePath + "/META-INF/MANIFEST.MF").openStream()) {
|
|
+ return new Manifest(stream);
|
|
+ } catch (final IOException ex) {
|
|
+ return null;
|
|
+ }
|
|
+ });
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
|
index 0ecff0322c3ff4e6e3c6fcaf72d0ab786ba423fa..c88eb8946d5ce145fc1cd27795826daeb7f27bff 100644
|
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
@@ -53,6 +53,7 @@ import org.bukkit.util.CachedServerIcon;
|
|
import org.jetbrains.annotations.Contract;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
+import io.papermc.paper.util.JarManifests; // Paper
|
|
|
|
/**
|
|
* Represents the Bukkit core, for version and Server singleton handling
|
|
@@ -102,7 +103,25 @@ public final class Bukkit {
|
|
}
|
|
|
|
Bukkit.server = server;
|
|
- server.getLogger().info("This server is running " + getName() + " version " + getVersion() + " (Implementing API version " + getBukkitVersion() + ")");
|
|
+ // Paper start - add git information
|
|
+ server.getLogger().info(getVersionMessage());
|
|
+ }
|
|
+ /**
|
|
+ * Gets message describing the version server is running.
|
|
+ *
|
|
+ * @return message describing the version server is running
|
|
+ */
|
|
+ @NotNull
|
|
+ public static String getVersionMessage() {
|
|
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
|
|
+ final String gitBranch = manifest == null ? null : manifest.getMainAttributes().getValue("Git-Branch");
|
|
+ final String gitCommit = manifest == null ? null : manifest.getMainAttributes().getValue("Git-Commit");
|
|
+ String branchMsg = " on " + gitBranch;
|
|
+ if ("master".equals(gitBranch) || "main".equals(gitBranch)) {
|
|
+ branchMsg = ""; // Don't show branch on main/master
|
|
+ }
|
|
+ return "This server is running " + getName() + " version " + getVersion() + " (Implementing API version " + getBukkitVersion() + ") (Git: " + gitCommit + branchMsg + ")";
|
|
+ // Paper end
|
|
}
|
|
|
|
/**
|
|
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
index 4c2ddc722a9dc4011906ad9530b13fa9be1d3ff9..57a21495843f3a144cd73473cdc8781d6129b7ca 100644
|
|
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
@@ -241,7 +241,7 @@ public class VersionCommand extends BukkitCommand {
|
|
private void setVersionMessage(final @NotNull Component msg) {
|
|
lastCheck = System.currentTimeMillis();
|
|
final Component message = net.kyori.adventure.text.TextComponent.ofChildren(
|
|
- Component.text("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")", net.kyori.adventure.text.format.NamedTextColor.WHITE),
|
|
+ Component.text(Bukkit.getVersionMessage(), net.kyori.adventure.text.format.NamedTextColor.WHITE),
|
|
Component.newline(),
|
|
msg
|
|
);
|