mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-26 19:07:40 +01:00
Make the default permission message configurable
This commit is contained in:
parent
7b3013d59b
commit
d9195b0be3
@ -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.
|
||||
*
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user