geforkt von Mirrors/Velocity
Fixed duplicate sending of resource packs responses to backend server (#1249)
Also fixes the sending of SUCCESSFUL responses to the backend server that will apply a resource pack in case Velocity has already applied one or more resource packs to the player
Dieser Commit ist enthalten in:
Ursprung
fc3bc1f3fe
Commit
7ca0689989
@ -95,9 +95,6 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ResourcePackResponsePacket packet) {
|
public boolean handle(ResourcePackResponsePacket packet) {
|
||||||
if (player.getConnectionInFlight() != null) {
|
|
||||||
player.getConnectionInFlight().ensureConnected().write(packet);
|
|
||||||
}
|
|
||||||
return player.resourcePackHandler().onResourcePackResponse(
|
return player.resourcePackHandler().onResourcePackResponse(
|
||||||
new ResourcePackResponseBundle(packet.getId(),
|
new ResourcePackResponseBundle(packet.getId(),
|
||||||
packet.getHash(),
|
packet.getHash(),
|
||||||
|
@ -146,10 +146,20 @@ public final class ModernResourcePackHandler extends ResourcePackHandler {
|
|||||||
}
|
}
|
||||||
// The resource pack has been applied correctly.
|
// The resource pack has been applied correctly.
|
||||||
case SUCCESSFUL -> {
|
case SUCCESSFUL -> {
|
||||||
|
pendingResourcePacks.remove(uuid);
|
||||||
if (queued != null) {
|
if (queued != null) {
|
||||||
appliedResourcePacks.put(uuid, queued);
|
appliedResourcePacks.put(uuid, queued);
|
||||||
|
} else {
|
||||||
|
// When transitioning to another server that has a resource pack to apply,
|
||||||
|
// if one or more resource packs have already been applied from Velocity,
|
||||||
|
// the player sends more than 1 SUCCESSFUL response to the backend server,
|
||||||
|
// which results in the server receiving more resource pack responses
|
||||||
|
// than the server has sent requests to the player
|
||||||
|
final ResourcePackInfo appliedPack = appliedResourcePacks.get(uuid);
|
||||||
|
if (appliedPack != null) {
|
||||||
|
return handleResponseResult(appliedPack, bundle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pendingResourcePacks.remove(uuid);
|
|
||||||
}
|
}
|
||||||
// An error occurred while trying to download the resource pack to the client,
|
// An error occurred while trying to download the resource pack to the client,
|
||||||
// so the resource pack cannot be applied.
|
// so the resource pack cannot be applied.
|
||||||
|
@ -20,6 +20,7 @@ package com.velocitypowered.proxy.connection.player.resourcepack;
|
|||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
|
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
|
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.connection.player.VelocityResourcePackInfo;
|
import com.velocitypowered.proxy.connection.player.VelocityResourcePackInfo;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequestPacket;
|
||||||
@ -147,12 +148,15 @@ public abstract sealed class ResourcePackHandler
|
|||||||
final @Nullable ResourcePackInfo queued,
|
final @Nullable ResourcePackInfo queued,
|
||||||
final @NotNull ResourcePackResponseBundle bundle
|
final @NotNull ResourcePackResponseBundle bundle
|
||||||
) {
|
) {
|
||||||
|
// If Velocity, through a plugin, has sent a resource pack to the client,
|
||||||
|
// there is no need to report the status of the response to the server
|
||||||
|
// since it has no information that a resource pack has been sent
|
||||||
final boolean handled = queued != null
|
final boolean handled = queued != null
|
||||||
&& queued.getOriginalOrigin() != ResourcePackInfo.Origin.DOWNSTREAM_SERVER;
|
&& queued.getOriginalOrigin() == ResourcePackInfo.Origin.PLUGIN_ON_PROXY;
|
||||||
if (!handled) {
|
if (!handled) {
|
||||||
if (player.getConnectionInFlight() != null
|
final VelocityServerConnection connectionInFlight = player.getConnectionInFlight();
|
||||||
&& player.getConnectionInFlight().getConnection() != null) {
|
if (connectionInFlight != null && connectionInFlight.getConnection() != null) {
|
||||||
player.getConnectionInFlight().getConnection().write(new ResourcePackResponsePacket(
|
connectionInFlight.getConnection().write(new ResourcePackResponsePacket(
|
||||||
bundle.uuid(), bundle.hash(), bundle.status()));
|
bundle.uuid(), bundle.hash(), bundle.status()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren