2021-06-11 14:02:28 +02: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
2024-07-06 21:19:14 +02:00
index 28b86658aea14b33470508944d8626b23c65bba2..577b4b89b50441572f0edd9325047c38e25e782e 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
2024-07-06 21:19:14 +02:00
@@ -2421,6 +2421,28 @@ public final class Bukkit {
2021-06-11 14:02:28 +02:00
return server.suggestPlayerNamesWhenNullTabCompletions();
}
+ /**
2022-06-10 01:19:38 +02:00
+ * Gets the default no permission message used on the server
2021-06-11 14:02:28 +02:00
+ *
2022-06-10 01:19:38 +02:00
+ * @return the default message
+ * @deprecated use {@link #permissionMessage()}
2021-06-11 14:02:28 +02:00
+ */
+ @NotNull
2022-06-10 01:19:38 +02:00
+ @Deprecated
2021-06-11 14:02:28 +02:00
+ public static String getPermissionMessage() {
+ return server.getPermissionMessage();
+ }
2022-06-10 01:19:38 +02: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 14:02:28 +02:00
+
/**
2022-03-19 14:39:38 +01:00
* Creates a PlayerProfile for the specified uuid, with name as null.
*
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
2024-07-06 21:19:14 +02:00
index 5c6c9f714097dfaead0093d752f1b373b70a75eb..08f6f85388e4c3e3aae40f709109f8706a400675 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
2024-07-06 21:19:14 +02:00
@@ -2109,6 +2109,23 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
2021-06-11 14:02:28 +02:00
*/
boolean suggestPlayerNamesWhenNullTabCompletions();
+ /**
2022-06-09 23:11:43 +02:00
+ * Gets the default no permission message used on the server
2021-06-11 14:02:28 +02:00
+ *
2022-06-09 23:11:43 +02:00
+ * @return the default message
+ * @deprecated use {@link #permissionMessage()}
2021-06-11 14:02:28 +02:00
+ */
+ @NotNull
2022-06-09 23:11:43 +02:00
+ @Deprecated
2021-06-11 14:02:28 +02:00
+ String getPermissionMessage();
2022-06-09 23:11:43 +02: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 14:02:28 +02:00
+
/**
2022-03-19 14:39:38 +01:00
* Creates a PlayerProfile for the specified uuid, with name as null.
*
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
2024-07-21 04:40:41 +02:00
index 8a298b655f4eaf5116994f98572a20e83a23838c..03d2643d166824458c88a49f20270e93b14f3988 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java
2024-07-21 04:40:41 +02:00
@@ -192,10 +192,9 @@ public abstract class Command {
2021-06-21 16:07:21 +02:00
return true;
2021-06-11 14:02:28 +02:00
}
2021-06-21 16:07:21 +02:00
- if (permissionMessage == null) {
2021-06-11 14:02:28 +02: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 22:52:03 +02:00
// Paper start - use components for permissionMessage
- } else if (!permissionMessage.equals(net.kyori.adventure.text.Component.empty())) {
2022-06-10 02:03:05 +02:00
+ net.kyori.adventure.text.Component permissionMessage = this.permissionMessage != null ? this.permissionMessage : Bukkit.permissionMessage();
2021-10-05 22:52:03 +02: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
}