Fix Async Tab Completion processing

previous logic was super broken and did not truncate your currently typed
part of the input from the suggestions.
This commit is contained in:
Aikar 2019-02-04 22:39:00 -05:00
parent abba3d113b
commit 5ae3895105
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
9 changed files with 52 additions and 51 deletions

View File

@ -1,4 +1,4 @@
From 4eedfa988b7e9b1d975fedfc09e4ac05fb071ac0 Mon Sep 17 00:00:00 2001
From 5086b17a95581c2e6db5359144c215d354025377 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 26 Nov 2017 13:19:58 -0500
Subject: [PATCH] AsyncTabCompleteEvent
@ -14,7 +14,7 @@ completion, such as offline players.
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
index 9afe20d40..59b0084c7 100644
index 7017c02ba..2ad238796 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -507,10 +507,10 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@ -30,7 +30,7 @@ index 9afe20d40..59b0084c7 100644
return;
}
// CraftBukkit end
@@ -520,12 +520,34 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -520,12 +520,35 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
stringreader.skip();
}
@ -58,10 +58,11 @@ index 9afe20d40..59b0084c7 100644
+ }
+ // Paper start - async tab completion
+ } else if (!completions.isEmpty()) {
+ com.mojang.brigadier.suggestion.SuggestionsBuilder suggestionsBuilder = new com.mojang.brigadier.suggestion.SuggestionsBuilder(packetplayintabcomplete.c(), stringreader.getTotalLength());
+ completions.forEach(suggestionsBuilder::suggest);
+ com.mojang.brigadier.suggestion.SuggestionsBuilder builder = new com.mojang.brigadier.suggestion.SuggestionsBuilder(packetplayintabcomplete.c(), stringreader.getTotalLength());
+
+ player.playerConnection.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestionsBuilder.build()));
+ builder = builder.createOffset(builder.getInput().lastIndexOf(' ') + 1);
+ completions.forEach(builder::suggest);
+ player.playerConnection.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), builder.buildFuture().join()));
+ }
+ // Paper end - async tab completion
+

View File

@ -1,14 +1,14 @@
From e5e2fc8ea552a3cadcf505ec83832845d8b3f7b7 Mon Sep 17 00:00:00 2001
From e5a7d6787e3f20b05192d5a1bcf6929ed1c99080 Mon Sep 17 00:00:00 2001
From: 0x22 <0x22@futureclient.net>
Date: Thu, 26 Apr 2018 04:41:11 -0400
Subject: [PATCH] Fix exploit that allowed colored signs to be created
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 59b0084c7b..f4b5627d46 100644
index 2ad238796..1fdffcfb0 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2479,7 +2479,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -2480,7 +2480,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
String[] lines = new String[4];
for (int i = 0; i < astring.length; ++i) {

View File

@ -1,4 +1,4 @@
From fa0a3dad58143b0bd96b5d8c6ed81f94c42b02b6 Mon Sep 17 00:00:00 2001
From be44a8f7dca619d2ee1b614d648bf2bbb935f0fb Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 3 Jul 2018 21:56:23 -0400
Subject: [PATCH] InventoryCloseEvent Reason API
@ -7,7 +7,7 @@ Allows you to determine why an inventory was closed, enabling plugin developers
to "confirm" things based on if it was player triggered close or not.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 6150b56e0e..3ca579e381 100644
index 6150b56e0..3ca579e38 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -943,7 +943,7 @@ public class Chunk implements IChunkAccess {
@ -29,7 +29,7 @@ index 6150b56e0e..3ca579e381 100644
}
}
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index e06f03e80a..59f108e490 100644
index e06f03e80..59f108e49 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -158,7 +158,7 @@ public abstract class EntityHuman extends EntityLiving {
@ -56,7 +56,7 @@ index e06f03e80a..59f108e490 100644
this.activeContainer = this.defaultContainer;
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index cd488d37f2..1054367d0e 100644
index cd488d37f..1054367d0 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -344,7 +344,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@ -110,10 +110,10 @@ index cd488d37f2..1054367d0e 100644
this.m();
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index f4b5627d46..b917e2ec76 100644
index 1fdffcfb0..adc57a374 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2015,7 +2015,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -2016,7 +2016,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer());
if (this.player.isFrozen()) return; // CraftBukkit
@ -123,7 +123,7 @@ index f4b5627d46..b917e2ec76 100644
this.player.m();
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 96eff10ffa..ddaa73e83d 100644
index 96eff10ff..ddaa73e83 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -422,7 +422,7 @@ public abstract class PlayerList {
@ -136,7 +136,7 @@ index 96eff10ffa..ddaa73e83d 100644
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game");
cserver.getPluginManager().callEvent(playerQuitEvent);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index b82aa903ca..a2bf6b0460 100644
index b82aa903c..a2bf6b046 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -513,8 +513,13 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@ -155,7 +155,7 @@ index b82aa903ca..a2bf6b0460 100644
public boolean isBlocking() {
return getHandle().isBlocking();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0753a0f266..ce58cfc11e 100644
index 0753a0f26..ce58cfc11 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -738,7 +738,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@ -168,7 +168,7 @@ index 0753a0f266..ce58cfc11e 100644
// Check if the fromWorld and toWorld are the same.
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index e75c188b5e..167a3baec7 100644
index e75c188b5..167a3baec 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1110,8 +1110,19 @@ public class CraftEventFactory {

View File

@ -1,4 +1,4 @@
From e90440b40f3966f973dd265572909ac1d14ba4b3 Mon Sep 17 00:00:00 2001
From 18dc435476b4008046ffb520fcb7adaea73f993e Mon Sep 17 00:00:00 2001
From: Minecrell <minecrell@minecrell.net>
Date: Fri, 13 Jul 2018 14:54:43 +0200
Subject: [PATCH] Refresh player inventory when cancelling
@ -16,10 +16,10 @@ Refresh the player inventory when PlayerInteractEntityEvent is
cancelled to avoid this problem.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index b917e2ec76..abeec6b5c9 100644
index adc57a374..9c1c1fbb4 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1930,6 +1930,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -1931,6 +1931,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
}
if (event.isCancelled()) {

View File

@ -1,4 +1,4 @@
From f6e01d6360441f498d56175e148300b20c5f786f Mon Sep 17 00:00:00 2001
From 716c9841e7095377b98c9f6d5116b31785b6c653 Mon Sep 17 00:00:00 2001
From: Gabriele C <sgdc3.mail@gmail.com>
Date: Mon, 22 Oct 2018 17:34:10 +0200
Subject: [PATCH] Add option to prevent players from moving into unloaded
@ -6,7 +6,7 @@ Subject: [PATCH] Add option to prevent players from moving into unloaded
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 575281991c..f47a648af3 100644
index 30985cdfc..2add466ac 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -574,4 +574,9 @@ public class PaperWorldConfig {
@ -20,7 +20,7 @@ index 575281991c..f47a648af3 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 0bcb9c1ab1..c1f47701cc 100644
index 74975a138..853fc3149 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -341,6 +341,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@ -37,7 +37,7 @@ index 0bcb9c1ab1..c1f47701cc 100644
if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(entity.getDisplayName().getString()))) {
// CraftBukkit end
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), d6, d7, d8);
@@ -848,9 +855,9 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -849,9 +856,9 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
double d1 = this.player.locY;
double d2 = this.player.locZ;
double d3 = this.player.locY;
@ -49,7 +49,7 @@ index 0bcb9c1ab1..c1f47701cc 100644
float f = packetplayinflying.a(this.player.yaw);
float f1 = packetplayinflying.b(this.player.pitch);
double d7 = d4 - this.l;
@@ -890,6 +897,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -891,6 +898,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
speed = player.abilities.walkSpeed * 10f;
}

View File

@ -1,4 +1,4 @@
From 0ddf48a449d2c390bc4e5a8bdac9cd162a771214 Mon Sep 17 00:00:00 2001
From 87abc431c2c2e1ec2e3c5d1f2922455c784771a3 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 23 Oct 2018 20:25:05 -0400
Subject: [PATCH] Don't sleep after profile lookups if not needed
@ -7,7 +7,7 @@ Mojang was sleeping even if we had no more requests to go after
the current one finished, resulting in 100ms lost per profile lookup
diff --git a/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java b/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java
index 26a743722c..6ed3199c3d 100644
index 71e48e87b..23f1447cf 100644
--- a/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java
+++ b/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java
@@ -42,6 +42,7 @@ public class YggdrasilGameProfileRepository implements GameProfileRepository {

View File

@ -1,14 +1,14 @@
From a3abb8955d68007d99c6fef60c26c708a91a6485 Mon Sep 17 00:00:00 2001
From 47f595ca18d5fb0a77009453183880356daebedf Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 11 Nov 2018 21:01:09 +0000
Subject: [PATCH] Don't allow digging into unloaded chunks
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index c1f47701cc..cb6d1deb88 100644
index 853fc3149..93d2766d5 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1222,6 +1222,11 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -1223,6 +1223,11 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
case START_DESTROY_BLOCK:
case ABORT_DESTROY_BLOCK:
case STOP_DESTROY_BLOCK:

View File

@ -1,4 +1,4 @@
From 92e515581ac52b59c5c38945a382d061756c6f16 Mon Sep 17 00:00:00 2001
From 40c15924cd11892e91ca103a60a577beb3e53437 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 16 Nov 2018 23:08:50 -0500
Subject: [PATCH] Book Size Limits
@ -6,7 +6,7 @@ Subject: [PATCH] Book Size Limits
Puts some limits on the size of books.
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 52ce8f89e5..07f0b45295 100644
index 52ce8f89e..07f0b4529 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -449,4 +449,11 @@ public class PaperConfig {
@ -22,7 +22,7 @@ index 52ce8f89e5..07f0b45295 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index cb6d1deb88..8d06b23eaf 100644
index 93d2766d5..4987acbf5 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -12,6 +12,8 @@ import java.util.Collections;
@ -34,7 +34,7 @@ index cb6d1deb88..8d06b23eaf 100644
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -747,6 +749,42 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -748,6 +750,42 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
}
public void a(PacketPlayInBEdit packetplayinbedit) {

View File

@ -1,4 +1,4 @@
From 8606eff98f1c567f87cebfbbfccd8019d0ff09bf Mon Sep 17 00:00:00 2001
From 1f58488cda8caceda4a60a543157035e4cee37dc Mon Sep 17 00:00:00 2001
From: Michael Himing <mhiming@gmail.com>
Date: Sun, 16 Dec 2018 13:07:33 +1100
Subject: [PATCH] Fix PlayerEditBookEvent
@ -10,10 +10,10 @@ it impossible to properly cancel the event or modify the book meta
cancelled writing
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 8d06b23eaf..a8a6e236ea 100644
index 4987acbf5..3bb285439 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -822,10 +822,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -823,10 +823,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
this.player.setSlot(enumitemslot, CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, itemstack2)); // CraftBukkit
} else {