13
0
geforkt von Mirrors/Paper

add side to PlayerSignCommandPreprocessEvent

Dieser Commit ist enthalten in:
Jake Potrebic 2023-06-08 22:57:24 -07:00
Ursprung 9ebf75d894
Commit f9fc44ff9f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: ECE0B3C133C016C5
3 geänderte Dateien mit 25 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -6,21 +6,23 @@ Subject: [PATCH] Add PlayerSignCommandPreprocessEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerSignCommandPreprocessEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerSignCommandPreprocessEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerSignCommandPreprocessEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerSignCommandPreprocessEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..a51a2288bf812e7d8845a6ec70274d625ff793b6 index 0000000000000000000000000000000000000000..6e539aee02fd5399e6b8f064a3ea368c12a54a53
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerSignCommandPreprocessEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerSignCommandPreprocessEvent.java
@@ -0,0 +1,34 @@ @@ -0,0 +1,47 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import org.bukkit.block.Sign; +import org.bukkit.block.Sign;
+import org.bukkit.block.sign.Side;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+import java.util.Set; +import java.util.Set;
+ +
+/** +/**
+ * Called when a {@link Player} clicks a sign that causes a command to run. + * Called when a {@link Player} clicks a side on a sign that causes a command to run.
+ * <p> + * <p>
+ * This command is run with elevated permissions which allows players to access commands on signs they wouldn't + * This command is run with elevated permissions which allows players to access commands on signs they wouldn't
+ * normally be able to run. + * normally be able to run.
@ -28,10 +30,13 @@ index 0000000000000000000000000000000000000000..a51a2288bf812e7d8845a6ec70274d62
+public class PlayerSignCommandPreprocessEvent extends PlayerCommandPreprocessEvent { +public class PlayerSignCommandPreprocessEvent extends PlayerCommandPreprocessEvent {
+ +
+ private final Sign sign; + private final Sign sign;
+ private final Side side;
+ +
+ public PlayerSignCommandPreprocessEvent(@NotNull Player player, @NotNull String message, @NotNull Set<Player> recipients, @NotNull Sign sign) { + @ApiStatus.Internal
+ public PlayerSignCommandPreprocessEvent(@NotNull Player player, @NotNull String message, @NotNull Set<Player> recipients, @NotNull Sign sign, final Side side) {
+ super(player, message, recipients); + super(player, message, recipients);
+ this.sign = sign; + this.sign = sign;
+ this.side = side;
+ } + }
+ +
+ /** + /**
@ -39,8 +44,16 @@ index 0000000000000000000000000000000000000000..a51a2288bf812e7d8845a6ec70274d62
+ * + *
+ * @return the sign + * @return the sign
+ */ + */
+ @NotNull + public @NotNull Sign getSign() {
+ public Sign getSign() { + return this.sign;
+ return sign; + }
+
+ /**
+ * Gets the side of the sign that the command originated from.
+ *
+ * @return the sign side
+ */
+ public @NotNull Side getSide() {
+ return this.side;
+ } + }
+} +}

Datei anzeigen

@ -28,10 +28,10 @@ index 3df8c60ab5cd1454660980883f80668d535b742b..37c3a00659ce21623be07317f4f6a45b
+/.factorypath +/.factorypath
diff --git a/build.gradle.kts b/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..ca692b4758172cb139938f28457cf5639a4411cf index 0000000000000000000000000000000000000000..9a355bbbe57629d0b66f8260ecf461e3bf1a539b
--- /dev/null --- /dev/null
+++ b/build.gradle.kts +++ b/build.gradle.kts
@@ -0,0 +1,137 @@ @@ -0,0 +1,138 @@
+import io.papermc.paperweight.util.* +import io.papermc.paperweight.util.*
+ +
+plugins { +plugins {
@ -136,6 +136,7 @@ index 0000000000000000000000000000000000000000..ca692b4758172cb139938f28457cf563
+ if (providers.gradleProperty("paper.runDisableWatchdog").getOrElse("false") == "true") { + if (providers.gradleProperty("paper.runDisableWatchdog").getOrElse("false") == "true") {
+ systemProperty("disable.watchdog", true) + systemProperty("disable.watchdog", true)
+ } + }
+ systemProperty("io.papermc.paper.suppress.sout.nags", true)
+ +
+ val memoryGb = providers.gradleProperty("paper.runMemoryGb").getOrElse("2") + val memoryGb = providers.gradleProperty("paper.runMemoryGb").getOrElse("2")
+ minHeapSize = "${memoryGb}G" + minHeapSize = "${memoryGb}G"

Datei anzeigen

@ -58,7 +58,7 @@ index 0000000000000000000000000000000000000000..01a2bc1feec808790bb93618ce46adb9
+ } + }
+} +}
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 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 4fe156701cf0664d0ab9472f5599fd87ee4ddeb2..80695b2698d2904cec2c54ebe0ef880d95ed9583 100644 index 4fe156701cf0664d0ab9472f5599fd87ee4ddeb2..ba6f0ba00cd2635bcd19889dca0349b363b079fe 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
@@ -274,7 +274,17 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C @@ -274,7 +274,17 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
@ -71,7 +71,7 @@ index 4fe156701cf0664d0ab9472f5599fd87ee4ddeb2..80695b2698d2904cec2c54ebe0ef880d
+ if (org.spigotmc.SpigotConfig.logCommands) { + if (org.spigotmc.SpigotConfig.logCommands) {
+ LOGGER.info("{} issued server command: {}", player.getScoreboardName(), command); + LOGGER.info("{} issued server command: {}", player.getScoreboardName(), command);
+ } + }
+ io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent event = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent((org.bukkit.entity.Player) player.getBukkitEntity(), command, new org.bukkit.craftbukkit.util.LazyPlayerSet(player.getServer()), (org.bukkit.block.Sign) io.papermc.paper.util.MCUtil.toBukkitBlock(this.level, this.worldPosition).getState()); + io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent event = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent((org.bukkit.entity.Player) player.getBukkitEntity(), command, new org.bukkit.craftbukkit.util.LazyPlayerSet(player.getServer()), (org.bukkit.block.Sign) io.papermc.paper.util.MCUtil.toBukkitBlock(this.level, this.worldPosition).getState(), front ? Side.FRONT : Side.BACK);
+ if (!event.callEvent()) { + if (!event.callEvent()) {
+ return false; + return false;
+ } + }