From e05d694e8cba781332d84678142d9d6a8cb954d7 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Sat, 30 Jul 2022 12:28:24 -0400 Subject: [PATCH] Custom Chat Completions API (#8212) --- ...stom-Chat-Completion-Suggestions-API.patch | 36 +++++++++++++++++++ ...stom-Chat-Completion-Suggestions-API.patch | 33 +++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 patches/api/Custom-Chat-Completion-Suggestions-API.patch create mode 100644 patches/server/Custom-Chat-Completion-Suggestions-API.patch diff --git a/patches/api/Custom-Chat-Completion-Suggestions-API.patch b/patches/api/Custom-Chat-Completion-Suggestions-API.patch new file mode 100644 index 0000000000..2e672cff57 --- /dev/null +++ b/patches/api/Custom-Chat-Completion-Suggestions-API.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> +Date: Sat, 30 Jul 2022 11:23:11 -0400 +Subject: [PATCH] Custom Chat Completion Suggestions API + + +diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/Player.java ++++ b/src/main/java/org/bukkit/entity/Player.java +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * @throws IllegalArgumentException If the level is negative or greater than {@code 4} (i.e. not within {@code [0, 4]}). + */ + void sendOpLevel(byte level); ++ ++ /** ++ * Adds custom chat completion suggestions that the client will ++ * suggest when typing in chat. ++ * ++ * @param completions custom completions ++ */ ++ void addAdditionalChatCompletions(@NotNull java.util.Collection<String> completions); ++ ++ /** ++ * Removes custom chat completion suggestions that the client ++ * suggests when typing in chat. ++ * ++ * Note: this only applies to previously added custom completions, ++ * online player names are always suggested and cannot be removed. ++ * ++ * @param completions custom completions ++ */ ++ void removeAdditionalChatCompletions(@NotNull java.util.Collection<String> completions); + // Paper end + + // Spigot start diff --git a/patches/server/Custom-Chat-Completion-Suggestions-API.patch b/patches/server/Custom-Chat-Completion-Suggestions-API.patch new file mode 100644 index 0000000000..b31d72d646 --- /dev/null +++ b/patches/server/Custom-Chat-Completion-Suggestions-API.patch @@ -0,0 +1,33 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> +Date: Sat, 30 Jul 2022 11:23:05 -0400 +Subject: [PATCH] Custom Chat Completion Suggestions API + + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + + this.getHandle().getServer().getPlayerList().sendPlayerPermissionLevel(this.getHandle(), level, false); + } ++ ++ @Override ++ public void addAdditionalChatCompletions(@NotNull Collection<String> completions) { ++ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket( ++ net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket.Action.ADD, ++ new ArrayList<>(completions) ++ )); ++ } ++ ++ @Override ++ public void removeAdditionalChatCompletions(@NotNull Collection<String> completions) { ++ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket( ++ net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket.Action.REMOVE, ++ new ArrayList<>(completions) ++ )); ++ } + // Paper end + + @Override