mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 21:31:25 +01:00
Merge branch 'master' into pre/1.13
This commit is contained in:
commit
fb13965fbf
@ -14,9 +14,17 @@ completion, such as offline players.
|
|||||||
Also adds isCommand and getLocation to the sync TabCompleteEvent
|
Also adds isCommand and getLocation to the sync TabCompleteEvent
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||||
index 5ffe4b374e..93807ffa62 100644
|
index 5ffe4b374e..b296f948ef 100644
|
||||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||||
|
@@ -0,0 +0,0 @@ import io.netty.util.concurrent.Future;
|
||||||
|
import io.netty.util.concurrent.GenericFutureListener;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
+import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,10 +43,6 @@ index 5ffe4b374e..93807ffa62 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
- ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener());
|
- ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener());
|
||||||
-
|
|
||||||
- this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
|
||||||
- if (((Suggestions) suggestions).isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [<args>] from showing for plugins with nothing more to offer
|
|
||||||
- this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), (Suggestions) suggestions)); // CraftBukkit - decompile error
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event;
|
+ com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event;
|
||||||
+ java.util.List<String> completions = new java.util.ArrayList<>();
|
+ java.util.List<String> completions = new java.util.ArrayList<>();
|
||||||
@ -47,9 +51,8 @@ index 5ffe4b374e..93807ffa62 100644
|
|||||||
+ buffer, true, null);
|
+ buffer, true, null);
|
||||||
+ event.callEvent();
|
+ event.callEvent();
|
||||||
+ completions = event.isCancelled() ? com.google.common.collect.ImmutableList.of() : event.getCompletions();
|
+ completions = event.isCancelled() ? com.google.common.collect.ImmutableList.of() : event.getCompletions();
|
||||||
+ if (event.isCancelled() || event.isHandled()) {
|
+ // If the event isn't handled, we can assume that we have no completions, and so we'll ask the server
|
||||||
+
|
+ if (!event.isHandled()) {
|
||||||
+ // Still fire sync event with the provided completions, if someone is listening
|
|
||||||
+ if (!event.isCancelled() && org.bukkit.event.server.TabCompleteEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
+ if (!event.isCancelled() && org.bukkit.event.server.TabCompleteEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||||
+ java.util.List<String> finalCompletions = completions;
|
+ java.util.List<String> finalCompletions = completions;
|
||||||
+ Waitable<java.util.List<String>> syncCompletions = new Waitable<java.util.List<String>>() {
|
+ Waitable<java.util.List<String>> syncCompletions = new Waitable<java.util.List<String>>() {
|
||||||
@ -67,14 +70,22 @@ index 5ffe4b374e..93807ffa62 100644
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ java.util.List<String> otherSuggestions = completions;
|
+ java.util.List<String> otherSuggestions = completions;
|
||||||
+ minecraftServer.postToMainThread(() -> sendSuggestions(packetplayintabcomplete, otherSuggestions));
|
+ minecraftServer.postToMainThread(() -> sendSuggestions(packetplayintabcomplete, stringreader, otherSuggestions));
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ } else if (!completions.isEmpty()) {
|
||||||
+ minecraftServer.postToMainThread(() -> sendSuggestions(packetplayintabcomplete, null));
|
+ com.mojang.brigadier.suggestion.SuggestionsBuilder suggestionsBuilder = new com.mojang.brigadier.suggestion.SuggestionsBuilder(packetplayintabcomplete.c(), packetplayintabcomplete.b());
|
||||||
+ }
|
+ completions.forEach(suggestionsBuilder::suggest);
|
||||||
+ public void sendSuggestions(PacketPlayInTabComplete packetplayintabcomplete, java.util.List<String> otherSuggestions) {
|
|
||||||
+
|
+
|
||||||
+ ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(packetplayintabcomplete.c(), this.player.getCommandListener());
|
+ player.playerConnection.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestionsBuilder.build()));
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
||||||
|
- if (((Suggestions) suggestions).isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [<args>] from showing for plugins with nothing more to offer
|
||||||
|
- this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), (Suggestions) suggestions)); // CraftBukkit - decompile error
|
||||||
|
+ }
|
||||||
|
+ public void sendSuggestions(PacketPlayInTabComplete packetplayintabcomplete, StringReader reader, List<String> otherSuggestions) {
|
||||||
|
+
|
||||||
|
+ ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(reader, this.player.getCommandListener());
|
||||||
+ //noinspection unchecked
|
+ //noinspection unchecked
|
||||||
+ java.util.concurrent.CompletableFuture<Suggestions> completionSuggestions = this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults);
|
+ java.util.concurrent.CompletableFuture<Suggestions> completionSuggestions = this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults);
|
||||||
+ completionSuggestions.thenAccept((Suggestions suggestions) -> {
|
+ completionSuggestions.thenAccept((Suggestions suggestions) -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user