From 18642fc046790eeea2003db6c85f583bbfcde512 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Fri, 23 Jun 2023 20:41:17 +0200 Subject: [PATCH] Updates for 1.20 Updates Spigot version Changes API version to 1.20 Updates depreciated sign code Waxes new permission signs --- pom.xml | 4 ++-- .../knarcraft/permissionsigns/listener/SignListener.java | 8 ++++++-- .../knarcraft/permissionsigns/manager/SignManager.java | 8 ++++++-- src/main/resources/plugin.yml | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 290b8cd..1919568 100644 --- a/pom.xml +++ b/pom.xml @@ -73,13 +73,13 @@ org.spigotmc spigot-api - 1.19.2-R0.1-SNAPSHOT + 1.20.1-R0.1-SNAPSHOT provided org.jetbrains annotations - 23.0.0 + 24.0.1 compile diff --git a/src/main/java/net/knarcraft/permissionsigns/listener/SignListener.java b/src/main/java/net/knarcraft/permissionsigns/listener/SignListener.java index 72b53b2..2af48b7 100644 --- a/src/main/java/net/knarcraft/permissionsigns/listener/SignListener.java +++ b/src/main/java/net/knarcraft/permissionsigns/listener/SignListener.java @@ -14,6 +14,8 @@ import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.Sign; +import org.bukkit.block.sign.Side; +import org.bukkit.block.sign.SignSide; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -194,7 +196,8 @@ public class SignListener implements Listener { * @param player

The player that interacted with the sign

*/ private void registerPermissionSign(Sign sign, SignCreationRequest request, Player player) { - String[] lines = sign.getLines(); + SignSide frontSide = sign.getSide(Side.FRONT); + String[] lines = frontSide.getLines(); //Don't allow non-empty signs to be overwritten if (!Arrays.stream(lines).allMatch(String::isEmpty)) { return; @@ -209,8 +212,9 @@ public class SignListener implements Listener { //Display the permission sign information on the sign String[] signLines = permissionSign.getSignLines(); for (int i = 0; i < signLines.length; i++) { - sign.setLine(i, signLines[i]); + frontSide.setLine(i, signLines[i]); } + sign.setWaxed(true); sign.update(); player.sendMessage(StringFormatter.getTranslatedInfoMessage(TranslatableMessage.PERMISSION_SIGN_CREATED)); } diff --git a/src/main/java/net/knarcraft/permissionsigns/manager/SignManager.java b/src/main/java/net/knarcraft/permissionsigns/manager/SignManager.java index 67cd763..133af72 100644 --- a/src/main/java/net/knarcraft/permissionsigns/manager/SignManager.java +++ b/src/main/java/net/knarcraft/permissionsigns/manager/SignManager.java @@ -7,6 +7,8 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Sign; +import org.bukkit.block.sign.Side; +import org.bukkit.block.sign.SignSide; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; @@ -127,12 +129,14 @@ public final class SignManager { continue; } String[] newLines = permissionSign.getSignLines(); - if (Arrays.equals(sign.getLines(), newLines)) { + SignSide frontSide = sign.getSide(Side.FRONT); + if (Arrays.equals(frontSide.getLines(), newLines)) { continue; } for (int i = 0; i < 4; i++) { - sign.setLine(i, newLines[i]); + frontSide.setLine(i, newLines[i]); } + sign.setWaxed(true); sign.update(); } for (Location signLocation : invalidPermissionSigns) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 870d4f4..dac0968 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: PermissionSigns version: 1.0.4 main: net.knarcraft.permissionsigns.PermissionSigns -api-version: 1.18 +api-version: '1.20' prefix: PermissionSigns depend: [ Vault ] authors: [ EpicKnarvik97 ]