|
| 1 | +/* |
| 2 | + * This file is part of OneConfig. |
| 3 | + * OneConfig - Next Generation Config Library for Minecraft: Java Edition |
| 4 | + * Copyright (C) 2021~2023 Polyfrost. |
| 5 | + * <https://polyfrost.cc> <https://github.com/Polyfrost/> |
| 6 | + * |
| 7 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 8 | + * |
| 9 | + * OneConfig is licensed under the terms of version 3 of the GNU Lesser |
| 10 | + * General Public License as published by the Free Software Foundation, AND |
| 11 | + * under the Additional Terms Applicable to OneConfig, as published by Polyfrost, |
| 12 | + * either version 1.0 of the Additional Terms, or (at your option) any later |
| 13 | + * version. |
| 14 | + * |
| 15 | + * This program is distributed in the hope that it will be useful, |
| 16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | + * Lesser General Public License for more details. |
| 19 | + * |
| 20 | + * You should have received a copy of the GNU Lesser General Public |
| 21 | + * License. If not, see <https://www.gnu.org/licenses/>. You should |
| 22 | + * have also received a copy of the Additional Terms Applicable |
| 23 | + * to OneConfig, as published by Polyfrost. If not, see |
| 24 | + * <https://polyfrost.cc/legal/oneconfig/additional-terms> |
| 25 | + */ |
| 26 | + |
| 27 | +package cc.polyfrost.oneconfig.internal.mixin; |
| 28 | + |
| 29 | +import cc.polyfrost.oneconfig.internal.hacks.SkyClientUpdaterHack; |
| 30 | +import org.spongepowered.asm.mixin.Dynamic; |
| 31 | +import org.spongepowered.asm.mixin.Mixin; |
| 32 | +import org.spongepowered.asm.mixin.Pseudo; |
| 33 | +import org.spongepowered.asm.mixin.Unique; |
| 34 | +import org.spongepowered.asm.mixin.injection.At; |
| 35 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 36 | +import org.spongepowered.asm.mixin.injection.Redirect; |
| 37 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
| 38 | + |
| 39 | +import javax.net.ssl.HttpsURLConnection; |
| 40 | +import java.io.InputStream; |
| 41 | + |
| 42 | +@Pseudo |
| 43 | +@Mixin(targets = "mynameisjeff.skyblockclientupdater.UpdateChecker", remap = false) |
| 44 | +public class SkyClientUpdaterMixin { |
| 45 | + |
| 46 | + @Unique private HttpsURLConnection oneconfig$connection; |
| 47 | + |
| 48 | + @Dynamic("SCC 1.3.6 or below. If this doesn't apply, Minecraft should still work fine.") |
| 49 | + @Redirect(method = "setupConnection", at = @At(value = "INVOKE", target = "Lkotlin/jvm/internal/Intrinsics;checkNotNull(Ljava/lang/Object;Ljava/lang/String;)V")) |
| 50 | + private void fixSSLOnOlderSCC(Object connection, String error) { |
| 51 | + this.oneconfig$connection = (HttpsURLConnection) connection; |
| 52 | + } |
| 53 | + |
| 54 | + @Dynamic("SCC 1.3.6 or below. If this doesn't apply, Minecraft should still work fine.") |
| 55 | + @Inject(method = "setupConnection", at = @At(value = "INVOKE", target = "Ljavax/net/ssl/HttpsURLConnection;getInputStream()Ljava/io/InputStream;")) |
| 56 | + private void fixSSLOnOlderSCC(String url, CallbackInfoReturnable<InputStream> cir) { |
| 57 | + if (this.oneconfig$connection != null) { |
| 58 | + this.oneconfig$connection.setSSLSocketFactory(SkyClientUpdaterHack.INSTANCE.getSSLContext().getSocketFactory()); |
| 59 | + } |
| 60 | + } |
| 61 | +} |
0 commit comments