Giter VIP home page Giter VIP logo

mclauncher-api's Introduction

Tomsik68's MCLauncher-API

Join the chat at https://gitter.im/tomsik68/mclauncher-api

An API for custom minecraft launchers which is aimed to be easy to work with.

=================

Aim of the project

  • Make people able to create custom minecraft launchers with ease.
  • Create a functional framework that interacts with minecraft & services around it
  • Create an up-to-date wiki full of minecraft launcher system documentation

License

Just for clearance, this API is not connected with Mojang in any way.

This project is under MIT license. More information can be found in LICENSE file.

Contributors

I'd like to thank people for helping me out to improve this project by using, supporting, finding errors etc.

Here's a list of people who supported the project so far:

  • Podshot
  • BaluMonster
  • lowky12
  • mathwhiz19
  • mrzban
  • laci200270
  • SlipsWhitley
  • Safranil
  • mcNETDev

mclauncher-api's People

Contributors

gitter-badger avatar jlleitschuh avatar lionzxy avatar lowky12 avatar mcnetdev avatar safranil avatar tomsik68 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mclauncher-api's Issues

MC 1.13 broken

Hey,

thanks for the library. I am trying to setup a custom launcher to download all assets for MC 1.13 but keep getting stuck at this line:

java.io.IOException: Server returned HTTP response code: 403 for URL: https://s3.amazonaws.com/Minecraft.Download/indexes/1.13.1.json

that is executed from IVersion#getInstaller().install(changed, mc, null);

The data url seems to be changed, could you please update?

ďakujem :)

Find out what logging section should do

Snippet from 1.14.1 pre-release:

    "client": {
      "argument": "-Dlog4j.configurationFile=${path}",
      "file": {
        "id": "client-1.12.xml",
        "sha1": "ef4f57b922df243d0cef096efe808c72db042149",
        "size": 877,
        "url": "https://launcher.mojang.com/v1/objects/ef4f57b922df243d0cef096efe808c72db042149/client-1.12.xml"
      },
      "type": "log4j2-xml"
    }
  },

Wiki is out of date

Incomplete list of things to update:

  • move pages explaining non-existing services & concepts (i.e. assets.minecraft.net, pre-1.6 launcher related stuff) somewhere out of the way to simplify wiki structure
  • versions.json --> version_manifest.json
  • Update extended version information
  • structure of libraries
  • structure of assets

Feel free to comment on this issue to report more missing/out-of-date parts.

Argument list from mc 1.13

Since Minecraft 1.13, the arguments list provided in the JSON file has changed:

At 1.12, a string key minecraftArguments contain the arguments list to use.

JSON for 1.12.2
{
  "minecraftArguments": "--username ${auth_player_name} --version ${version_name} --gameDir ${game_directory} --assetsDir ${assets_root} --assetIndex ${assets_index_name} --uuid ${auth_uuid} --accessToken ${auth_access_token} --userType ${user_type} --versionType ${version_type}"
}

Since 1.13, it's an array arguments. It's split JVM and Minecraft arguments and add some rules (for Win10, x86, ...)

JSON for 1.13
{
  "arguments":{
    "game":[
      "--username",
      "${auth_player_name}",
      "--version",
      "${version_name}",
      "--gameDir",
      "${game_directory}",
      "--assetsDir",
      "${assets_root}",
      "--assetIndex",
      "${assets_index_name}",
      "--uuid",
      "${auth_uuid}",
      "--accessToken",
      "${auth_access_token}",
      "--userType",
      "${user_type}",
      "--versionType",
      "${version_type}",
      {
        "rules":[
          {
            "action":"allow",
            "features":{
              "is_demo_user":true
            }
          }
        ],
        "value":"--demo"
      },
      {
        "rules":[
          {
            "action":"allow",
            "features":{
              "has_custom_resolution":true
            }
          }
        ],
        "value":[
          "--width",
          "${resolution_width}",
          "--height",
          "${resolution_height}"
        ]
      }
    ],
    "jvm":[
      {
        "rules":[
          {
            "action":"allow",
            "os":{
              "name":"osx"
            }
          }
        ],
        "value":[
          "-XstartOnFirstThread"
        ]
      },
      {
        "rules":[
          {
            "action":"allow",
            "os":{
              "name":"windows"
            }
          }
        ],
        "value":"-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump"
      },
      {
        "rules":[
          {
            "action":"allow",
            "os":{
              "name":"windows",
              "version":"^10\\."
            }
          }
        ],
        "value":[
          "-Dos.name=Windows 10",
          "-Dos.version=10.0"
        ]
      },
      {
        "rules":[
          {
            "action":"allow",
            "os":{
              "arch":"x86"
            }
          }
        ],
        "value":"-Xss1M"
      },
      "-Djava.library.path=${natives_directory}",
      "-Dminecraft.launcher.brand=${launcher_name}",
      "-Dminecraft.launcher.version=${launcher_version}",
      "-cp",
      "${classpath}"
    ]
  }
}

@tomsik68, do you think the class sk.tomsik68.mclauncher.impl.versions.mcdownload.Rule can do the trick?

Note: I can do the changes in a pull request to adapt the API.

See : 1.12.2 and 1.13.

Add maven

Hi, this is not an issue, more like an idea/request:

If you add maven support, you will be also giving support for gradle (gradle can import maven dependencies) and more people will use this API

Trying to find info.json causes java.lang.NullPointerException

The launch code I am using is from this commit. Here is the few lines before the error:

Looking for C:\Users\{Windows Username}\Java\Programs\PodLauncher\PodLauncher\Game-Dirs\Launch\bin\s1.8-pre2\info.json
java.lang.NullPointerException
    at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionLauncher.getMinecraftArguments(MCDownloadVersionLauncher.java:30)
    at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionLauncher.launch(MCDownloadVersionLauncher.java:98)
    at io.github.podshot.Podlauncher.LaunchMinecraft.launch(LaunchMinecraft.java:69)
    at io.github.podshot.Podlauncher.LaunchMinecraft.<init>(LaunchMinecraft.java:45)
    at io.github.podshot.Podlauncher.gui.MainGUI.actionPerformed(MainGUI.java:218)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Resource index URLs

Resource index URLs can now be found in the new structure of version:

{
"assetIndex": {
"url": ...
}
}

Python Library aviable

I jsut wnt to inform you, that I have taken a look at this again and I have now finished a Python Library based on your documentation. You can find it here. It is currently a Beta who has some Problems with olderversions, but the newest Version and the newest Forge Version are working. jdMinecraftLauncher is a program from me which are already using this new lib.

It would be nice, if you can add a link to my lib in your Readme or Wiki for People who are want to make a launcher and finding your Project.

Offline launching with MinecraftLauncherBackend

If downloading versions in MCDownloadOnlineVersionList fails, then also downloading versions in MCDownloadVersionList fails. This is a problem if one wants to use only locally installed versions and play without internet connectivity.

the solution of offline game, if u don't know how to do, just see this

this launcher api is so great and thanks a lot :)

this is a offline example,it's easy and it works ! :

if(launchOptions.getOnline_mode() == 1){
iSession = GlobalAuthenticationSystem.doPasswordLogin(launchOptions.getUserName(),launchOptions.getPassword());
}else{
iSession = new ISession() {
public String getUsername() {
return launchOptions.getUserName();
}

            public String getSessionID() {
                return UUID.randomUUID().toString();
            }

            public String getUUID() {
                return UUID.randomUUID().toString();
            }

            public ESessionType getType() {
                return ESessionType.MOJANG;
            }

            public List<Prop> getProperties() {
                return null;
            }
        };
    }

MCLib patching support? (Fabric)

Have been searching through dozens of repos, trying to find a library that supports this:
Can you use fabric here? And I mean being able to patch a fabric .jar with minecraft and running it.

Change unit tests to real unit tests

Unit tests currently test the functionality of API. While this is neat feature we'd like to have, it introduces hassle to building with maven. And this is not what unit tests should be used for :)

Compulsory(in terms of maven) unit tests should definitely change to integration tests users can run on demand. Perhaps extract them into another project. The point is, just get them out of test package that is used by maven.

wrong usage of ETag/If-None-Match

In FileUtils.java function downloadFileWithProgress

    URLConnection connection = u.openConnection();
    if (md5 != null)
        connection.setRequestProperty("If-None-Match", md5);
    connection.connect();

The correct usage should be

    URLConnection connection = u.openConnection();
    if (md5 != null)
        connection.setRequestProperty("If-None-Match", "\"" + md5 + "\"");
    connection.connect();

Missing random asset files

When playing Minecraft for a while, it crashes because required assets are not available. mclauncher-api seemingly skips downloading some (random) assets.

Can't install Minecraft 1.8

If I run minecraftLauncherBackend.updateMinecraft("1.8", null) I get this error:

/usr/lib/jvm/java-8-openjdk-amd64/bin/java -javaagent:/snap/intellij-idea-community/152/lib/idea_rt.jar=33832:/snap/intellij-idea-community/152/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/icedtea-sound.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jaccess.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/nashorn.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/management-agent.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar:/home/jakob/zw/mclauncher-cmd/out/production/mclauncher-cmd:/home/jakob/Downloads/mclauncher-api-0.3.4.jar:/home/jakob/Downloads/json-smart-1.1.1.jar jakobdev.mclauncher_cmd.mclauncher_cmd install 1.8
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking com.mojang:netty:1.6
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking java3d:vecmath:1.5.2
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking net.sf.trove4j:trove4j:3.0.3
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking com.ibm.icu:icu4j-core-mojang:51.2
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking net.sf.jopt-simple:jopt-simple:4.6
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking com.paulscode:codecjorbis:20101023
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking com.paulscode:codecwav:20101023
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking com.paulscode:libraryjavasound:20101123
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking com.paulscode:librarylwjglopenal:20100824
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking com.paulscode:soundsystem:20120107
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking io.netty:netty-all:4.0.15.Final
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking com.google.guava:guava:17.0
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking org.apache.commons:commons-lang3:3.3.2
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking commons-io:commons-io:2.4
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking commons-codec:commons-codec:1.9
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking net.java.jinput:jinput:2.0.5
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking net.java.jutils:jutils:1.0.0
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking com.google.code.gson:gson:2.2.4
Jul 16, 2019 9:09:59 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking com.mojang:authlib:1.5.21
Jul 16, 2019 9:10:00 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking com.mojang:realms:1.6.1
Jul 16, 2019 9:10:00 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking org.apache.commons:commons-compress:1.8.1
Jul 16, 2019 9:10:00 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking org.apache.httpcomponents:httpclient:4.3.3
Jul 16, 2019 9:10:00 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking commons-logging:commons-logging:1.1.3
Jul 16, 2019 9:10:00 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking org.apache.httpcomponents:httpcore:4.3.2
Jul 16, 2019 9:10:00 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking org.apache.logging.log4j:log4j-api:2.0-beta9
Jul 16, 2019 9:10:00 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking org.apache.logging.log4j:log4j-core:2.0-beta9
Jul 16, 2019 9:10:00 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking org.lwjgl.lwjgl:lwjgl:2.9.1
Jul 16, 2019 9:10:00 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking org.lwjgl.lwjgl:lwjgl_util:2.9.1
Jul 16, 2019 9:10:00 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking org.lwjgl.lwjgl:lwjgl-platform:2.9.1
Jul 16, 2019 9:10:00 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller downloadLibrary
INFORMATION: Downloading library /home/jakob/.minecraft/libraries/org/lwjgl/lwjgl/lwjgl-platform/2.9.1/natives.jar
Jul 16, 2019 9:10:01 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking net.java.jinput:jinput-platform:2.0.5
Jul 16, 2019 9:10:01 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller downloadLibrary
INFORMATION: Downloading library /home/jakob/.minecraft/libraries/net/java/jinput/jinput-platform/2.0.5/natives.jar
Jul 16, 2019 9:10:01 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking tv.twitch:twitch:6.5
Jul 16, 2019 9:10:01 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller install
INFORMATION: Checking tv.twitch:twitch-platform:6.5
Jul 16, 2019 9:10:01 PM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller downloadLibrary
INFORMATION: Downloading library /home/jakob/.minecraft/libraries/tv/twitch/twitch-platform/6.5/natives.jar
Exception in thread "main" java.lang.NullPointerException
	at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller.downloadLibrary(MCDownloadVersionInstaller.java:155)
	at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionInstaller.install(MCDownloadVersionInstaller.java:98)
	at sk.tomsik68.mclauncher.backend.MinecraftLauncherBackend.updateMinecraft(MinecraftLauncherBackend.java:62)
	at jakobdev.mclauncher_cmd.mclauncher_cmd.main(mclauncher_cmd.java:27)

Process finished with exit code 1

Help with forge (Using demo)

I tried using the provided demo and I keep getting problems with getting forge working.
====== FILE ======
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;

import mistMinecraft.MinecraftPreload;
import sk.tomsik68.mclauncher.api.common.ILaunchSettings;
import sk.tomsik68.mclauncher.api.common.MCLauncherAPI;
import sk.tomsik68.mclauncher.api.common.mc.MinecraftInstance;
import sk.tomsik68.mclauncher.api.login.ISession;
import sk.tomsik68.mclauncher.api.versions.IVersion;
import sk.tomsik68.mclauncher.backend.GlobalAuthenticationSystem;
import sk.tomsik68.mclauncher.impl.common.Platform;
import sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionList;

public class FORDGETEST {

public static void main(String[] a) throws Exception {
    test();
}

public static void test() {
    MCLauncherAPI.log.setLevel(Level.ALL);
    try {
        // finally use my minecraft credentials
        System.out.println("Logging in...");


        final ISession session = GlobalAuthenticationSystem.login(null);
        System.out.println("Success! Launching...");
        final MinecraftInstance mc = new MinecraftInstance(
                Platform.getCurrentPlatform().getWorkingDirectory());
        final MCDownloadVersionList versionList = new MCDownloadVersionList();
        IVersion toLaunch = versionList.retrieveVersionInfo("Pack2");
        System.out.println(toLaunch);
        try {
            toLaunch.getInstaller().install(toLaunch, mc, null);
            List<String> launchCommand = toLaunch.getLauncher()
                    .getLaunchCommand(session, mc, null,
                            toLaunch, new ILaunchSettings() {

                                @Override
                                public boolean isModifyAppletOptions() {
                                    return false;
                                }

                                @Override
                                public File getJavaLocation() {
                                    return null;
                                }

                                @Override
                                public List<String> getJavaArguments() {
                                    return Arrays
                                            .asList("-XX:+UseConcMarkSweepGC",
                                                    "-XX:+CMSIncrementalMode",
                                                    "-XX:-UseAdaptiveSizePolicy",
                                                    "-Xmn128M");
                                }

                                @Override
                                public String getInitHeap() {
                                    return "512M";
                                }

                                @Override
                                public String getHeap() {
                                    return "1G";
                                }

                                @Override
                                public Map<String, String> getCustomParameters() {
                                    return null;
                                }

                                @Override
                                public List<String> getCommandPrefix() {
                                    return null;
                                }
                            }, null);
            for (String cmd : launchCommand) {
                System.out.print(cmd + " ");
            }
            System.out.println();
            ProcessBuilder pb = new ProcessBuilder(
                    launchCommand);
            pb.redirectError(new File("mcerr.log"));
            pb.redirectOutput(new File("mcout.log"));
            pb.directory(mc.getLocation());
            Process proc = pb.start();
            BufferedReader br = new BufferedReader(
                    new InputStreamReader(proc.getInputStream()));
            String line;
            while (isProcessAlive(proc)) {
                line = br.readLine();
                if (line != null && line.length() > 0)
                    System.out.println(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


        //versionList.startDownload();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

protected static boolean isProcessAlive(Process proc) {
    try {
        System.out.println("Process exited with error code:"
                + proc.exitValue());
        return false;
    } catch (Exception e) {
        return true;
    }

}

}

====== OUTPUT ======
Logging in...
Success! Launching...
java.io.IOException: Server returned HTTP response code: 403 for URL: http://s3.amazonaws.com/Minecraft.Download/versions/Pack2/Pack2.json
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sk.tomsik68.mclauncher.util.HttpUtils.httpGet(HttpUtils.java:29)
at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionList.retrieveVersionInfo(MCDownloadVersionList.java:43)
at FORDGETEST.test(FORDGETEST.java:37)
at FORDGETEST.main(FORDGETEST.java:22)

logout should not use doCheckedLoginPost

Hello,

YDLoginService#logout shouldn't use YDLoginService#doCheckedLoginPost to do a disconnection because the Mojang API seem to return nothing, after a debug, an exception is thrown at line 64 (tag v0.3.1).

The JSONObject jsonObject = (JSONObject)JSONValue.parse(jsonString); statement parse an empty string and return a String object.

Here is the stacktrace :

java.lang.ClassCastException: java.lang.String cannot be cast to net.minidev.json.JSONObject
    at sk.tomsik68.mclauncher.impl.login.yggdrasil.YDLoginService.doCheckedLoginPost(YDLoginService.java:64)
    at sk.tomsik68.mclauncher.impl.login.yggdrasil.YDLoginService.logout(YDLoginService.java:137)
    at safranil.minecraft.miroa.MiroaLauncher.logout(MiroaLauncher.java:116)
    at safranil.minecraft.miroa.OptionController.logoutAction(OptionController.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
    at [...]
    at java.lang.Thread.run(Thread.java:745)

Can you correct this ?

Regards

Can't download Minecraft 1.12.2

When I'm trying to run method minecraftLauncherBackend.updateMinecraft("1.12.2", null);
I've got this error.

Exception in thread "main" java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at sk.tomsik68.mclauncher.impl.versions.mcdownload.Artifact.fromJson(Artifact.java:21)
at sk.tomsik68.mclauncher.impl.versions.mcdownload.Library.(Library.java:44)
at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersion.(MCDownloadVersion.java:78)
at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadOnlineVersionList.retrieveVersionInfo(MCDownloadOnlineVersionList.java:50)
at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionList.retrieveVersionInfo(MCDownloadVersionList.java:44)
at sk.tomsik68.mclauncher.backend.MinecraftLauncherBackend.findVersion(MinecraftLauncherBackend.java:29)
at sk.tomsik68.mclauncher.backend.MinecraftLauncherBackend.updateMinecraft(MinecraftLauncherBackend.java:61)
at mpeciakk.launcher.Main.main(Main.java:24)

Can't login with Yggdrasil

Profiles can't be read,
Users UUIDs are now stored in the usercache.json file and usernamecache.json.

Commandline Programm

While working my launcher in python, I#M be thinking it would be nice to have a command line program that can be used from every programming language and not only from Java.

I'm thinking at something like this:
java -jar mclauncher-cmd install "release 1.14.3" "/home/Username/.minecraft"
would install Minecraft 1.14.3 into "/home/Username/.minecraft. The Program print it's progress in the terminal.

java -jar mclauncher-cmd command "release 1.14.3" "/home/Username/.minecraft"
would print the command to run Minecraft. The Launcher just had to insert Username UUID, Seesion ID and other options and than execute the command.

Need help with installing

I'm writing a launcher in Python but I need help with installing Minecraft. I had now made this code. I have put it into a format that works without the rest od the launcher. Can you please look over it and say me what is missing?

LaunchWrapper

Please modify the api to use laucnhwrapper(for forge)

YDUserObject class missing

I downloaded MCLauncherAPI sources, and I got errors because the class sk.tomsik68.mclauncher.impl.login.yggdrasil.YDUserObject doesn't exist

[Question] Tos and Eula

Does this API give me any problems with the Minecraft Terms of Service and the End User License Agreement?

1.13 new jar URLs

URLs are now in this structure:

{
...
"downloads": {
"client": {
"url": ...
...
}
}
...
}

Failed to launch forge

I call MinecraftLauncherBackend.launchMinecraft with 1.12.2-forge1.12.2-14.23.3.2678 as VersionId, it will crash with this stacktrace:

Exception in thread "main" java.lang.NullPointerException
	at java.util.Objects.requireNonNull(Objects.java:203)
	at sk.tomsik68.mclauncher.impl.versions.mcdownload.Artifact.fromJson(Artifact.java:21)
	at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersion.fromJson(MCDownloadVersion.java:112)
	at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadLocalVersionList.retrieveVersionInfo(MCDownloadLocalVersionList.java:58)
	at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionList.retrieveVersionInfo(MCDownloadVersionList.java:42)
	at sk.tomsik68.mclauncher.backend.MinecraftLauncherBackend.findVersion(MinecraftLauncherBackend.java:29)
	at sk.tomsik68.mclauncher.backend.MinecraftLauncherBackend.launchMinecraft(MinecraftLauncherBackend.java:89)
	at jakobdev.mclauncher_cmd.mclauncher_cmd.main(mclauncher_cmd.java:18)

If I call it with 1.14.3 or 1.12.2 as Version ID everything works great. Forge works in the normal Minecraft Launcher, so it should be installed correctly.

Downloading Forge Files Fails

Here is the code that is problematic:

YDLoginService loginService = new YDLoginService();
            IProfile profile = new LegacyProfile(username, password);
            ISession session = loginService.login(profile);

            monitor.setStatus("Success! Launching...");

            String path = Platform.getCurrentPlatform().getWorkingDirectory().getAbsolutePath();
            final MinecraftInstance mc = new MinecraftInstance(Platform.getCurrentPlatform().getWorkingDirectory());
            // lets get the forge json file
            File file = new File(path + "/versions/forge/forge.json");
            monitor.setStatus("Installing Forge");
            MCFileUtils.downloadFileWithProgress("link/to/forgejson/location/forge.json",
                    file, monitor);

            // this will install the forge and vanilla client
            MCDownloadVersionList versionList = new MCDownloadVersionList(mc);
            IVersion toLaunch = versionList.retrieveVersionInfo("forge");
            toLaunch.getInstaller().install(toLaunch, mc, monitor);

The reason is the forge files are sometimes in a packed format and the main jar url is actually different than what your api sets it to. I did a really ugly and quick patch to make it work which is here:

https://github.com/CityOfLearning/mclauncher-api/blob/dyn/tomsik68/mclauncher/util/MCFileUtils.java#L116-L125

really what I should do is get the proper link from the forge method using this: https://github.com/MinecraftForge/Installer/blob/master/src/main/java/net/minecraftforge/installer/Artifact.java

But I just wanted to raise it to your attention as well 😄

[Question] Video Tutorial

Is there a video tutorial for this API?
I didn't understand every part in the Wiki and i would love to see a video that shows everything and some examples.

[Not an issue] Output in jTextArea

Hey,
I am sorry if this is the incorrect place for posting this.. But I really needed to ask..
Is there a way I can get the output shown on the console In a jTextArea?.. Example:

INFO: Updating asset file: minecraft/sounds/dig/cloth4.ogg (size:4844B)
Dec 24, 2015 3:04:42 AM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDResourcesInstaller downloadAssetList
INFO: Updating asset file: minecraft/sounds/mob/skeleton/hurt1.ogg (size:9986B)
Dec 24, 2015 3:04:42 AM sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDResourcesInstaller downloadAssetList
INFO: Updating asset file: minecraft/sounds/dig/sand4.ogg (size:5491B)

This is the example you posted that I am using to download the files:

        final MCDownloadVersionList list = new MCDownloadVersionList();
        final MinecraftInstance mc = new MinecraftInstance(new File("testmc"));
        list.addObserver(new IObserver<String>() {
            private boolean installed = false;

            @Override
            public void onUpdate(IObservable<String> observable, String id) {
                id = (String) jComboBox1.getSelectedItem();

                IVersion changed = null;
                try {
                    changed = list.retrieveVersionInfo(id);

                } catch (Exception e) {
                    e.printStackTrace();
                }
                System.out.println("Version "+changed.getId());
                if(installed) return;
                installed = true;
                System.out.println("Installing " + changed.getDisplayName());
                try {
                    changed.getInstaller().install(changed, mc, null);
                } catch (Exception e) {
                    e.printStackTrace();
                    //fail();
                }
            }
        });
        try {

            list.startDownload();

        } catch (Exception e) {
            e.printStackTrace();
            //fail();

        } 

something like this:

screenshot from 2015-12-24 03 23 12

API to make custom launchers on 1.15.2

Does it work for minecraft 1.15.2 ? and does it download 1.15.2 forge if you want ? i was trying to make this work on my launcher but i couldn't :/ previously i was using jMCLaunchLib but now it is no longer updated and i need to find good launch lib which work well
sorry for my english :)

Can't compile source on netbeans

Hi, I downloaded the source code and wanted to compile it in netbeans. However it gives me the following error:

-------------------------------------------------------------
COMPILATION ERROR : 
-------------------------------------------------------------
sk/tomsik68/mclauncher/impl/versions/mcdownload/MCDownloadVersionInstaller.java:[27,23] constructor MCDownloadVersionList in class sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionList cannot be applied to given types;
  required: sk.tomsik68.mclauncher.api.common.mc.MinecraftInstance
  found: no arguments
  reason: actual and formal argument lists differ in length
sk/tomsik68/mclauncher/backend/MinecraftLauncherBackend.java:[44,55] constructor MCDownloadVersionList in class sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionList cannot be applied to given types;
  required: sk.tomsik68.mclauncher.api.common.mc.MinecraftInstance
  found: no arguments
  reason: actual and formal argument lists differ in length
2 errors 
-------------------------------------------------------------

Am I missing something?
Any help regarding this would be great!

Regards,
Ammar Ahmad

Play in no internet?

Um I am not sure if that part is implemented or not (so this is sort of a suggestion).. I tried looking for it but couldn't find it. Here is what I mean...
If the user has no internet connection, the details about the minecraft version can not be resolved.
Example:

IVersion changed = null;
            try {
                changed = versionList.retrieveVersionInfo("1.8");
            } catch (Exception e) {
                e.printStackTrace();
            }

Is the example over here: https://github.com/tomsik68/mclauncher-api/blob/master/src/test/java/TestMCDownloadLaunch.java

If I go into the function retrieveVersionInfo which has code:

@Override
    public IVersion retrieveVersionInfo(String id) throws Exception{
        String fullVersionJSONString = HttpUtils.httpGet(FULL_VERSION_URL_TEMPLATE.replace("<VERSION>", id));
        JSONObject fullVersionObject = (JSONObject) JSONValue.parse(fullVersionJSONString);
        // ,create a MCDownloadVersion based on it
        MCDownloadVersion version = new MCDownloadVersion(fullVersionObject);
        // resolve inheritance if needed
        resolveInheritance(version);
        return version;
    }

Now over here its trying to connect to the internet.. So the user won't be able to play minecraft if no internet is available.. (tested it..)

As again.. I am not sure if this is something thats not implemented, I just wanted to give suggestion.

Regards,
Ammar Ahmad

How to use forge with api?

I'm trying to run forge with code

        MinecraftInstance mc = new MinecraftInstance(Platform.getCurrentPlatform().getWorkingDirectory());

        ISession session = GlobalAuthenticationSystem.login(null);

        MCDownloadVersionList versionList = new MCDownloadVersionList(mc);
        IVersion toLaunch = versionList.retrieveVersionInfo("1.12.2-forge1.12.2-14.23.5.2838");
        toLaunch.getInstaller().install(toLaunch, mc, null);

but i've got error

Exception in thread "main" java.lang.NullPointerException
	at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersion.fromJson(MCDownloadVersion.java:69)
	at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadLocalVersionList.retrieveVersionInfo(MCDownloadLocalVersionList.java:58)
	at sk.tomsik68.mclauncher.impl.versions.mcdownload.MCDownloadVersionList.retrieveVersionInfo(MCDownloadVersionList.java:42)
	at com.followtm.btlauncher.Main.main(Main.java:36)

(line 36 in Main.java is IVersion toLaunch = versionList.retrieveVersionInfo("1.12.2-forge1.12.2-14.23.5.2838");

I installed forge by forge installer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.