mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-14 11:05:10 -05:00
Added support for 3D Shareware clients
This commit is contained in:
parent
920de17dd0
commit
fa9b6fd976
6 changed files with 38 additions and 11 deletions
|
@ -16,6 +16,7 @@ For a full user guide go to the [Usage for Players](#usage-for-players-gui) sect
|
|||
|
||||
## Supported Client versions
|
||||
- Release (1.7.2 - 1.21.1)
|
||||
- April Fools (3D Shareware)
|
||||
- Bedrock Edition (Requires the [Geyser plugin](https://geysermc.org/download))
|
||||
- Beta 1.7.3 (Requires the [Beta2Release plugin](https://github.com/ViaVersionAddons/ViaProxyBeta2Release))
|
||||
- Classic, Alpha, Beta, Release 1.0 - 1.6.4 (Only passthrough)
|
||||
|
|
|
@ -18,15 +18,14 @@
|
|||
package net.raphimc.viaproxy.protocoltranslator.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import net.raphimc.netminecraft.constants.MCPipeline;
|
||||
import net.raphimc.vialoader.netty.VLPipeline;
|
||||
|
||||
public class ViaProxyVLPipeline extends VLPipeline {
|
||||
|
||||
public ViaProxyVLPipeline(UserConnection user, ProtocolVersion version) {
|
||||
super(user, version);
|
||||
public ViaProxyVLPipeline(final UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,17 +19,34 @@ package net.raphimc.viaproxy.protocoltranslator.providers;
|
|||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionType;
|
||||
import com.viaversion.viaversion.protocol.RedirectProtocolVersion;
|
||||
import com.viaversion.viaversion.protocol.version.BaseVersionProvider;
|
||||
import net.raphimc.viaproxy.proxy.session.ProxyConnection;
|
||||
|
||||
public class ViaProxyVersionProvider extends BaseVersionProvider {
|
||||
|
||||
@Override
|
||||
public ProtocolVersion getClosestServerProtocol(UserConnection connection) throws Exception {
|
||||
public ProtocolVersion getClientProtocol(UserConnection connection) {
|
||||
final ProtocolVersion clientProtocol = connection.getProtocolInfo().protocolVersion();
|
||||
if (clientProtocol.getVersionType() == VersionType.SPECIAL && ProtocolVersion.isRegistered(VersionType.SPECIAL, clientProtocol.getOriginalVersion())) {
|
||||
return ProtocolVersion.getProtocol(VersionType.SPECIAL, clientProtocol.getOriginalVersion());
|
||||
} else {
|
||||
return super.getClientProtocol(connection);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtocolVersion getClosestServerProtocol(UserConnection connection) {
|
||||
final ProtocolVersion clientProtocol = connection.getProtocolInfo().protocolVersion();
|
||||
if (connection.isClientSide()) {
|
||||
return ProxyConnection.fromUserConnection(connection).getServerVersion();
|
||||
} else if (clientProtocol.getVersionType() == VersionType.RELEASE) {
|
||||
return clientProtocol;
|
||||
} else if (clientProtocol instanceof RedirectProtocolVersion redirectProtocolVersion) {
|
||||
return redirectProtocolVersion.getOrigin();
|
||||
} else {
|
||||
return super.getClosestServerProtocol(connection);
|
||||
return ProtocolVersion.v1_7_2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,15 +17,21 @@
|
|||
*/
|
||||
package net.raphimc.viaproxy.proxy.client2proxy;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.handler.codec.haproxy.HAProxyMessageDecoder;
|
||||
import net.raphimc.netminecraft.constants.MCPipeline;
|
||||
import net.raphimc.netminecraft.netty.codec.NoReadFlowControlHandler;
|
||||
import net.raphimc.netminecraft.netty.connection.MinecraftChannelInitializer;
|
||||
import net.raphimc.netminecraft.packet.registry.DefaultPacketRegistry;
|
||||
import net.raphimc.vialoader.netty.VLPipeline;
|
||||
import net.raphimc.viaproxy.ViaProxy;
|
||||
import net.raphimc.viaproxy.plugins.events.Client2ProxyChannelInitializeEvent;
|
||||
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
||||
import net.raphimc.viaproxy.protocoltranslator.impl.ViaProxyVLPipeline;
|
||||
import net.raphimc.viaproxy.proxy.client2proxy.passthrough.LegacyPassthroughInitialHandler;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
@ -58,6 +64,11 @@ public class Client2ProxyChannelInitializer extends MinecraftChannelInitializer
|
|||
super.initChannel(channel);
|
||||
channel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(new DefaultPacketRegistry(false, -1));
|
||||
|
||||
final UserConnection user = new UserConnectionImpl(channel, false);
|
||||
new ProtocolPipelineImpl(user);
|
||||
channel.pipeline().addLast(new ViaProxyVLPipeline(user));
|
||||
channel.pipeline().addAfter(VLPipeline.VIA_CODEC_NAME, "via-" + MCPipeline.FLOW_CONTROL_HANDLER_NAME, new NoReadFlowControlHandler());
|
||||
|
||||
if (ViaProxy.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.POST, channel, false)).isCancelled()) {
|
||||
channel.close();
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<Packet> {
|
|||
this.proxyConnection.setClientVersion(clientVersion);
|
||||
this.proxyConnection.setC2pConnectionState(packet.intendedState.getConnectionState());
|
||||
|
||||
if (!clientVersion.isKnown()) {
|
||||
if (!ProtocolVersion.isRegistered(clientVersion.getVersionType(), clientVersion.getOriginalVersion())) {
|
||||
this.proxyConnection.kickClient("§cYour client version is not supported by ViaProxy!");
|
||||
}
|
||||
|
||||
|
|
|
@ -62,10 +62,6 @@ public class Proxy2ServerChannelInitializer extends MinecraftChannelInitializer
|
|||
|
||||
final ProxyConnection proxyConnection = ProxyConnection.fromChannel(channel);
|
||||
|
||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
||||
new ProtocolPipelineImpl(user);
|
||||
proxyConnection.setUserConnection(user);
|
||||
|
||||
if (ViaProxy.getConfig().getBackendProxyUrl() != null && !proxyConnection.getServerVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
channel.pipeline().addLast(VIAPROXY_PROXY_HANDLER_NAME, this.getProxyHandler());
|
||||
}
|
||||
|
@ -76,7 +72,10 @@ public class Proxy2ServerChannelInitializer extends MinecraftChannelInitializer
|
|||
super.initChannel(channel);
|
||||
channel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(new DefaultPacketRegistry(true, proxyConnection.getClientVersion().getVersion()));
|
||||
|
||||
channel.pipeline().addLast(new ViaProxyVLPipeline(user, proxyConnection.getServerVersion()));
|
||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
||||
new ProtocolPipelineImpl(user);
|
||||
proxyConnection.setUserConnection(user);
|
||||
channel.pipeline().addLast(new ViaProxyVLPipeline(user));
|
||||
channel.pipeline().addAfter(VLPipeline.VIA_CODEC_NAME, "via-" + MCPipeline.FLOW_CONTROL_HANDLER_NAME, new NoReadFlowControlHandler());
|
||||
if (proxyConnection.getServerVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||
channel.pipeline().remove(MCPipeline.COMPRESSION_HANDLER_NAME);
|
||||
|
|
Loading…
Reference in a new issue