Skip to content

Commit 64c9ee6

Browse files
Allow getting/setting the sign's editor uuid (#10637)
* Allow getting/setting the sign's editor uuid * rebased --------- Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
1 parent 4401748 commit 64c9ee6

File tree

2 files changed

+53
-15
lines changed

2 files changed

+53
-15
lines changed

patches/api/0399-Add-Sign-getInteractableSideFor.patch renamed to patches/api/0399-More-Sign-Block-API.patch

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: Jake Potrebic <jake.m.potrebic@gmail.com>
33
Date: Fri, 23 Jun 2023 12:16:35 -0700
4-
Subject: [PATCH] Add Sign#getInteractableSideFor
4+
Subject: [PATCH] More Sign Block API
55

6+
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
67

78
diff --git a/src/main/java/org/bukkit/block/Sign.java b/src/main/java/org/bukkit/block/Sign.java
8-
index 1fdb1144949adc3a2b5cbc3aca94d2f8e0c6d9ee..7983ccb54f5f358dea1ffb530b9cc5bd716fb9b1 100644
9+
index 1fdb1144949adc3a2b5cbc3aca94d2f8e0c6d9ee..340e3adcc57227f2e570826681ea81b9159805de 100644
910
--- a/src/main/java/org/bukkit/block/Sign.java
1011
+++ b/src/main/java/org/bukkit/block/Sign.java
11-
@@ -187,4 +187,34 @@ public interface Sign extends TileState, Colorable {
12+
@@ -182,9 +182,58 @@ public interface Sign extends TileState, Colorable {
13+
/**
14+
* Gets the player that is currently allowed to edit this sign. <br>
15+
* Edits from other players will be rejected if this value is not null.
16+
+ * <br><br>You should prefer {@link #getAllowedEditorUniqueId()} if you don't
17+
+ * need the player instance as this method will fetch the player from UUID.
18+
*
19+
* @return the player allowed to edit this sign, or null
1220
*/
1321
@Nullable
1422
public Player getAllowedEditor();
15-
+ // Paper start - get side for player
23+
+ // Paper start - More Sign Block API
24+
+ /**
25+
+ * Gets the allowed editor's UUID.
26+
+ * <br>Edits from other players will be rejected if this value is not null.
27+
+ *
28+
+ * @return the allowed editor's UUID, or null
29+
+ */
30+
+ @Nullable java.util.UUID getAllowedEditorUniqueId();
31+
+
32+
+ /**
33+
+ * Sets the allowed editor's UUID.
34+
+ * <br><br><b>Note:</b> the server sets the UUID back to null if the player can't
35+
+ * interact with the sign (is either offline or outside the allowed interaction range).
36+
+ *
37+
+ * @param uuid the allowed editor's UUID
38+
+ */
39+
+ void setAllowedEditorUniqueId(@Nullable java.util.UUID uuid);
40+
+
1641
+ /**
1742
+ * Compute the side facing the specified entity.
1843
+ *
@@ -41,5 +66,5 @@ index 1fdb1144949adc3a2b5cbc3aca94d2f8e0c6d9ee..7983ccb54f5f358dea1ffb530b9cc5bd
4166
+ * @return the side the coordinates are facing
4267
+ */
4368
+ @NotNull Side getInteractableSideFor(double x, double z);
44-
+ // Paper end
69+
+ // Paper end - More Sign Block API
4570
}

patches/server/0838-Add-Sign-getInteractableSideFor.patch renamed to patches/server/0838-More-Sign-Block-API.patch

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,61 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: Jake Potrebic <jake.m.potrebic@gmail.com>
33
Date: Fri, 23 Jun 2023 12:16:28 -0700
4-
Subject: [PATCH] Add Sign#getInteractableSideFor
4+
Subject: [PATCH] More Sign Block API
55

6+
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
67

78
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
8-
index bfe8029852385875af4ebe73c63e688f61042021..a28be7a332659be655f419d969e0c64e659b6c21 100644
9+
index bfe8029852385875af4ebe73c63e688f61042021..3070cd2b588f5a69fd8c0d3551e16251680d8c27 100644
910
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
1011
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
1112
@@ -68,12 +68,17 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
1213
}
1314

1415
public boolean isFacingFrontText(net.minecraft.world.entity.player.Player player) {
15-
+ // Paper start - Add Sign#getInteractableSideFor
16+
+ // Paper start - More Sign Block API
1617
+ return this.isFacingFrontText(player.getX(), player.getZ());
1718
+ }
1819
+ public boolean isFacingFrontText(double x, double z) {
19-
+ // Paper end - Add Sign#getInteractableSideFor
20+
+ // Paper end - More Sign Block API
2021
Block block = this.getBlockState().getBlock();
2122

2223
if (block instanceof SignBlock blocksign) {
2324
Vec3 vec3d = blocksign.getSignHitboxCenterPosition(this.getBlockState());
2425
- double d0 = player.getX() - ((double) this.getBlockPos().getX() + vec3d.x);
2526
- double d1 = player.getZ() - ((double) this.getBlockPos().getZ() + vec3d.z);
26-
+ double d0 = x - ((double) this.getBlockPos().getX() + vec3d.x); // Paper - Add Sign#getInteractableSideFor
27-
+ double d1 = z - ((double) this.getBlockPos().getZ() + vec3d.z); // Paper - Add Sign#getInteractableSideFor
27+
+ double d0 = x - ((double) this.getBlockPos().getX() + vec3d.x); // Paper - More Sign Block API
28+
+ double d1 = z - ((double) this.getBlockPos().getZ() + vec3d.z); // Paper - More Sign Block API
2829
float f = blocksign.getYRotationDegrees(this.getBlockState());
2930
float f1 = (float) (Mth.atan2(d1, d0) * 57.2957763671875D) - 90.0F;
3031

3132
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
32-
index 8303343ecca91076839f4436d6b3a3bf4739c2fd..cefbb015a77b9e3cab56e5ed4fe35fba91641632 100644
33+
index 8303343ecca91076839f4436d6b3a3bf4739c2fd..e3c333d26dea9af9dd51e1662f81f1d472ab0233 100644
3334
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
3435
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
35-
@@ -198,6 +198,14 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState<
36+
@@ -198,6 +198,26 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState<
3637
}
3738
// Paper end
3839

39-
+ // Paper start - side facing API
40+
+ // Paper start - More Sign Block API
41+
+ @Override
42+
+ public java.util.UUID getAllowedEditorUniqueId() {
43+
+ this.ensureNoWorldGeneration();
44+
+ return this.getTileEntity().getPlayerWhoMayEdit();
45+
+ }
46+
+
47+
+ @Override
48+
+ public void setAllowedEditorUniqueId(java.util.UUID uuid) {
49+
+ this.ensureNoWorldGeneration();
50+
+ this.getTileEntity().setAllowedPlayerEditor(uuid);
51+
+ }
52+
+
4053
+ @Override
4154
+ public Side getInteractableSideFor(final double x, final double z) {
4255
+ this.requirePlaced();
4356
+ return this.getSnapshot().isFacingFrontText(x, z) ? Side.FRONT : Side.BACK;
4457
+ }
45-
+ // Paper end
58+
+ // Paper end - More Sign Block API
4659
+
4760
public static Component[] sanitizeLines(String[] lines) {
4861
Component[] components = new Component[4];

0 commit comments

Comments
 (0)