Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.Neranaton.ReachEscrot.Bootstrap;
- import java.io.File;
- import java.io.IOException;
- import fr.theshark34.openlauncherlib.LaunchException;
- import fr.theshark34.openlauncherlib.minecraft.util.GameDirGenerator;
- import fr.theshark34.openlauncherlib.util.CrashReporter;
- import fr.theshark34.openlauncherlib.util.SplashScreen;
- import fr.theshark34.supdate.BarAPI;
- import fr.theshark34.supdate.SUpdate;
- import fr.theshark34.swinger.Swinger;
- import fr.theshark34.swinger.colored.SColoredBar;
- public class ReachEscrotBootstrap {
- private static SplashScreen splash;
- private static SColoredBar bar;
- private static Thread barThread;
- private static final File SC_B_DIR = new File(GameDirGenerator.createGameDir("ReachEscrot"), "Launcher");
- private static final File SC_B_C_DIR = new File(GameDirGenerator.createGameDir("ReachEscrot"), "Launcher/crash");
- private static final CrashReporter SC_B_REPORTER = new CrashReporter("ReachEscrot Bootstrap", SC_B_C_DIR);
- private static CrashReporter errorUtil = new CrashReporter(null, new File(SC_B_DIR, "Launcher/crashes/*"));
- public static void main(String[] args) {
- Swinger.setResourcePath("fr/Neranaton/ReachEscrot/BootStrap/resources/");
- displaySplash();
- try {
- doUpdate();
- } catch (Exception e) {
- errorUtil.catchError(e, "Impossible de mettre a jour le Launcher !");
- barThread.interrupt();
- }
- try {
- launchLauncher();
- } catch (LaunchException e) {
- errorUtil.catchError(e, "Impossible de lancer le Launcher !");
- }
- }
- private static void displaySplash() {
- splash = new SplashScreen("ReachEscrot 1", Swinger.getResource("splash.png"));
- splash.setLayout(null);
- bar = new SColoredBar(Swinger.getTransparentWhite(100), Swinger.getTransparentWhite(175));
- bar.setBounds(0, 490, 330, 20);
- splash.add(bar);
- splash.setVisible(true);
- }
- private static void doUpdate() throws Exception {
- SUpdate su = new SUpdate("http://escrot.livehost.fr/Bootstrap", new File(SC_B_DIR, "Launcher"));
- barThread = new Thread() {
- @Override
- public void run() {
- while(!this.isInterrupted()) {
- bar.setValue((int) (BarAPI.getNumberOfTotalDownloadedBytes() / 1000));
- bar.setMaximum((int) (BarAPI.getNumberOfTotalBytesToDownload() / 1000));
- }
- }
- };
- barThread.start();
- su.start();
- barThread.interrupt();
- }
- private static void launchLauncher()throws LaunchException{
- ClasspathConstructor constructor = new ClasspathConstructor();
- ExploredDirectory gameDir = Explorer.dir(SC_B_DIR);
- constructor.add(gameDir.sub("Libs").allRecursive().files().match("^(.*\.((jar)$))$"));
- constructor.add(gameDir.get("launcher.jar"));
- ExternalLaunchProfile profile = new ExternalLaunchProfile("fr.neranaton.reachescrot.LauncherFrame", constructor.make());
- ExternalLauncher launcher = new ExternalLauncher(profile);
- Process p = launcher.launch();
- splash.setVisible(false);
- ProcessLogManager manager = new ProcessLogManager(p.getInputStream());
- manager.start();
- try{
- p.waitFor();
- }catch (InterruptedException ignored){
- }
- System.exit(0);
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement