geforkt von Mirrors/Velocity
Fix tab complete for proxy commands for 1.12.2 and below and fix command tab complete repeating suggestions
Dieser Commit ist enthalten in:
Ursprung
c88a3807e7
Commit
7dffa7ce33
@ -412,8 +412,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Offer> offers = new ArrayList<>();
|
List<Offer> offers = new ArrayList<>();
|
||||||
for (String suggestion : suggestions) {
|
for (String offer : suggestions) {
|
||||||
offers.add(new Offer(suggestion));
|
offers.add(new Offer(offer));
|
||||||
}
|
}
|
||||||
int startPos = packet.getCommand().lastIndexOf(' ') + 1;
|
int startPos = packet.getCommand().lastIndexOf(' ') + 1;
|
||||||
if (startPos > 0) {
|
if (startPos > 0) {
|
||||||
@ -460,10 +460,14 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
String command = request.getCommand().substring(1);
|
String command = request.getCommand().substring(1);
|
||||||
server.getCommandManager().offerSuggestions(player, command)
|
server.getCommandManager().offerSuggestions(player, command)
|
||||||
.thenAcceptAsync(offers -> {
|
.thenAcceptAsync(offers -> {
|
||||||
boolean needsSlash = player.getProtocolVersion().compareTo(MINECRAFT_1_13) < 0;
|
boolean legacy = player.getProtocolVersion().compareTo(MINECRAFT_1_13) < 0;
|
||||||
try {
|
try {
|
||||||
for (String offer : offers) {
|
for (String offer : offers) {
|
||||||
response.getOffers().add(new Offer(needsSlash ? "/" + offer : offer, null));
|
offer = legacy && !offer.startsWith("/") ? "/" + offer : offer;
|
||||||
|
if (legacy && offer.startsWith(command)) {
|
||||||
|
offer = offer.substring(command.length());
|
||||||
|
}
|
||||||
|
response.getOffers().add(new Offer(offer, null));
|
||||||
}
|
}
|
||||||
response.getOffers().sort(null);
|
response.getOffers().sort(null);
|
||||||
player.getConnection().write(response);
|
player.getConnection().write(response);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.velocitypowered.proxy.util;
|
package com.velocitypowered.proxy.util;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||||
@ -19,6 +20,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
*/
|
*/
|
||||||
public final class BrigadierUtils {
|
public final class BrigadierUtils {
|
||||||
|
|
||||||
|
private static final Splitter SPACE_SPLITTER = Splitter.on(' ');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a literal node that redirects its execution to
|
* Returns a literal node that redirects its execution to
|
||||||
* the given destination node.
|
* the given destination node.
|
||||||
@ -103,7 +106,7 @@ public final class BrigadierUtils {
|
|||||||
if (line.isEmpty()) {
|
if (line.isEmpty()) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
return line.trim().split(" ", -1);
|
return SPACE_SPLITTER.splitToList(line).toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren