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
2021-11-24 01:09:49 +00:00
index 832b3f72c4a314dc0f38d412bdc999508f7d2b7b..80517b3bc7fe470c418cf9343c86b151ad9a702a 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
2021-11-24 01:09:49 +00:00
@@ -1947,6 +1947,15 @@ public final class Bukkit {
2021-06-11 12:02:28 +00: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-11-24 01:09:49 +00:00
index 58e347f771b85c6bfbb06690f6a80fffaf1538f6..2534560ccc8340500b71572ee6121df8ec06e154 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
2021-11-24 01:09:49 +00:00
@@ -1710,6 +1710,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
2021-06-11 12:02:28 +00: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-11-22 05:21:37 +00:00
index b1152f4dede61383232cc6713d448840612eac13..95847fcb1ac2e430ee192f4f7ac94e981151c5db 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())) {
+ 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
}