2021-06-11 12:02:28 +00:00
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
2023-06-12 23:51:45 +00:00
index 36a127864be2a75a38bcc6eacafde5109e5c6c69..8649a3453bd3c3ee5f2bf5b706b125cb70d3bb1b 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
2023-06-12 23:51:45 +00:00
@@ -2241,6 +2241,28 @@ public final class Bukkit {
2021-06-11 12:02:28 +00:00
return server.suggestPlayerNamesWhenNullTabCompletions();
}
+ /**
2022-06-09 23:19:38 +00:00
+ * Gets the default no permission message used on the server
2021-06-11 12:02:28 +00:00
+ *
2022-06-09 23:19:38 +00:00
+ * @return the default message
+ * @deprecated use {@link #permissionMessage()}
2021-06-11 12:02:28 +00:00
+ */
+ @NotNull
2022-06-09 23:19:38 +00:00
+ @Deprecated
2021-06-11 12:02:28 +00:00
+ public static String getPermissionMessage() {
+ return server.getPermissionMessage();
+ }
2022-06-09 23:19:38 +00:00
+
+ /**
+ * 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();
+ }
2021-06-11 12:02:28 +00:00
+
/**
2022-03-19 13:39:38 +00:00
* Creates a PlayerProfile for the specified uuid, with name as null.
*
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
2023-06-12 23:51:45 +00:00
index 2ac191185e4dabb2f39b05a56548b0d97daa2979..771a504a6f64644f434e2a6d20d285d338b5dff4 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
2023-06-12 23:51:45 +00:00
@@ -1951,6 +1951,23 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
2021-06-11 12:02:28 +00:00
*/
boolean suggestPlayerNamesWhenNullTabCompletions();
+ /**
2022-06-09 21:11:43 +00:00
+ * Gets the default no permission message used on the server
2021-06-11 12:02:28 +00:00
+ *
2022-06-09 21:11:43 +00:00
+ * @return the default message
+ * @deprecated use {@link #permissionMessage()}
2021-06-11 12:02:28 +00:00
+ */
+ @NotNull
2022-06-09 21:11:43 +00:00
+ @Deprecated
2021-06-11 12:02:28 +00:00
+ String getPermissionMessage();
2022-06-09 21:11:43 +00:00
+
+ /**
+ * Gets the default no permission message used on the server
+ *
+ * @return the default message
+ */
+ @NotNull net.kyori.adventure.text.Component permissionMessage();
2021-06-11 12:02:28 +00:00
+
/**
2022-03-19 13:39:38 +00:00
* Creates a PlayerProfile for the specified uuid, with name as null.
*
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
2023-03-31 04:09:13 +00:00
index 1c6205cc667bbec8f6aca479f13b3e9cfcd63ab2..b791358f90fe92bc2264d9a26492245763813af3 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java
2021-10-05 20:52:03 +00:00
@@ -184,10 +184,9 @@ public abstract class Command {
2021-06-21 14:07:21 +00:00
return true;
2021-06-11 12:02:28 +00:00
}
2021-06-21 14:07:21 +00:00
- if (permissionMessage == null) {
2021-06-11 12:02:28 +00:00
- 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.");
2021-10-05 20:52:03 +00:00
// Paper start - use components for permissionMessage
- } else if (!permissionMessage.equals(net.kyori.adventure.text.Component.empty())) {
2022-06-10 00:03:05 +00:00
+ net.kyori.adventure.text.Component permissionMessage = this.permissionMessage != null ? this.permissionMessage : Bukkit.permissionMessage();
2021-10-05 20:52:03 +00:00
+ 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
}