Archiviert
13
0

Expose server build information (#10729)

* Expose server build information

* squash patches

* final tweaks

---------

Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: masmc05 <masmc05@gmail.com>
Dieser Commit ist enthalten in:
Riley Park 2024-05-15 17:06:59 -07:00 committet von GitHub
Ursprung 3fc93581bb
Commit f17519338b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
1360 geänderte Dateien mit 1817 neuen und 1446 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,528 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach@zachbr.io>
Date: Mon, 27 May 2019 01:10:06 -0500
Subject: [PATCH] Expose server build information
Co-authored-by: Professor Bloodstone <git@bloodstone.dev>
Co-authored-by: Mark Vainomaa <mikroskeem@mikroskeem.eu>
Co-authored-by: masmc05 <masmc05@gmail.com>
Co-authored-by: Riley Park <rileysebastianpark@gmail.com>
diff --git a/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java
new file mode 100644
index 0000000000000000000000000000000000000000..a736d7bcdc5861a01b66ba36158db1c716339346
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java
@@ -0,0 +1,45 @@
+package com.destroystokyo.paper.util;
+
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor;
+import org.bukkit.Bukkit;
+import org.jetbrains.annotations.NotNull;
+
+public interface VersionFetcher {
+ /**
+ * Amount of time to cache results for in milliseconds
+ * <p>
+ * Negative values will never cache.
+ *
+ * @return cache time
+ */
+ long getCacheTime();
+
+ /**
+ * Gets the version message to cache and show to command senders.
+ *
+ * <p>NOTE: This is run in a new thread separate from that of the command processing thread</p>
+ *
+ * @param serverVersion the current version of the server (will match {@link Bukkit#getVersion()})
+ * @return the message to show when requesting a version
+ */
+ @NotNull
+ Component getVersionMessage(@NotNull String serverVersion);
+
+ class DummyVersionFetcher implements VersionFetcher {
+
+ @Override
+ public long getCacheTime() {
+ return -1;
+ }
+
+ @NotNull
+ @Override
+ public Component getVersionMessage(@NotNull String serverVersion) {
+ Bukkit.getLogger().warning("Version provider has not been set, cannot check for updates!");
+ Bukkit.getLogger().info("Override the default implementation of org.bukkit.UnsafeValues#getVersionFetcher()");
+ new Throwable().printStackTrace();
+ return Component.text("Unable to check for updates. No version provider set.", NamedTextColor.RED);
+ }
+ }
+}
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfo.java b/src/main/java/io/papermc/paper/ServerBuildInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..9df9d09aa477d4cd3c496ba0933c816df1ef0964
--- /dev/null
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
@@ -0,0 +1,121 @@
+package io.papermc.paper;
+
+import java.time.Instant;
+import java.util.Optional;
+import java.util.OptionalInt;
+import net.kyori.adventure.key.Key;
+import net.kyori.adventure.util.Services;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Information about the current server build.
+ */
+@ApiStatus.NonExtendable
+public interface ServerBuildInfo {
+ /**
+ * The brand id for Paper.
+ */
+ Key BRAND_PAPER_ID = Key.key("papermc", "paper");
+
+ /**
+ * Gets the {@code ServerBuildInfo}.
+ *
+ * @return the {@code ServerBuildInfo}
+ */
+ static @NotNull ServerBuildInfo buildInfo() {
+ //<editor-fold defaultstate="collapsed" desc="Holder">
+ final class Holder {
+ static final Optional<ServerBuildInfo> INSTANCE = Services.service(ServerBuildInfo.class);
+ }
+ //</editor-fold>
+ return Holder.INSTANCE.orElseThrow();
+ }
+
+ /**
+ * Gets the brand id of the server.
+ *
+ * @return the brand id of the server (e.g. "papermc:paper")
+ */
+ @NotNull Key brandId();
+
+ /**
+ * Checks if the current server supports the specified brand.
+ *
+ * @param brandId the brand to check (e.g. "papermc:folia")
+ * @return {@code true} if the server supports the specified brand
+ */
+ @ApiStatus.Experimental
+ boolean isBrandCompatible(final @NotNull Key brandId);
+
+ /**
+ * Gets the brand name of the server.
+ *
+ * @return the brand name of the server (e.g. "Paper")
+ */
+ @NotNull String brandName();
+
+ /**
+ * Gets the Minecraft version id.
+ *
+ * @return the Minecraft version id (e.g. "1.20.4", "1.20.2-pre2", "23w31a")
+ */
+ @NotNull String minecraftVersionId();
+
+ /**
+ * Gets the Minecraft version name.
+ *
+ * @return the Minecraft version name (e.g. "1.20.4", "1.20.2 Pre-release 2", "23w31a")
+ */
+ @NotNull String minecraftVersionName();
+
+ /**
+ * Gets the build number.
+ *
+ * @return the build number
+ */
+ @NotNull OptionalInt buildNumber();
+
+ /**
+ * Gets the build time.
+ *
+ * @return the build time
+ */
+ @NotNull Instant buildTime();
+
+ /**
+ * Gets the git commit branch.
+ *
+ * @return the git commit branch
+ */
+ @NotNull Optional<String> gitBranch();
+
+ /**
+ * Gets the git commit hash.
+ *
+ * @return the git commit hash
+ */
+ @NotNull Optional<String> gitCommit();
+
+ /**
+ * Creates a string representation of the server build information.
+ *
+ * @param representation the type of representation
+ * @return a string
+ */
+ @NotNull String asString(final @NotNull StringRepresentation representation);
+
+ /**
+ * String representation types.
+ */
+ enum StringRepresentation {
+ /**
+ * A simple version string, in format {@code <minecraftVersionId>-<buildNumber>-<gitCommit>}.
+ */
+ VERSION_SIMPLE,
+ /**
+ * A simple version string, in format {@code <minecraftVersionId>-<buildNumber>-<gitBranch>@<gitCommit> (<buildTime>)}.
+ */
+ VERSION_FULL,
+ }
+}
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 ea5f1b4085fd2ec355c4c8036f3bc729e30fd1b7..f4bf442b065e93b49a7e17658f73d7569d644b25 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -109,13 +109,26 @@ 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 io.papermc.paper.ServerBuildInfo version = io.papermc.paper.ServerBuildInfo.buildInfo();
+ return "This server is running " + getName() + " version " + version.asString(io.papermc.paper.ServerBuildInfo.StringRepresentation.VERSION_FULL) + " (Implementing API version " + getBukkitVersion() + ")";
+ // Paper end
}
/**
* Gets the name of this server implementation.
*
* @return name of this server implementation
+ * @see io.papermc.paper.ServerBuildInfo#brandName()
*/
@NotNull
public static String getName() {
@@ -126,6 +139,7 @@ public final class Bukkit {
* Gets the version string of this server implementation.
*
* @return version of this server implementation
+ * @see io.papermc.paper.ServerBuildInfo
*/
@NotNull
public static String getVersion() {
@@ -142,6 +156,20 @@ public final class Bukkit {
return server.getBukkitVersion();
}
+ // Paper start - expose game version
+ /**
+ * Gets the version of game this server implements
+ *
+ * @return version of game
+ * @see io.papermc.paper.ServerBuildInfo#minecraftVersionId()
+ * @see io.papermc.paper.ServerBuildInfo#minecraftVersionName()
+ */
+ @NotNull
+ public static String getMinecraftVersion() {
+ return server.getMinecraftVersion();
+ }
+ // Paper end
+
/**
* Gets a view of all currently logged in players. This {@linkplain
* Collections#unmodifiableCollection(Collection) view} is a reused
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index e37649ce4b3981f2cff96b64ed3bd4093c015346..7c646d1bb8b011c156b0688f9396bbcbba43d077 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -119,6 +119,16 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@NotNull
public String getBukkitVersion();
+ // Paper start - expose game version
+ /**
+ * Gets the version of game this server implements
+ *
+ * @return version of game
+ */
+ @NotNull
+ String getMinecraftVersion();
+ // Paper end
+
/**
* Gets a view of all currently logged in players. This {@linkplain
* Collections#unmodifiableCollection(Collection) view} is a reused
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 9082e67324f810857db26bb89ecea7e9f866f80d..da997507b96908027c49dabc6daf7c787dcad95d 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -155,5 +155,12 @@ public interface UnsafeValues {
* @return name
*/
String getTimingsServerName();
+
+ /**
+ * Called once by the version command on first use, then cached.
+ */
+ default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
+ return new com.destroystokyo.paper.util.VersionFetcher.DummyVersionFetcher();
+ }
// 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 04b4fb6859df0221f8f9f92c5a7ac2dda1073355..fd5d9881abfd930bb883120f018f76dc78b62b14 100644
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
@@ -24,8 +24,25 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
+// Paper start - version command 2.0
+import com.destroystokyo.paper.util.VersionFetcher;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor;
+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
public class VersionCommand extends BukkitCommand {
+ private VersionFetcher versionFetcher; // Paper - version command 2.0
+ private VersionFetcher getVersionFetcher() { // lazy load because unsafe isn't available at command registration
+ if (versionFetcher == null) {
+ versionFetcher = Bukkit.getUnsafe().getVersionFetcher();
+ }
+
+ return versionFetcher;
+ }
+
public VersionCommand(@NotNull String name) {
super(name);
@@ -40,7 +57,7 @@ public class VersionCommand extends BukkitCommand {
if (!testPermission(sender)) return true;
if (args.length == 0) {
- sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")");
+ //sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); // Paper - moved to setVersionMessage
sendVersion(sender);
} else {
StringBuilder name = new StringBuilder();
@@ -79,8 +96,17 @@ public class VersionCommand extends BukkitCommand {
private void describeToSender(@NotNull Plugin plugin, @NotNull CommandSender sender) {
PluginDescriptionFile desc = plugin.getDescription();
- sender.sendMessage(ChatColor.GREEN + desc.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + desc.getVersion());
-
+ // Paper start - version command 2.0
+ sender.sendMessage(
+ Component.text()
+ .append(Component.text(desc.getName(), NamedTextColor.GREEN))
+ .append(Component.text(" version "))
+ .append(Component.text(desc.getVersion(), NamedTextColor.GREEN)
+ .hoverEvent(Component.text("Click to copy to clipboard", NamedTextColor.WHITE))
+ .clickEvent(ClickEvent.copyToClipboard(desc.getVersion()))
+ )
+ );
+ // Paper end - version command 2.0
if (desc.getDescription() != null) {
sender.sendMessage(desc.getDescription());
}
@@ -146,14 +172,14 @@ public class VersionCommand extends BukkitCommand {
private final ReentrantLock versionLock = new ReentrantLock();
private boolean hasVersion = false;
- private String versionMessage = null;
+ private Component versionMessage = null; // Paper
private final Set<CommandSender> versionWaiters = new HashSet<CommandSender>();
private boolean versionTaskStarted = false;
private long lastCheck = 0;
private void sendVersion(@NotNull CommandSender sender) {
if (hasVersion) {
- if (System.currentTimeMillis() - lastCheck > 21600000) {
+ if (System.currentTimeMillis() - lastCheck > getVersionFetcher().getCacheTime()) { // Paper - use version supplier
lastCheck = System.currentTimeMillis();
hasVersion = false;
} else {
@@ -168,7 +194,7 @@ public class VersionCommand extends BukkitCommand {
return;
}
versionWaiters.add(sender);
- sender.sendMessage("Checking version, please wait...");
+ sender.sendMessage(Component.text("Checking version, please wait...", NamedTextColor.WHITE, TextDecoration.ITALIC)); // Paper
if (!versionTaskStarted) {
versionTaskStarted = true;
new Thread(new Runnable() {
@@ -186,6 +212,13 @@ public class VersionCommand extends BukkitCommand {
private void obtainVersion() {
String version = Bukkit.getVersion();
+ // Paper start
+ if (version.startsWith("null")) { // running from ide?
+ setVersionMessage(Component.text("Unknown version, custom build?", NamedTextColor.YELLOW));
+ return;
+ }
+ setVersionMessage(getVersionFetcher().getVersionMessage(version));
+ /*
if (version == null) version = "Custom";
String[] parts = version.substring(0, version.indexOf(' ')).split("-");
if (parts.length == 4) {
@@ -215,11 +248,24 @@ public class VersionCommand extends BukkitCommand {
} else {
setVersionMessage("Unknown version, custom build?");
}
+ */
+ // Paper end
}
- private void setVersionMessage(@NotNull String msg) {
+ // Paper start
+ private void setVersionMessage(final @NotNull Component msg) {
lastCheck = System.currentTimeMillis();
- versionMessage = msg;
+ final Component message = Component.textOfChildren(
+ Component.text(Bukkit.getVersionMessage(), NamedTextColor.WHITE),
+ Component.newline(),
+ msg
+ );
+ this.versionMessage = Component.text()
+ .append(message)
+ .hoverEvent(Component.text("Click to copy to clipboard", NamedTextColor.WHITE))
+ .clickEvent(ClickEvent.copyToClipboard(PlainTextComponentSerializer.plainText().serialize(message)))
+ .build();
+ // Paper end
versionLock.lock();
try {
hasVersion = true;
diff --git a/src/test/java/io/papermc/paper/TestServerBuildInfo.java b/src/test/java/io/papermc/paper/TestServerBuildInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..17be27a869c1047a7a9440fb8f3717260d4abbd0
--- /dev/null
+++ b/src/test/java/io/papermc/paper/TestServerBuildInfo.java
@@ -0,0 +1,59 @@
+package io.papermc.paper;
+
+import java.time.Instant;
+import java.util.Optional;
+import java.util.OptionalInt;
+import net.kyori.adventure.key.Key;
+import org.jetbrains.annotations.NotNull;
+
+public class TestServerBuildInfo implements ServerBuildInfo {
+ @Override
+ public @NotNull Key brandId() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isBrandCompatible(final @NotNull Key brandId) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NotNull String brandName() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NotNull String minecraftVersionId() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NotNull String minecraftVersionName() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NotNull OptionalInt buildNumber() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NotNull Instant buildTime() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NotNull Optional<String> gitBranch() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NotNull Optional<String> gitCommit() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NotNull String asString(final @NotNull StringRepresentation representation) {
+ return "";
+ }
+}
diff --git a/src/test/resources/META-INF/services/io.papermc.paper.ServerBuildInfo b/src/test/resources/META-INF/services/io.papermc.paper.ServerBuildInfo
new file mode 100644
index 0000000000000000000000000000000000000000..64e2f8559b9c5a52e0a3229d3d12f65e9af145b3
--- /dev/null
+++ b/src/test/resources/META-INF/services/io.papermc.paper.ServerBuildInfo
@@ -0,0 +1 @@
+io.papermc.paper.TestServerBuildInfo

Datei anzeigen

@ -1,200 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach@zachbr.io>
Date: Mon, 27 May 2019 01:10:06 -0500
Subject: [PATCH] Version Command 2.0
diff --git a/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java
new file mode 100644
index 0000000000000000000000000000000000000000..a736d7bcdc5861a01b66ba36158db1c716339346
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java
@@ -0,0 +1,45 @@
+package com.destroystokyo.paper.util;
+
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor;
+import org.bukkit.Bukkit;
+import org.jetbrains.annotations.NotNull;
+
+public interface VersionFetcher {
+ /**
+ * Amount of time to cache results for in milliseconds
+ * <p>
+ * Negative values will never cache.
+ *
+ * @return cache time
+ */
+ long getCacheTime();
+
+ /**
+ * Gets the version message to cache and show to command senders.
+ *
+ * <p>NOTE: This is run in a new thread separate from that of the command processing thread</p>
+ *
+ * @param serverVersion the current version of the server (will match {@link Bukkit#getVersion()})
+ * @return the message to show when requesting a version
+ */
+ @NotNull
+ Component getVersionMessage(@NotNull String serverVersion);
+
+ class DummyVersionFetcher implements VersionFetcher {
+
+ @Override
+ public long getCacheTime() {
+ return -1;
+ }
+
+ @NotNull
+ @Override
+ public Component getVersionMessage(@NotNull String serverVersion) {
+ Bukkit.getLogger().warning("Version provider has not been set, cannot check for updates!");
+ Bukkit.getLogger().info("Override the default implementation of org.bukkit.UnsafeValues#getVersionFetcher()");
+ new Throwable().printStackTrace();
+ return Component.text("Unable to check for updates. No version provider set.", NamedTextColor.RED);
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 9082e67324f810857db26bb89ecea7e9f866f80d..da997507b96908027c49dabc6daf7c787dcad95d 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -155,5 +155,12 @@ public interface UnsafeValues {
* @return name
*/
String getTimingsServerName();
+
+ /**
+ * Called once by the version command on first use, then cached.
+ */
+ default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
+ return new com.destroystokyo.paper.util.VersionFetcher.DummyVersionFetcher();
+ }
// 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 04b4fb6859df0221f8f9f92c5a7ac2dda1073355..b437cf212a63aa96a9492db8d01d5d37061aee23 100644
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
@@ -24,8 +24,25 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
+// Paper start - version command 2.0
+import com.destroystokyo.paper.util.VersionFetcher;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor;
+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
public class VersionCommand extends BukkitCommand {
+ private VersionFetcher versionFetcher; // Paper - version command 2.0
+ private VersionFetcher getVersionFetcher() { // lazy load because unsafe isn't available at command registration
+ if (versionFetcher == null) {
+ versionFetcher = Bukkit.getUnsafe().getVersionFetcher();
+ }
+
+ return versionFetcher;
+ }
+
public VersionCommand(@NotNull String name) {
super(name);
@@ -40,7 +57,7 @@ public class VersionCommand extends BukkitCommand {
if (!testPermission(sender)) return true;
if (args.length == 0) {
- sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")");
+ //sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); // Paper - moved to setVersionMessage
sendVersion(sender);
} else {
StringBuilder name = new StringBuilder();
@@ -79,8 +96,17 @@ public class VersionCommand extends BukkitCommand {
private void describeToSender(@NotNull Plugin plugin, @NotNull CommandSender sender) {
PluginDescriptionFile desc = plugin.getDescription();
- sender.sendMessage(ChatColor.GREEN + desc.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + desc.getVersion());
-
+ // Paper start - version command 2.0
+ sender.sendMessage(
+ Component.text()
+ .append(Component.text(desc.getName(), NamedTextColor.GREEN))
+ .append(Component.text(" version "))
+ .append(Component.text(desc.getVersion(), NamedTextColor.GREEN)
+ .hoverEvent(Component.text("Click to copy to clipboard", NamedTextColor.WHITE))
+ .clickEvent(ClickEvent.copyToClipboard(desc.getVersion()))
+ )
+ );
+ // Paper end - version command 2.0
if (desc.getDescription() != null) {
sender.sendMessage(desc.getDescription());
}
@@ -146,14 +172,14 @@ public class VersionCommand extends BukkitCommand {
private final ReentrantLock versionLock = new ReentrantLock();
private boolean hasVersion = false;
- private String versionMessage = null;
+ private Component versionMessage = null; // Paper
private final Set<CommandSender> versionWaiters = new HashSet<CommandSender>();
private boolean versionTaskStarted = false;
private long lastCheck = 0;
private void sendVersion(@NotNull CommandSender sender) {
if (hasVersion) {
- if (System.currentTimeMillis() - lastCheck > 21600000) {
+ if (System.currentTimeMillis() - lastCheck > getVersionFetcher().getCacheTime()) { // Paper - use version supplier
lastCheck = System.currentTimeMillis();
hasVersion = false;
} else {
@@ -168,7 +194,7 @@ public class VersionCommand extends BukkitCommand {
return;
}
versionWaiters.add(sender);
- sender.sendMessage("Checking version, please wait...");
+ sender.sendMessage(Component.text("Checking version, please wait...", NamedTextColor.WHITE, TextDecoration.ITALIC)); // Paper
if (!versionTaskStarted) {
versionTaskStarted = true;
new Thread(new Runnable() {
@@ -186,6 +212,13 @@ public class VersionCommand extends BukkitCommand {
private void obtainVersion() {
String version = Bukkit.getVersion();
+ // Paper start
+ if (version.startsWith("null")) { // running from ide?
+ setVersionMessage(Component.text("Unknown version, custom build?", NamedTextColor.YELLOW));
+ return;
+ }
+ setVersionMessage(getVersionFetcher().getVersionMessage(version));
+ /*
if (version == null) version = "Custom";
String[] parts = version.substring(0, version.indexOf(' ')).split("-");
if (parts.length == 4) {
@@ -215,11 +248,24 @@ public class VersionCommand extends BukkitCommand {
} else {
setVersionMessage("Unknown version, custom build?");
}
+ */
+ // Paper end
}
- private void setVersionMessage(@NotNull String msg) {
+ // Paper start
+ private void setVersionMessage(final @NotNull Component msg) {
lastCheck = System.currentTimeMillis();
- versionMessage = msg;
+ final Component message = Component.textOfChildren(
+ Component.text("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")", NamedTextColor.WHITE),
+ Component.newline(),
+ msg
+ );
+ this.versionMessage = Component.text()
+ .append(message)
+ .hoverEvent(Component.text("Click to copy to clipboard", NamedTextColor.WHITE))
+ .clickEvent(ClickEvent.copyToClipboard(PlainTextComponentSerializer.plainText().serialize(message)))
+ .build();
+ // Paper end
versionLock.lock();
try {
hasVersion = true;

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Expose server CommandMap
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index ea5f1b4085fd2ec355c4c8036f3bc729e30fd1b7..c427d9dd916db6fe5078fb570eb57cfbd0766080 100644
index f4bf442b065e93b49a7e17658f73d7569d644b25..db217a9486e327b4340a54d65439055d86f363cc 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2294,6 +2294,19 @@ public final class Bukkit {
@@ -2322,6 +2322,19 @@ public final class Bukkit {
return server.getUnsafe();
}
@ -29,10 +29,10 @@ index ea5f1b4085fd2ec355c4c8036f3bc729e30fd1b7..c427d9dd916db6fe5078fb570eb57cfb
public static Server.Spigot spigot() {
return server.spigot();
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index e37649ce4b3981f2cff96b64ed3bd4093c015346..fbe2f6e349f242a2c4e64e63aa8ffdff7fa7dc81 100644
index 7c646d1bb8b011c156b0688f9396bbcbba43d077..69153de6847bb8740803e5f731a0586d41a0eed3 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1794,6 +1794,15 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1804,6 +1804,15 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
public double[] getTPS();
// Paper end

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Graduate bungeecord chat API from spigot subclasses
Change Javadoc to be accurate
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index c427d9dd916db6fe5078fb570eb57cfbd0766080..19efe5cb6a8c2dcc5b293ff24caa58c9a57fc083 100644
index db217a9486e327b4340a54d65439055d86f363cc..25f506c344883d00a63ee2b5a998d3ff3ffd6cd5 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -443,6 +443,30 @@ public final class Bukkit {
@@ -471,6 +471,30 @@ public final class Bukkit {
return server.broadcastMessage(message);
}
@ -41,10 +41,10 @@ index c427d9dd916db6fe5078fb570eb57cfbd0766080..19efe5cb6a8c2dcc5b293ff24caa58c9
* Gets the name of the update folder. The update folder is used to safely
* update plugins at the right moment on a plugin load.
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index fbe2f6e349f242a2c4e64e63aa8ffdff7fa7dc81..4c9c14b60eb6fd1d9845632c2c2fa765d882a741 100644
index 69153de6847bb8740803e5f731a0586d41a0eed3..65d68716e1ff8277c534399621cf961ddf312509 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -372,6 +372,30 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -382,6 +382,30 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@Deprecated // Paper
public int broadcastMessage(@NotNull String message);

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add command to reload permissions.yml and require confirm to
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 19efe5cb6a8c2dcc5b293ff24caa58c9a57fc083..c9be84560ee18ffe1bb84f159b2ed61c79f9e971 100644
index 25f506c344883d00a63ee2b5a998d3ff3ffd6cd5..8dc5b43e937405070d9bdbd914fcdec243e59983 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2329,6 +2329,13 @@ public final class Bukkit {
@@ -2357,6 +2357,13 @@ public final class Bukkit {
public static org.bukkit.command.CommandMap getCommandMap() {
return server.getCommandMap();
}
@ -24,10 +24,10 @@ index 19efe5cb6a8c2dcc5b293ff24caa58c9a57fc083..c9be84560ee18ffe1bb84f159b2ed61c
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 4c9c14b60eb6fd1d9845632c2c2fa765d882a741..c0c61a29ba8d3c95ff76c36e4333740320302b4a 100644
index 65d68716e1ff8277c534399621cf961ddf312509..47766c5312a402e3329a1d4bc5e5e0c05f2b007f 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2055,4 +2055,6 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2065,4 +2065,6 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@NotNull
Spigot spigot();
// Spigot end

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Allow Reloading of Command Aliases
Reload the aliases stored in commands.yml
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index c9be84560ee18ffe1bb84f159b2ed61c79f9e971..2dfd0080a0b0f05c5e5defa4326e0da9b85c2df5 100644
index 8dc5b43e937405070d9bdbd914fcdec243e59983..fdf5b8c69e98e000f897aca73ef97fa03371bb7c 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2336,6 +2336,15 @@ public final class Bukkit {
@@ -2364,6 +2364,15 @@ public final class Bukkit {
public static void reloadPermissions() {
server.reloadPermissions();
}
@ -26,10 +26,10 @@ index c9be84560ee18ffe1bb84f159b2ed61c79f9e971..2dfd0080a0b0f05c5e5defa4326e0da9
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index c0c61a29ba8d3c95ff76c36e4333740320302b4a..422a000ec33163f2f07502a05302b5d8851b2318 100644
index 47766c5312a402e3329a1d4bc5e5e0c05f2b007f..08141d729809132ed36d6088f37543e792395768 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2057,4 +2057,6 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2067,4 +2067,6 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
// Spigot end
void reloadPermissions(); // Paper

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add configuration option to prevent player names from being
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 2dfd0080a0b0f05c5e5defa4326e0da9b85c2df5..6b3a332f556e7c49796a62f20fd33241bbcde09e 100644
index fdf5b8c69e98e000f897aca73ef97fa03371bb7c..fbddd654b4ba7b2613884fdd22f3e62ddfc078c8 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2345,6 +2345,16 @@ public final class Bukkit {
@@ -2373,6 +2373,16 @@ public final class Bukkit {
public static boolean reloadCommandAliases() {
return server.reloadCommandAliases();
}
@ -27,10 +27,10 @@ index 2dfd0080a0b0f05c5e5defa4326e0da9b85c2df5..6b3a332f556e7c49796a62f20fd33241
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 422a000ec33163f2f07502a05302b5d8851b2318..9088bd9dfb515381d5df1c255ae3319f9cdde81e 100644
index 08141d729809132ed36d6088f37543e792395768..1f039a3609a5a1208af408b0565f07664558a23f 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2059,4 +2059,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2069,4 +2069,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
void reloadPermissions(); // Paper
boolean reloadCommandAliases(); // Paper

Datei anzeigen

@ -49,10 +49,10 @@ index a04cde615f8c4bc593f8d9f8f6f1438008aaa707..548f6d28c28d74bed8b58ee828759093
* @param target the target to remove from this list
*/
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 6b3a332f556e7c49796a62f20fd33241bbcde09e..3b7087d5c71a498f513f67514db9e118780363c7 100644
index fbddd654b4ba7b2613884fdd22f3e62ddfc078c8..53f56d95bdf484caed9effbedfe507f6745bb8c0 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1506,6 +1506,8 @@ public final class Bukkit {
@@ -1534,6 +1534,8 @@ public final class Bukkit {
/**
* Gets every player that has ever played on this server.
@ -127,10 +127,10 @@ index 4c9fd558fbf7f57a948fbb7f80f4651048c0fb57..458119a9ef7ce8e1f59bd47caa5b4bc6
* @param statePredicate The predicate which should get used to test if a block should be set or not.
* @return true if the tree was created successfully, otherwise false
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 9088bd9dfb515381d5df1c255ae3319f9cdde81e..012b5954a2f9dc61fb8ad29c4b8bce2648ddc681 100644
index 1f039a3609a5a1208af408b0565f07664558a23f..b0734f8253ed540916db7bc75cd7dd24e86031c7 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -570,13 +570,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -580,13 +580,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* </ul>
* <p>
* <b>Note:</b> If set to 0, {@link SpawnCategory} mobs spawning will be disabled.
@ -145,7 +145,7 @@ index 9088bd9dfb515381d5df1c255ae3319f9cdde81e..012b5954a2f9dc61fb8ad29c4b8bce26
*/
public int getTicksPerSpawns(@NotNull SpawnCategory spawnCategory);
@@ -1284,6 +1281,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1294,6 +1291,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
/**
* Gets every player that has ever played on this server.

Datei anzeigen

@ -327,10 +327,10 @@ index 0000000000000000000000000000000000000000..8f913a078dd692a9feafb98a6e6c9583
+ }
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 3b7087d5c71a498f513f67514db9e118780363c7..b165a4f99802ced243f1fb56af2bcf2c2ab7abf1 100644
index 53f56d95bdf484caed9effbedfe507f6745bb8c0..5aa1aafddd28a5aa52274f37c09bf0fda75f7ea3 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2357,6 +2357,83 @@ public final class Bukkit {
@@ -2385,6 +2385,83 @@ public final class Bukkit {
public static boolean suggestPlayerNamesWhenNullTabCompletions() {
return server.suggestPlayerNamesWhenNullTabCompletions();
}
@ -415,10 +415,10 @@ index 3b7087d5c71a498f513f67514db9e118780363c7..b165a4f99802ced243f1fb56af2bcf2c
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 012b5954a2f9dc61fb8ad29c4b8bce2648ddc681..f7a9756d3e3cd337b72b406ca862b81c27d4e44e 100644
index b0734f8253ed540916db7bc75cd7dd24e86031c7..c2cf0e547137b8a023ea009c7a5d0080def5f5f8 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2067,5 +2067,76 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2077,5 +2077,76 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return true if player names should be suggested
*/
boolean suggestPlayerNamesWhenNullTabCompletions();

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Player.setPlayerProfile API
This can be useful for changing name or skins after a player has logged in.
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index b165a4f99802ced243f1fb56af2bcf2c2ab7abf1..3ea17583766a462317a6a609ac693b5e488e006d 100644
index 5aa1aafddd28a5aa52274f37c09bf0fda75f7ea3..8521ef27d1e6c06e7228acb47388b02c50dc0e84 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1348,8 +1348,10 @@ public final class Bukkit {
@@ -1376,8 +1376,10 @@ public final class Bukkit {
* @return the new PlayerProfile
* @throws IllegalArgumentException if both the unique id is
* <code>null</code> and the name is <code>null</code> or blank
@ -20,7 +20,7 @@ index b165a4f99802ced243f1fb56af2bcf2c2ab7abf1..3ea17583766a462317a6a609ac693b5e
public static PlayerProfile createPlayerProfile(@Nullable UUID uniqueId, @Nullable String name) {
return server.createPlayerProfile(uniqueId, name);
}
@@ -1360,8 +1362,10 @@ public final class Bukkit {
@@ -1388,8 +1390,10 @@ public final class Bukkit {
* @param uniqueId the unique id
* @return the new PlayerProfile
* @throws IllegalArgumentException if the unique id is <code>null</code>
@ -31,7 +31,7 @@ index b165a4f99802ced243f1fb56af2bcf2c2ab7abf1..3ea17583766a462317a6a609ac693b5e
public static PlayerProfile createPlayerProfile(@NotNull UUID uniqueId) {
return server.createPlayerProfile(uniqueId);
}
@@ -1373,8 +1377,10 @@ public final class Bukkit {
@@ -1401,8 +1405,10 @@ public final class Bukkit {
* @return the new PlayerProfile
* @throws IllegalArgumentException if the name is <code>null</code> or
* blank
@ -56,10 +56,10 @@ index ff59479f4782ac7726504aab239de79fdc840cde..abbf3d6f11350ab2dd47a277771d9f46
/**
* Checks if this player has had their profile banned.
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 8e4bf531c0a2f7101c2a3733fe33733d31c611fd..427b49836becbb0c9e1cb2e94fab7eb1db452ad9 100644
index c2cf0e547137b8a023ea009c7a5d0080def5f5f8..e4b42323e8d168f9daee3d1b38f3591b45bc6a1b 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1153,8 +1153,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1163,8 +1163,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return the new PlayerProfile
* @throws IllegalArgumentException if both the unique id is
* <code>null</code> and the name is <code>null</code> or blank
@ -70,7 +70,7 @@ index 8e4bf531c0a2f7101c2a3733fe33733d31c611fd..427b49836becbb0c9e1cb2e94fab7eb1
PlayerProfile createPlayerProfile(@Nullable UUID uniqueId, @Nullable String name);
/**
@@ -1163,8 +1165,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1173,8 +1175,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @param uniqueId the unique id
* @return the new PlayerProfile
* @throws IllegalArgumentException if the unique id is <code>null</code>
@ -81,7 +81,7 @@ index 8e4bf531c0a2f7101c2a3733fe33733d31c611fd..427b49836becbb0c9e1cb2e94fab7eb1
PlayerProfile createPlayerProfile(@NotNull UUID uniqueId);
/**
@@ -1174,8 +1178,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1184,8 +1188,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return the new PlayerProfile
* @throws IllegalArgumentException if the name is <code>null</code> or
* blank

Datei anzeigen

@ -9,10 +9,10 @@ In Offline Mode, will return an Offline UUID
This is a more performant way to obtain a UUID for a name than loading an OfflinePlayer
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 3ea17583766a462317a6a609ac693b5e488e006d..3e32a6bbf593b269f1af23c7e2fdafaccc0d2110 100644
index 8521ef27d1e6c06e7228acb47388b02c50dc0e84..7bf662bd0eafcec46bb12cae78628e5045cbc299 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -721,6 +721,20 @@ public final class Bukkit {
@@ -749,6 +749,20 @@ public final class Bukkit {
return server.getPlayer(id);
}
@ -34,10 +34,10 @@ index 3ea17583766a462317a6a609ac693b5e488e006d..3e32a6bbf593b269f1af23c7e2fdafac
* Gets the plugin manager for interfacing with plugins.
*
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 427b49836becbb0c9e1cb2e94fab7eb1db452ad9..19e6cee94caabfe93c841da783c86a3c283ebcb9 100644
index e4b42323e8d168f9daee3d1b38f3591b45bc6a1b..f352b10ad81ee21ddbf9d09ccbc6e919cb670bf9 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -619,6 +619,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -629,6 +629,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@Nullable
public Player getPlayer(@NotNull UUID id);

Datei anzeigen

@ -1,101 +0,0 @@
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 3e32a6bbf593b269f1af23c7e2fdafaccc0d2110..d60780a26e10f5f9c80446693552384281327b51 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -60,6 +60,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
@@ -109,7 +110,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 b437cf212a63aa96a9492db8d01d5d37061aee23..fd5d9881abfd930bb883120f018f76dc78b62b14 100644
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
@@ -256,7 +256,7 @@ public class VersionCommand extends BukkitCommand {
private void setVersionMessage(final @NotNull Component msg) {
lastCheck = System.currentTimeMillis();
final Component message = Component.textOfChildren(
- Component.text("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")", NamedTextColor.WHITE),
+ Component.text(Bukkit.getVersionMessage(), NamedTextColor.WHITE),
Component.newline(),
msg
);

Datei anzeigen

@ -1132,7 +1132,7 @@ index 0000000000000000000000000000000000000000..5376e51adf5af15572b0d760b17f2de6
+ .ensureSize("WATER_BASED", 11).lock();
+}
diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java
index 1be862110e94654be12fcef5980388abf242ac7f..298ae1294a122705bca6bd74ea540185839d1ed5 100644
index 54861b283e82f0a9789eda508356c8a8accb0545..33c75db0fcbbd771a59764c5d90484cee27b60cf 100644
--- a/src/main/java/org/bukkit/Tag.java
+++ b/src/main/java/org/bukkit/Tag.java
@@ -11,6 +11,10 @@ import org.jetbrains.annotations.NotNull;

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Make the default permission message configurable
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index d60780a26e10f5f9c80446693552384281327b51..f248515862c3bc418b42b8e197feb43addfd122d 100644
index 7bf662bd0eafcec46bb12cae78628e5045cbc299..de678fa681fbd94efa8fd85568ee092ae26fca85 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2397,6 +2397,28 @@ public final class Bukkit {
@@ -2406,6 +2406,28 @@ public final class Bukkit {
return server.suggestPlayerNamesWhenNullTabCompletions();
}
@ -38,10 +38,10 @@ index d60780a26e10f5f9c80446693552384281327b51..f248515862c3bc418b42b8e197feb43a
* Creates a PlayerProfile for the specified uuid, with name as null.
*
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 19e6cee94caabfe93c841da783c86a3c283ebcb9..69f236d965c631510b008a7eb38aa1b62a4e196a 100644
index f352b10ad81ee21ddbf9d09ccbc6e919cb670bf9..a7a04a4e9c94cc43ccf84abb3b7956b60c79e8fe 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2086,6 +2086,23 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2096,6 +2096,23 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
boolean suggestPlayerNamesWhenNullTabCompletions();

Datei anzeigen

@ -40,10 +40,10 @@ index ac420f0059fc50d3e1294f85df7515c9e17ff78f..24daba85ce4129fb0babe67570059ca8
public static Art getById(int id) {
return BY_ID.get(id);
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index f248515862c3bc418b42b8e197feb43addfd122d..395d7245aac45a1b805e15ee1fdb9949574f3f59 100644
index de678fa681fbd94efa8fd85568ee092ae26fca85..cddf3250c4a7efe239248b5e9662f33f5c0b702f 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -870,9 +870,8 @@ public final class Bukkit {
@@ -879,9 +879,8 @@ public final class Bukkit {
*
* @param id the id of the map to get
* @return a map view if it exists, or null otherwise
@ -54,7 +54,7 @@ index f248515862c3bc418b42b8e197feb43addfd122d..395d7245aac45a1b805e15ee1fdb9949
@Nullable
public static MapView getMap(int id) {
return server.getMap(id);
@@ -951,8 +950,14 @@ public final class Bukkit {
@@ -960,8 +959,14 @@ public final class Bukkit {
* Returns the primary logger associated with this server instance.
*
* @return Logger associated with this server
@ -69,7 +69,7 @@ index f248515862c3bc418b42b8e197feb43addfd122d..395d7245aac45a1b805e15ee1fdb9949
public static Logger getLogger() {
return server.getLogger();
}
@@ -1349,10 +1354,8 @@ public final class Bukkit {
@@ -1358,10 +1363,8 @@ public final class Bukkit {
* @param name the name the player to retrieve
* @return an offline player
* @see #getOfflinePlayer(java.util.UUID)
@ -81,7 +81,7 @@ index f248515862c3bc418b42b8e197feb43addfd122d..395d7245aac45a1b805e15ee1fdb9949
@NotNull
public static OfflinePlayer getOfflinePlayer(@NotNull String name) {
return server.getOfflinePlayer(name);
@@ -1954,7 +1957,7 @@ public final class Bukkit {
@@ -1963,7 +1966,7 @@ public final class Bukkit {
*
* @return the scoreboard manager or null if no worlds are loaded.
*/
@ -498,10 +498,10 @@ index 6277451c3c6c551078c237cd767b6d70c4f585ea..10f5cfb1885833a1d2c1027c03974da4
CRACKED(0x0),
GLYPHED(0x1),
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 3d5ef29bcfed92dc7fb3bb6d59538ba4a4e3de5f..43f8cdd600aa2c2e33136068b3c4b4b81a6544d4 100644
index a7a04a4e9c94cc43ccf84abb3b7956b60c79e8fe..6412546d84874cb93fcdc8426a402bec4e276057 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -730,9 +730,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -740,9 +740,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*
* @param id the id of the map to get
* @return a map view if it exists, or null otherwise
@ -512,7 +512,7 @@ index 3d5ef29bcfed92dc7fb3bb6d59538ba4a4e3de5f..43f8cdd600aa2c2e33136068b3c4b4b8
@Nullable
public MapView getMap(int id);
@@ -799,8 +798,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -809,8 +808,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* Returns the primary logger associated with this server instance.
*
* @return Logger associated with this server
@ -527,7 +527,7 @@ index 3d5ef29bcfed92dc7fb3bb6d59538ba4a4e3de5f..43f8cdd600aa2c2e33136068b3c4b4b8
public Logger getLogger();
/**
@@ -1137,10 +1142,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1147,10 +1152,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @param name the name the player to retrieve
* @return an offline player
* @see #getOfflinePlayer(java.util.UUID)
@ -539,7 +539,7 @@ index 3d5ef29bcfed92dc7fb3bb6d59538ba4a4e3de5f..43f8cdd600aa2c2e33136068b3c4b4b8
@NotNull
public OfflinePlayer getOfflinePlayer(@NotNull String name);
@@ -1649,7 +1652,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1659,7 +1662,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*
* @return the scoreboard manager or null if no worlds are loaded.
*/

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Expose the internal current tick
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 395d7245aac45a1b805e15ee1fdb9949574f3f59..d1e1c49ecf6a1ede71548fbac6143e38ba6dfea1 100644
index cddf3250c4a7efe239248b5e9662f33f5c0b702f..836b5d1363ffcff08708b6b4721253ade99eb987 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2498,6 +2498,10 @@ public final class Bukkit {
@@ -2507,6 +2507,10 @@ public final class Bukkit {
public static com.destroystokyo.paper.profile.PlayerProfile createProfileExact(@Nullable UUID uuid, @Nullable String name) {
return server.createProfileExact(uuid, name);
}
@ -20,10 +20,10 @@ index 395d7245aac45a1b805e15ee1fdb9949574f3f59..d1e1c49ecf6a1ede71548fbac6143e38
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 43f8cdd600aa2c2e33136068b3c4b4b81a6544d4..f11c1caa81c97d1a31d8cc980ad4dab2e2573ec4 100644
index 6412546d84874cb93fcdc8426a402bec4e276057..387478b3e4ad9877f3338b719ff447126ef16285 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2176,5 +2176,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2186,5 +2186,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
@NotNull
com.destroystokyo.paper.profile.PlayerProfile createProfileExact(@Nullable UUID uuid, @Nullable String name);

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Add tick times API
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index d1e1c49ecf6a1ede71548fbac6143e38ba6dfea1..385be33869f3850f8b1d3e690c8e0fc43adcbdce 100644
index 836b5d1363ffcff08708b6b4721253ade99eb987..1a8f4e122b84b423fe19bfafad56d6d3df9ec134 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2170,6 +2170,25 @@ public final class Bukkit {
@@ -2179,6 +2179,25 @@ public final class Bukkit {
public static double[] getTPS() {
return server.getTPS();
}
@ -35,10 +35,10 @@ index d1e1c49ecf6a1ede71548fbac6143e38ba6dfea1..385be33869f3850f8b1d3e690c8e0fc4
/**
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index cf242e2e6d538d3d38b7b10321ab375e018b24b1..d6d83b22389aee98967adda2631fa65ecbf00781 100644
index 387478b3e4ad9877f3338b719ff447126ef16285..fc4e259e5ca7a4b25f276bda7f2f5ea022d0c552 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1836,6 +1836,21 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1846,6 +1846,21 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
@NotNull
public double[] getTPS();

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Expose MinecraftServer#isRunning
This allows for plugins to detect if the server is actually turning off in onDisable rather than just plugins reloading.
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 385be33869f3850f8b1d3e690c8e0fc43adcbdce..f24d57a89dc4fdf73298bbb4cc187794c7bd6706 100644
index 1a8f4e122b84b423fe19bfafad56d6d3df9ec134..1c30e523d08250c8a5477fe4d749b779223f069a 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2521,6 +2521,15 @@ public final class Bukkit {
@@ -2530,6 +2530,15 @@ public final class Bukkit {
public static int getCurrentTick() {
return server.getCurrentTick();
}
@ -26,10 +26,10 @@ index 385be33869f3850f8b1d3e690c8e0fc43adcbdce..f24d57a89dc4fdf73298bbb4cc187794
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 965032124406a63c70dc9007245f74fb2e503c52..17f6b930c7d462cd8112bb5a845c25202e6c78b5 100644
index fc4e259e5ca7a4b25f276bda7f2f5ea022d0c552..1f4ebdaf9cfd14de9ff2d0cea7d110fe7630dc9a 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2198,5 +2198,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2208,5 +2208,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return Current tick
*/
int getCurrentTick();

Datei anzeigen

@ -226,10 +226,10 @@ index 0000000000000000000000000000000000000000..e21f7574763dd4f13794f91bbef192ef
+ <T extends Mob> Collection<Goal<T>> getRunningGoalsWithout(@NotNull T mob, @NotNull GoalType type);
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index b608a6dc26bfc6d08f1e31107fed8ef1aaf90e1d..79db7b5c25a7c824b107a5c79f40c61983d2757c 100644
index 1c30e523d08250c8a5477fe4d749b779223f069a..f2fa4c419f212ea5d7ca0aab4ead4bd44dac5947 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2542,6 +2542,16 @@ public final class Bukkit {
@@ -2539,6 +2539,16 @@ public final class Bukkit {
public static boolean isStopping() {
return server.isStopping();
}

Datei anzeigen

@ -1,50 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
Date: Fri, 1 May 2020 17:39:02 +0300
Subject: [PATCH] Expose game version
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index f24d57a89dc4fdf73298bbb4cc187794c7bd6706..b608a6dc26bfc6d08f1e31107fed8ef1aaf90e1d 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -161,6 +161,18 @@ public final class Bukkit {
return server.getBukkitVersion();
}
+ // Paper start - expose game version
+ /**
+ * Gets the version of game this server implements
+ *
+ * @return version of game
+ */
+ @NotNull
+ public static String getMinecraftVersion() {
+ return server.getMinecraftVersion();
+ }
+ // Paper end
+
/**
* Gets a view of all currently logged in players. This {@linkplain
* Collections#unmodifiableCollection(Collection) view} is a reused
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 015f1167bdc752fe6665807866caa0cda5ba0571..987e01f48f7f8b19fd6292a11988b1aeb90a09f6 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -119,6 +119,16 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@NotNull
public String getBukkitVersion();
+ // Paper start - expose game version
+ /**
+ * Gets the version of game this server implements
+ *
+ * @return version of game
+ */
+ @NotNull
+ String getMinecraftVersion();
+ // Paper end
+
/**
* Gets a view of all currently logged in players. This {@linkplain
* Collections#unmodifiableCollection(Collection) view} is a reused

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Create HoverEvent from ItemStack Entity
diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java
index e34c89a945a0f12cdc4be8cc232c8de986474372..dbebaf8172ec6872f56958b9583affde4f8400a4 100644
index 4c4e52b2c200408c4e33a141e1eed78126ceaaee..53b8934cb829f37971cb3ecd5652c9974dec6ab0 100644
--- a/src/main/java/org/bukkit/inventory/ItemFactory.java
+++ b/src/main/java/org/bukkit/inventory/ItemFactory.java
@@ -265,4 +265,65 @@ public interface ItemFactory {

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Add getOfflinePlayerIfCached(String)
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 79db7b5c25a7c824b107a5c79f40c61983d2757c..732ed3724e784ad659cb4411dbd73b42a8330a2c 100644
index f2fa4c419f212ea5d7ca0aab4ead4bd44dac5947..3210587c341bc8d80ddc7f387ca4030dbd0074c9 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1373,6 +1373,27 @@ public final class Bukkit {
@@ -1370,6 +1370,27 @@ public final class Bukkit {
return server.getOfflinePlayer(name);
}
@ -37,7 +37,7 @@ index 79db7b5c25a7c824b107a5c79f40c61983d2757c..732ed3724e784ad659cb4411dbd73b42
* Gets the player by the given UUID, regardless if they are offline or
* online.
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 8aba385b9d1a9b71c3304f1d802f18d4434f34d5..395f7910f535bfd33a5676b011ab62a53e30e140 100644
index 711de014b7cf69459526e6c20c94f29ee4db11c4..f0c1d16c6bee58826a3cde3c4988e02690207fce 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1157,6 +1157,25 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen