Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.whyspi.fightofcube.launcher;
- import java.io.File;
- import java.io.IOException;
- import fr.theshark34.openauth.AuthenticationException;
- import fr.theshark34.openlauncherlib.launcher.AuthInfos;
- import fr.theshark34.openlauncherlib.launcher.GameFolder;
- import fr.theshark34.openlauncherlib.launcher.GameInfos;
- import fr.theshark34.openlauncherlib.launcher.GameLauncher;
- import fr.theshark34.openlauncherlib.launcher.GameTweak;
- import fr.theshark34.openlauncherlib.launcher.GameType;
- import fr.theshark34.openlauncherlib.launcher.GameVersion;
- 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 FC_VERSION = new GameVersion("1.7.10", GameType.V1_7_10);
- public static final GameInfos FC_INFOS = new GameInfos("FightOfCube", FC_VERSION, false, new GameTweak[] {GameTweak.FORGE});
- public static final File FC_DIR = FC_INFOS.getGameDir();
- private static AuthInfos authInfos;
- private static Thread updateThread;
- public static void auth(String username) throws AuthenticationException {
- Launcher.authInfos = new AuthInfos(username, "sry", "nope");
- }
- public static void update() throws Exception {
- SUpdate su = new SUpdate("http://fightofcube.raidcraft.org/launcher/", FC_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("Vérification 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("Téléchargement des fichiers " +
- BarAPI.getNumberOfDownloadedFiles() + "/" + BarAPI.getNumberOfFileToDownload() + " " +
- Swinger.percentage(val, max) + "%");
- }
- }
- };
- updateThread.start();
- su.start();
- updateThread.interrupt();
- }
- public static void launch() throws IOException{
- GameLauncher gameLauncher = new GameLauncher(FC_INFOS, GameFolder.BASIC, authInfos);
- Process p = gameLauncher.launch();
- try {
- Thread.sleep(5000L);
- } catch (InterruptedException e) {
- }
- LauncherFrame.getInstance().setVisible(false);
- try {
- p.waitFor();
- } catch (InterruptedException e) {
- }
- System.exit(0);
- }
- public static void interruptThread() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement