Try to make some of the suggested changes
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
87bcefd08a
commit
94067f34cf
@ -192,7 +192,7 @@ void MinecraftInstance::loadSpecificSettings()
|
||||
m_settings->registerSetting("JoinServerOnLaunch", false);
|
||||
m_settings->registerSetting("JoinServerOnLaunchAddress", "");
|
||||
|
||||
m_settings->registerSetting("LegacySkinFix", true);
|
||||
m_settings->registerSetting("LegacySkinFix", true);
|
||||
|
||||
qDebug() << "Instance-type specific settings were loaded!";
|
||||
|
||||
@ -441,7 +441,9 @@ QStringList MinecraftInstance::javaArguments()
|
||||
args << "-Duser.language=en";
|
||||
|
||||
if (javaVersion.isModular() && traits().contains("legacySkins") && settings()->get("LegacySkinFix").toBool())
|
||||
args << "--add-opens" << "java.base/java.net=ALL-UNNAMED";
|
||||
// allow reflective access to java.net - required by the skin fix
|
||||
args << "--add-opens"
|
||||
<< "java.base/java.net=ALL-UNNAMED";
|
||||
|
||||
return args;
|
||||
}
|
||||
|
@ -23,8 +23,7 @@ set(SRC
|
||||
org/prismlauncher/utils/JsonParser.java
|
||||
org/prismlauncher/utils/Parameters.java
|
||||
org/prismlauncher/utils/ReflectionUtils.java
|
||||
org/prismlauncher/utils/url/NullConnection.java
|
||||
org/prismlauncher/utils/url/UrlUtils.java
|
||||
org/prismlauncher/utils/UrlUtils.java
|
||||
org/prismlauncher/utils/logging/Level.java
|
||||
org/prismlauncher/utils/logging/Log.java
|
||||
net/minecraft/Launcher.java
|
||||
|
@ -45,8 +45,7 @@ import java.util.Map;
|
||||
|
||||
import org.prismlauncher.utils.Base64;
|
||||
import org.prismlauncher.utils.JsonParser;
|
||||
import org.prismlauncher.utils.url.NullConnection;
|
||||
import org.prismlauncher.utils.url.UrlUtils;
|
||||
import org.prismlauncher.utils.UrlUtils;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final class Handler extends URLStreamHandler {
|
||||
@ -71,10 +70,6 @@ final class Handler extends URLStreamHandler {
|
||||
@Override
|
||||
protected URLConnection openConnection(URL address, Proxy proxy) throws IOException {
|
||||
address = redirect(address);
|
||||
|
||||
if (address == null)
|
||||
return NullConnection.INSTANCE;
|
||||
|
||||
return UrlUtils.openHttpConnection(address, proxy);
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,8 @@ import java.net.URLStreamHandlerFactory;
|
||||
import org.prismlauncher.fix.Fix;
|
||||
import org.prismlauncher.utils.Base64;
|
||||
import org.prismlauncher.utils.Parameters;
|
||||
import org.prismlauncher.utils.UrlUtils;
|
||||
import org.prismlauncher.utils.logging.Log;
|
||||
import org.prismlauncher.utils.url.UrlUtils;
|
||||
|
||||
/**
|
||||
* Fixes skins by redirecting to other URLs.
|
||||
|
@ -33,7 +33,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.prismlauncher.utils.url;
|
||||
package org.prismlauncher.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
@ -47,8 +47,8 @@ import java.net.URLStreamHandler;
|
||||
import org.prismlauncher.utils.logging.Log;
|
||||
|
||||
/**
|
||||
* A utility class for URLs which uses reflection to access hidden methods.
|
||||
* Unfortunately not supported on newer Java versions.
|
||||
* A utility class for URLs which uses reflection to access constructors for
|
||||
* internal classes.
|
||||
*/
|
||||
public final class UrlUtils {
|
||||
|
||||
@ -57,12 +57,12 @@ public final class UrlUtils {
|
||||
|
||||
static {
|
||||
try {
|
||||
// invoke URL.getURLStreamHandler to obtain some of the default handlers before
|
||||
// they are overridden
|
||||
// we first obtain the stock URLStreamHandler for http as we overwrite it later
|
||||
Method getURLStreamHandler = URL.class.getDeclaredMethod("getURLStreamHandler", String.class);
|
||||
getURLStreamHandler.setAccessible(true);
|
||||
http = (URLStreamHandler) getURLStreamHandler.invoke(null, "http");
|
||||
|
||||
// we next find the openConnection method
|
||||
Method openConnectionReflect = URLStreamHandler.class.getDeclaredMethod("openConnection", URL.class,
|
||||
Proxy.class);
|
||||
openConnectionReflect.setAccessible(true);
|
||||
@ -97,7 +97,7 @@ public final class UrlUtils {
|
||||
} catch (IOException | Error | RuntimeException e) {
|
||||
throw e; // rethrow if possible
|
||||
} catch (Throwable e) {
|
||||
throw new Error(e); // otherwise, wrap in Error
|
||||
throw new AssertionError(e); // oh dear! this isn't meant to happen
|
||||
}
|
||||
}
|
||||
|
@ -1,66 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
|
||||
*
|
||||
* 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, version 3.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Linking this library statically or dynamically with other modules is
|
||||
* making a combined work based on this library. Thus, the terms and
|
||||
* conditions of the GNU General Public License cover the whole
|
||||
* combination.
|
||||
*
|
||||
* As a special exception, the copyright holders of this library give
|
||||
* you permission to link this library with independent modules to
|
||||
* produce an executable, regardless of the license terms of these
|
||||
* independent modules, and to copy and distribute the resulting
|
||||
* executable under terms of your choice, provided that you also meet,
|
||||
* for each linked independent module, the terms and conditions of the
|
||||
* license of that module. An independent module is a module which is
|
||||
* not derived from or based on this library. If you modify this
|
||||
* library, you may extend this exception to your version of the
|
||||
* library, but you are not obliged to do so. If you do not wish to do
|
||||
* so, delete this exception statement from your version.
|
||||
*
|
||||
* 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 org.prismlauncher.utils.url;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
|
||||
/**
|
||||
* Spoof 404 response from server to avoid unnecessary requests.
|
||||
*/
|
||||
public final class NullConnection extends HttpURLConnection {
|
||||
|
||||
public static final NullConnection INSTANCE = new NullConnection();
|
||||
|
||||
public NullConnection() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect() throws IOException {
|
||||
responseCode = 404;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usingProxy() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user