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