geforkt von Mirrors/Paper
[Bleeding] Implemented customizable permission messages.
By: Wesley Wolfe <weswolf@aol.com>
Dieser Commit ist enthalten in:
Ursprung
3dadfe5e85
Commit
0293f10d23
@ -21,6 +21,7 @@ public abstract class Command {
|
|||||||
protected String description = "";
|
protected String description = "";
|
||||||
protected String usageMessage;
|
protected String usageMessage;
|
||||||
private String permission;
|
private String permission;
|
||||||
|
private String permissionMessage;
|
||||||
|
|
||||||
protected Command(String name) {
|
protected Command(String name) {
|
||||||
this(name, "", "/" + name, new ArrayList<String>());
|
this(name, "", "/" + name, new ArrayList<String>());
|
||||||
@ -86,7 +87,14 @@ public abstract class Command {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 in error.");
|
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 in error.");
|
||||||
|
} else if (permissionMessage.length() != 0) {
|
||||||
|
for (String line : permissionMessage.replace("<permission>", permission).split("\n")) {
|
||||||
|
target.sendMessage(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,6 +179,15 @@ public abstract class Command {
|
|||||||
return activeAliases;
|
return activeAliases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a message to be displayed on a failed permission check for this command
|
||||||
|
*
|
||||||
|
* @return Permission check failed message
|
||||||
|
*/
|
||||||
|
public String getPermissionMessage() {
|
||||||
|
return permissionMessage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a brief description of this command
|
* Gets a brief description of this command
|
||||||
*
|
*
|
||||||
@ -214,6 +231,17 @@ public abstract class Command {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the message sent when a permission check fails
|
||||||
|
*
|
||||||
|
* @param permissionMessage New permission message, null to indicate default message, or an empty string to indicate no message
|
||||||
|
* @return This command object, for linking
|
||||||
|
*/
|
||||||
|
public Command setPermissionMessage(String permissionMessage) {
|
||||||
|
this.permissionMessage = permissionMessage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the example usage of this command
|
* Sets the example usage of this command
|
||||||
*
|
*
|
||||||
|
@ -27,6 +27,7 @@ public class PluginCommandYamlParser {
|
|||||||
Object usage = entry.getValue().get("usage");
|
Object usage = entry.getValue().get("usage");
|
||||||
Object aliases = entry.getValue().get("aliases");
|
Object aliases = entry.getValue().get("aliases");
|
||||||
Object permission = entry.getValue().get("permission");
|
Object permission = entry.getValue().get("permission");
|
||||||
|
Object permissionMessage = entry.getValue().get("permission-message");
|
||||||
|
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
newCmd.setDescription(description.toString());
|
newCmd.setDescription(description.toString());
|
||||||
@ -54,6 +55,10 @@ public class PluginCommandYamlParser {
|
|||||||
newCmd.setPermission(permission.toString());
|
newCmd.setPermission(permission.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (permissionMessage != null) {
|
||||||
|
newCmd.setPermissionMessage(permissionMessage.toString());
|
||||||
|
}
|
||||||
|
|
||||||
pluginCmds.add(newCmd);
|
pluginCmds.add(newCmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren