Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-26 00:00:55 +01:00
Adventure 4.3.0: Player list header/footer
Dieser Commit ist enthalten in:
Ursprung
9825f5891b
Commit
5da085d82f
@ -32,11 +32,12 @@ dependencies {
|
|||||||
// DEPRECATED: Will be removed in Velocity 2.0.0
|
// DEPRECATED: Will be removed in Velocity 2.0.0
|
||||||
api 'com.moandjiezana.toml:toml4j:0.7.2'
|
api 'com.moandjiezana.toml:toml4j:0.7.2'
|
||||||
|
|
||||||
api "net.kyori:adventure-api:${adventureVersion}"
|
api(platform("net.kyori:adventure-bom:${adventureVersion}"))
|
||||||
api "net.kyori:adventure-text-serializer-gson:${adventureVersion}"
|
api("net.kyori:adventure-api")
|
||||||
api "net.kyori:adventure-text-serializer-legacy:${adventureVersion}"
|
api("net.kyori:adventure-text-serializer-gson")
|
||||||
api "net.kyori:adventure-text-serializer-plain:${adventureVersion}"
|
api("net.kyori:adventure-text-serializer-legacy")
|
||||||
api "net.kyori:adventure-text-serializer-legacy-text3:${adventurePlatformVersion}"
|
api("net.kyori:adventure-text-serializer-plain")
|
||||||
|
api("net.kyori:adventure-text-serializer-legacy-text3:${adventurePlatformVersion}") // adventure-platform
|
||||||
|
|
||||||
api "org.slf4j:slf4j-api:${slf4jVersion}"
|
api "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||||
api 'com.google.inject:guice:4.2.3'
|
api 'com.google.inject:guice:4.2.3'
|
||||||
|
@ -146,6 +146,20 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
void clearHeaderAndFooter();
|
void clearHeaderAndFooter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the player's player list header.
|
||||||
|
*
|
||||||
|
* @return this player's player list header
|
||||||
|
*/
|
||||||
|
Component getPlayerListHeader();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the player's player list footer.
|
||||||
|
*
|
||||||
|
* @return this player's tab list
|
||||||
|
*/
|
||||||
|
Component getPlayerListFooter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player's tab list.
|
* Returns the player's tab list.
|
||||||
*
|
*
|
||||||
|
@ -28,7 +28,9 @@ public interface TabList {
|
|||||||
*
|
*
|
||||||
* @param header the header component
|
* @param header the header component
|
||||||
* @param footer the footer component
|
* @param footer the footer component
|
||||||
|
* @deprecated Use {@link Player#sendPlayerListHeaderAndFooter(Component, Component)} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
void setHeaderAndFooter(Component header, Component footer);
|
void setHeaderAndFooter(Component header, Component footer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,7 @@ allprojects {
|
|||||||
ext {
|
ext {
|
||||||
// dependency versions
|
// dependency versions
|
||||||
textVersion = '3.0.4'
|
textVersion = '3.0.4'
|
||||||
adventureVersion = '4.2.0'
|
adventureVersion = '4.3.0'
|
||||||
adventurePlatformVersion = '4.0.0-SNAPSHOT'
|
adventurePlatformVersion = '4.0.0-SNAPSHOT'
|
||||||
junitVersion = '5.7.0'
|
junitVersion = '5.7.0'
|
||||||
slf4jVersion = '1.7.30'
|
slf4jVersion = '1.7.30'
|
||||||
|
@ -66,7 +66,9 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'it.unimi.dsi:fastutil:8.4.1'
|
implementation 'it.unimi.dsi:fastutil:8.4.1'
|
||||||
implementation 'net.kyori:event-method-asm:4.0.0-SNAPSHOT'
|
implementation 'net.kyori:event-method-asm:4.0.0-SNAPSHOT'
|
||||||
implementation 'net.kyori:adventure-nbt:4.0.0-SNAPSHOT'
|
|
||||||
|
implementation(platform("net.kyori:adventure-bom:${adventureVersion}"))
|
||||||
|
implementation("net.kyori:adventure-nbt")
|
||||||
|
|
||||||
implementation 'org.asynchttpclient:async-http-client:2.12.1'
|
implementation 'org.asynchttpclient:async-http-client:2.12.1'
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ import com.velocitypowered.proxy.protocol.StateRegistry;
|
|||||||
import com.velocitypowered.proxy.protocol.packet.Chat;
|
import com.velocitypowered.proxy.protocol.packet.Chat;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
|
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter;
|
||||||
import com.velocitypowered.proxy.protocol.packet.KeepAlive;
|
import com.velocitypowered.proxy.protocol.packet.KeepAlive;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest;
|
||||||
@ -61,6 +62,7 @@ import java.net.InetSocketAddress;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -105,6 +107,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
private @Nullable VelocityServerConnection connectionInFlight;
|
private @Nullable VelocityServerConnection connectionInFlight;
|
||||||
private @Nullable PlayerSettings settings;
|
private @Nullable PlayerSettings settings;
|
||||||
private @Nullable ModInfo modInfo;
|
private @Nullable ModInfo modInfo;
|
||||||
|
private Component playerListHeader = Component.empty();
|
||||||
|
private Component playerListFooter = Component.empty();
|
||||||
private final VelocityTabList tabList;
|
private final VelocityTabList tabList;
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
private ClientConnectionPhase connectionPhase;
|
private ClientConnectionPhase connectionPhase;
|
||||||
@ -116,9 +120,9 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
@Nullable InetSocketAddress virtualHost, boolean onlineMode) {
|
@Nullable InetSocketAddress virtualHost, boolean onlineMode) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||||
this.tabList = new VelocityTabList(connection);
|
this.tabList = new VelocityTabList(this);
|
||||||
} else {
|
} else {
|
||||||
this.tabList = new VelocityTabListLegacy(connection);
|
this.tabList = new VelocityTabListLegacy(this);
|
||||||
}
|
}
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
@ -301,6 +305,33 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getPlayerListHeader() {
|
||||||
|
return this.playerListHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getPlayerListFooter() {
|
||||||
|
return this.playerListFooter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendPlayerListHeader(@NonNull final Component header) {
|
||||||
|
this.sendPlayerListHeaderAndFooter(header, this.playerListFooter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendPlayerListFooter(@NonNull final Component footer) {
|
||||||
|
this.sendPlayerListHeaderAndFooter(this.playerListHeader, footer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendPlayerListHeaderAndFooter(final Component header, final Component footer) {
|
||||||
|
this.playerListHeader = Objects.requireNonNull(header, "header");
|
||||||
|
this.playerListFooter = Objects.requireNonNull(footer, "footer");
|
||||||
|
this.connection.write(HeaderAndFooter.create(header, footer, this.getProtocolVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showTitle(net.kyori.adventure.title.@NonNull Title title) {
|
public void showTitle(net.kyori.adventure.title.@NonNull Title title) {
|
||||||
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(this
|
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(this
|
||||||
@ -363,6 +394,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
this.profile = profile.withProperties(Preconditions.checkNotNull(properties));
|
this.profile = profile.withProperties(Preconditions.checkNotNull(properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer) {
|
public void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer) {
|
||||||
tabList.setHeaderAndFooter(header, footer);
|
tabList.setHeaderAndFooter(header, footer);
|
||||||
|
@ -8,6 +8,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
|||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
|
||||||
public class HeaderAndFooter implements MinecraftPacket {
|
public class HeaderAndFooter implements MinecraftPacket {
|
||||||
@ -51,15 +52,8 @@ public class HeaderAndFooter implements MinecraftPacket {
|
|||||||
return handler.handle(this);
|
return handler.handle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HeaderAndFooter create(net.kyori.text.Component header,
|
public static HeaderAndFooter create(Component header,
|
||||||
net.kyori.text.Component footer) {
|
Component footer, ProtocolVersion protocolVersion) {
|
||||||
return new HeaderAndFooter(
|
|
||||||
net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE.serialize(header),
|
|
||||||
net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE.serialize(footer));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HeaderAndFooter create(net.kyori.adventure.text.Component header,
|
|
||||||
net.kyori.adventure.text.Component footer, ProtocolVersion protocolVersion) {
|
|
||||||
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(protocolVersion);
|
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(protocolVersion);
|
||||||
return new HeaderAndFooter(serializer.serialize(header), serializer.serialize(footer));
|
return new HeaderAndFooter(serializer.serialize(header), serializer.serialize(footer));
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.velocitypowered.api.proxy.player.TabList;
|
|||||||
import com.velocitypowered.api.proxy.player.TabListEntry;
|
import com.velocitypowered.api.proxy.player.TabListEntry;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter;
|
import com.velocitypowered.proxy.protocol.packet.HeaderAndFooter;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PlayerListItem;
|
import com.velocitypowered.proxy.protocol.packet.PlayerListItem;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -15,31 +16,39 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import net.kyori.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class VelocityTabList implements TabList {
|
public class VelocityTabList implements TabList {
|
||||||
|
|
||||||
|
protected final ConnectedPlayer player;
|
||||||
protected final MinecraftConnection connection;
|
protected final MinecraftConnection connection;
|
||||||
protected final Map<UUID, VelocityTabListEntry> entries = new ConcurrentHashMap<>();
|
protected final Map<UUID, VelocityTabListEntry> entries = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public VelocityTabList(MinecraftConnection connection) {
|
public VelocityTabList(final ConnectedPlayer player) {
|
||||||
this.connection = connection;
|
this.player = player;
|
||||||
|
this.connection = player.getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public void setHeaderAndFooter(net.kyori.text.Component header,
|
||||||
|
net.kyori.text.Component footer) {
|
||||||
|
Preconditions.checkNotNull(header, "header");
|
||||||
|
Preconditions.checkNotNull(footer, "footer");
|
||||||
|
this.player.sendPlayerListHeaderAndFooter(
|
||||||
|
LegacyText3ComponentSerializer.get().deserialize(header),
|
||||||
|
LegacyText3ComponentSerializer.get().deserialize(footer)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void setHeaderAndFooter(Component header, Component footer) {
|
public void setHeaderAndFooter(Component header, Component footer) {
|
||||||
Preconditions.checkNotNull(header, "header");
|
Preconditions.checkNotNull(header, "header");
|
||||||
Preconditions.checkNotNull(footer, "footer");
|
Preconditions.checkNotNull(footer, "footer");
|
||||||
connection.write(HeaderAndFooter.create(header, footer));
|
this.player.sendPlayerListHeaderAndFooter(header, footer);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHeaderAndFooter(net.kyori.adventure.text.Component header,
|
|
||||||
net.kyori.adventure.text.Component footer) {
|
|
||||||
Preconditions.checkNotNull(header, "header");
|
|
||||||
Preconditions.checkNotNull(footer, "footer");
|
|
||||||
connection.write(HeaderAndFooter.create(header, footer, connection.getProtocolVersion()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,7 +3,7 @@ package com.velocitypowered.proxy.tablist;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.velocitypowered.api.proxy.player.TabListEntry;
|
import com.velocitypowered.api.proxy.player.TabListEntry;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PlayerListItem;
|
import com.velocitypowered.proxy.protocol.packet.PlayerListItem;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PlayerListItem.Item;
|
import com.velocitypowered.proxy.protocol.packet.PlayerListItem.Item;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -18,14 +18,16 @@ public class VelocityTabListLegacy extends VelocityTabList {
|
|||||||
|
|
||||||
private final Map<String, UUID> nameMapping = new ConcurrentHashMap<>();
|
private final Map<String, UUID> nameMapping = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public VelocityTabListLegacy(MinecraftConnection connection) {
|
public VelocityTabListLegacy(final ConnectedPlayer player) {
|
||||||
super(connection);
|
super(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer) {
|
public void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void setHeaderAndFooter(Component header, Component footer) {
|
public void setHeaderAndFooter(Component header, Component footer) {
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren