Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. package fr.whyspi.fightofcube.launcher;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. import fr.theshark34.openauth.AuthenticationException;
  7. import fr.theshark34.openlauncherlib.launcher.AuthInfos;
  8. import fr.theshark34.openlauncherlib.launcher.GameFolder;
  9. import fr.theshark34.openlauncherlib.launcher.GameInfos;
  10. import fr.theshark34.openlauncherlib.launcher.GameLauncher;
  11. import fr.theshark34.openlauncherlib.launcher.GameTweak;
  12. import fr.theshark34.openlauncherlib.launcher.GameType;
  13. import fr.theshark34.openlauncherlib.launcher.GameVersion;
  14. import fr.theshark34.supdate.BarAPI;
  15. import fr.theshark34.supdate.SUpdate;
  16. import fr.theshark34.supdate.application.integrated.FileDeleter;
  17. import fr.theshark34.swinger.Swinger;
  18.  
  19. public class Launcher {
  20.  
  21. public static final GameVersion FC_VERSION = new GameVersion("1.7.10", GameType.V1_7_10);
  22. public static final GameInfos FC_INFOS = new GameInfos("FightOfCube", FC_VERSION, false, new GameTweak[] {GameTweak.FORGE});
  23. public static final File FC_DIR = FC_INFOS.getGameDir();
  24.  
  25. private static AuthInfos authInfos;
  26. private static Thread updateThread;
  27.  
  28.  
  29. public static void auth(String username) throws AuthenticationException {
  30. Launcher.authInfos = new AuthInfos(username, "sry", "nope");
  31. }
  32.  
  33. public static void update() throws Exception {
  34. SUpdate su = new SUpdate("http://fightofcube.raidcraft.org/launcher/", FC_DIR);
  35. su.addApplication(new FileDeleter());
  36.  
  37. updateThread = new Thread() {
  38. private int val;
  39. private int max;
  40.  
  41. @Override
  42. public void run() {
  43. while(!this.isInterrupted()) {
  44. if(BarAPI.getNumberOfFileToDownload() == 0) {
  45. LauncherFrame.getInstance().getLauncherPanel().setInfoText("Vérification des fichiers");
  46. continue;
  47. }
  48.  
  49. val = (int) (BarAPI.getNumberOfTotalDownloadedBytes() / 1000);
  50. max = (int) (BarAPI.getNumberOfTotalBytesToDownload() / 1000);
  51.  
  52. LauncherFrame.getInstance().getLauncherPanel().getProgressBar().setMaximum(max);
  53. LauncherFrame.getInstance().getLauncherPanel().getProgressBar().setValue(val);
  54.  
  55. LauncherFrame.getInstance().getLauncherPanel().setInfoText("Téléchargement des fichiers " +
  56. BarAPI.getNumberOfDownloadedFiles() + "/" + BarAPI.getNumberOfFileToDownload() + " " +
  57. Swinger.percentage(val, max) + "%");
  58. }
  59. }
  60. };
  61. updateThread.start();
  62.  
  63. su.start();
  64. updateThread.interrupt();
  65. }
  66.  
  67. public static void launch() throws IOException{
  68. GameLauncher gameLauncher = new GameLauncher(FC_INFOS, GameFolder.BASIC, authInfos);
  69. Process p = gameLauncher.launch();
  70. try {
  71. Thread.sleep(5000L);
  72. } catch (InterruptedException e) {
  73. }
  74. LauncherFrame.getInstance().setVisible(false);
  75. try {
  76. p.waitFor();
  77. } catch (InterruptedException e) {
  78. }
  79. System.exit(0);
  80. }
  81.  
  82. public static void interruptThread() {
  83.  
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement