Advertisement
Guest User

Bootstrap

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