Adds a permission for registering placeholder signs
This commit is contained in:
parent
ea3f25e278
commit
e96c551121
@ -23,6 +23,8 @@ won't be changed unless the player passes all world protection checks.
|
|||||||
|
|
||||||
## Permissions
|
## Permissions
|
||||||
|
|
||||||
| Permission | Description |
|
| Permission | Description |
|
||||||
|-----------------------|-----------------------------------------|
|
|------------------------------|---------------------------------------------------------------------------------------------------------------|
|
||||||
| placeholdersigns.edit | Allows the use of the /editSign command |
|
| 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. |
|
@ -20,6 +20,11 @@ public class SignTextListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onSignCreate(SignChangeEvent event) {
|
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();
|
String[] lines = event.getLines();
|
||||||
Map<Integer, String> placeholders = new HashMap<>();
|
Map<Integer, String> placeholders = new HashMap<>();
|
||||||
|
|
||||||
@ -37,8 +42,8 @@ public class SignTextListener implements Listener {
|
|||||||
PlaceholderSignHandler signHandler = PlaceholderSigns.getInstance().getSignHandler();
|
PlaceholderSignHandler signHandler = PlaceholderSigns.getInstance().getSignHandler();
|
||||||
PlaceholderSign existingSign = signHandler.getFromLocation(location);
|
PlaceholderSign existingSign = signHandler.getFromLocation(location);
|
||||||
|
|
||||||
// Register the placeholder sign
|
|
||||||
if (!placeholders.isEmpty() && existingSign == null) {
|
if (!placeholders.isEmpty() && existingSign == null) {
|
||||||
|
// Register a new placeholder sign
|
||||||
PlaceholderSign placeholderSign = new PlaceholderSign(event.getBlock().getLocation(), placeholders);
|
PlaceholderSign placeholderSign = new PlaceholderSign(event.getBlock().getLocation(), placeholders);
|
||||||
signHandler.registerSign(placeholderSign);
|
signHandler.registerSign(placeholderSign);
|
||||||
} else if (!placeholders.isEmpty()) {
|
} else if (!placeholders.isEmpty()) {
|
||||||
|
@ -12,6 +12,14 @@ commands:
|
|||||||
description: Changes the line of a sign without a text limit
|
description: Changes the line of a sign without a text limit
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
placeholdersigns.*:
|
||||||
|
children:
|
||||||
|
- placeholdersigns.edit
|
||||||
|
- placeholdersigns.placeholder
|
||||||
|
default: op
|
||||||
placeholdersigns.edit:
|
placeholdersigns.edit:
|
||||||
description: Allows a player to use the /editSign command
|
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
|
Loading…
Reference in New Issue
Block a user