mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-26 22:40:21 +01:00
Allow non-op players to execute the click event callback (#9652)
This commit is contained in:
parent
a0632a8f06
commit
7366520a54
7 changed files with 48 additions and 45 deletions
|
@ -62,4 +62,5 @@ dawon <dawon@dawon.eu>
|
|||
Ollie <69084614+olijeffers0n@users.noreply.github.com>
|
||||
Oliwier Miodun <naczs@blueflow.pl>
|
||||
aerulion <aerulion@gmail.com>
|
||||
Lukas Planz <lukas.planz@web.de>
|
||||
```
|
||||
|
|
|
@ -117,9 +117,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/io/papermc/paper/command/PaperCommands.java
|
||||
+++ b/src/main/java/io/papermc/paper/command/PaperCommands.java
|
||||
@@ -0,0 +0,0 @@ public final class PaperCommands {
|
||||
private static final Map<String, Command> COMMANDS = new HashMap<>();
|
||||
static {
|
||||
COMMANDS.put("paper", new PaperCommand("paper"));
|
||||
COMMANDS.put("callback", new CallbackCommand("callback"));
|
||||
+ COMMANDS.put("mspt", new MSPTCommand("mspt"));
|
||||
}
|
||||
|
||||
|
|
|
@ -1292,7 +1292,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ @Override
|
||||
+ public @NotNull ClickEvent create(final @NotNull ClickCallback<Audience> callback, final ClickCallback.@NotNull Options options) {
|
||||
+ return ClickEvent.runCommand("/paper callback " + CALLBACK_MANAGER.addCallback(callback, options));
|
||||
+ return ClickEvent.runCommand("/paper:callback " + CALLBACK_MANAGER.addCallback(callback, options));
|
||||
+ }
|
||||
+
|
||||
+ public static final class CallbackManager {
|
||||
|
|
|
@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
@@ -0,0 +0,0 @@ public final class PaperCommand extends Command {
|
||||
commands.put(Set.of("entity"), new EntityCommand());
|
||||
commands.put(Set.of("reload"), new ReloadCommand());
|
||||
commands.put(Set.of("version"), new VersionCommand());
|
||||
commands.put(Set.of("callback"), new CallbackCommand());
|
||||
+ commands.put(Set.of("dumpplugins"), new DumpPluginsCommand());
|
||||
|
||||
return commands.entrySet().stream()
|
||||
|
|
|
@ -5,6 +5,47 @@ Subject: [PATCH] Paper command
|
|||
|
||||
Co-authored-by: Zach Brown <1254957+zachbr@users.noreply.github.com>
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/command/CallbackCommand.java b/src/main/java/io/papermc/paper/command/CallbackCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/CallbackCommand.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.command;
|
||||
+
|
||||
+import io.papermc.paper.adventure.providers.ClickCallbackProviderImpl;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+import java.util.UUID;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public class CallbackCommand extends Command {
|
||||
+
|
||||
+ protected CallbackCommand(final String name) {
|
||||
+ super(name);
|
||||
+ this.description = "ClickEvent callback";
|
||||
+ this.usageMessage = "/callback <uuid>";
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(final CommandSender sender, final String commandLabel, final String[] args) {
|
||||
+ if (args.length != 1) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ final UUID id;
|
||||
+ try {
|
||||
+ id = UUID.fromString(args[0]);
|
||||
+ } catch (final IllegalArgumentException ignored) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ ClickCallbackProviderImpl.CALLBACK_MANAGER.runCallback(sender, id);
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/command/CommandUtil.java b/src/main/java/io/papermc/paper/command/CommandUtil.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
|
@ -125,7 +166,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ commands.put(Set.of("entity"), new EntityCommand());
|
||||
+ commands.put(Set.of("reload"), new ReloadCommand());
|
||||
+ commands.put(Set.of("version"), new VersionCommand());
|
||||
+ commands.put(Set.of("callback"), new CallbackCommand());
|
||||
+
|
||||
+ return commands.entrySet().stream()
|
||||
+ .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue())))
|
||||
|
@ -255,6 +295,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ private static final Map<String, Command> COMMANDS = new HashMap<>();
|
||||
+ static {
|
||||
+ COMMANDS.put("paper", new PaperCommand("paper"));
|
||||
+ COMMANDS.put("callback", new CallbackCommand("callback"));
|
||||
+ }
|
||||
+
|
||||
+ public static void registerCommands(final MinecraftServer server) {
|
||||
|
@ -289,45 +330,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/command/subcommands/CallbackCommand.java b/src/main/java/io/papermc/paper/command/subcommands/CallbackCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/subcommands/CallbackCommand.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.command.subcommands;
|
||||
+
|
||||
+import io.papermc.paper.adventure.providers.ClickCallbackProviderImpl;
|
||||
+import io.papermc.paper.command.PaperSubcommand;
|
||||
+import java.util.UUID;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class CallbackCommand implements PaperSubcommand {
|
||||
+ @Override
|
||||
+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ if (args.length != 1) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ final UUID id;
|
||||
+ try {
|
||||
+ id = UUID.fromString(args[0]);
|
||||
+ } catch (final IllegalArgumentException ignored) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ ClickCallbackProviderImpl.CALLBACK_MANAGER.runCallback(sender, id);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean tabCompletes() {
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java b/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
|
|
|
@ -15407,7 +15407,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
@@ -0,0 +0,0 @@ public final class PaperCommand extends Command {
|
||||
commands.put(Set.of("callback"), new CallbackCommand());
|
||||
commands.put(Set.of("version"), new VersionCommand());
|
||||
commands.put(Set.of("dumpplugins"), new DumpPluginsCommand());
|
||||
commands.put(Set.of("fixlight"), new FixLightCommand());
|
||||
+ commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand());
|
||||
|
|
|
@ -4350,8 +4350,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
@@ -0,0 +0,0 @@ public final class PaperCommand extends Command {
|
||||
commands.put(Set.of("reload"), new ReloadCommand());
|
||||
commands.put(Set.of("version"), new VersionCommand());
|
||||
commands.put(Set.of("callback"), new CallbackCommand());
|
||||
commands.put(Set.of("dumpplugins"), new DumpPluginsCommand());
|
||||
+ commands.put(Set.of("fixlight"), new FixLightCommand());
|
||||
|
||||
|
|
Loading…
Reference in a new issue