mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +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());
|
Request.getRequestService().registerEventHandler(new BasicLauncherEventHandler());
|
||||||
Objects.requireNonNull(args, "args");
|
Objects.requireNonNull(args, "args");
|
||||||
if (started.getAndSet(true))
|
if (started.getAndSet(true))
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class DebugMain {
|
||||||
public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft");
|
public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft");
|
||||||
public static String unlockSecret = System.getProperty("launcherdebug.unlocksecret", "");
|
public static String unlockSecret = System.getProperty("launcherdebug.unlocksecret", "");
|
||||||
public static boolean offlineMode = Boolean.getBoolean("launcherdebug.offlinemode");
|
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[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(",");
|
||||||
public static String[] moduleFiles = System.getProperty("launcherdebug.modulefiles", "").split(",");
|
public static String[] moduleFiles = System.getProperty("launcherdebug.modulefiles", "").split(",");
|
||||||
public static LauncherConfig.LauncherEnvironment environment = LauncherConfig.LauncherEnvironment.valueOf(System.getProperty("launcherdebug.env", "STD"));
|
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();
|
service = StdWebSocketService.initWebSockets(webSocketURL).get();
|
||||||
}
|
}
|
||||||
Request.setRequestService(service);
|
Request.setRequestService(service);
|
||||||
if(autoRefresh) {
|
if(!disableAutoRefresh) {
|
||||||
Request.startAutoRefresh();
|
Request.startAutoRefresh();
|
||||||
}
|
}
|
||||||
LogHelper.debug("Initialization LauncherEngine");
|
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 Map<String, ExtendedToken> extendedTokens;
|
||||||
private static volatile String authId;
|
private static volatile String authId;
|
||||||
private static volatile long tokenExpiredTime;
|
private static volatile long tokenExpiredTime;
|
||||||
private static ScheduledExecutorService executorService;
|
private static volatile ScheduledExecutorService executorService;
|
||||||
|
private static volatile boolean autoRefreshRunning;
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
public final UUID requestUUID = UUID.randomUUID();
|
public final UUID requestUUID = UUID.randomUUID();
|
||||||
private transient final AtomicBoolean started = new AtomicBoolean(false);
|
private transient final AtomicBoolean started = new AtomicBoolean(false);
|
||||||
|
|
||||||
public static void startAutoRefresh() {
|
public static synchronized void startAutoRefresh() {
|
||||||
executorService = Executors.newSingleThreadScheduledExecutor();
|
if(!autoRefreshRunning) {
|
||||||
executorService.scheduleAtFixedRate(() -> {
|
executorService = Executors.newSingleThreadScheduledExecutor();
|
||||||
try {
|
executorService.scheduleAtFixedRate(() -> {
|
||||||
restore(false, true);
|
try {
|
||||||
} catch (Exception e) {
|
restore(false, true);
|
||||||
LogHelper.error(e);
|
} catch (Exception e) {
|
||||||
}
|
LogHelper.error(e);
|
||||||
}, 60, 60, TimeUnit.SECONDS);
|
}
|
||||||
|
}, 60, 60, TimeUnit.SECONDS);
|
||||||
|
autoRefreshRunning = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RequestService getRequestService() {
|
public static RequestService getRequestService() {
|
||||||
|
|
Loading…
Reference in a new issue