Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. package fr.ghostymaniakk.boot;
  2.  
  3. import java.awt.Color;
  4. import java.io.File;
  5. import java.io.IOException;
  6.  
  7. import fr.theshark34.openlauncherlib.LaunchException;
  8. import fr.theshark34.openlauncherlib.external.ClasspathConstructor;
  9. import fr.theshark34.openlauncherlib.external.ExternalLaunchProfile;
  10. import fr.theshark34.openlauncherlib.external.ExternalLauncher;
  11. import fr.theshark34.openlauncherlib.minecraft.util.GameDirGenerator;
  12. import fr.theshark34.openlauncherlib.util.CrashReporter;
  13. import fr.theshark34.openlauncherlib.util.ProcessLogManager;
  14. import fr.theshark34.openlauncherlib.util.SplashScreen;
  15. import fr.theshark34.openlauncherlib.util.explorer.ExploredDirectory;
  16. import fr.theshark34.openlauncherlib.util.explorer.Explorer;
  17. import fr.theshark34.supdate.BarAPI;
  18. import fr.theshark34.supdate.SUpdate;
  19. import fr.theshark34.swinger.Swinger;
  20. import fr.theshark34.swinger.colored.SColoredBar;
  21.  
  22. public class Bootstrap {
  23. private static SplashScreen splash;
  24. private static SColoredBar bar;
  25. private static Thread barThread;
  26. public static final File NF_DIR = new File(GameDirGenerator.createGameDir("LordFight"), "Launcher");
  27. private static CrashReporter errorUtil = new CrashReporter("crash", new File(NF_DIR, "Launcher/crashes/"));
  28.  
  29. public static void main(String[] args) throws LaunchException {
  30. Swinger.setResourcePath("/fr/ghostymaniakk/boot/ressources/");
  31.  
  32. displaySplash();
  33. try {
  34. doUpdate();
  35. } catch (Exception e) {
  36. errorUtil.catchError(e, "Impossible de mettre a jour LordFight !");
  37. barThread.interrupt();
  38. }
  39. try {
  40. launchLauncher();
  41. } catch (IOException e) {
  42. errorUtil.catchError(e, "Impossible de lancer LordFight !");
  43. }
  44. }
  45.  
  46. private static void displaySplash() {
  47. splash = new SplashScreen("LordFight", Swinger.getResource("background.png"));
  48. splash.setBackground(new Color(0, 0, 0, 0));
  49. bar = new SColoredBar(new Color(255, 255, 255, 15), new Color(255, 255, 255, 0));
  50. bar.setBounds(0, 40, 80, 0);
  51. splash.setUndecorated(true);
  52. splash.add(bar);
  53. splash.setVisible(true);
  54.  
  55. }
  56.  
  57. private static void doUpdate() throws Exception {
  58. SUpdate su = new SUpdate("http://launcher.lordfight.fr/launcher/", NF_DIR);
  59.  
  60. barThread = new Thread() {
  61. public void run() {
  62. while (!isInterrupted()) {
  63. Bootstrap.bar.setValue((int) (BarAPI.getNumberOfTotalDownloadedBytes() / 1000L));
  64. Bootstrap.bar.setMaximum((int) (BarAPI.getNumberOfTotalBytesToDownload() / 1000L));
  65. }
  66. }
  67. };
  68. barThread.start();
  69.  
  70. su.start();
  71. barThread.interrupt();
  72. }
  73.  
  74. private static void launchLauncher() throws IOException, LaunchException {
  75. ClasspathConstructor constructor = new ClasspathConstructor();
  76. ExploredDirectory gameDir = Explorer.dir(NF_DIR);
  77. constructor.add(gameDir.sub("libraries").allRecursive().files().match("^(.*\\.((jar)$))*$"));
  78. constructor.add(new File[] { gameDir.get("launcher.jar") });
  79. ExternalLaunchProfile profile = new ExternalLaunchProfile("fr.vorion.lordfightlauncher.Main", constructor.make());
  80. ExternalLauncher launcher = new ExternalLauncher(profile);
  81.  
  82. Process p = launcher.launch();
  83. ProcessLogManager manager = new ProcessLogManager (p.getInputStream());
  84. manager.start();
  85. try {
  86. p.waitFor();
  87. } catch (InterruptedException localInterruptedException) {
  88. }
  89. System.exit(0);
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement