| 941 | } |
| 942 | |
| 943 | shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) |
| 944 | { |
| 945 | updateRuntimeContext(); |
| 946 | // FIXME: get rid of shared_from_this ... |
| 947 | auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this())); |
| 948 | auto pptr = process.get(); |
| 949 | |
| 950 | APPLICATION->icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG"); |
| 951 | |
| 952 | // print a header |
| 953 | { |
| 954 | process->appendStep(new TextPrint(pptr, "Minecraft folder is:\n" + gameRoot() + "\n\n", MessageLevel::Launcher)); |
| 955 | } |
| 956 | |
| 957 | // check java |
| 958 | { |
| 959 | process->appendStep(new CheckJava(pptr)); |
| 960 | } |
| 961 | |
| 962 | // check launch method |
| 963 | QStringList validMethods = {"LauncherPart", "DirectJava"}; |
| 964 | QString method = launchMethod(); |
| 965 | if(!validMethods.contains(method)) |
| 966 | { |
| 967 | process->appendStep(new TextPrint(pptr, "Selected launch method \"" + method + "\" is not valid.\n", MessageLevel::Fatal)); |
| 968 | return process; |
| 969 | } |
| 970 | |
| 971 | // create the .minecraft folder and server-resource-packs (workaround for Minecraft bug MCL-3732) |
| 972 | { |
| 973 | process->appendStep(new CreateGameFolders(pptr)); |
| 974 | } |
| 975 | |
| 976 | if (!serverToJoin && settings()->get("JoinServerOnLaunch").toBool()) |
| 977 | { |
| 978 | QString fullAddress = settings()->get("JoinServerOnLaunchAddress").toString(); |
| 979 | serverToJoin.reset(new MinecraftServerTarget(MinecraftServerTarget::parse(fullAddress))); |
| 980 | } |
| 981 | |
| 982 | if(serverToJoin && serverToJoin->port == 25565) |
| 983 | { |
| 984 | // Resolve server address to join on launch |
| 985 | auto *step = new LookupServerAddress(pptr); |
| 986 | step->setLookupAddress(serverToJoin->address); |
| 987 | step->setOutputAddressPtr(serverToJoin); |
| 988 | process->appendStep(step); |
| 989 | } |
| 990 | |
| 991 | // run pre-launch command if that's needed |
| 992 | if(getPreLaunchCommand().size()) |
| 993 | { |
| 994 | auto step = new PreLaunchCommand(pptr); |
| 995 | step->setWorkingDirectory(gameRoot()); |
| 996 | process->appendStep(step); |
| 997 | } |
| 998 | |
| 999 | *m_authlibinjector_javaagent = QString(); |
| 1000 | if (!session->authlib_injector_base_url.isNull()) |
nothing calls this directly
no test coverage detected