mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-01-23 21:51:26 +01:00
Refactor ProtocolHack#injectPreviousVersionReset to match modifications
This commit is contained in:
parent
b5b677da71
commit
ac7121be47
@ -75,7 +75,7 @@ public abstract class MixinConnectScreen_1 {
|
|||||||
this.viaFabricPlus$useClassiCubeAccount = AuthenticationSettings.global().setSessionNameToClassiCubeNameInServerList.getValue() && ViaFabricPlusClassicMPPassProvider.classicMpPassForNextJoin != null;
|
this.viaFabricPlus$useClassiCubeAccount = AuthenticationSettings.global().setSessionNameToClassiCubeNameInServerList.getValue() && ViaFabricPlusClassicMPPassProvider.classicMpPassForNextJoin != null;
|
||||||
|
|
||||||
final ChannelFuture future = original.call(address, useEpoll, connection);
|
final ChannelFuture future = original.call(address, useEpoll, connection);
|
||||||
future.channel().closeFuture().addListener(channel -> ProtocolHack.resetPreviousVersion());
|
ProtocolHack.injectPreviousVersionReset(future.channel());
|
||||||
|
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public abstract class MixinMinecraftClient {
|
|||||||
@Inject(method = "startIntegratedServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/lang/String;ILnet/minecraft/network/listener/ClientLoginPacketListener;)V", shift = At.Shift.BEFORE))
|
@Inject(method = "startIntegratedServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/lang/String;ILnet/minecraft/network/listener/ClientLoginPacketListener;)V", shift = At.Shift.BEFORE))
|
||||||
private void disableProtocolHack(LevelStorage.Session session, ResourcePackManager dataPackManager, SaveLoader saveLoader, boolean newWorld, CallbackInfo ci, @Local ClientConnection clientConnection) {
|
private void disableProtocolHack(LevelStorage.Session session, ResourcePackManager dataPackManager, SaveLoader saveLoader, boolean newWorld, CallbackInfo ci, @Local ClientConnection clientConnection) {
|
||||||
ProtocolHack.setTargetVersion(ProtocolHack.NATIVE_VERSION, true);
|
ProtocolHack.setTargetVersion(ProtocolHack.NATIVE_VERSION, true);
|
||||||
clientConnection.channel.closeFuture().addListener(channel -> ProtocolHack.resetPreviousVersion());
|
ProtocolHack.injectPreviousVersionReset(clientConnection.channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -162,11 +162,13 @@ public class ProtocolHack {
|
|||||||
/**
|
/**
|
||||||
* Resets the previous version if it is set. Calling {@link #setTargetVersion(VersionEnum, boolean)} with revertOnDisconnect set to true will set it.
|
* Resets the previous version if it is set. Calling {@link #setTargetVersion(VersionEnum, boolean)} with revertOnDisconnect set to true will set it.
|
||||||
*/
|
*/
|
||||||
public static void resetPreviousVersion() {
|
public static void injectPreviousVersionReset(final Channel channel) {
|
||||||
if (previousVersion != null) { // Revert the version if the player disconnects and a previous version is set
|
if (previousVersion == null) return;
|
||||||
|
|
||||||
|
channel.closeFuture().addListener(future -> {
|
||||||
setTargetVersion(previousVersion);
|
setTargetVersion(previousVersion);
|
||||||
previousVersion = null;
|
previousVersion = null;
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,11 +207,11 @@ public class ProtocolHack {
|
|||||||
*/
|
*/
|
||||||
public static UserConnection getPlayNetworkUserConnection() {
|
public static UserConnection getPlayNetworkUserConnection() {
|
||||||
final ClientPlayNetworkHandler handler = MinecraftClient.getInstance().getNetworkHandler();
|
final ClientPlayNetworkHandler handler = MinecraftClient.getInstance().getNetworkHandler();
|
||||||
if (handler != null) {
|
if (handler == null) {
|
||||||
return ((IClientConnection) handler.getConnection()).viaFabricPlus$getUserConnection();
|
throw new IllegalStateException("The player is not connected to a server");
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalStateException("The player is not connected to a server");
|
return ((IClientConnection) handler.getConnection()).viaFabricPlus$getUserConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user