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
2021-10-05 05:14:11 +02:00
index 7a5ed3f1ff00ac689f570cd8c02fbd6c7beb7f44..a4b717250bf4800803b3173c2f2771b11777577f 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
2021-10-05 05:14:11 +02:00
@@ -1915,6 +1915,15 @@ public final class Bukkit {
2021-06-11 14:02:28 +02:00
return server.suggestPlayerNamesWhenNullTabCompletions();
}
+ /**
+ *
+ * @return the default no permission message used on the server
+ */
+ @NotNull
+ public static String getPermissionMessage() {
+ return server.getPermissionMessage();
+ }
+
/**
* Creates a PlayerProfile for the specified uuid, with name as null
* @param uuid UUID to create profile for
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
2021-10-05 05:14:11 +02:00
index 87690bd58bdab40edcfddc40b26acc8e1f8cf8fc..bb77ab2a93eb4242b2e66c679effc7e466ed6f6f 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
2021-10-05 05:14:11 +02:00
@@ -1684,6 +1684,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
2021-06-11 14:02:28 +02:00
*/
boolean suggestPlayerNamesWhenNullTabCompletions();
+ /**
+ *
+ * @return the default no permission message used on the server
+ */
+ @NotNull
+ String getPermissionMessage();
+
/**
* Creates a PlayerProfile for the specified uuid, with name as null
* @param uuid UUID to create profile for
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
2021-10-05 22:52:03 +02:00
index 91b08156172c12ea890e426958769a1eef8cd8d4..6161208cb5e862be0e7bf4ed0954a1558a0ac5b5 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
2021-10-05 22:52:03 +02:00
@@ -184,10 +184,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())) {
+ net.kyori.adventure.text.Component permissionMessage = this.permissionMessage != null ? this.permissionMessage : io.papermc.paper.text.PaperComponents.legacySectionSerializer().deserialize(Bukkit.getPermissionMessage());
+ 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
}