aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0722-Custom-Chat-Completion-Suggestions-API.patch
blob: 7a419b3d744e2f949070a219bac70b9c07035207 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 2514fbae7c87a96c12e44d21ff7df1d2f3243387..dc360a7a8a8d23be9d8301a5e6fbff5499c9a947 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -708,6 +708,24 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
     }
     // Paper end - Add sendOpLevel API
 
+    // Paper start - custom chat completions API
+    @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 - custom chat completions API
+
     @Override
     public void setCompassTarget(Location loc) {
         Preconditions.checkArgument(loc != null, "Location cannot be null");