Allow non-op players to execute the click event callback (#9652)

This commit is contained in:
Md5Lukas 2023-08-28 13:21:13 +02:00 committed by GitHub
parent b8edb0e130
commit b4e3b3d1dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 73 additions and 70 deletions

View file

@ -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>
```

View file

@ -1268,7 +1268,7 @@ index 0000000000000000000000000000000000000000..2ee72fe7cb56e70404b8c86f0c957875
+}
diff --git a/src/main/java/io/papermc/paper/adventure/providers/ClickCallbackProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/ClickCallbackProviderImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..3c17001bcd3862a76a22df488bff80a0ff4d1b83
index 0000000000000000000000000000000000000000..23432eea862c6df716d7726a32da3a0612a3fb77
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/providers/ClickCallbackProviderImpl.java
@@ -0,0 +1,96 @@
@ -1292,7 +1292,7 @@ index 0000000000000000000000000000000000000000..3c17001bcd3862a76a22df488bff80a0
+
+ @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 {

View file

@ -5,6 +5,47 @@ Subject: [PATCH] Paper command
Co-authored-by: Zach Brown <zach.brown@destroystokyo.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..fa4202abd13c1c286bd398938103d1103d5443e7
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/CallbackCommand.java
@@ -0,0 +1,35 @@
+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..953c30500892e5f0c55b8597bc708ea85bf56d6e
@ -82,10 +123,10 @@ index 0000000000000000000000000000000000000000..953c30500892e5f0c55b8597bc708ea8
+}
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..e7931b6cb2a46d07ac017f620b807e3474dc481e
index 0000000000000000000000000000000000000000..8ccc59473bac983ced6b9e4a57e0ec4ebd2b0f32
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -0,0 +1,144 @@
@@ -0,0 +1,143 @@
+package io.papermc.paper.command;
+
+import io.papermc.paper.command.subcommands.*;
@ -125,7 +166,6 @@ index 0000000000000000000000000000000000000000..e7931b6cb2a46d07ac017f620b807e34
+ 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())))
@ -232,10 +272,10 @@ index 0000000000000000000000000000000000000000..e7931b6cb2a46d07ac017f620b807e34
+}
diff --git a/src/main/java/io/papermc/paper/command/PaperCommands.java b/src/main/java/io/papermc/paper/command/PaperCommands.java
new file mode 100644
index 0000000000000000000000000000000000000000..6a00f3d38da8107825ab1d405f337fd077b09f72
index 0000000000000000000000000000000000000000..5e5ec700a368cfdaa1ea0b3f0fa82089895d4b92
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/PaperCommands.java
@@ -0,0 +1,27 @@
@@ -0,0 +1,28 @@
+package io.papermc.paper.command;
+
+import net.minecraft.server.MinecraftServer;
@ -255,6 +295,7 @@ index 0000000000000000000000000000000000000000..6a00f3d38da8107825ab1d405f337fd0
+ 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..7e9e0ff8639be135bf8575e375cbada5
+ 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..c5111eef4ba85ed96f7496b7db6954106fa05053
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/subcommands/CallbackCommand.java
@@ -0,0 +1,33 @@
+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..ff99336e0b8131ae161cfa5c4fc83c6905e3dbc8

View file

@ -5,22 +5,22 @@ Subject: [PATCH] Paper Plugins
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
index e7931b6cb2a46d07ac017f620b807e3474dc481e..16fdfda717300a3168c27526470f83ce6239e95f 100644
index 8ccc59473bac983ced6b9e4a57e0ec4ebd2b0f32..6d06b772ffb9d47d6a717462a4b2b494544e80ae 100644
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -38,6 +38,7 @@ public final class PaperCommand extends Command {
@@ -37,6 +37,7 @@ 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()
.flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue())))
diff --git a/src/main/java/io/papermc/paper/command/PaperCommands.java b/src/main/java/io/papermc/paper/command/PaperCommands.java
index 6a00f3d38da8107825ab1d405f337fd077b09f72..d44d0074446c1c54e87dc8078dff7fef1d92f343 100644
index 5e5ec700a368cfdaa1ea0b3f0fa82089895d4b92..72f2e81b9905a0d57ed8e2a88578f62d5235c456 100644
--- a/src/main/java/io/papermc/paper/command/PaperCommands.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommands.java
@@ -23,5 +23,6 @@ public final class PaperCommands {
@@ -24,5 +24,6 @@ public final class PaperCommands {
COMMANDS.forEach((s, command) -> {
server.server.getCommandMap().register(s, "Paper", command);
});

View file

@ -4346,12 +4346,12 @@ index 0000000000000000000000000000000000000000..dd995e25ae620ae36cd5eecb2fe10ad0
+
+}
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
index 16fdfda717300a3168c27526470f83ce6239e95f..a52e6e8be323863ece6624a8ae7f9455279bdc23 100644
index 6d06b772ffb9d47d6a717462a4b2b494544e80ae..de0e1ad2c78e5132651494f198703533847c84bd 100644
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -39,6 +39,7 @@ public final class PaperCommand extends Command {
@@ -38,6 +38,7 @@ 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());

View file

@ -15403,11 +15403,11 @@ index 0000000000000000000000000000000000000000..f7b0e2564ac4bd2db1d2b2bdc230c9f5
+ }
+}
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
index a52e6e8be323863ece6624a8ae7f9455279bdc23..e3467aaf6d0c8d486b84362e3c20b3fe631b50ff 100644
index de0e1ad2c78e5132651494f198703533847c84bd..0dd48e4098191c8b6e29945d62bc473e9f3a1e77 100644
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -40,6 +40,7 @@ public final class PaperCommand extends Command {
commands.put(Set.of("callback"), new CallbackCommand());
@@ -39,6 +39,7 @@ public final class PaperCommand extends Command {
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());

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Make the default permission message configurable
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
index e3467aaf6d0c8d486b84362e3c20b3fe631b50ff..8f16640fc2f1233c10392d7e32a54d784fd8e370 100644
index 0dd48e4098191c8b6e29945d62bc473e9f3a1e77..ae51993e0de706cb62c96795ca9de7663893a5bf 100644
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -76,7 +76,7 @@ public final class PaperCommand extends Command {
@@ -75,7 +75,7 @@ public final class PaperCommand extends Command {
if (sender.hasPermission(BASE_PERM + permission) || sender.hasPermission("bukkit.command.paper")) {
return true;
}

View file

@ -194,10 +194,10 @@ index 0000000000000000000000000000000000000000..0bb4aaa546939b67a5d22865190f3047
+ }
+}
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
index 8f16640fc2f1233c10392d7e32a54d784fd8e370..1e9f191dc0f9d98f4404d2796f15b13912860b13 100644
index ae51993e0de706cb62c96795ca9de7663893a5bf..5bfa245a621a0bf7ef60cd01f4c04576b770384e 100644
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -41,6 +41,7 @@ public final class PaperCommand extends Command {
@@ -40,6 +40,7 @@ public final class PaperCommand extends Command {
commands.put(Set.of("dumpplugins"), new DumpPluginsCommand());
commands.put(Set.of("fixlight"), new FixLightCommand());
commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand());

View file

@ -113,13 +113,13 @@ index 0000000000000000000000000000000000000000..8b5293b0c696ef21d0101493ffa41b60
+ }
+}
diff --git a/src/main/java/io/papermc/paper/command/PaperCommands.java b/src/main/java/io/papermc/paper/command/PaperCommands.java
index d44d0074446c1c54e87dc8078dff7fef1d92f343..bbb8b1933ef33a3b91f69545f69dd3cfb84b27f5 100644
index 72f2e81b9905a0d57ed8e2a88578f62d5235c456..7b58b2d6297800c2dcdbf7539e5ab8e7703f39f1 100644
--- a/src/main/java/io/papermc/paper/command/PaperCommands.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommands.java
@@ -17,6 +17,7 @@ public final class PaperCommands {
private static final Map<String, Command> COMMANDS = new HashMap<>();
@@ -18,6 +18,7 @@ public final class PaperCommands {
static {
COMMANDS.put("paper", new PaperCommand("paper"));
COMMANDS.put("callback", new CallbackCommand("callback"));
+ COMMANDS.put("mspt", new MSPTCommand("mspt"));
}

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Paper dumpitem command
Let's you quickly view the item in your hands NBT data
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
index 1e9f191dc0f9d98f4404d2796f15b13912860b13..6d56c812262f7f109598ef4a941d0226b1eb638a 100644
index 5bfa245a621a0bf7ef60cd01f4c04576b770384e..a8b41d6a42e23a7cd839cc3d5e5cae84860f802c 100644
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -42,6 +42,7 @@ public final class PaperCommand extends Command {
@@ -41,6 +41,7 @@ public final class PaperCommand extends Command {
commands.put(Set.of("fixlight"), new FixLightCommand());
commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand());
commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());

View file

@ -10,10 +10,10 @@ Also has a hover text on each mob category listing what entity types are
in said category
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
index 6d56c812262f7f109598ef4a941d0226b1eb638a..db9567711f7e0ad1778d41e79b59e31916aa9f09 100644
index a8b41d6a42e23a7cd839cc3d5e5cae84860f802c..b7fc337ab2bbe3c6d80ed70834e294ab3a7f9dc2 100644
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -43,6 +43,7 @@ public final class PaperCommand extends Command {
@@ -42,6 +42,7 @@ public final class PaperCommand extends Command {
commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand());
commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());
commands.put(Set.of("dumpitem"), new DumpItemCommand());

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Add /paper dumplisteners command
Co-authored-by: TwoLeggedCat <80929284+TwoLeggedCat@users.noreply.github.com>
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
index db9567711f7e0ad1778d41e79b59e31916aa9f09..7ba60b4b4f29a42c58d98aafc5ea0fa3214f554c 100644
index b7fc337ab2bbe3c6d80ed70834e294ab3a7f9dc2..05b29305f5e3018a662884c2ef1af5ae4f6867ee 100644
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
@@ -44,6 +44,7 @@ public final class PaperCommand extends Command {
@@ -43,6 +43,7 @@ public final class PaperCommand extends Command {
commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());
commands.put(Set.of("dumpitem"), new DumpItemCommand());
commands.put(Set.of("mobcaps", "playermobcaps"), new MobcapsCommand());