Advertisement
Guest User

LAUNCHER.CLASS

a guest
May 17th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. package fr.redsun.exolauncher;
  2.  
  3. import java.io.File;
  4.  
  5. import fr.theshark34.openauth.AuthPoints;
  6. import fr.theshark34.openauth.AuthenticationException;
  7. import fr.theshark34.openauth.Authenticator;
  8. import fr.theshark34.openauth.model.AuthAgent;
  9. import fr.theshark34.openauth.model.response.AuthResponse;
  10. import fr.theshark34.openlauncherlib.LaunchException;
  11. import fr.theshark34.openlauncherlib.external.ExternalLaunchProfile;
  12. import fr.theshark34.openlauncherlib.external.ExternalLauncher;
  13. import fr.theshark34.openlauncherlib.minecraft.AuthInfos;
  14. import fr.theshark34.openlauncherlib.minecraft.GameFolder;
  15. import fr.theshark34.openlauncherlib.minecraft.GameInfos;
  16. import fr.theshark34.openlauncherlib.minecraft.GameTweak;
  17. import fr.theshark34.openlauncherlib.minecraft.GameType;
  18. import fr.theshark34.openlauncherlib.minecraft.GameVersion;
  19. import fr.theshark34.openlauncherlib.minecraft.MinecraftLauncher;
  20. import fr.theshark34.supdate.BarAPI;
  21. import fr.theshark34.supdate.SUpdate;
  22. import fr.theshark34.supdate.application.integrated.FileDeleter;
  23. import fr.theshark34.swinger.Swinger;
  24.  
  25.  
  26. public class Launcher {
  27.  
  28. public static final GameVersion EX_VERSION = new GameVersion("1.12", GameType.V1_8_HIGHER);
  29. public static final GameInfos EX_INFOS = new GameInfos("exolia", EX_VERSION, new GameTweak[] {GameTweak.FORGE});
  30. public static final File EX_DIR = EX_INFOS.getGameDir();
  31. public static final GameTweak FORGE = new GameTweak()
  32. {
  33. @Override
  34. public String getName()
  35. {
  36. return "FML Tweaker";
  37. }
  38.  
  39. @Override
  40. public String getTweakClass(GameInfos infos)
  41. {
  42. return "net.minecraftforge.fml.common.launcher.FMLTweaker";
  43. }
  44. };
  45. private static AuthInfos authInfos;
  46. private static Thread updateThread;
  47.  
  48. public static void auth(String username, String password) throws AuthenticationException {
  49. Authenticator authenticator = new Authenticator(Authenticator.MOJANG_AUTH_URL, AuthPoints.NORMAL_AUTH_POINTS);
  50. AuthResponse response = authenticator.authenticate(AuthAgent.MINECRAFT, username, password, "");
  51. authInfos = new AuthInfos(response.getSelectedProfile().getName(), response.getAccessToken(), response.getSelectedProfile().getId());
  52. }
  53.  
  54. public static void update() throws Exception {
  55. SUpdate su = new SUpdate("http://data-ascraft.web.boxtoplay.com/", EX_DIR);
  56. su.addApplication(new FileDeleter());
  57.  
  58. updateThread = new Thread() {
  59.  
  60. private int val;
  61. private int max;
  62.  
  63. @Override
  64. public void run() {
  65.  
  66. while(!this.isInterrupted()) {
  67.  
  68. if(BarAPI.getNumberOfFileToDownload() == 0) {
  69. LauncherFrame.getInstance().getLauncherPanel().SetInfoText("Recherche de fichiers manquant...");
  70. continue;
  71. }
  72.  
  73. val = (int) (BarAPI.getNumberOfTotalDownloadedBytes() / 1000);
  74. max = (int) (BarAPI.getNumberOfTotalDownloadedBytes() / 1000);
  75.  
  76.  
  77. LauncherFrame.getInstance().getLauncherPanel().getProgressBar().setMaximum(max);
  78.  
  79.  
  80. LauncherFrame.getInstance().getLauncherPanel().getProgressBar().setValue(val);
  81.  
  82. LauncherFrame.getInstance().getLauncherPanel().SetInfoText("Telechargement en cours. Prenez une pause. " + BarAPI.getNumberOfDownloadedFiles()+ "->" + BarAPI.getNumberOfFileToDownload() + " " + Swinger.percentage(val,max) + "%");
  83.  
  84. }
  85.  
  86. }
  87.  
  88. };
  89. updateThread.start();
  90.  
  91. su.start();
  92.  
  93. updateThread.interrupt();
  94. }
  95.  
  96.  
  97.  
  98.  
  99. public static void launch() throws LaunchException {
  100. ExternalLaunchProfile profile = MinecraftLauncher.createExternalProfile(EX_INFOS, GameFolder.BASIC, authInfos);
  101. ExternalLauncher launcher = new ExternalLauncher(profile);
  102. launcher.launch();
  103. System.exit(0);
  104. }
  105.  
  106.  
  107.  
  108. public static void interruptThread() {
  109.  
  110. updateThread.interrupt();
  111.  
  112. }
  113.  
  114.  
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement