Paper/patches/api/0154-Make-the-default-permission-message-configurable.patch
Nassim Jahnke 6483ecb8a2
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:
a6aba46f PR-1078: Improve Javadocs of Player#loadData() and Player#saveData()
1e2e6a18 SPIGOT-7946: API for server pause when empty seconds
54a36938 SPIGOT-7944, PR-1077: Allow nullable fields in DamageTypeTags

CraftBukkit Changes:
2702c5c8e SPIGOT-7946: API for server pause when empty seconds
485f910fc SPIGOT-7947: addPassenger doesn't work if the vehicle is a player
ecf3dff0e SPIGOT-7949: Registering a new scoreboard objective with an empty display name throws a NPE
9b048cc84 SPIGOT-7948: `Bukkit#dispatchCommand` uses the wrong `CommandListenerWrapper` for Players
7b44d4640 SPIGOT-7931: Fix sync in Anvil View when result item is taken
2024-11-09 17:01:35 +01: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 720f1cc07824fe6e46cdd8bbe8f5a9b15b9c816d..f9067281bd5f1ac11dcb9cc2e19f3c5f17face21 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2445,6 +2445,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 f1d2776eab476aae60b5dd5cb7eeb41a2235825c..2719461e49a74f979d49dea9c664dfe3da8d2c8e 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2127,6 +2127,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 8a298b655f4eaf5116994f98572a20e83a23838c..03d2643d166824458c88a49f20270e93b14f3988 100644
--- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java
@@ -192,10 +192,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
}