mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-21 16:37:42 +01:00
brainwaves
This commit is contained in:
@@ -53,6 +53,9 @@ import com.velocitypowered.proxy.VelocityServer;
|
|||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation;
|
import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation;
|
||||||
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
||||||
|
import com.velocitypowered.proxy.connection.player.LegacyResourcePackManager;
|
||||||
|
import com.velocitypowered.proxy.connection.player.ModernResourcePackManager;
|
||||||
|
import com.velocitypowered.proxy.connection.player.ResourcePackManager;
|
||||||
import com.velocitypowered.proxy.connection.player.VelocityResourcePackInfo;
|
import com.velocitypowered.proxy.connection.player.VelocityResourcePackInfo;
|
||||||
import com.velocitypowered.proxy.connection.util.ConnectionMessages;
|
import com.velocitypowered.proxy.connection.util.ConnectionMessages;
|
||||||
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
|
||||||
@@ -150,6 +153,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
private ClientConnectionPhase connectionPhase;
|
private ClientConnectionPhase connectionPhase;
|
||||||
private final CompletableFuture<Void> teardownFuture = new CompletableFuture<>();
|
private final CompletableFuture<Void> teardownFuture = new CompletableFuture<>();
|
||||||
private @MonotonicNonNull List<String> serversToTry = null;
|
private @MonotonicNonNull List<String> serversToTry = null;
|
||||||
|
private ResourcePackManager resourcePackManager;
|
||||||
private @MonotonicNonNull Boolean previousResourceResponse;
|
private @MonotonicNonNull Boolean previousResourceResponse;
|
||||||
private final Queue<ResourcePackInfo> outstandingResourcePacks = new ArrayDeque<>();
|
private final Queue<ResourcePackInfo> outstandingResourcePacks = new ArrayDeque<>();
|
||||||
private @Nullable ResourcePackInfo pendingResourcePack;
|
private @Nullable ResourcePackInfo pendingResourcePack;
|
||||||
@@ -186,6 +190,13 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
} else {
|
} else {
|
||||||
this.tabList = new VelocityTabListLegacy(this, server);
|
this.tabList = new VelocityTabListLegacy(this, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (connection.getProtocolVersion().getProtocol() >= ProtocolVersion.MINECRAFT_1_20_2.getProtocol()) {
|
||||||
|
this.resourcePackManager = new ModernResourcePackManager(this);
|
||||||
|
} else {
|
||||||
|
this.resourcePackManager = new LegacyResourcePackManager(this);
|
||||||
|
}
|
||||||
|
|
||||||
this.playerKey = playerKey;
|
this.playerKey = playerKey;
|
||||||
this.chatQueue = new ChatQueue(this);
|
this.chatQueue = new ChatQueue(this);
|
||||||
this.chatBuilderFactory = new ChatBuilderFactory(this.getProtocolVersion());
|
this.chatBuilderFactory = new ChatBuilderFactory(this.getProtocolVersion());
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.velocitypowered.proxy.connection.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
|
|
||||||
|
public class LegacyResourcePackManager implements ResourcePackManager {
|
||||||
|
private final ConnectedPlayer connectedPlayer;
|
||||||
|
|
||||||
|
public LegacyResourcePackManager(ConnectedPlayer connectedPlayer) {
|
||||||
|
this.connectedPlayer = connectedPlayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.velocitypowered.proxy.connection.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
|
|
||||||
|
public class ModernResourcePackManager implements ResourcePackManager {
|
||||||
|
private final ConnectedPlayer connectedPlayer;
|
||||||
|
|
||||||
|
public ModernResourcePackManager(ConnectedPlayer connectedPlayer) {
|
||||||
|
this.connectedPlayer = connectedPlayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.velocitypowered.proxy.connection.player;
|
||||||
|
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest;
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponse;
|
||||||
|
|
||||||
|
public interface ResourcePackManager {
|
||||||
|
|
||||||
|
void processResponse(ResourcePackResponse response);
|
||||||
|
|
||||||
|
void sendRequest(ResourcePackRequest request);
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ public final class VelocityResourcePackInfo implements ResourcePackInfo {
|
|||||||
|
|
||||||
private final UUID id;
|
private final UUID id;
|
||||||
private final String url;
|
private final String url;
|
||||||
private final @Nullable byte[] hash;
|
private final byte @Nullable [] hash;
|
||||||
private final boolean shouldForce;
|
private final boolean shouldForce;
|
||||||
private final @Nullable Component prompt; // 1.17+ only
|
private final @Nullable Component prompt; // 1.17+ only
|
||||||
private final Origin origin;
|
private final Origin origin;
|
||||||
@@ -89,19 +89,13 @@ public final class VelocityResourcePackInfo implements ResourcePackInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder asBuilder() {
|
public Builder asBuilder() {
|
||||||
return new BuilderImpl(url)
|
return new BuilderImpl(url).setId(id).setShouldForce(shouldForce).setHash(hash)
|
||||||
.setId(id)
|
|
||||||
.setShouldForce(shouldForce)
|
|
||||||
.setHash(hash)
|
|
||||||
.setPrompt(prompt);
|
.setPrompt(prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder asBuilder(String newUrl) {
|
public Builder asBuilder(String newUrl) {
|
||||||
return new BuilderImpl(newUrl)
|
return new BuilderImpl(newUrl).setId(id).setShouldForce(shouldForce).setHash(hash)
|
||||||
.setId(id)
|
|
||||||
.setShouldForce(shouldForce)
|
|
||||||
.setHash(hash)
|
|
||||||
.setPrompt(prompt);
|
.setPrompt(prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +107,7 @@ public final class VelocityResourcePackInfo implements ResourcePackInfo {
|
|||||||
private UUID id;
|
private UUID id;
|
||||||
private final String url;
|
private final String url;
|
||||||
private boolean shouldForce;
|
private boolean shouldForce;
|
||||||
private @Nullable byte[] hash;
|
private byte @Nullable [] hash;
|
||||||
private @Nullable Component prompt;
|
private @Nullable Component prompt;
|
||||||
private Origin origin = Origin.PLUGIN_ON_PROXY;
|
private Origin origin = Origin.PLUGIN_ON_PROXY;
|
||||||
|
|
||||||
@@ -135,7 +129,7 @@ public final class VelocityResourcePackInfo implements ResourcePackInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuilderImpl setHash(@Nullable byte[] hash) {
|
public BuilderImpl setHash(byte @Nullable [] hash) {
|
||||||
if (hash != null) {
|
if (hash != null) {
|
||||||
Preconditions.checkArgument(hash.length == 20, "Hash length is not 20");
|
Preconditions.checkArgument(hash.length == 20, "Hash length is not 20");
|
||||||
this.hash = hash.clone(); // Thanks spotbugs, very helpful.
|
this.hash = hash.clone(); // Thanks spotbugs, very helpful.
|
||||||
|
|||||||
Reference in New Issue
Block a user