Paper/patches/api/0160-Make-the-default-permission-message-configurable.patch
Nassim Jahnke d8e07590e3
Updated Upstream (Bukkit/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

Bukkit Changes:
5dbedae1 PR-864: Fix Registry#match() failing namespaced inputs
49256865 PR-863: Fix boolean PersistentDataType
9f15450b SPIGOT-7195, SPIGOT-7197: Add DataPack API
ebef5b6a Disable InterfaceIsType Checkstyle check
01d577f5 Slight tweak to boolean PersistentDataType javadoc
d2b99e56 PR-857: Add boolean PersistentDataType

CraftBukkit Changes:
2270366cd PR-1196: Test Registry instances more thoroughly
863dacb7a PR-1191: Do not start on pre-release Java 17
1f2dd8e12 SPIGOT-7362: Properly handle null in CraftBlock#blockFaceToNotch()
dbc70bed5 SPIGOT-7195, SPIGOT-7197: Add DataPack API
2023-06-06 11:09:19 +02:00

85 lines
3.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 18 Nov 2018 19:44:54 +0000
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 733b537d4236e5cb06efc188183ad876db31c0ff..71cd6f405c35e1e1a02c1bac64b509ae6ba5c7cd 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2213,6 +2213,28 @@ public final class Bukkit {
return server.suggestPlayerNamesWhenNullTabCompletions();
}
+ /**
+ * Gets the default no permission message used on the server
+ *
+ * @return the default message
+ * @deprecated use {@link #permissionMessage()}
+ */
+ @NotNull
+ @Deprecated
+ public static String getPermissionMessage() {
+ return server.getPermissionMessage();
+ }
+
+ /**
+ * Gets the default no permission message used on the server
+ *
+ * @return the default message
+ */
+ @NotNull
+ public static net.kyori.adventure.text.Component permissionMessage() {
+ return server.permissionMessage();
+ }
+
/**
* 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 878b3ff92be8fcb977240824ae404fb5bed42d48..43c14b492879d56993586a7b64eb374654ca67a6 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1929,6 +1929,23 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
boolean suggestPlayerNamesWhenNullTabCompletions();
+ /**
+ * Gets the default no permission message used on the server
+ *
+ * @return the default message
+ * @deprecated use {@link #permissionMessage()}
+ */
+ @NotNull
+ @Deprecated
+ String getPermissionMessage();
+
+ /**
+ * Gets the default no permission message used on the server
+ *
+ * @return the default message
+ */
+ @NotNull net.kyori.adventure.text.Component permissionMessage();
+
/**
* Creates a PlayerProfile for the specified uuid, with name as null.
*
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
index 1c6205cc667bbec8f6aca479f13b3e9cfcd63ab2..b791358f90fe92bc2264d9a26492245763813af3 100644
--- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java
@@ -184,10 +184,9 @@ public abstract class Command {
return true;
}
- if (permissionMessage == null) {
- target.sendMessage(ChatColor.RED + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is a mistake.");
// Paper start - use components for permissionMessage
- } else if (!permissionMessage.equals(net.kyori.adventure.text.Component.empty())) {
+ net.kyori.adventure.text.Component permissionMessage = this.permissionMessage != null ? this.permissionMessage : Bukkit.permissionMessage();
+ if (!permissionMessage.equals(net.kyori.adventure.text.Component.empty())) {
target.sendMessage(permissionMessage.replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("<permission>").replacement(permission).build()));
// Paper end
}