Compare commits

...

10 commits

Author SHA1 Message Date
58cc93c579 Fix things 2024-03-16 16:11:59 -07:00
1a681d4c0a Get everything working 2023-12-05 19:32:17 -07:00
758fcbb4e0 Delete old JavaFX as it is deprecated 2023-12-04 04:15:35 -07:00
672ccde696 Update archive classifier 2023-12-04 04:13:37 -07:00
461fdb1c98 Update build files 2023-12-04 04:12:10 -07:00
ca98123efc Update build files 2023-12-04 04:11:47 -07:00
fc03fecfb4 Update build files 2023-12-04 04:11:15 -07:00
1b6f2106cb Update build files 2023-12-04 04:11:06 -07:00
087c725bd4 Update build files 2023-12-04 04:10:31 -07:00
dcaf72c438 Update build files 2023-12-04 04:09:57 -07:00
23 changed files with 229 additions and 253 deletions

View file

@ -13,27 +13,41 @@ plugins {
id 'application'
}
sourceCompatibility = '1.17'
targetCompatibility = '1.17'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
configurations {
provided
compile.extendsFrom(provided)
runtime.extendsFrom(provided)
implementation.extendsFrom(provided)
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
gradlePluginPortal()
maven {
url = "https://maven.zontreck.com/repository/internal"
name = "Caches"
}
maven {
url = "https://maven.zontreck.com/repository/zontreck"
name = "ACRepo"
}
}
dependencies {
implementation ("com.google.code.gson:gson:2.10.1")
provided ("com.google.code.gson:gson:2.10.1")
//implementation ("com.google.code.findbugs:jsr305:3.0.2")
implementation ("com.google.guava:guava:31.1-jre")
provided ("com.google.guava:guava:31.1-jre")
implementation ("net.sf.jopt-simple:jopt-simple:5.0.4")
provided ("net.sf.jopt-simple:jopt-simple:5.0.4")
//implementation ("org.apache.commons:commons-lang3:3.12.0")
implementation ("org.apache.commons:commons-text:1.10.0")
implementation ("commons-io:commons-io:2.11.0")
implementation ("commons-codec:commons-codec:1.15")
implementation ("org.apache.logging.log4j:log4j-core:2.19.0")
implementation ("org.apache.logging.log4j:log4j-api:2.19.0")
provided ("org.apache.commons:commons-text:1.10.0")
provided ("commons-io:commons-io:2.11.0")
provided ("commons-codec:commons-codec:1.15")
provided ("org.apache.logging.log4j:log4j-core:2.19.0")
provided ("org.apache.logging.log4j:log4j-api:2.19.0")
provided ("dev.zontreck:LibAC:1.5.11")
}
@ -63,9 +77,9 @@ task jarjar(type: Jar) {
'Multi-Release': 'true'
)
}
classifier = "AIO"
archiveClassifier = "AIO"
duplicatesStrategy = "exclude"
from { configurations.external.collect { it.isDirectory() ? it : zipTree(it) } }
from { configurations.provided.collect { it.isDirectory() ? it : zipTree(it) } }
exclude 'META-INF/*'
exclude 'META-INF/*'

View file

@ -4,12 +4,14 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.UserType;
import com.mojang.authlib.exceptions.AuthenticationException;
import com.mojang.authlib.properties.PropertyMap;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
public interface UserAuthentication {
public boolean canLogIn();
public void logIn() throws AuthenticationException;
public void logIn() throws AuthenticationException, NoSuchAlgorithmException;
public void doRegister(String username, String password) throws AuthenticationException;

View file

@ -5,7 +5,7 @@ import java.util.Map;
public enum UserType {
LEGACY("legacy"),
MOJANG("mojang");
MOJANG("zontreck");
private static final Map<String, UserType> BY_NAME;
private final String name;

View file

@ -18,8 +18,7 @@ import java.util.HashMap;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
public class LegacyUserAuthentication
extends HttpUserAuthentication {
public class LegacyUserAuthentication extends HttpUserAuthentication {
public static final URL AUTHENTICATION_URL = HttpAuthenticationService.constantURL(LauncherConstants.URL_LOGIN);
private static final int AUTHENTICATION_VERSION = 14;
private static final int RESPONSE_PART_PROFILE_NAME = 2;
@ -69,6 +68,11 @@ extends HttpUserAuthentication {
this.setUserType(UserType.LEGACY);
}
@Override
public void doRegister(String username, String password) throws AuthenticationException {
System.out.println("Perform Registration!");
}
@Override
public void logOut() {
super.logOut();

View file

@ -55,7 +55,7 @@ implements GameProfileRepository {
do {
failed = false;
try {
final ProfileSearchResultsResponse response = this.authenticationService.makeRequest(HttpAuthenticationService.constantURL("https://api.mojang.com/profiles/" + agent.getName().toLowerCase()), request, ProfileSearchResultsResponse.class);
final ProfileSearchResultsResponse response = this.authenticationService.makeRequest(HttpAuthenticationService.constantURL("https://api.zontreck.com/crafting/profiles/" + agent.getName().toLowerCase()), request, ProfileSearchResultsResponse.class);
failCount = 0;
YggdrasilGameProfileRepository.LOGGER.debug("Page {} returned {} results, parsing", page,
response.getProfiles().length);

View file

@ -39,13 +39,15 @@ public class YggdrasilUserAuthentication
extends HttpUserAuthentication {
private static final Logger LOGGER = LogManager.getLogger();
private static final String BASE_URL = LauncherConstants.URL_AUTHENTICATION;
private static final URL ROUTE_AUTHENTICATE = HttpAuthenticationService.constantURL(BASE_URL+"authenticate/");
private static final URL ROUTE_AUTHENTICATE = HttpAuthenticationService.constantURL(LauncherConstants.URL_AUTHENTICATE);
private static final URL ROUTE_REFRESH = HttpAuthenticationService.constantURL(BASE_URL+"refresh/");
private static final URL ROUTE_VALIDATE = HttpAuthenticationService.constantURL(BASE_URL+"validate/");
private static final URL ROUTE_INVALIDATE = HttpAuthenticationService.constantURL(BASE_URL+"invalidate/");
private static final URL ROUTE_SIGNOUT = HttpAuthenticationService.constantURL(BASE_URL+"signout/");
private static final URL ROUTE_REGISTER = HttpAuthenticationService.constantURL(LauncherConstants.URL_REGISTER);
public static final URL ROUTE_VERSIONS = HttpAuthenticationService.constantURL(LauncherConstants.VERSION_MANIFEST);
private static final String STORAGE_KEY_ACCESS_TOKEN = "accessToken";
private final Agent agent;
private GameProfile[] profiles;
@ -63,7 +65,7 @@ extends HttpUserAuthentication {
}
@Override
public void logIn() throws AuthenticationException {
public void logIn() throws AuthenticationException, NoSuchAlgorithmException {
if (StringUtils.isBlank(this.getUsername())) {
throw new InvalidCredentialsException("Invalid username");
}
@ -83,6 +85,7 @@ extends HttpUserAuthentication {
// Register!
this.register(username, password);
}else throw new InvalidCredentialsException("Invalid password");
}
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
@ -113,12 +116,18 @@ extends HttpUserAuthentication {
if(response.registered)
{
} else {
if(!response.getError().isEmpty())
{
// There's an error
throw new AuthenticationException("The account already exists");
}
}
}
protected void logInWithPassword() throws AuthenticationException {
protected void logInWithPassword() throws AuthenticationException, NoSuchAlgorithmException {
if (StringUtils.isBlank(this.getUsername())) {
throw new InvalidCredentialsException("Invalid username");
}
@ -126,7 +135,13 @@ extends HttpUserAuthentication {
throw new InvalidCredentialsException("Invalid password");
}
LOGGER.info("Logging in with username & password");
AuthenticationRequest request = new AuthenticationRequest(this, this.getUsername(), this.getPassword());
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(this.getPassword().getBytes());
String hash = bytesToHex(md5.digest()).toUpperCase();
AuthenticationRequest request = new AuthenticationRequest(this, this.getUsername(), hash);
AuthenticationResponse response = this.getAuthenticationService().makeRequest(ROUTE_AUTHENTICATE, request, AuthenticationResponse.class);
if (!response.getClientToken().equals(this.getAuthenticationService().getClientToken())) {
throw new AuthenticationException("Server requested we change our client token. Don't know how to handle this!");

View file

@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.logging.log4j.util.StringBuilderFormattable;
@ -84,5 +85,16 @@ public class GameProcessBuilder {
return String.format("{}{}{}{}{}", processPath, arguments, sysOutFilter, directory, logProcessor);
}
public void sanitizeNulls() {
for(int i = 0; i< arguments.size(); i++)
{
if(arguments.get(i) == null || arguments.get(i).isEmpty())
{
arguments.remove(i);
sanitizeNulls();
return;
}
}
}
}

7
src/main/java/net/minecraft/hopper/HopperService.java Normal file → Executable file
View file

@ -13,11 +13,12 @@ import net.minecraft.hopper.Response;
import net.minecraft.hopper.SubmitRequest;
import net.minecraft.hopper.SubmitResponse;
import net.minecraft.hopper.Util;
import net.minecraft.launcher.LauncherConstants;
public final class HopperService {
private static final String BASE_URL = "http://hopper.minecraft.net/crashes/";
private static final URL ROUTE_SUBMIT = Util.constantURL("http://hopper.minecraft.net/crashes/submit_report/");
private static final URL ROUTE_PUBLISH = Util.constantURL("http://hopper.minecraft.net/crashes/publish_report/");
private static final String BASE_URL = LauncherConstants.BASE_URL+"hopper/crashes/";
private static final URL ROUTE_SUBMIT = Util.constantURL(BASE_URL+"/submit_report/");
private static final URL ROUTE_PUBLISH = Util.constantURL(BASE_URL+"/publish_report/");
private static final String[] INTERESTING_SYSTEM_PROPERTY_KEYS = new String[]{"os.version", "os.name", "os.arch", "java.version", "java.vendor", "sun.arch.data.model"};
private static final Gson GSON = new Gson();

4
src/main/java/net/minecraft/hopper/SubmitResponse.java Normal file → Executable file
View file

@ -1,9 +1,5 @@
package net.minecraft.hopper;
import net.minecraft.hopper.Crash;
import net.minecraft.hopper.Problem;
import net.minecraft.hopper.Report;
import net.minecraft.hopper.Response;
public class SubmitResponse
extends Response {

11
src/main/java/net/minecraft/hopper/Util.java Normal file → Executable file
View file

@ -42,7 +42,7 @@ public class Util {
}
throw e;
}
return IOUtils.toString(stream);
return IOUtils.toString(stream, "UTF-8");
}
public static URL constantURL(String input) {
@ -53,5 +53,14 @@ public class Util {
throw new Error(e);
}
}
public static <T> T firstNonNull(T... objs)
{
for (T elem : objs) {
if(elem!=null)return elem;
}
return null;
}
}

View file

@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.UserAuthentication;
import com.mojang.authlib.exceptions.AuthenticationException;
import com.mojang.authlib.exceptions.InvalidCredentialsException;
import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
import com.mojang.launcher.OperatingSystem;
import com.mojang.launcher.UserInterface;
import com.mojang.launcher.updater.DateTypeAdapter;
@ -28,6 +29,7 @@ import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.URL;
import java.nio.charset.Charset;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar;
@ -123,7 +125,7 @@ public class Launcher {
LOGGER.info("System.getProperty('sun.arch.data.model') == '" + System.getProperty("sun.arch.data.model") + "'");
LOGGER.info("proxy == " + proxy);
this.launchDispatcher = new GameLaunchDispatcher(this, this.processArgs(args));
this.launcher = new com.mojang.launcher.Launcher(this.userInterface, workingDirectory, proxy, proxyAuth, new MinecraftVersionManager(new LocalVersionList(workingDirectory), new RemoteVersionList(LauncherConstants.PROPERTIES.getVersionManifest(), proxy)), Agent.MINECRAFT, MinecraftReleaseTypeFactory.instance(), 21);
this.launcher = new com.mojang.launcher.Launcher(this.userInterface, workingDirectory, proxy, proxyAuth, new MinecraftVersionManager(new LocalVersionList(workingDirectory), new RemoteVersionList(YggdrasilUserAuthentication.ROUTE_VERSIONS, proxy)), Agent.MINECRAFT, MinecraftReleaseTypeFactory.instance(), 21);
this.profileManager = new ProfileManager(this);
((SwingUserInterface)this.userInterface).initializeFrame();
this.refreshVersionsAndProfiles();
@ -262,6 +264,9 @@ public class Launcher {
catch (AuthenticationException e) {
LOGGER.error("Exception whilst logging into profile", (Throwable)e);
this.getUserInterface().showLoginPrompt();
} catch (NoSuchAlgorithmException e) {
LOGGER.error("Your JRE seems to be corrupt! Md5 does not work");
throw new RuntimeException(e);
}
} else {
this.getUserInterface().showLoginPrompt();
@ -284,6 +289,10 @@ public class Launcher {
}
catch (AuthenticationException e) {
LOGGER.error("Exception whilst logging into profile", (Throwable)e);
} catch (NoSuchAlgorithmException e) {
LOGGER.error("Your JRE seems to be corrupt! Md5 does not work");
throw new RuntimeException(e);
}
}
}

View file

@ -17,15 +17,17 @@ import org.apache.commons.io.IOUtils;
public class LauncherConstants {
public static final int VERSION_FORMAT = 21;
public static final String VERSION_STRING = "1.0.2";
public static final String VERSION_STRING = "1.0.3";
public static final int PROFILES_FORMAT = 1;
public static final String BASE_URL = "https://api.zontreck.dev/zni/yggdrasil/";
public static final String URL_REGISTER = BASE_URL+"register/";
public static final String BASE_URL = "https://api.zontreck.com/crafting/yggdrasil/";
public static final String VERSION_MANIFEST = "https://git.zontreck.com/zontreck/MinecraftBuilds/raw/branch/master/yggdrasil/versions/version_manifest.json";
public static final String URL_AUTHENTICATION = BASE_URL+"auth/";
public static final String URL_AUTHENTICATE = URL_AUTHENTICATION + "authenticate/";
public static final String URL_REGISTER = URL_AUTHENTICATION+"register/";
public static final String URL_JAR_FALLBACK = BASE_URL+"download/";
public static final String URL_RESOURCE_BASE = BASE_URL+"resources/";
public static final String URL_LIBRARY_BASE = BASE_URL+"libraries/";
public static final String URL_LOGIN = BASE_URL+"login/";
public static final String URL_AUTHENTICATION = BASE_URL+"auth/";
public static final String URL_SESSION = BASE_URL+"sessions/";
//public static final String URL_WEBSITE = "http://mcupdate.tumblr.com"; // The old legacy blog (no longer updated)
public static final String URL_WEBSITE = BASE_URL+"mcupdate/";
@ -112,7 +114,7 @@ public class LauncherConstants {
public static class LauncherProperties {
private LauncherEnvironment environment = LauncherEnvironment.PRODUCTION;
private URL versionManifest = LauncherConstants.constantURL(BASE_URL+"versions/version_manifest.json");
private URL versionManifest = LauncherConstants.constantURL(LauncherConstants.VERSION_MANIFEST);
public LauncherEnvironment getEnvironment() {
return this.environment;

View file

@ -19,6 +19,8 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.locks.ReentrantLock;
import net.minecraft.hopper.Util;
import net.minecraft.launcher.Launcher;
import net.minecraft.launcher.MinecraftUserInterface;
import net.minecraft.launcher.game.MinecraftGameRunner;
@ -118,7 +120,7 @@ implements GameRunnerListener {
this.launcher.getLauncher().getVersionManager().getExecutorService().execute(new Runnable() {
@Override
public void run() {
gameRunner.setVisibility(Objects.firstNonNull(profile.getLauncherVisibilityOnGameClose(), Profile.DEFAULT_LAUNCHER_VISIBILITY));
gameRunner.setVisibility(Util.firstNonNull(profile.getLauncherVisibilityOnGameClose(), Profile.DEFAULT_LAUNCHER_VISIBILITY));
VersionSyncInfo syncInfo = null;
if (lastVersionId != null) {
syncInfo = GameLaunchDispatcher.this.launcher.getLauncher().getVersionManager().getVersionSyncInfo(
@ -164,11 +166,11 @@ implements GameRunnerListener {
public boolean isRunningInSameFolder() {
this.lock.lock();
try {
File currentGameDir = Objects.firstNonNull(this.launcher.getProfileManager().getSelectedProfile().getGameDir(), this.launcher.getLauncher().getWorkingDirectory());
File currentGameDir = Util.firstNonNull(this.launcher.getProfileManager().getSelectedProfile().getGameDir(), this.launcher.getLauncher().getWorkingDirectory());
for (MinecraftGameRunner runner : this.instances.values()) {
File otherGameDir;
Profile profile = runner.getSelectedProfile();
if (profile == null || !currentGameDir.equals(otherGameDir = Objects.firstNonNull(profile.getGameDir(), this.launcher.getLauncher().getWorkingDirectory()))) continue;
if (profile == null || !currentGameDir.equals(otherGameDir = Util.firstNonNull(profile.getGameDir(), this.launcher.getLauncher().getWorkingDirectory()))) continue;
boolean bl = true;
return bl;
}

View file

@ -55,6 +55,8 @@ import java.util.TreeSet;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import net.minecraft.hopper.Util;
import net.minecraft.launcher.CompatibilityRule;
import net.minecraft.launcher.CurrentLaunchFeatureMatcher;
import net.minecraft.launcher.Launcher;
@ -74,7 +76,7 @@ import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.text.StrSubstitutor;
import org.apache.commons.text.StringSubstitutor;
import org.apache.logging.log4j.Logger;
public class MinecraftGameRunner
@ -176,7 +178,7 @@ implements GameProcessRunnable {
if (!(serverResourcePacksDir = new File(gameDirectory, "server-resource-packs")).exists()) {
serverResourcePacksDir.mkdirs();
}
GameProcessBuilder processBuilder = new GameProcessBuilder(Objects.firstNonNull(this.selectedProfile.getJavaPath(), OperatingSystem.getCurrentPlatform().getJavaDir()));
GameProcessBuilder processBuilder = new GameProcessBuilder(Util.firstNonNull(this.selectedProfile.getJavaPath(), OperatingSystem.getCurrentPlatform().getJavaDir()));
processBuilder.withSysOutFilter(new Predicate<String>(){
@Override
@ -195,11 +197,12 @@ implements GameProcessRunnable {
processBuilder.withArguments(defaultArgument.split(" "));
}
CompatibilityRule.FeatureMatcher featureMatcher = this.createFeatureMatcher();
StrSubstitutor argumentsSubstitutor = this.createArgumentsSubstitutor(this.getVersion(), this.selectedProfile, gameDirectory, assetsDir, this.auth);
StringSubstitutor argumentsSubstitutor = this.createArgumentsSubstitutor(this.getVersion(), this.selectedProfile, gameDirectory, assetsDir, this.auth);
this.getVersion().addArguments(ArgumentType.JVM, featureMatcher, processBuilder, argumentsSubstitutor);
processBuilder.withArguments(this.getVersion().getMainClass());
LOGGER.info("Half command: " + StringUtils.join(processBuilder.getFullCommands(), " "));
this.getVersion().addArguments(ArgumentType.GAME, featureMatcher, processBuilder, argumentsSubstitutor);
LOGGER.info("Full command: " + StringUtils.join(processBuilder.getFullCommands(), " "));
Proxy proxy = this.getLauncher().getProxy();
PasswordAuthentication proxyAuth = this.getLauncher().getProxyAuth();
if (!proxy.equals(Proxy.NO_PROXY)) {
@ -212,6 +215,7 @@ implements GameProcessRunnable {
}
}
processBuilder.withArguments(this.additionalLaunchArgs);
processBuilder.sanitizeNulls();
try {
LOGGER.debug("Running " + StringUtils.join(processBuilder.getFullCommands(), " "));
GameProcess process = this.processFactory.startGame(processBuilder);
@ -263,12 +267,12 @@ implements GameProcessRunnable {
if (target.isFile()) continue;
FileUtils.copyFile(original, target, false);
}
FileUtils.writeStringToFile(new File(virtualRoot, ".lastused"), this.dateAdapter.serializeToString(new Date()));
FileUtils.writeStringToFile(new File(virtualRoot, ".lastused"), this.dateAdapter.serializeToString(new Date()), "UTF-8",false);
}
return virtualRoot;
}
public StrSubstitutor createArgumentsSubstitutor(CompleteMinecraftVersion version, Profile selectedProfile, File gameDirectory, File assetsDirectory, UserAuthentication authentication) {
public StringSubstitutor createArgumentsSubstitutor(CompleteMinecraftVersion version, Profile selectedProfile, File gameDirectory, File assetsDirectory, UserAuthentication authentication) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("auth_access_token", authentication.getAuthenticatedToken());
map.put("user_properties", new GsonBuilder().registerTypeAdapter((Type)((Object)PropertyMap.class), new LegacyPropertyMapSerializer()).create().toJson(authentication.getUserProperties()));
@ -317,13 +321,11 @@ implements GameProcessRunnable {
catch (IOException assetIndex) {
// empty catch block
}
map.put("launcher_name", "java-minecraft-launcher");
map.put("launcher_name", "minecraft-launcher");
map.put("launcher_version", LauncherConstants.getVersionName());
map.put("natives_directory", this.nativeDir.getAbsolutePath());
map.put("classpath", this.constructClassPath(this.getVersion()));
map.put("classpath_separator", System.getProperty("path.separator"));
map.put("primary_jar", new File(this.getLauncher().getWorkingDirectory(), "versions/" + this.getVersion().getJar() + "/" + this.getVersion().getJar() + ".jar").getAbsolutePath());
return new StrSubstitutor(map);
return new StringSubstitutor(map);
}
private void migrateOldAssets() {

View file

@ -7,6 +7,8 @@ import com.mojang.launcher.versions.ReleaseType;
import com.mojang.launcher.versions.ReleaseTypeFactory;
import java.io.File;
import java.util.Set;
import net.minecraft.hopper.Util;
import net.minecraft.launcher.game.MinecraftReleaseType;
import net.minecraft.launcher.game.MinecraftReleaseTypeFactory;
import net.minecraft.launcher.profile.LauncherVisibilityRule;
@ -29,6 +31,8 @@ implements Comparable<Profile> {
private Boolean useHopperCrashService;
private LauncherVisibilityRule launcherVisibilityOnGameClose;
private String customArgs;
public Profile() {
}
@ -43,6 +47,7 @@ implements Comparable<Profile> {
this.allowedReleaseTypes = copy.allowedReleaseTypes == null ? null : Sets.newHashSet(copy.allowedReleaseTypes);
this.useHopperCrashService = copy.useHopperCrashService;
this.launcherVisibilityOnGameClose = copy.launcherVisibilityOnGameClose;
this.customArgs = copy.customArgs;
}
public Profile(String name) {
@ -50,7 +55,7 @@ implements Comparable<Profile> {
}
public String getName() {
return Objects.firstNonNull(this.name, "");
return Util.firstNonNull(this.name, "");
}
public void setName(String name) {
@ -97,6 +102,14 @@ implements Comparable<Profile> {
this.resolution = resolution;
}
public String getCustomArgs() {
return customArgs;
}
public void setCustomArgs(String customArgs) {
this.customArgs = customArgs;
}
@Deprecated
public String getPlayerUUID() {
return this.playerUUID;

View file

@ -4,6 +4,8 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.mojang.authlib.legacy.LegacyUserAuthentication;
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
import com.mojang.launcher.Http;
import com.mojang.launcher.updater.LowerCaseEnumTypeAdapterFactory;
import com.mojang.launcher.updater.VersionManager;
@ -18,6 +20,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
import javax.swing.JLabel;
import net.minecraft.launcher.Launcher;
import net.minecraft.launcher.LauncherConstants;
import net.minecraft.launcher.ui.bottombar.SidebarGridForm;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -25,8 +28,8 @@ import org.apache.logging.log4j.Logger;
public class StatusPanelForm
extends SidebarGridForm {
private static final Logger LOGGER = LogManager.getLogger();
private static final String SERVER_SESSION = "session.minecraft.net";
private static final String SERVER_LOGIN = "login.minecraft.net";
private static final String SERVER_SESSION = LauncherConstants.URL_SESSION;
private static final String SERVER_LOGIN = LauncherConstants.URL_LOGIN;
private final Launcher minecraftLauncher;
private final JLabel sessionStatus = new JLabel("???");
private final JLabel loginStatus = new JLabel("???");
@ -60,15 +63,15 @@ extends SidebarGridForm {
public void run() {
try {
final TypeToken<List<Map<String, ServerStatus>>> token = new TypeToken<List<Map<String, ServerStatus>>>() {};
final List<Map<String, ServerStatus>> statuses = StatusPanelForm.this.gson.fromJson(Http.performGet(new URL("http://status.mojang.com/check"), StatusPanelForm.this.minecraftLauncher.getLauncher().getProxy()), token.getType());
final List<Map<String, ServerStatus>> statuses = StatusPanelForm.this.gson.fromJson(Http.performGet(new URL(LauncherConstants.URL_STATUS_CHECKER), StatusPanelForm.this.minecraftLauncher.getLauncher().getProxy()), token.getType());
for (final Map<String, ServerStatus> serverStatusInformation : statuses) {
if (serverStatusInformation.containsKey("login.minecraft.net")) {
StatusPanelForm.this.loginStatus.setText(serverStatusInformation.get("login.minecraft.net").title);
if (serverStatusInformation.containsKey("login")) {
StatusPanelForm.this.loginStatus.setText(serverStatusInformation.get("login").title);
} else {
if (!serverStatusInformation.containsKey("session.minecraft.net")) {
if (!serverStatusInformation.containsKey("session")) {
continue;
}
StatusPanelForm.this.sessionStatus.setText(serverStatusInformation.get("session.minecraft.net").title);
StatusPanelForm.this.sessionStatus.setText(serverStatusInformation.get("session").title);
}
}
} catch (Exception e) {

View file

@ -15,6 +15,7 @@ import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
@ -132,6 +133,9 @@ implements ActionListener {
ExistingUserListForm.this.popup.getErrorForm().displayError(ex,"We couldn't log you back in as " + selected + ".", "Please try to log in again.");
ExistingUserListForm.this.removeUser((String) selected, uuid);
ExistingUserListForm.this.popup.setCanLogIn(true);
} catch (NoSuchAlgorithmException ex) {
LOGGER.error("Your JRE seems to be corrupt! Md5 does not work");
throw new RuntimeException(ex);
}
} else {
ExistingUserListForm.this.popup.setCanLogIn(true);

View file

@ -22,6 +22,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URI;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;
import java.util.concurrent.ThreadPoolExecutor;
import javax.swing.Box;
@ -138,9 +139,14 @@ public class LogInForm extends JPanel implements ActionListener {
public void run(){
try {
LogInForm.this.authentication.doRegister(LogInForm.this.usernameField.getText(), StringUtils.valueOf(LogInForm.this.passwordField.getPassword()));
LogInForm.this.popup.setCanLogIn(true);
LogInForm.this.popup.getErrorForm().displayError(new Exception(), "Your account was successfully created!");
} catch (AuthenticationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
LogInForm.this.popup.setCanLogIn(true);
LogInForm.this.popup.getErrorForm().displayError(e, "Something went wrong");
}
}
});
@ -235,6 +241,9 @@ public class LogInForm extends JPanel implements ActionListener {
LOGGER.error("Couldn't log in", (Throwable)ex);
LogInForm.this.popup.getErrorForm().displayError(ex, "Sorry, but we couldn't connect to our servers.", "Please make sure that you are online and that Minecraft is not blocked.");
LogInForm.this.popup.setCanLogIn(true);
} catch (NoSuchAlgorithmException e) {
LOGGER.error("Your JRE seems to be corrupt! Md5 does not work");
throw new RuntimeException(e);
}
}

View file

@ -27,6 +27,9 @@ extends JPanel {
private final JCheckBox javaArgsCustom = new JCheckBox("JVM Arguments:");
private final JTextField javaArgsField = new JTextField();
private final JCheckBox useCustomGameArgs = new JCheckBox("Custom Game Arguments:");
private final JTextField gameArgsCustom = new JTextField();
public ProfileJavaPanel(ProfileEditorPopup editor) {
this.editor = editor;
this.setLayout(new GridBagLayout());
@ -55,6 +58,13 @@ extends JPanel {
constraints.weightx = 0.0;
constraints.fill = 0;
++constraints.gridy;
this.add((Component) this.useCustomGameArgs, constraints);
constraints.fill=2;
constraints.weightx=1.0;
this.add((Component)this.gameArgsCustom, constraints);
constraints.weightx = 0.0;
constraints.fill = 0;
++constraints.gridy;
}
protected void fillDefaultValues() {
@ -68,6 +78,7 @@ extends JPanel {
}
this.updateJavaPathState();
String args = this.editor.getProfile().getJavaArgs();
String customArgs = this.editor.getProfile().getCustomArgs();
if (args != null) {
this.javaArgsCustom.setSelected(true);
this.javaArgsField.setText(args);
@ -75,7 +86,18 @@ extends JPanel {
this.javaArgsCustom.setSelected(false);
this.javaArgsField.setText("-Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M");
}
if(customArgs != null)
{
this.useCustomGameArgs.setSelected(true);
this.gameArgsCustom.setText(customArgs);
}else {
this.useCustomGameArgs.setSelected(false);
this.gameArgsCustom.setText("");
}
this.updateJavaArgsState();
this.updateCustomGameArgsState();
}
protected void addEventHandlers() {
@ -127,6 +149,50 @@ extends JPanel {
ProfileJavaPanel.this.updateJavaArgs();
}
});
this.useCustomGameArgs.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent itemEvent) {
ProfileJavaPanel.this.updateCustomGameArgsState();
}
});
this.gameArgsCustom.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent documentEvent) {
ProfileJavaPanel.this.updateCustomGameArgs();
}
@Override
public void removeUpdate(DocumentEvent documentEvent) {
ProfileJavaPanel.this.updateCustomGameArgs();
}
@Override
public void changedUpdate(DocumentEvent documentEvent) {
ProfileJavaPanel.this.updateCustomGameArgs();
}
});
}
private void updateCustomGameArgs() {
if(this.useCustomGameArgs.isSelected())
{
this.editor.getProfile().setCustomArgs(this.gameArgsCustom.getText());
}else this.editor.getProfile().setCustomArgs(null);
}
private void updateCustomGameArgsState() {
if (this.useCustomGameArgs.isSelected())
{
this.gameArgsCustom.setEnabled(true);
this.editor.getProfile().setCustomArgs("");
}
else {
this.editor.getProfile().setCustomArgs(null);
this.gameArgsCustom.setEnabled(false);
}
}
private void updateJavaPath() {

View file

@ -1,22 +1,16 @@
package net.minecraft.launcher.ui.tabs;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.beans.IntrospectionException;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import javax.swing.JPanel;
import net.minecraft.launcher.Launcher;
import net.minecraft.launcher.ui.tabs.website.Browser;
import net.minecraft.launcher.ui.tabs.website.JFXBrowser;
import net.minecraft.launcher.ui.tabs.website.LegacySwingBrowser;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -42,24 +36,6 @@ extends JPanel {
}
private Browser selectBrowser() {
if (this.hasJFX()) {
LOGGER.info("JFX is already initialized");
return new JFXBrowser();
}
File jfxrt = new File(System.getProperty("java.home"), "lib/jfxrt.jar");
if (jfxrt.isFile()) {
LOGGER.debug("Attempting to load {}...", jfxrt);
try {
WebsiteTab.addToSystemClassLoader(jfxrt);
LOGGER.info("JFX has been detected & successfully loaded");
return new JFXBrowser();
}
catch (Throwable e) {
LOGGER.debug("JFX has been detected but unsuccessfully loaded", e);
return new LegacySwingBrowser();
}
}
LOGGER.debug("JFX was not found at {}", jfxrt);
return new LegacySwingBrowser();
}

View file

@ -1,169 +0,0 @@
/*
* Decompiled with CFR 0_132.
*
* Could not load the following classes:
* javafx.application.Platform
* javafx.beans.property.ReadOnlyObjectProperty
* javafx.beans.value.ChangeListener
* javafx.beans.value.ObservableValue
* javafx.collections.ObservableList
* javafx.concurrent.Worker
* javafx.concurrent.Worker$State
* javafx.embed.swing.JFXPanel
* javafx.scene.Group
* javafx.scene.Parent
* javafx.scene.Scene
* javafx.scene.web.WebEngine
* javafx.scene.web.WebView
*/
package net.minecraft.launcher.ui.tabs.website;
import com.mojang.launcher.OperatingSystem;
import java.awt.Component;
import java.awt.Dimension;
import java.net.URI;
import javafx.application.Platform;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;
import javafx.concurrent.Worker;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import net.minecraft.launcher.ui.tabs.website.Browser;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
public class JFXBrowser
implements Browser {
private static final Logger LOGGER = LogManager.getLogger();
private final Object lock = new Object();
private final JFXPanel fxPanel = new JFXPanel();
private String urlToBrowseTo;
private Dimension size;
private WebView browser;
private WebEngine webEngine;
public JFXBrowser() {
Platform.runLater((Runnable)new Runnable(){
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@Override
public void run() {
Group root = new Group();
Scene scene = new Scene((Parent)root);
JFXBrowser.this.fxPanel.setScene(scene);
Object object = JFXBrowser.this.lock;
synchronized (object) {
JFXBrowser.this.browser = new WebView();
JFXBrowser.this.browser.setContextMenuEnabled(false);
if (JFXBrowser.this.size != null) {
JFXBrowser.this.resize(JFXBrowser.this.size);
}
JFXBrowser.this.webEngine = JFXBrowser.this.browser.getEngine();
JFXBrowser.this.webEngine.setJavaScriptEnabled(false);
JFXBrowser.this.webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
public void changed(final ObservableValue<? extends Worker.State> observableValue,
final Worker.State oldState, final Worker.State newState) {
if (newState == Worker.State.SUCCEEDED) {
final EventListener listener = new EventListener() {
@Override
public void handleEvent(final Event event) {
if (event.getTarget() instanceof Element) {
Element element;
String href;
for (element = (Element) event.getTarget(), href = element.getAttribute("href"); StringUtils.isEmpty(href) && element.getParentNode() instanceof Element;
element = (Element) element.getParentNode(), href = element.getAttribute("href")) {
}
if (href != null && href.length() > 0) {
try {
OperatingSystem.openLink(new URI(href));
} catch (Exception e) {
JFXBrowser.LOGGER.error("Unexpected exception opening link " + href, e);
}
event.preventDefault();
event.stopPropagation();
}
}
}
};
final Document doc = JFXBrowser.this.webEngine.getDocument();
if (doc != null) {
final NodeList elements = doc.getElementsByTagName("a");
for (int i = 0; i < elements.getLength(); ++i) {
final Node item = elements.item(i);
if (item instanceof EventTarget) {
((EventTarget) item).addEventListener("click", listener, false);
}
}
}
}
}
});
if (JFXBrowser.this.urlToBrowseTo != null) {
JFXBrowser.this.loadUrl(JFXBrowser.this.urlToBrowseTo);
}
}
root.getChildren().add(JFXBrowser.this.browser);
}
});
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@Override
public void loadUrl(final String url) {
Object object = this.lock;
synchronized (object) {
this.urlToBrowseTo = url;
if (this.webEngine != null) {
Platform.runLater((Runnable)new Runnable(){
@Override
public void run() {
JFXBrowser.this.webEngine.load(url);
}
});
}
}
}
@Override
public Component getComponent() {
return this.fxPanel;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@Override
public void resize(Dimension size) {
Object object = this.lock;
synchronized (object) {
this.size = size;
if (this.browser != null) {
this.browser.setMinSize(size.getWidth(), size.getHeight());
this.browser.setMaxSize(size.getWidth(), size.getHeight());
this.browser.setPrefSize(size.getWidth(), size.getHeight());
}
}
}
}

View file

@ -351,6 +351,11 @@ implements CompleteVersion {
if (featureMatcher.hasFeature("has_custom_resolution", true)) {
builder.withArguments("--width", substitutor.replace("${resolution_width}"), "--height", substitutor.replace("${resolution_height}"));
}
for(String arg : Launcher.getCurrentInstance().getProfileManager().getSelectedProfile().getCustomArgs().split(" "))
{
builder.withArguments(substitutor.replace(arg));
}
} else if (type == ArgumentType.JVM) {
if (OperatingSystem.getCurrentPlatform() == OperatingSystem.WINDOWS) {
builder.withArguments("-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump");
@ -364,7 +369,8 @@ implements CompleteVersion {
builder.withArguments(substitutor.replace("-Dminecraft.launcher.brand=${launcher_name}"));
builder.withArguments(substitutor.replace("-Dminecraft.launcher.version=${launcher_version}"));
builder.withArguments(substitutor.replace("-Dminecraft.client.jar=${primary_jar}"));
builder.withArguments("-cp", substitutor.replace("${classpath}"));
builder.withArguments("-jar", substitutor.replace("${primary_jar}"));
}
}
}

View file

@ -1 +1 @@
{"environment":"dev","versionManifest":"https://api.zontreck.dev/yggdrasil/versions/version_manifest.json"}
{"environment":"dev","versionManifest":"https://git.zontreck.com/zontreck/MinecraftBuilds/raw/branch/master/yggdrasil/versions/version_manifest.json"}