Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-25 15:50:19 +01:00
Fix TabCompleteResponse
Dieser Commit ist enthalten in:
Ursprung
32228e85ab
Commit
b00d3bcf5b
@ -53,6 +53,7 @@ import com.velocitypowered.proxy.protocol.packet.TabCompleteResponse.Offer;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatHandler;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.ChatTimeKeeper;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.CommandHandler;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedChatHandler;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedCommandHandler;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.keyed.KeyedPlayerChat;
|
||||
@ -631,10 +632,11 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
List<Offer> offers = new ArrayList<>();
|
||||
for (Suggestion suggestion : suggestions.getList()) {
|
||||
String offer = suggestion.getText();
|
||||
Component tooltip = null;
|
||||
ComponentHolder tooltip = null;
|
||||
if (suggestion.getTooltip() != null
|
||||
&& suggestion.getTooltip() instanceof VelocityBrigadierMessage) {
|
||||
tooltip = ((VelocityBrigadierMessage) suggestion.getTooltip()).asComponent();
|
||||
tooltip = new ComponentHolder(player.getProtocolVersion(),
|
||||
((VelocityBrigadierMessage) suggestion.getTooltip()).asComponent());
|
||||
}
|
||||
offers.add(new Offer(offer, tooltip));
|
||||
}
|
||||
@ -696,10 +698,11 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
if (legacy && offer.startsWith(command)) {
|
||||
offer = offer.substring(command.length());
|
||||
}
|
||||
Component tooltip = null;
|
||||
ComponentHolder tooltip = null;
|
||||
if (suggestion.getTooltip() != null
|
||||
&& suggestion.getTooltip() instanceof VelocityBrigadierMessage) {
|
||||
tooltip = ((VelocityBrigadierMessage) suggestion.getTooltip()).asComponent();
|
||||
tooltip = new ComponentHolder(player.getProtocolVersion(),
|
||||
((VelocityBrigadierMessage) suggestion.getTooltip()).asComponent());
|
||||
}
|
||||
response.getOffers().add(new Offer(offer, tooltip));
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class TabCompleteResponse implements MinecraftPacket {
|
||||
@ -84,8 +84,7 @@ public class TabCompleteResponse implements MinecraftPacket {
|
||||
int offersAvailable = ProtocolUtils.readVarInt(buf);
|
||||
for (int i = 0; i < offersAvailable; i++) {
|
||||
String offer = ProtocolUtils.readString(buf);
|
||||
Component tooltip = buf.readBoolean() ? ProtocolUtils.getJsonChatSerializer(version)
|
||||
.deserialize(ProtocolUtils.readString(buf)) : null;
|
||||
ComponentHolder tooltip = buf.readBoolean() ? ComponentHolder.read(buf, version) : null;
|
||||
offers.add(new Offer(offer, tooltip));
|
||||
}
|
||||
} else {
|
||||
@ -107,8 +106,7 @@ public class TabCompleteResponse implements MinecraftPacket {
|
||||
ProtocolUtils.writeString(buf, offer.text);
|
||||
buf.writeBoolean(offer.tooltip != null);
|
||||
if (offer.tooltip != null) {
|
||||
ProtocolUtils.writeString(buf, ProtocolUtils.getJsonChatSerializer(version)
|
||||
.serialize(offer.tooltip));
|
||||
offer.tooltip.write(buf);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -127,14 +125,13 @@ public class TabCompleteResponse implements MinecraftPacket {
|
||||
public static class Offer implements Comparable<Offer> {
|
||||
|
||||
private final String text;
|
||||
private final @Nullable Component tooltip;
|
||||
private final @Nullable ComponentHolder tooltip;
|
||||
|
||||
public Offer(String text) {
|
||||
this(text, null);
|
||||
}
|
||||
|
||||
public Offer(String text,
|
||||
@Nullable Component tooltip) {
|
||||
public Offer(String text, @Nullable ComponentHolder tooltip) {
|
||||
this.text = text;
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren