diff --git a/launcher.exe b/launcher.exe new file mode 100755 index 0000000..29e97d2 Binary files /dev/null and b/launcher.exe differ diff --git a/launcher.sh b/launcher.sh new file mode 100755 index 0000000..c93b4d8 --- /dev/null +++ b/launcher.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Check if minicraft.jar exists +if [ -f "minicraft.jar" ]; then + echo "minicraft.jar found." +else + echo "minicraft.jar not found. Downloading the latest version..." + + # Fetch the latest release information from GitHub + latest_release=$(curl -s https://api.github.com/repos/MinicraftPlus/minicraft-plus-online/releases/latest | grep "browser_download_url.*minicraft_plus-.*\.jar" | cut -d '"' -f 4) + + # Download the latest version of minicraft_plus.jar + wget -O minicraft.jar $latest_release + + echo "Download complete." +fi + +# Run minicraft.jar +java -jar minicraft.jar diff --git a/launcher32bit.exe b/launcher32bit.exe new file mode 100755 index 0000000..250a93a Binary files /dev/null and b/launcher32bit.exe differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..96e80f5 --- /dev/null +++ b/main.cpp @@ -0,0 +1,91 @@ +#include +#include +#include +#include +#include + +// Function to check if a file exists +bool FileExists(const std::string& filename) { + std::ifstream file(filename); + return file.good(); +} + +// Function to download and install Java 8 +void InstallJava() { + std::cout << "Java 8 or higher is not installed. Downloading Java 8..." << std::endl; + std::string command = "curl -L -o java_installer.exe https://javadl.oracle.com/webapps/download/AutoDL?BundleId=251654_7ed26d28139143f38c58992680c214a5 && start java_installer.exe"; + std::system(command.c_str()); + std::cout << "Please install Java and restart the program." << std::endl; + exit(1); +} + +// Function to get the latest release URL from GitHub +std::string GetLatestReleaseUrl() { + std::string command = "curl -s https://api.github.com/repos/MinicraftPlus/minicraft-plus-online/releases/latest"; + std::string response; + char buffer[128]; + FILE* pipe = popen(command.c_str(), "r"); + if (!pipe) { + std::cerr << "Failed to run curl command." << std::endl; + return ""; + } + while (fgets(buffer, sizeof(buffer), pipe) != nullptr) { + response += buffer; + } + pclose(pipe); + + std::istringstream stream(response); + std::string line; + while (std::getline(stream, line)) { + if (line.find("browser_download_url") != std::string::npos && line.find(".jar") != std::string::npos) { + size_t start = line.find("https://"); + size_t end = line.find_last_of('"'); + if (start != std::string::npos && end != std::string::npos) { + return line.substr(start, end - start); + } + } + } + return ""; +} + +// Function to download a file using curl command +bool DownloadFile(const std::string& url, const std::string& filename) { + std::string command = "curl -L -o " + filename + " " + url; + int result = std::system(command.c_str()); + return result == 0; +} + +int main() { + const std::string jarFilename = "minicraft.jar"; + + if (FileExists(jarFilename)) { + std::cout << jarFilename << " found." << std::endl; + } else { + std::cout << jarFilename << " not found. Downloading the latest version..." << std::endl; + std::string latestReleaseUrl = GetLatestReleaseUrl(); + + if (latestReleaseUrl.empty()) { + std::cerr << "Failed to get the latest release URL." << std::endl; + return 1; + } + + if (DownloadFile(latestReleaseUrl, jarFilename)) { + std::cout << "Download complete." << std::endl; + } else { + std::cerr << "Failed to download the file." << std::endl; + return 1; + } + } + + // Run minicraft.jar + std::cout << "Running minicraft.jar..." << std::endl; + int result = std::system(("java -jar " + jarFilename).c_str()); + + if (result != 0) { + std::cerr << "Java is not installed or failed to run minicraft.jar. Installing Java..." << std::endl; + InstallJava(); + return 1; + } + + return 0; +}