Skip to content

Commit f8ad1f5

Browse files
committed
(api) add lock signEditLockTagKey to make plugin able to tag sign as unchangeable
1 parent f4beb76 commit f8ad1f5

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>cat.nyaa</groupId>
88
<artifactId>ukit</artifactId>
9-
<version>1.7</version>
9+
<version>1.7.1</version>
1010

1111
<properties>
1212
<maven.compiler.source>21</maven.compiler.source>

src/main/java/cat/nyaa/ukit/api/UKitAPI.java

+2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import cat.nyaa.ukit.SpigotLoader;
44
import cat.nyaa.ukit.loginpush.LoginPushRecorder;
55
import net.kyori.adventure.text.Component;
6+
import org.bukkit.NamespacedKey;
67

78
import java.sql.SQLException;
89
import java.util.UUID;
910

1011
public class UKitAPI {
1112
private final SpigotLoader pluginInstance;
1213
private final LoginPushRecorder loginPushRecorder;
14+
public static final NamespacedKey signEditLockTagKey = new NamespacedKey("ukit", "sign_tagged_unchangeable");
1315
private static UKitAPI instance;
1416

1517
public UKitAPI(SpigotLoader pluginInstance, LoginPushRecorder loginPushRecorder) {

src/main/java/cat/nyaa/ukit/signedit/SignEditFunction.java

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cat.nyaa.ukit.signedit;
22

33
import cat.nyaa.ukit.SpigotLoader;
4+
import cat.nyaa.ukit.api.UKitAPI;
45
import cat.nyaa.ukit.utils.LockettePluginUtils;
56
import cat.nyaa.ukit.utils.SubCommandExecutor;
67
import cat.nyaa.ukit.utils.SubTabCompleter;
@@ -52,6 +53,10 @@ public boolean invokeCommand(CommandSender commandSender, Command command, Strin
5253
commandSender.sendMessage(pluginInstance.language.signEditLang.cantModifyLockSign.produce());
5354
return true;
5455
}
56+
if (taggedAsUnchangeable(sign)) {
57+
commandSender.sendMessage(pluginInstance.language.signEditLang.signTaggedAsUnchangeable.produce());
58+
return true;
59+
}
5560
int line;
5661
try {
5762
line = Integer.parseInt(args[0]);
@@ -104,6 +109,10 @@ private boolean inInSpawnProtection(Location location) {
104109
return location.toVector().subtract(location.getWorld().getSpawnLocation().toVector()).length() <= pluginInstance.getServer().getSpawnRadius();
105110
}
106111

112+
private boolean taggedAsUnchangeable(Sign sign) {
113+
return sign.getPersistentDataContainer().has(UKitAPI.signEditLockTagKey);
114+
}
115+
107116
@Override
108117
public String getHelp() {
109118
return pluginInstance.language.signEditLang.help.produce(
@@ -130,6 +139,9 @@ public List<String> tabComplete(CommandSender sender, Command command, String al
130139
if (LockettePluginUtils.isLockSign(targetBlock)) {
131140
return List.of();
132141
}
142+
if (taggedAsUnchangeable(sign)) {
143+
return List.of();
144+
}
133145
var lookingSide = Utils.getSignSideLookingAt(player, sign);
134146
var signSide = sign.getSide(lookingSide);
135147
var suggestion = signSide.getLine(line - 1).replaceAll("&", "§§").replaceAll("§", "&");

src/main/java/cat/nyaa/ukit/signedit/SignEditLang.java

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class SignEditLang {
1111
public Text notASign = Text.of("&cThe block which you are looking at is not a sign");
1212

1313
public Text cantModifyLockSign = Text.of("&cLock sign couldn't be modified");
14+
public Text signTaggedAsUnchangeable = Text.of("&cThis sign has tagged as unchangeable");
1415

1516
public Text modifyCancelled = Text.of("&cThis sign couldn't be modified due to server side configuration");
1617
public Text invalidLineNumber = Text.of("&c{input} is not a valid line number, it should be a number between 1 and 4");

0 commit comments

Comments
 (0)