Adds a permission for registering placeholder signs

This commit is contained in:
Kristian Knarvik 2023-04-05 22:12:53 +02:00
parent ea3f25e278
commit e96c551121
3 changed files with 20 additions and 5 deletions

View File

@ -23,6 +23,8 @@ won't be changed unless the player passes all world protection checks.
## Permissions
| Permission | Description |
|-----------------------|-----------------------------------------|
| placeholdersigns.edit | Allows the use of the /editSign command |
| Permission | Description |
|------------------------------|---------------------------------------------------------------------------------------------------------------|
| placeholdersigns.* | Gives all permissions. |
| placeholdersigns.edit | Allows the use of the /editSign command. |
| placeholdersigns.placeholder | Allows a player to make signs containing placeholders. Without this, placeholders are treated as normal text. |

View File

@ -20,6 +20,11 @@ public class SignTextListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSignCreate(SignChangeEvent event) {
// Only check for placeholders if the player is allowed to
if (!event.getPlayer().hasPermission("placeholdersigns.placeholder")) {
return;
}
String[] lines = event.getLines();
Map<Integer, String> placeholders = new HashMap<>();
@ -37,8 +42,8 @@ public class SignTextListener implements Listener {
PlaceholderSignHandler signHandler = PlaceholderSigns.getInstance().getSignHandler();
PlaceholderSign existingSign = signHandler.getFromLocation(location);
// Register the placeholder sign
if (!placeholders.isEmpty() && existingSign == null) {
// Register a new placeholder sign
PlaceholderSign placeholderSign = new PlaceholderSign(event.getBlock().getLocation(), placeholders);
signHandler.registerSign(placeholderSign);
} else if (!placeholders.isEmpty()) {

View File

@ -12,6 +12,14 @@ commands:
description: Changes the line of a sign without a text limit
permissions:
placeholdersigns.*:
children:
- placeholdersigns.edit
- placeholdersigns.placeholder
default: op
placeholdersigns.edit:
description: Allows a player to use the /editSign command
default: op
default: false
placeholdersigns.placeholder:
description: Allows a player to make signs containing placeholders
default: false