Now uses _ for space, and \_ for underscore in descriptions
This commit is contained in:
parent
c9d0907b2f
commit
fee287f884
@ -25,10 +25,10 @@ permanently by another cause) when they expire.
|
|||||||
|
|
||||||
/ps create <name> <description> <permission,permission> <cost> <duration> - Creates a new permission sign. The name is
|
/ps create <name> <description> <permission,permission> <cost> <duration> - Creates a new permission sign. The name is
|
||||||
used to describe what the permission sign does, and is displayed on the sign. The description is used to describe what
|
used to describe what the permission sign does, and is displayed on the sign. The description is used to describe what
|
||||||
the permission sign does, but without any limit on the length (use "\_" between words, like: This\_is\_a\_sentence). The
|
the permission sign does, but without any limit on the length (use "_" between words, like: This_is_a_sentence). To use
|
||||||
permission,permission is the list of comma-separated permissions the permission sign will grant to the using player. The
|
actual underscores, escape them like "\_". The permission,permission is the list of comma-separated permissions the
|
||||||
cost is the cost to use the permission sign. The duration is the number of seconds the player should keep the permission
|
permission sign will grant to the using player. The cost is the cost to use the permission sign. The duration is the
|
||||||
for. Use 0 for permanent.
|
number of seconds the player should keep the permission for. Use 0 for permanent.
|
||||||
|
|
||||||
#### The create command permission list
|
#### The create command permission list
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class CreateCommand implements CommandExecutor {
|
|||||||
*/
|
*/
|
||||||
private PermissionSign parseSign(@NotNull CommandSender sender, @NotNull String[] args) {
|
private PermissionSign parseSign(@NotNull CommandSender sender, @NotNull String[] args) {
|
||||||
String name = args[0];
|
String name = args[0];
|
||||||
String description = args[1].replaceAll("\\\\_", " ");
|
String description = replaceUnderscoresWithSpaces(args[1]);
|
||||||
String[] permissions = args[2].replaceAll("\\?", " ").split(",");
|
String[] permissions = args[2].replaceAll("\\?", " ").split(",");
|
||||||
for (String permission : permissions) {
|
for (String permission : permissions) {
|
||||||
if (permission.contains(":")) {
|
if (permission.contains(":")) {
|
||||||
@ -93,4 +93,20 @@ public class CreateCommand implements CommandExecutor {
|
|||||||
return new PermissionSign(name, description, List.of(permissions), duration, cost);
|
return new PermissionSign(name, description, List.of(permissions), duration, cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces underscores with spaces in the given description
|
||||||
|
*
|
||||||
|
* <p>This basically replaces all underscores with spaces, but keeps escaped underscores (\_) as underscores.</p>
|
||||||
|
*
|
||||||
|
* @param description <p>The description to replace underscores in</p>
|
||||||
|
* @return <p>The string with underscores replaced</p>
|
||||||
|
*/
|
||||||
|
private String replaceUnderscoresWithSpaces(String description) {
|
||||||
|
String temporaryString = "\\|ESCAPED-UNDERSCORE\\|";
|
||||||
|
description = description.replaceAll("\\\\_", temporaryString);
|
||||||
|
description = description.replaceAll("_", " ");
|
||||||
|
description = description.replaceAll(temporaryString, "_");
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user