Makes some 1.20 changes
Updates spigot version Updates depreciated sign code Adds a new permission for editing waxed signs
This commit is contained in:
parent
837eac46b7
commit
82032dbbbc
12
README.md
12
README.md
@ -23,8 +23,10 @@ won't be changed unless the player passes all world protection checks.
|
||||
|
||||
## Permissions
|
||||
|
||||
| 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. |
|
||||
| Permission | Description |
|
||||
|------------------------------------|---------------------------------------------------------------------------------------------------------------|
|
||||
| placeholdersigns.* | Gives all permissions. |
|
||||
| placeholdersigns.edit | Allows unrestricted use of the /editSign command. |
|
||||
| placeholdersigns.edit.use | Allows use of the /editSign command. |
|
||||
| placeholdersigns.edit.bypass-waxed | Allows use of the /editSign command on a waxed sign. |
|
||||
| placeholdersigns.placeholder | Allows a player to make signs containing placeholders. Without this, placeholders are treated as normal text. |
|
4
pom.xml
4
pom.xml
@ -62,7 +62,7 @@
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<id>placeholder-api</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
@ -82,7 +82,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -12,6 +12,7 @@ import net.knarcraft.placeholdersigns.util.ColorHelper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.sign.Side;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -130,10 +131,10 @@ public final class PlaceholderSigns extends JavaPlugin {
|
||||
|
||||
// Update placeholders
|
||||
Map<Integer, String> placeholders = placeholderSign.placeholders();
|
||||
String[] lines = sign.getLines();
|
||||
String[] lines = sign.getSide(Side.FRONT).getLines();
|
||||
boolean updateRequired = false;
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String oldText = sign.getLine(i);
|
||||
String oldText = sign.getSide(Side.FRONT).getLine(i);
|
||||
|
||||
// The new text of the sign is either the same, or the original placeholder
|
||||
String newText;
|
||||
@ -148,7 +149,7 @@ public final class PlaceholderSigns extends JavaPlugin {
|
||||
|
||||
// Only change the line if the text has changed
|
||||
if (!newText.equals(oldText)) {
|
||||
sign.setLine(i, newText);
|
||||
sign.getSide(Side.FRONT).setLine(i, newText);
|
||||
updateRequired = true;
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,11 @@ package net.knarcraft.placeholdersigns.listener;
|
||||
import net.knarcraft.placeholdersigns.PlaceholderSigns;
|
||||
import net.knarcraft.placeholdersigns.container.LineChangeRequest;
|
||||
import net.knarcraft.placeholdersigns.util.ColorHelper;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.sign.Side;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -24,18 +27,23 @@ public class SignClickListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (sign.isWaxed() && !player.hasPermission("placeholdersigns.edit.bypass-waxed")) {
|
||||
player.sendMessage(ChatColor.RED + "You do not have the necessary permissions to edit a waxed sign.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the player has run the /editSign command
|
||||
LineChangeRequest request = PlaceholderSigns.getInstance().getChangeRequest(event.getPlayer());
|
||||
LineChangeRequest request = PlaceholderSigns.getInstance().getChangeRequest(player);
|
||||
if (request == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String[] lines = sign.getLines();
|
||||
String[] lines = sign.getSide(Side.FRONT).getLines();
|
||||
lines[request.line()] = request.text();
|
||||
|
||||
// Run the sign change event to allow protection plugins to cancel, and allow the sign text listener to trigger
|
||||
SignChangeEvent changeEvent = new SignChangeEvent(event.getClickedBlock(), event.getPlayer(), lines);
|
||||
SignChangeEvent changeEvent = new SignChangeEvent(event.getClickedBlock(), player, lines, Side.FRONT);
|
||||
Bukkit.getPluginManager().callEvent(changeEvent);
|
||||
if (changeEvent.isCancelled()) {
|
||||
return;
|
||||
@ -44,11 +52,11 @@ public class SignClickListener implements Listener {
|
||||
// Update the sign with the new text
|
||||
String[] finalLines = changeEvent.getLines();
|
||||
for (int i = 0; i < finalLines.length; i++) {
|
||||
sign.setLine(i, ColorHelper.translateAllColorCodes(finalLines[i]));
|
||||
sign.getSide(Side.FRONT).setLine(i, ColorHelper.translateAllColorCodes(finalLines[i]));
|
||||
}
|
||||
sign.update();
|
||||
|
||||
event.getPlayer().sendMessage("The sign line was successfully changed.");
|
||||
player.sendMessage("The sign line was successfully changed.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: PlaceholderSigns
|
||||
version: '${project.version}'
|
||||
main: net.knarcraft.placeholdersigns.PlaceholderSigns
|
||||
api-version: 1.19
|
||||
api-version: '1.20'
|
||||
depend:
|
||||
- PlaceholderAPI
|
||||
|
||||
@ -18,8 +18,17 @@ permissions:
|
||||
- placeholdersigns.placeholder
|
||||
default: op
|
||||
placeholdersigns.edit:
|
||||
description: Allows a player to use the /editSign command without restriction
|
||||
default: false
|
||||
children:
|
||||
- placeholdersigns.edit.use
|
||||
- placeholdersigns.edit.bypass-waxed
|
||||
placeholdersigns.edit.use:
|
||||
description: Allows a player to use the /editSign command
|
||||
default: false
|
||||
placeholdersigns.edit.bypass-waxed:
|
||||
description: Allows a player to use the /editSign command on a waxed sign
|
||||
default: false
|
||||
placeholdersigns.placeholder:
|
||||
description: Allows a player to make signs containing placeholders
|
||||
default: false
|
Loading…
Reference in New Issue
Block a user