3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Merge branch 'dev/1.1.0' into experiment/io_uring

# Conflicts:
#	proxy/build.gradle
Dieser Commit ist enthalten in:
Andrew Steinborn 2020-12-10 06:50:44 -05:00
Commit 08558b327e
9 geänderte Dateien mit 95 neuen und 38 gelöschten Zeilen

Datei anzeigen

@ -32,11 +32,12 @@ dependencies {
// DEPRECATED: Will be removed in Velocity 2.0.0
api 'com.moandjiezana.toml:toml4j:0.7.2'
api "net.kyori:adventure-api:${adventureVersion}"
api "net.kyori:adventure-text-serializer-gson:${adventureVersion}"
api "net.kyori:adventure-text-serializer-legacy:${adventureVersion}"
api "net.kyori:adventure-text-serializer-plain:${adventureVersion}"
api "net.kyori:adventure-text-serializer-legacy-text3:${adventurePlatformVersion}"
api(platform("net.kyori:adventure-bom:${adventureVersion}"))
api("net.kyori:adventure-api")
api("net.kyori:adventure-text-serializer-gson")
api("net.kyori:adventure-text-serializer-legacy")
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 'com.google.inject:guice:4.2.3'

Datei anzeigen

@ -146,6 +146,20 @@ public interface Player extends CommandSource, Identified, InboundConnection,
@Deprecated
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.
*

Datei anzeigen

@ -28,7 +28,9 @@ public interface TabList {
*
* @param header the header component
* @param footer the footer component
* @deprecated Use {@link Player#sendPlayerListHeaderAndFooter(Component, Component)} instead
*/
@Deprecated
void setHeaderAndFooter(Component header, Component footer);
/**

Datei anzeigen

@ -21,12 +21,12 @@ allprojects {
ext {
// dependency versions
textVersion = '3.0.4'
adventureVersion = '4.2.0'
adventureVersion = '4.3.0'
adventurePlatformVersion = '4.0.0-SNAPSHOT'
junitVersion = '5.7.0'
slf4jVersion = '1.7.30'
log4jVersion = '2.13.3'
nettyVersion = '4.1.54.Final'
nettyVersion = '4.1.55.Final'
guavaVersion = '25.1-jre'
checkerFrameworkVersion = '3.6.1'
configurateVersion = '3.7.1'

Datei anzeigen

@ -51,7 +51,7 @@ dependencies {
implementation "io.netty:netty-handler:${nettyVersion}"
implementation "io.netty:netty-transport-native-epoll:${nettyVersion}"
implementation "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64"
implementation "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-aarch64"
implementation "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-aarch_64"
implementation "io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.1.Final:linux-x86_64"
implementation "io.netty:netty-resolver-dns:${nettyVersion}"
@ -67,7 +67,9 @@ dependencies {
implementation 'it.unimi.dsi:fastutil:8.4.1'
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'

Datei anzeigen

@ -45,6 +45,7 @@ import com.velocitypowered.proxy.protocol.StateRegistry;
import com.velocitypowered.proxy.protocol.packet.Chat;
import com.velocitypowered.proxy.protocol.packet.ClientSettings;
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.PluginMessage;
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest;
@ -61,6 +62,7 @@ import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@ -105,6 +107,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
private @Nullable VelocityServerConnection connectionInFlight;
private @Nullable PlayerSettings settings;
private @Nullable ModInfo modInfo;
private Component playerListHeader = Component.empty();
private Component playerListFooter = Component.empty();
private final VelocityTabList tabList;
private final VelocityServer server;
private ClientConnectionPhase connectionPhase;
@ -115,11 +119,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
@Nullable InetSocketAddress virtualHost, boolean onlineMode) {
this.server = server;
if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
this.tabList = new VelocityTabList(connection);
} else {
this.tabList = new VelocityTabListLegacy(connection);
}
this.profile = profile;
this.connection = connection;
this.virtualHost = virtualHost;
@ -127,6 +126,12 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
this.connectionPhase = connection.getType().getInitialClientPhase();
this.knownChannels = CappedSet.create(MAX_PLUGIN_CHANNELS);
this.onlineMode = onlineMode;
if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
this.tabList = new VelocityTabList(this);
} else {
this.tabList = new VelocityTabListLegacy(this);
}
}
@Override
@ -301,6 +306,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
public void showTitle(net.kyori.adventure.title.@NonNull Title title) {
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(this
@ -363,6 +395,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
this.profile = profile.withProperties(Preconditions.checkNotNull(properties));
}
@Deprecated
@Override
public void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer) {
tabList.setHeaderAndFooter(header, footer);

Datei anzeigen

@ -8,6 +8,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
public class HeaderAndFooter implements MinecraftPacket {
@ -51,15 +52,8 @@ public class HeaderAndFooter implements MinecraftPacket {
return handler.handle(this);
}
public static HeaderAndFooter create(net.kyori.text.Component header,
net.kyori.text.Component footer) {
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) {
public static HeaderAndFooter create(Component header,
Component footer, ProtocolVersion protocolVersion) {
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(protocolVersion);
return new HeaderAndFooter(serializer.serialize(header), serializer.serialize(footer));
}

Datei anzeigen

@ -5,6 +5,7 @@ import com.velocitypowered.api.proxy.player.TabList;
import com.velocitypowered.api.proxy.player.TabListEntry;
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.HeaderAndFooter;
import com.velocitypowered.proxy.protocol.packet.PlayerListItem;
import java.util.ArrayList;
@ -15,31 +16,39 @@ import java.util.Map;
import java.util.Optional;
import java.util.UUID;
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;
public class VelocityTabList implements TabList {
protected final ConnectedPlayer player;
protected final MinecraftConnection connection;
protected final Map<UUID, VelocityTabListEntry> entries = new ConcurrentHashMap<>();
public VelocityTabList(MinecraftConnection connection) {
this.connection = connection;
public VelocityTabList(final ConnectedPlayer player) {
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
public void setHeaderAndFooter(Component header, Component footer) {
Preconditions.checkNotNull(header, "header");
Preconditions.checkNotNull(footer, "footer");
connection.write(HeaderAndFooter.create(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()));
this.player.sendPlayerListHeaderAndFooter(header, footer);
}
@Override

Datei anzeigen

@ -3,7 +3,7 @@ package com.velocitypowered.proxy.tablist;
import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.proxy.player.TabListEntry;
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.Item;
import java.util.Collections;
@ -18,14 +18,16 @@ public class VelocityTabListLegacy extends VelocityTabList {
private final Map<String, UUID> nameMapping = new ConcurrentHashMap<>();
public VelocityTabListLegacy(MinecraftConnection connection) {
super(connection);
public VelocityTabListLegacy(final ConnectedPlayer player) {
super(player);
}
@Deprecated
@Override
public void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer) {
}
@Deprecated
@Override
public void setHeaderAndFooter(Component header, Component footer) {
}