mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[ANY] Small IDEA Code Inspect
This commit is contained in:
parent
27219f7dd7
commit
f82d5dfa03
15 changed files with 17 additions and 25 deletions
|
@ -470,9 +470,9 @@ public String toString() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MySQLUserHardware implements UserHardware {
|
public static class MySQLUserHardware implements UserHardware {
|
||||||
private HardwareReportRequest.HardwareInfo hardwareInfo;
|
private final HardwareReportRequest.HardwareInfo hardwareInfo;
|
||||||
private byte[] publicKey;
|
private byte[] publicKey;
|
||||||
private long id;
|
private final long id;
|
||||||
private boolean banned;
|
private boolean banned;
|
||||||
|
|
||||||
public MySQLUserHardware(HardwareReportRequest.HardwareInfo hardwareInfo, byte[] publicKey, long id, boolean banned) {
|
public MySQLUserHardware(HardwareReportRequest.HardwareInfo hardwareInfo, byte[] publicKey, long id, boolean banned) {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
import pro.gravit.utils.helper.SecurityHelper;
|
import pro.gravit.utils.helper.SecurityHelper;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
|
@ -63,7 +63,6 @@ public Path process(Path inputJar) throws IOException {
|
||||||
for (Path e : server.launcherBinary.coreLibs) {
|
for (Path e : server.launcherBinary.coreLibs) {
|
||||||
reader.getCp().add(new JarFile(e.toFile()));
|
reader.getCp().add(new JarFile(e.toFile()));
|
||||||
}
|
}
|
||||||
;
|
|
||||||
context.pushJarFile(inputJar, (e) -> blacklist.contains(e.getName()), (e) -> true);
|
context.pushJarFile(inputJar, (e) -> blacklist.contains(e.getName()), (e) -> true);
|
||||||
|
|
||||||
// map for guard
|
// map for guard
|
||||||
|
|
|
@ -34,7 +34,7 @@ public void invoke(String... args) throws Exception {
|
||||||
verifyArgs(args, 1);
|
verifyArgs(args, 1);
|
||||||
Path targetDir = Paths.get(args[0]);
|
Path targetDir = Paths.get(args[0]);
|
||||||
if (!IOHelper.isDir(targetDir))
|
if (!IOHelper.isDir(targetDir))
|
||||||
throw new IllegalArgumentException(String.format("%s not directory", targetDir.toString()));
|
throw new IllegalArgumentException(String.format("%s not directory", targetDir));
|
||||||
Optional<SignJarTask> task = server.launcherBinary.getTaskByClass(SignJarTask.class);
|
Optional<SignJarTask> task = server.launcherBinary.getTaskByClass(SignJarTask.class);
|
||||||
if (task.isEmpty()) throw new IllegalStateException("SignJarTask not found");
|
if (task.isEmpty()) throw new IllegalStateException("SignJarTask not found");
|
||||||
IOHelper.walk(targetDir, new SignJarVisitor(task.get()), true);
|
IOHelper.walk(targetDir, new SignJarVisitor(task.get()), true);
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class UpdatesManager {
|
||||||
private final LaunchServer server;
|
private final LaunchServer server;
|
||||||
private final Logger logger = LogManager.getLogger();
|
private final Logger logger = LogManager.getLogger();
|
||||||
private volatile Map<String, HashedDir> updatesDirMap;
|
private volatile Map<String, HashedDir> updatesDirMap;
|
||||||
private Path cacheFile;
|
private final Path cacheFile;
|
||||||
|
|
||||||
public UpdatesManager(LaunchServer server) {
|
public UpdatesManager(LaunchServer server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
|
|
@ -78,8 +78,8 @@ default Map<String, String> getParamsFromUri(String uri) {
|
||||||
String sub = uri.substring(ind + 1);
|
String sub = uri.substring(ind + 1);
|
||||||
String[] result = sub.split("&");
|
String[] result = sub.split("&");
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
for (int i = 0; i < result.length; ++i) {
|
for (String s : result) {
|
||||||
String c = URLDecoder.decode(result[i], Charset.defaultCharset());
|
String c = URLDecoder.decode(s, Charset.defaultCharset());
|
||||||
int index = c.indexOf("=");
|
int index = c.indexOf("=");
|
||||||
if (index <= 0) {
|
if (index <= 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -89,7 +89,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (needUserInfo && client.isAuth) {
|
if (needUserInfo && client.isAuth) {
|
||||||
sendResult(new RestoreRequestEvent(CurrentUserResponse.collectUserInfoFromClient(client), invalidTokens));
|
sendResult(new RestoreRequestEvent(CurrentUserResponse.collectUserInfoFromClient(server, client), invalidTokens));
|
||||||
} else {
|
} else {
|
||||||
sendResult(new RestoreRequestEvent(invalidTokens));
|
sendResult(new RestoreRequestEvent(invalidTokens));
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||||
WebSocketFrameHandler frameHandler = ctx.pipeline().get(WebSocketFrameHandler.class);
|
WebSocketFrameHandler frameHandler = ctx.pipeline().get(WebSocketFrameHandler.class);
|
||||||
frameHandler.setClient(rClient[0]);
|
frameHandler.setClient(rClient[0]);
|
||||||
if (needUserInfo) {
|
if (needUserInfo) {
|
||||||
sendResult(new RestoreSessionRequestEvent(CurrentUserResponse.collectUserInfoFromClient(rClient[0])));
|
sendResult(new RestoreSessionRequestEvent(CurrentUserResponse.collectUserInfoFromClient(server, rClient[0])));
|
||||||
} else {
|
} else {
|
||||||
sendResult(new RestoreSessionRequestEvent());
|
sendResult(new RestoreSessionRequestEvent());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package pro.gravit.launcher;
|
package pro.gravit.launcher;
|
||||||
|
|
||||||
import pro.gravit.launcher.events.ExtendedTokenRequestEvent;
|
import pro.gravit.launcher.events.ExtendedTokenRequestEvent;
|
||||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
|
||||||
import pro.gravit.launcher.events.request.ErrorRequestEvent;
|
|
||||||
import pro.gravit.launcher.events.request.SecurityReportRequestEvent;
|
import pro.gravit.launcher.events.request.SecurityReportRequestEvent;
|
||||||
import pro.gravit.launcher.request.Request;
|
import pro.gravit.launcher.request.Request;
|
||||||
import pro.gravit.launcher.request.WebSocketEvent;
|
import pro.gravit.launcher.request.WebSocketEvent;
|
||||||
|
|
|
@ -141,7 +141,7 @@ public final LauncherModule preInit() {
|
||||||
* @return true if adding a handler was successful
|
* @return true if adding a handler was successful
|
||||||
*/
|
*/
|
||||||
protected <T extends Event> boolean registerEvent(EventHandler<T> handle, Class<T> tClass) {
|
protected <T extends Event> boolean registerEvent(EventHandler<T> handle, Class<T> tClass) {
|
||||||
EventEntity<T> eventEntity = new EventEntity<T>(handle, tClass);
|
EventEntity<T> eventEntity = new EventEntity<>(handle, tClass);
|
||||||
eventList.add(eventEntity);
|
eventList.add(eventEntity);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
import pro.gravit.launcher.hasher.FileNameMatcher;
|
import pro.gravit.launcher.hasher.FileNameMatcher;
|
||||||
import pro.gravit.launcher.profiles.optional.OptionalDepend;
|
import pro.gravit.launcher.profiles.optional.OptionalDepend;
|
||||||
import pro.gravit.launcher.profiles.optional.OptionalFile;
|
import pro.gravit.launcher.profiles.optional.OptionalFile;
|
||||||
import pro.gravit.launcher.profiles.optional.OptionalTrigger;
|
|
||||||
import pro.gravit.launcher.profiles.optional.OptionalType;
|
import pro.gravit.launcher.profiles.optional.OptionalType;
|
||||||
|
import pro.gravit.launcher.profiles.optional.triggers.OptionalTrigger;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
import pro.gravit.utils.helper.VerifyHelper;
|
import pro.gravit.utils.helper.VerifyHelper;
|
||||||
|
|
||||||
|
@ -376,12 +376,10 @@ public void verify() {
|
||||||
if (s == null)
|
if (s == null)
|
||||||
throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.dependenciesFile", f.name));
|
throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.dependenciesFile", f.name));
|
||||||
}
|
}
|
||||||
if (f.triggers != null) {
|
if (f.triggersList != null) {
|
||||||
for (OptionalTrigger trigger : f.triggers) {
|
for (OptionalTrigger trigger : f.triggersList) {
|
||||||
if (trigger == null)
|
if (trigger == null)
|
||||||
throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.triggers", f.name));
|
throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.triggers", f.name));
|
||||||
if (trigger.type == null)
|
|
||||||
throw new IllegalArgumentException(String.format("trigger.type must not be null in updateOptional.%s.triggers", f.name));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ public abstract class Request<R extends WebSocketEvent> implements WebSocketRequ
|
||||||
private static Map<String, String> extendedTokens;
|
private static Map<String, String> extendedTokens;
|
||||||
private static String authId;
|
private static String authId;
|
||||||
private static long tokenExpiredTime;
|
private static long tokenExpiredTime;
|
||||||
private static List<ExtendedTokenCallback> extendedTokenCallbacks = new ArrayList<>(4);
|
private static final List<ExtendedTokenCallback> extendedTokenCallbacks = new ArrayList<>(4);
|
||||||
private static List<BiConsumer<String, AuthRequestEvent.OAuthRequestEvent>> oauthChangeHandlers = new ArrayList<>(4);
|
private static final List<BiConsumer<String, AuthRequestEvent.OAuthRequestEvent>> oauthChangeHandlers = new ArrayList<>(4);
|
||||||
@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);
|
||||||
|
|
|
@ -77,7 +77,7 @@ public static String rawFormat(LogHelper.Level level, String dateTime, boolean s
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatVersion(String product) {
|
public static String formatVersion(String product) {
|
||||||
return String.format("GravitLauncher (fork sashok724's Launcher) %s v%s", product, Version.getVersion().toString());
|
return String.format("GravitLauncher (fork sashok724's Launcher) %s v%s", product, Version.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatLicense(String product) {
|
public static String formatLicense(String product) {
|
||||||
|
|
|
@ -47,7 +47,7 @@ public static boolean tryAddModule(List<Path> paths, String moduleName, StringBu
|
||||||
Path result = tryFindModule(path, moduleName);
|
Path result = tryFindModule(path, moduleName);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
if (args.length() != 0) args.append(File.pathSeparatorChar);
|
if (args.length() != 0) args.append(File.pathSeparatorChar);
|
||||||
args.append(result.toAbsolutePath().toString());
|
args.append(result.toAbsolutePath());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,7 @@ public static Downloader downloadList(List<AsyncDownloader.SizedFile> files, Str
|
||||||
downloader.future = downloader.downloadFiles(files, baseURL, targetDir, callback, executor, threads);
|
downloader.future = downloader.downloadFiles(files, baseURL, targetDir, callback, executor, threads);
|
||||||
if (closeExecutor) {
|
if (closeExecutor) {
|
||||||
ExecutorService finalExecutor = executor;
|
ExecutorService finalExecutor = executor;
|
||||||
downloader.future = downloader.future.thenAccept(e -> {
|
downloader.future = downloader.future.thenAccept(e -> finalExecutor.shutdownNow());
|
||||||
finalExecutor.shutdownNow();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return downloader;
|
return downloader;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue