Updates for 1.20
All checks were successful
EpicKnarvik97/PermissionSigns/pipeline/head This commit looks good
KnarCraft/PermissionSigns/pipeline/head This commit looks good

Updates Spigot version
Changes API version to 1.20
Updates depreciated sign code
Waxes new permission signs
This commit is contained in:
Kristian Knarvik 2023-06-23 20:41:17 +02:00
parent 4c47332c98
commit 18642fc046
4 changed files with 15 additions and 7 deletions

View File

@ -73,13 +73,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.0.0</version>
<version>24.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -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 <p>The player that interacted with the sign</p>
*/
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));
}

View File

@ -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) {

View File

@ -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 ]