Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.Tristan29490.EdgeCraft.launcher;
- import java.io.File;
- import fr.theshark34.openauth.AuthPoints;
- import fr.theshark34.openauth.AuthenticationException;
- import fr.theshark34.openauth.Authenticator;
- import fr.theshark34.openauth.model.AuthAgent;
- import fr.theshark34.openauth.model.response.AuthResponse;
- import fr.theshark34.openlauncherlib.LaunchException;
- import fr.theshark34.openlauncherlib.internal.InternalLaunchProfile;
- import fr.theshark34.openlauncherlib.internal.InternalLauncher;
- import fr.theshark34.openlauncherlib.minecraft.AuthInfos;
- import fr.theshark34.openlauncherlib.minecraft.GameFolder;
- import fr.theshark34.openlauncherlib.minecraft.GameInfos;
- import fr.theshark34.openlauncherlib.minecraft.GameTweak;
- import fr.theshark34.openlauncherlib.minecraft.GameType;
- import fr.theshark34.openlauncherlib.minecraft.GameVersion;
- import fr.theshark34.openlauncherlib.minecraft.MinecraftLauncher;
- import fr.theshark34.openlauncherlib.util.CrashReporter;
- import fr.theshark34.supdate.BarAPI;
- import fr.theshark34.supdate.SUpdate;
- import fr.theshark34.supdate.application.integrated.FileDeleter;
- import fr.theshark34.swinger.Swinger;
- public class Launcher {
- public static final GameVersion EC_VERSION = new GameVersion("1.7.10", GameType.V1_7_10);
- public static final GameInfos EC_INFOS = new GameInfos("EdgeCraft", EC_VERSION, new GameTweak[] {GameTweak.FORGE});
- public static final File EC_DIR = EC_INFOS.getGameDir();
- public static final File EC_CRASHES_DIR = new File(EC_DIR, "crashes");
- private static AuthInfos authInfos;
- private static Thread updateThread;
- private static CrashReporter crashReporter = new CrashReporter(null, EC_CRASHES_DIR);
- public static void auth(String username, String password) throws AuthenticationException {
- Authenticator authenticator = new Authenticator (Authenticator.MOJANG_AUTH_URL, AuthPoints.NORMAL_AUTH_POINTS);
- AuthResponse response = authenticator.authenticate(AuthAgent.MINECRAFT, username, password, "");
- authInfos = new AuthInfos(response.getSelectedProfile().getName(), response.getAccessToken(), response.getSelectedProfile().getId());
- }
- public static void update() throws Exception {
- SUpdate su = new SUpdate("http://edgecraftlaunch.livehost.fr/supdate-launcher/", EC_DIR);
- su.addApplication(new FileDeleter());
- updateThread = new Thread() {
- private int val;
- private int max;
- @Override
- public void run() {
- while(!this.isInterrupted()) {
- if(BarAPI.getNumberOfFileToDownload() == 0) {
- Launcherframe.getInstance().getLauncherPanel().setInfoText("Verification des fichiers...");
- continue;
- }
- val = (int) (BarAPI.getNumberOfTotalDownloadedBytes() / 1000);
- max = (int) (BarAPI.getNumberOfTotalBytesToDownload() / 1000);
- Launcherframe.getInstance().getLauncherPanel().getProgressBar().setMaximum(max);
- Launcherframe.getInstance().getLauncherPanel().getProgressBar().setValue(val);
- Launcherframe.getInstance().getLauncherPanel().setInfoText("Telechargement des fichiers " + BarAPI.getNumberOfDownloadedFiles() + "/" + BarAPI.getNumberOfFileToDownload() +
- " " + Swinger.percentage(val, max) + "%");
- }
- }
- };
- updateThread.start();
- su.start();
- updateThread.interrupt();
- }
- public static void launch() throws LaunchException {
- InternalLaunchProfile profile = MinecraftLauncher.createInternalProfile(EC_INFOS, GameFolder.BASIC, authInfos);
- InternalLauncher launcher = new InternalLauncher(profile);
- Launcherframe.getInstance().setVisible(false);
- launcher.launch();
- System.exit(0);
- }
- public static void interruptThread() {
- updateThread.interrupt();
- }
- public static CrashReporter getErrorUtil() {
- return crashReporter;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement