diff options
author | SoSeDiK <[email protected]> | 2024-08-18 00:36:27 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2024-08-17 14:36:27 -0700 |
commit | 64c9ee6584ce15e5b486bdc7183fe902e22fddf3 (patch) | |
tree | 2b65c982ba181417b84394353c2a7afd0e98ebd5 | |
parent | 44017487a81534067fd17e2d5e8669e61e19d719 (diff) | |
download | Paper-64c9ee6584ce15e5b486bdc7183fe902e22fddf3.tar.gz Paper-64c9ee6584ce15e5b486bdc7183fe902e22fddf3.zip |
Allow getting/setting the sign's editor uuid (#10637)
* Allow getting/setting the sign's editor uuid
* rebased
---------
Co-authored-by: Jake Potrebic <[email protected]>
-rw-r--r-- | patches/api/0399-More-Sign-Block-API.patch (renamed from patches/api/0399-Add-Sign-getInteractableSideFor.patch) | 35 | ||||
-rw-r--r-- | patches/server/0838-More-Sign-Block-API.patch (renamed from patches/server/0838-Add-Sign-getInteractableSideFor.patch) | 33 |
2 files changed, 53 insertions, 15 deletions
diff --git a/patches/api/0399-Add-Sign-getInteractableSideFor.patch b/patches/api/0399-More-Sign-Block-API.patch index 1e085323ca..57b372521c 100644 --- a/patches/api/0399-Add-Sign-getInteractableSideFor.patch +++ b/patches/api/0399-More-Sign-Block-API.patch @@ -1,18 +1,43 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <[email protected]> Date: Fri, 23 Jun 2023 12:16:35 -0700 -Subject: [PATCH] Add Sign#getInteractableSideFor +Subject: [PATCH] More Sign Block API +Co-authored-by: SoSeDiK <[email protected]> diff --git a/src/main/java/org/bukkit/block/Sign.java b/src/main/java/org/bukkit/block/Sign.java -index 1fdb1144949adc3a2b5cbc3aca94d2f8e0c6d9ee..7983ccb54f5f358dea1ffb530b9cc5bd716fb9b1 100644 +index 1fdb1144949adc3a2b5cbc3aca94d2f8e0c6d9ee..340e3adcc57227f2e570826681ea81b9159805de 100644 --- a/src/main/java/org/bukkit/block/Sign.java +++ b/src/main/java/org/bukkit/block/Sign.java -@@ -187,4 +187,34 @@ public interface Sign extends TileState, Colorable { +@@ -182,9 +182,58 @@ public interface Sign extends TileState, Colorable { + /** + * Gets the player that is currently allowed to edit this sign. <br> + * Edits from other players will be rejected if this value is not null. ++ * <br><br>You should prefer {@link #getAllowedEditorUniqueId()} if you don't ++ * need the player instance as this method will fetch the player from UUID. + * + * @return the player allowed to edit this sign, or null */ @Nullable public Player getAllowedEditor(); -+ // Paper start - get side for player ++ // Paper start - More Sign Block API ++ /** ++ * Gets the allowed editor's UUID. ++ * <br>Edits from other players will be rejected if this value is not null. ++ * ++ * @return the allowed editor's UUID, or null ++ */ ++ @Nullable java.util.UUID getAllowedEditorUniqueId(); ++ ++ /** ++ * Sets the allowed editor's UUID. ++ * <br><br><b>Note:</b> the server sets the UUID back to null if the player can't ++ * interact with the sign (is either offline or outside the allowed interaction range). ++ * ++ * @param uuid the allowed editor's UUID ++ */ ++ void setAllowedEditorUniqueId(@Nullable java.util.UUID uuid); ++ + /** + * Compute the side facing the specified entity. + * @@ -41,5 +66,5 @@ index 1fdb1144949adc3a2b5cbc3aca94d2f8e0c6d9ee..7983ccb54f5f358dea1ffb530b9cc5bd + * @return the side the coordinates are facing + */ + @NotNull Side getInteractableSideFor(double x, double z); -+ // Paper end ++ // Paper end - More Sign Block API } diff --git a/patches/server/0838-Add-Sign-getInteractableSideFor.patch b/patches/server/0838-More-Sign-Block-API.patch index 2833829ce4..3be6f4e353 100644 --- a/patches/server/0838-Add-Sign-getInteractableSideFor.patch +++ b/patches/server/0838-More-Sign-Block-API.patch @@ -1,48 +1,61 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <[email protected]> Date: Fri, 23 Jun 2023 12:16:28 -0700 -Subject: [PATCH] Add Sign#getInteractableSideFor +Subject: [PATCH] More Sign Block API +Co-authored-by: SoSeDiK <[email protected]> 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 -index bfe8029852385875af4ebe73c63e688f61042021..a28be7a332659be655f419d969e0c64e659b6c21 100644 +index bfe8029852385875af4ebe73c63e688f61042021..3070cd2b588f5a69fd8c0d3551e16251680d8c27 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java @@ -68,12 +68,17 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C } public boolean isFacingFrontText(net.minecraft.world.entity.player.Player player) { -+ // Paper start - Add Sign#getInteractableSideFor ++ // Paper start - More Sign Block API + return this.isFacingFrontText(player.getX(), player.getZ()); + } + public boolean isFacingFrontText(double x, double z) { -+ // Paper end - Add Sign#getInteractableSideFor ++ // Paper end - More Sign Block API Block block = this.getBlockState().getBlock(); if (block instanceof SignBlock blocksign) { Vec3 vec3d = blocksign.getSignHitboxCenterPosition(this.getBlockState()); - double d0 = player.getX() - ((double) this.getBlockPos().getX() + vec3d.x); - double d1 = player.getZ() - ((double) this.getBlockPos().getZ() + vec3d.z); -+ double d0 = x - ((double) this.getBlockPos().getX() + vec3d.x); // Paper - Add Sign#getInteractableSideFor -+ double d1 = z - ((double) this.getBlockPos().getZ() + vec3d.z); // Paper - Add Sign#getInteractableSideFor ++ double d0 = x - ((double) this.getBlockPos().getX() + vec3d.x); // Paper - More Sign Block API ++ double d1 = z - ((double) this.getBlockPos().getZ() + vec3d.z); // Paper - More Sign Block API float f = blocksign.getYRotationDegrees(this.getBlockState()); float f1 = (float) (Mth.atan2(d1, d0) * 57.2957763671875D) - 90.0F; diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java -index 8303343ecca91076839f4436d6b3a3bf4739c2fd..cefbb015a77b9e3cab56e5ed4fe35fba91641632 100644 +index 8303343ecca91076839f4436d6b3a3bf4739c2fd..e3c333d26dea9af9dd51e1662f81f1d472ab0233 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java -@@ -198,6 +198,14 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState< +@@ -198,6 +198,26 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState< } // Paper end -+ // Paper start - side facing API ++ // Paper start - More Sign Block API ++ @Override ++ public java.util.UUID getAllowedEditorUniqueId() { ++ this.ensureNoWorldGeneration(); ++ return this.getTileEntity().getPlayerWhoMayEdit(); ++ } ++ ++ @Override ++ public void setAllowedEditorUniqueId(java.util.UUID uuid) { ++ this.ensureNoWorldGeneration(); ++ this.getTileEntity().setAllowedPlayerEditor(uuid); ++ } ++ + @Override + public Side getInteractableSideFor(final double x, final double z) { + this.requirePlaced(); + return this.getSnapshot().isFacingFrontText(x, z) ? Side.FRONT : Side.BACK; + } -+ // Paper end ++ // Paper end - More Sign Block API + public static Component[] sanitizeLines(String[] lines) { Component[] components = new Component[4]; |