Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.ghostymaniakk.boot;
- import java.awt.Color;
- import java.io.File;
- import java.io.IOException;
- import fr.theshark34.openlauncherlib.LaunchException;
- import fr.theshark34.openlauncherlib.external.ClasspathConstructor;
- import fr.theshark34.openlauncherlib.external.ExternalLaunchProfile;
- import fr.theshark34.openlauncherlib.external.ExternalLauncher;
- import fr.theshark34.openlauncherlib.minecraft.util.GameDirGenerator;
- import fr.theshark34.openlauncherlib.util.CrashReporter;
- import fr.theshark34.openlauncherlib.util.ProcessLogManager;
- import fr.theshark34.openlauncherlib.util.SplashScreen;
- import fr.theshark34.openlauncherlib.util.explorer.ExploredDirectory;
- import fr.theshark34.openlauncherlib.util.explorer.Explorer;
- import fr.theshark34.supdate.BarAPI;
- import fr.theshark34.supdate.SUpdate;
- import fr.theshark34.swinger.Swinger;
- import fr.theshark34.swinger.colored.SColoredBar;
- public class Bootstrap {
- private static SplashScreen splash;
- private static SColoredBar bar;
- private static Thread barThread;
- public static final File NF_DIR = new File(GameDirGenerator.createGameDir("LordFight"), "Launcher");
- private static CrashReporter errorUtil = new CrashReporter("crash", new File(NF_DIR, "Launcher/crashes/"));
- public static void main(String[] args) throws LaunchException {
- Swinger.setResourcePath("/fr/ghostymaniakk/boot/ressources/");
- displaySplash();
- try {
- doUpdate();
- } catch (Exception e) {
- errorUtil.catchError(e, "Impossible de mettre a jour LordFight !");
- barThread.interrupt();
- }
- try {
- launchLauncher();
- } catch (IOException e) {
- errorUtil.catchError(e, "Impossible de lancer LordFight !");
- }
- }
- private static void displaySplash() {
- splash = new SplashScreen("LordFight", Swinger.getResource("background.png"));
- splash.setBackground(new Color(0, 0, 0, 0));
- bar = new SColoredBar(new Color(255, 255, 255, 15), new Color(255, 255, 255, 0));
- bar.setBounds(0, 40, 80, 0);
- splash.setUndecorated(true);
- splash.add(bar);
- splash.setVisible(true);
- }
- private static void doUpdate() throws Exception {
- SUpdate su = new SUpdate("http://launcher.lordfight.fr/launcher/", NF_DIR);
- barThread = new Thread() {
- public void run() {
- while (!isInterrupted()) {
- Bootstrap.bar.setValue((int) (BarAPI.getNumberOfTotalDownloadedBytes() / 1000L));
- Bootstrap.bar.setMaximum((int) (BarAPI.getNumberOfTotalBytesToDownload() / 1000L));
- }
- }
- };
- barThread.start();
- su.start();
- barThread.interrupt();
- }
- private static void launchLauncher() throws IOException, LaunchException {
- ClasspathConstructor constructor = new ClasspathConstructor();
- ExploredDirectory gameDir = Explorer.dir(NF_DIR);
- constructor.add(gameDir.sub("libraries").allRecursive().files().match("^(.*\\.((jar)$))*$"));
- constructor.add(new File[] { gameDir.get("launcher.jar") });
- ExternalLaunchProfile profile = new ExternalLaunchProfile("fr.vorion.lordfightlauncher.Main", constructor.make());
- ExternalLauncher launcher = new ExternalLauncher(profile);
- Process p = launcher.launch();
- ProcessLogManager manager = new ProcessLogManager (p.getInputStream());
- manager.start();
- try {
- p.waitFor();
- } catch (InterruptedException localInterruptedException) {
- }
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement