mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +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 {
|
||||
private HardwareReportRequest.HardwareInfo hardwareInfo;
|
||||
private final HardwareReportRequest.HardwareInfo hardwareInfo;
|
||||
private byte[] publicKey;
|
||||
private long id;
|
||||
private final long id;
|
||||
private 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.Logger;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
|
|
@ -63,7 +63,6 @@ public Path process(Path inputJar) throws IOException {
|
|||
for (Path e : server.launcherBinary.coreLibs) {
|
||||
reader.getCp().add(new JarFile(e.toFile()));
|
||||
}
|
||||
;
|
||||
context.pushJarFile(inputJar, (e) -> blacklist.contains(e.getName()), (e) -> true);
|
||||
|
||||
// map for guard
|
||||
|
|
|
@ -34,7 +34,7 @@ public void invoke(String... args) throws Exception {
|
|||
verifyArgs(args, 1);
|
||||
Path targetDir = Paths.get(args[0]);
|
||||
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);
|
||||
if (task.isEmpty()) throw new IllegalStateException("SignJarTask not found");
|
||||
IOHelper.walk(targetDir, new SignJarVisitor(task.get()), true);
|
||||
|
|
|
@ -20,7 +20,7 @@ public class UpdatesManager {
|
|||
private final LaunchServer server;
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
private volatile Map<String, HashedDir> updatesDirMap;
|
||||
private Path cacheFile;
|
||||
private final Path cacheFile;
|
||||
|
||||
public UpdatesManager(LaunchServer server) {
|
||||
this.server = server;
|
||||
|
|
|
@ -78,8 +78,8 @@ default Map<String, String> getParamsFromUri(String uri) {
|
|||
String sub = uri.substring(ind + 1);
|
||||
String[] result = sub.split("&");
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (int i = 0; i < result.length; ++i) {
|
||||
String c = URLDecoder.decode(result[i], Charset.defaultCharset());
|
||||
for (String s : result) {
|
||||
String c = URLDecoder.decode(s, Charset.defaultCharset());
|
||||
int index = c.indexOf("=");
|
||||
if (index <= 0) {
|
||||
continue;
|
||||
|
|
|
@ -89,7 +89,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
|||
});
|
||||
}
|
||||
if (needUserInfo && client.isAuth) {
|
||||
sendResult(new RestoreRequestEvent(CurrentUserResponse.collectUserInfoFromClient(client), invalidTokens));
|
||||
sendResult(new RestoreRequestEvent(CurrentUserResponse.collectUserInfoFromClient(server, client), invalidTokens));
|
||||
} else {
|
||||
sendResult(new RestoreRequestEvent(invalidTokens));
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
|||
WebSocketFrameHandler frameHandler = ctx.pipeline().get(WebSocketFrameHandler.class);
|
||||
frameHandler.setClient(rClient[0]);
|
||||
if (needUserInfo) {
|
||||
sendResult(new RestoreSessionRequestEvent(CurrentUserResponse.collectUserInfoFromClient(rClient[0])));
|
||||
sendResult(new RestoreSessionRequestEvent(CurrentUserResponse.collectUserInfoFromClient(server, rClient[0])));
|
||||
} else {
|
||||
sendResult(new RestoreSessionRequestEvent());
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package pro.gravit.launcher;
|
||||
|
||||
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.request.Request;
|
||||
import pro.gravit.launcher.request.WebSocketEvent;
|
||||
|
|
|
@ -141,7 +141,7 @@ public final LauncherModule preInit() {
|
|||
* @return true if adding a handler was successful
|
||||
*/
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
import pro.gravit.launcher.hasher.FileNameMatcher;
|
||||
import pro.gravit.launcher.profiles.optional.OptionalDepend;
|
||||
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.triggers.OptionalTrigger;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
|
@ -376,12 +376,10 @@ public void verify() {
|
|||
if (s == null)
|
||||
throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.dependenciesFile", f.name));
|
||||
}
|
||||
if (f.triggers != null) {
|
||||
for (OptionalTrigger trigger : f.triggers) {
|
||||
if (f.triggersList != null) {
|
||||
for (OptionalTrigger trigger : f.triggersList) {
|
||||
if (trigger == null)
|
||||
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 String authId;
|
||||
private static long tokenExpiredTime;
|
||||
private static List<ExtendedTokenCallback> extendedTokenCallbacks = new ArrayList<>(4);
|
||||
private static List<BiConsumer<String, AuthRequestEvent.OAuthRequestEvent>> oauthChangeHandlers = new ArrayList<>(4);
|
||||
private static final List<ExtendedTokenCallback> extendedTokenCallbacks = new ArrayList<>(4);
|
||||
private static final List<BiConsumer<String, AuthRequestEvent.OAuthRequestEvent>> oauthChangeHandlers = new ArrayList<>(4);
|
||||
@LauncherNetworkAPI
|
||||
public final UUID requestUUID = UUID.randomUUID();
|
||||
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) {
|
||||
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) {
|
||||
|
|
|
@ -47,7 +47,7 @@ public static boolean tryAddModule(List<Path> paths, String moduleName, StringBu
|
|||
Path result = tryFindModule(path, moduleName);
|
||||
if (result != null) {
|
||||
if (args.length() != 0) args.append(File.pathSeparatorChar);
|
||||
args.append(result.toAbsolutePath().toString());
|
||||
args.append(result.toAbsolutePath());
|
||||
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);
|
||||
if (closeExecutor) {
|
||||
ExecutorService finalExecutor = executor;
|
||||
downloader.future = downloader.future.thenAccept(e -> {
|
||||
finalExecutor.shutdownNow();
|
||||
});
|
||||
downloader.future = downloader.future.thenAccept(e -> finalExecutor.shutdownNow());
|
||||
}
|
||||
return downloader;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue