Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Handle KnownPacks packet required for 1.20.5 vanilla connections (#1302)
Dieser Commit ist enthalten in:
Ursprung
bf507dc0b8
Commit
3afd687bf1
@ -63,6 +63,7 @@ import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerChatP
|
|||||||
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommandPacket;
|
import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerCommandPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.ActiveFeaturesPacket;
|
import com.velocitypowered.proxy.protocol.packet.config.ActiveFeaturesPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
|
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.config.KnownPacksPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.RegistrySyncPacket;
|
import com.velocitypowered.proxy.protocol.packet.config.RegistrySyncPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
|
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdatePacket;
|
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdatePacket;
|
||||||
@ -334,4 +335,8 @@ public interface MinecraftSessionHandler {
|
|||||||
default boolean handle(TransferPacket transfer) {
|
default boolean handle(TransferPacket transfer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default boolean handle(KnownPacksPacket packet) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import com.velocitypowered.proxy.protocol.packet.PingIdentifyPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
|
import com.velocitypowered.proxy.protocol.packet.ResourcePackResponsePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
|
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.config.KnownPacksPacket;
|
||||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
@ -131,6 +132,15 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(KnownPacksPacket packet) {
|
||||||
|
if (player.getConnectionInFlight() != null) {
|
||||||
|
player.getConnectionInFlight().ensureConnected().write(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleGeneric(MinecraftPacket packet) {
|
public void handleGeneric(MinecraftPacket packet) {
|
||||||
VelocityServerConnection serverConnection = player.getConnectedServer();
|
VelocityServerConnection serverConnection = player.getConnectedServer();
|
||||||
|
@ -92,6 +92,7 @@ import com.velocitypowered.proxy.protocol.packet.chat.session.SessionPlayerComma
|
|||||||
import com.velocitypowered.proxy.protocol.packet.chat.session.UnsignedPlayerCommandPacket;
|
import com.velocitypowered.proxy.protocol.packet.chat.session.UnsignedPlayerCommandPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.ActiveFeaturesPacket;
|
import com.velocitypowered.proxy.protocol.packet.config.ActiveFeaturesPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
|
import com.velocitypowered.proxy.protocol.packet.config.FinishedUpdatePacket;
|
||||||
|
import com.velocitypowered.proxy.protocol.packet.config.KnownPacksPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.RegistrySyncPacket;
|
import com.velocitypowered.proxy.protocol.packet.config.RegistrySyncPacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
|
import com.velocitypowered.proxy.protocol.packet.config.StartUpdatePacket;
|
||||||
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdatePacket;
|
import com.velocitypowered.proxy.protocol.packet.config.TagsUpdatePacket;
|
||||||
@ -165,6 +166,10 @@ public enum StateRegistry {
|
|||||||
ResourcePackResponsePacket::new,
|
ResourcePackResponsePacket::new,
|
||||||
map(0x05, MINECRAFT_1_20_2, false),
|
map(0x05, MINECRAFT_1_20_2, false),
|
||||||
map(0x06, MINECRAFT_1_20_5, false));
|
map(0x06, MINECRAFT_1_20_5, false));
|
||||||
|
serverbound.register(
|
||||||
|
KnownPacksPacket.class,
|
||||||
|
KnownPacksPacket::new,
|
||||||
|
map(0x07, MINECRAFT_1_20_5, false));
|
||||||
|
|
||||||
clientbound.register(
|
clientbound.register(
|
||||||
PluginMessagePacket.class, PluginMessagePacket::new,
|
PluginMessagePacket.class, PluginMessagePacket::new,
|
||||||
@ -207,6 +212,8 @@ public enum StateRegistry {
|
|||||||
map(0x08, MINECRAFT_1_20_2, false),
|
map(0x08, MINECRAFT_1_20_2, false),
|
||||||
map(0x09, MINECRAFT_1_20_3, false),
|
map(0x09, MINECRAFT_1_20_3, false),
|
||||||
map(0x0D, MINECRAFT_1_20_5, false));
|
map(0x0D, MINECRAFT_1_20_5, false));
|
||||||
|
clientbound.register(KnownPacksPacket.class, KnownPacksPacket::new,
|
||||||
|
map(0x0E, MINECRAFT_1_20_5, false));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
PLAY {
|
PLAY {
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Velocity Contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.velocitypowered.proxy.protocol.packet.config;
|
||||||
|
|
||||||
|
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 io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
public class KnownPacksPacket implements MinecraftPacket {
|
||||||
|
|
||||||
|
private KnownPack[] packs;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,
|
||||||
|
ProtocolVersion protocolVersion) {
|
||||||
|
final int packCount = ProtocolUtils.readVarInt(buf);
|
||||||
|
final KnownPack[] packs = new KnownPack[packCount];
|
||||||
|
|
||||||
|
for (int i = 0; i < packCount; i++) {
|
||||||
|
packs[i] = KnownPack.read(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.packs = packs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void encode(ByteBuf buf, ProtocolUtils.Direction direction,
|
||||||
|
ProtocolVersion protocolVersion) {
|
||||||
|
ProtocolUtils.writeVarInt(buf, packs.length);
|
||||||
|
|
||||||
|
for (KnownPack pack : packs) {
|
||||||
|
pack.write(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(MinecraftSessionHandler handler) {
|
||||||
|
return handler.handle(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public record KnownPack(String namespace, String id, String version) {
|
||||||
|
private static KnownPack read(ByteBuf buf) {
|
||||||
|
return new KnownPack(ProtocolUtils.readString(buf), ProtocolUtils.readString(buf), ProtocolUtils.readString(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void write(ByteBuf buf) {
|
||||||
|
ProtocolUtils.writeString(buf, namespace);
|
||||||
|
ProtocolUtils.writeString(buf, id);
|
||||||
|
ProtocolUtils.writeString(buf, version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren