mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FIX] Enable autoRefresh in default
This commit is contained in:
parent
a3bcfed793
commit
224649aa13
3 changed files with 17 additions and 12 deletions
|
@ -234,6 +234,7 @@ public void start(String... args) throws Throwable {
|
|||
};
|
||||
}
|
||||
}
|
||||
Request.startAutoRefresh();
|
||||
Request.getRequestService().registerEventHandler(new BasicLauncherEventHandler());
|
||||
Objects.requireNonNull(args, "args");
|
||||
if (started.getAndSet(true))
|
||||
|
|
|
@ -29,7 +29,7 @@ public class DebugMain {
|
|||
public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft");
|
||||
public static String unlockSecret = System.getProperty("launcherdebug.unlocksecret", "");
|
||||
public static boolean offlineMode = Boolean.getBoolean("launcherdebug.offlinemode");
|
||||
public static boolean autoRefresh = Boolean.getBoolean("launcherdebug.autorefresh");
|
||||
public static boolean disableAutoRefresh = Boolean.getBoolean("launcherdebug.disableautorefresh");
|
||||
public static String[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(",");
|
||||
public static String[] moduleFiles = System.getProperty("launcherdebug.modulefiles", "").split(",");
|
||||
public static LauncherConfig.LauncherEnvironment environment = LauncherConfig.LauncherEnvironment.valueOf(System.getProperty("launcherdebug.env", "STD"));
|
||||
|
@ -69,7 +69,7 @@ public static void main(String[] args) throws Throwable {
|
|||
service = StdWebSocketService.initWebSockets(webSocketURL).get();
|
||||
}
|
||||
Request.setRequestService(service);
|
||||
if(autoRefresh) {
|
||||
if(!disableAutoRefresh) {
|
||||
Request.startAutoRefresh();
|
||||
}
|
||||
LogHelper.debug("Initialization LauncherEngine");
|
||||
|
|
|
@ -28,20 +28,24 @@ public abstract class Request<R extends WebSocketEvent> implements WebSocketRequ
|
|||
private static volatile Map<String, ExtendedToken> extendedTokens;
|
||||
private static volatile String authId;
|
||||
private static volatile long tokenExpiredTime;
|
||||
private static ScheduledExecutorService executorService;
|
||||
private static volatile ScheduledExecutorService executorService;
|
||||
private static volatile boolean autoRefreshRunning;
|
||||
@LauncherNetworkAPI
|
||||
public final UUID requestUUID = UUID.randomUUID();
|
||||
private transient final AtomicBoolean started = new AtomicBoolean(false);
|
||||
|
||||
public static void startAutoRefresh() {
|
||||
executorService = Executors.newSingleThreadScheduledExecutor();
|
||||
executorService.scheduleAtFixedRate(() -> {
|
||||
try {
|
||||
restore(false, true);
|
||||
} catch (Exception e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
}, 60, 60, TimeUnit.SECONDS);
|
||||
public static synchronized void startAutoRefresh() {
|
||||
if(!autoRefreshRunning) {
|
||||
executorService = Executors.newSingleThreadScheduledExecutor();
|
||||
executorService.scheduleAtFixedRate(() -> {
|
||||
try {
|
||||
restore(false, true);
|
||||
} catch (Exception e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
}, 60, 60, TimeUnit.SECONDS);
|
||||
autoRefreshRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static RequestService getRequestService() {
|
||||
|
|
Loading…
Reference in a new issue