From 8ce5b4179c9698fa7660c0b4b1f8c84dab4f167a Mon Sep 17 00:00:00 2001 From: Gravit Date: Fri, 25 Sep 2020 22:44:39 +0700 Subject: [PATCH] [FIX] IDEA Inspect and bug fixes --- .../pro/gravit/launchserver/StarterAgent.java | 5 +-- .../launchserver/asm/InjectClassAcceptor.java | 16 +++---- .../auth/handler/HibernateAuthHandler.java | 1 - .../auth/protect/hwid/MemoryHWIDProvider.java | 2 +- .../auth/provider/JsonAuthProvider.java | 1 - .../auth/provider/RejectAuthProvider.java | 4 +- .../launchserver/binary/ProguardConf.java | 14 +++--- .../binary/tasks/CertificateAutogenTask.java | 2 +- .../binary/tasks/MainBuildTask.java | 16 +++---- .../command/hash/SaveProfilesCommand.java | 2 +- .../command/service/SignDirCommand.java | 2 +- .../launchserver/helper/DamerauHelper.java | 2 - .../manangers/PingServerManager.java | 2 +- .../gravit/launchserver/socket/Client.java | 1 - .../launchserver/socket/WebSocketService.java | 16 +++---- .../socket/handlers/NettyWebAPIHandler.java | 13 +----- .../handlers/WebSocketFrameHandler.java | 9 +--- .../fileserver/FileServerHandler.java | 2 +- .../response/auth/CurrentUserResponse.java | 1 - .../response/auth/RegisterResponse.java | 44 ------------------- .../management/ServerStatusResponse.java | 1 - .../response/profile/ProfileByUsername.java | 1 - .../secure/VerifySecureLevelKeyResponse.java | 1 - .../launchserver/ASMTransformersTest.java | 1 + .../gravit/launcher/utils/HWIDProvider.java | 6 +-- .../gravit/launcher/ClientPermissions.java | 1 + .../request/CurrentUserRequestEvent.java | 2 +- .../request/ServerStatusRequestEvent.java | 1 - .../launcher/profiles/ClientProfile.java | 9 +--- .../profiles/optional/OptionalFile.java | 4 +- .../optional/actions/OptionalAction.java | 2 +- .../optional/actions/OptionalActionFile.java | 1 - .../pro/gravit/launcher/request/Request.java | 1 - .../request/auth/CheckServerRequest.java | 4 +- .../request/auth/JoinServerRequest.java | 6 +-- .../request/update/UpdateRequest.java | 2 +- .../uuid/BatchProfileByUsernameRequest.java | 2 +- .../request/uuid/ProfileByUUIDRequest.java | 2 +- .../uuid/ProfileByUsernameRequest.java | 2 +- .../websockets/StdWebSocketService.java | 2 +- .../YggdrasilMinecraftSessionService.java | 2 +- .../pro/gravit/launcher/hasher/HashedDir.java | 6 +-- .../launcher/hasher/HashedEntryAdapter.java | 2 +- .../gravit/utils/UniversalJsonAdapter.java | 1 - .../main/java/pro/gravit/utils/Version.java | 2 +- .../utils/command/JLineCommandHandler.java | 6 +-- .../pro/gravit/utils/helper/CommonHelper.java | 7 +-- 47 files changed, 70 insertions(+), 162 deletions(-) delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/StarterAgent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/StarterAgent.java index c8f4a633..a6edd6b3 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/StarterAgent.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/StarterAgent.java @@ -21,7 +21,7 @@ public static boolean isAgentStarted() { public static void premain(String agentArgument, Instrumentation inst) { StarterAgent.inst = inst; - libraries = Paths.get(Optional.ofNullable(agentArgument).map(e -> e.trim()).filter(e -> !e.isEmpty()).orElse("libraries")); + libraries = Paths.get(Optional.ofNullable(agentArgument).map(String::trim).filter(e -> !e.isEmpty()).orElse("libraries")); isStarted = true; try { Files.walkFileTree(libraries, Collections.singleton(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new StarterVisitor()); @@ -40,11 +40,10 @@ private static final class StarterVisitor extends SimpleFileVisitor { DPERMS = Collections.unmodifiableSet(perms); } - private final Path filef; private final boolean fixLib; private StarterVisitor() { - this.filef = StarterAgent.libraries.resolve(".libraries_chmoded"); + Path filef = StarterAgent.libraries.resolve(".libraries_chmoded"); this.fixLib = !Files.exists(filef) && !Boolean.getBoolean("launcher.noLibrariesPosixPermsFix"); if (fixLib) { try { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java index 72a18b1d..46914d91 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java @@ -79,7 +79,7 @@ private static void visit(ClassNode classNode, Map values) { return; } field.invisibleAnnotations.remove(valueAnnotation); - AtomicReference valueName = new AtomicReference(null); + AtomicReference valueName = new AtomicReference<>(null); valueAnnotation.accept(new AnnotationVisitor(Opcodes.ASM7) { @Override public void visit(final String name, final Object value) { @@ -142,15 +142,11 @@ public void visit(final String name, final Object value) { } private static Serializer serializerClass(int opcode) { - return new Serializer() { - @Override - public InsnList serialize(Number value) { - InsnList ret = new InsnList(); - ret.add(NodeUtils.push(value.intValue())); - ret.add(new InsnNode(opcode)); - return ret; - } - + return (Serializer) value -> { + InsnList ret = new InsnList(); + ret.add(NodeUtils.push(value.intValue())); + ret.add(new InsnNode(opcode)); + return ret; }; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java index 74f31969..62cf5fd6 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java @@ -1,7 +1,6 @@ package pro.gravit.launchserver.auth.handler; import pro.gravit.launchserver.dao.User; -import pro.gravit.utils.helper.LogHelper; import java.util.UUID; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/hwid/MemoryHWIDProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/hwid/MemoryHWIDProvider.java index 9ec34510..54e0aec7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/hwid/MemoryHWIDProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/hwid/MemoryHWIDProvider.java @@ -73,7 +73,7 @@ public HardwareReportRequest.HardwareInfo findHardwareInfoByPublicKey(byte[] pub if(e.banned) throw new HWIDException("You HWID banned"); return e.hardware; } - }; + } return null; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java index 2b9756c7..7efa2a90 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java @@ -1,6 +1,5 @@ package pro.gravit.launchserver.auth.provider; -import com.google.gson.Gson; import com.google.gson.JsonElement; import pro.gravit.launcher.ClientPermissions; import pro.gravit.launcher.HTTPRequest; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java index fe52e5f3..9e94d72d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java @@ -14,8 +14,8 @@ import java.util.Map; public final class RejectAuthProvider extends AuthProvider implements Reconfigurable { - private String message; - private ArrayList whitelist = new ArrayList<>(); + public String message; + public ArrayList whitelist = new ArrayList<>(); public RejectAuthProvider() { } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java index bf3cb6bd..e955a30f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/ProguardConf.java @@ -52,19 +52,19 @@ public String[] buildConfig(Path inputJar, Path outputJar) { List confStrs = new ArrayList<>(); prepare(false); if (srv.config.launcher.proguardGenMappings) - confStrs.add("-printmapping \'" + mappings.toFile().getName() + "\'"); - confStrs.add("-obfuscationdictionary \'" + words.toFile().getName() + "\'"); - confStrs.add("-injar \'" + inputJar.toAbsolutePath() + "\'"); - confStrs.add("-outjar \'" + outputJar.toAbsolutePath() + "\'"); + confStrs.add("-printmapping '" + mappings.toFile().getName() + "'"); + confStrs.add("-obfuscationdictionary '" + words.toFile().getName() + "'"); + confStrs.add("-injar '" + inputJar.toAbsolutePath() + "'"); + confStrs.add("-outjar '" + outputJar.toAbsolutePath() + "'"); Collections.addAll(confStrs, JVMHelper.JVM_VERSION >= 9 ? JAVA9_OPTS : JAVA8_OPTS); srv.launcherBinary.coreLibs.stream() - .map(e -> "-libraryjars \'" + e.toAbsolutePath().toString() + "\'") + .map(e -> "-libraryjars '" + e.toAbsolutePath().toString() + "'") .forEach(confStrs::add); srv.launcherBinary.addonLibs.stream() - .map(e -> "-libraryjars \'" + e.toAbsolutePath().toString() + "\'") + .map(e -> "-libraryjars '" + e.toAbsolutePath().toString() + "'") .forEach(confStrs::add); - confStrs.add("-classobfuscationdictionary \'" + words.toFile().getName() + "\'"); + confStrs.add("-classobfuscationdictionary '" + words.toFile().getName() + "'"); confStrs.add("@".concat(config.toFile().getName())); return confStrs.toArray(new String[0]); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java index 9e5a1af4..f4e84389 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java @@ -35,7 +35,7 @@ public class CertificateAutogenTask implements LauncherBuildTask { public X509Certificate certificate; public X509CertificateHolder bcCertificate; public CMSSignedDataGenerator signedDataGenerator; - private LaunchServer server; + private final LaunchServer server; public CertificateAutogenTask(LaunchServer server) { this.server = server; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java index dcab43f4..d6f768e1 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -29,11 +29,11 @@ public class MainBuildTask implements LauncherBuildTask { public final ClassMetadataReader reader; private final LaunchServer server; - public Set blacklist = new HashSet<>(); - public List transformers = new ArrayList<>(); - public IOHookSet preBuildHook = new IOHookSet<>(); - public IOHookSet postBuildHook = new IOHookSet<>(); - public Map properties = new HashMap<>(); + public final Set blacklist = new HashSet<>(); + public final List transformers = new ArrayList<>(); + public final IOHookSet preBuildHook = new IOHookSet<>(); + public final IOHookSet postBuildHook = new IOHookSet<>(); + public final Map properties = new HashMap<>(); public MainBuildTask(LaunchServer srv) { server = srv; @@ -123,14 +123,13 @@ protected void initProps() { public byte[] transformClass(byte[] bytes, String classname, BuildContext context) { byte[] result = bytes; - ClassReader cr = null; - ClassWriter writer = null; + ClassWriter writer; ClassNode cn = null; for (Transformer t : transformers) { if (t instanceof ASMTransformer) { ASMTransformer asmTransformer = (ASMTransformer) t; if (cn == null) { - cr = new ClassReader(result); + ClassReader cr = new ClassReader(result); cn = new ClassNode(); cr.accept(cn, 0); } @@ -144,7 +143,6 @@ public byte[] transformClass(byte[] bytes, String classname, BuildContext contex byte[] old_result = result; result = t.transform(result, classname, context); if (old_result != result) { - cr = null; cn = null; } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java index 3c253ec7..12c05a9d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/SaveProfilesCommand.java @@ -24,7 +24,7 @@ public SaveProfilesCommand(LaunchServer server) { super(server); } - @SuppressWarnings("deprecated") + @SuppressWarnings("deprecation") public static void saveProfile(ClientProfile profile, Path path) throws IOException { if (profile.getUUID() == null) profile.setUUID(UUID.randomUUID()); if(profile.getServers().size() == 0) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SignDirCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SignDirCommand.java index f0557e0b..b6cbc886 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SignDirCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SignDirCommand.java @@ -39,7 +39,7 @@ public void invoke(String... args) throws Exception { } private class SignJarVisitor extends SimpleFileVisitor { - private SignJarTask task; + private final SignJarTask task; public SignJarVisitor(SignJarTask task) { this.task = task; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/DamerauHelper.java b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/DamerauHelper.java index 31853004..96c1bd3e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/DamerauHelper.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/DamerauHelper.java @@ -1,7 +1,5 @@ package pro.gravit.launchserver.helper; -import java.util.Arrays; - public class DamerauHelper { //Расстояние Дамерау — Левенштейна. GitHub https://github.com/crwohlfeil/damerau-levenshtein public static int calculateDistance(CharSequence source, CharSequence target) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/PingServerManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/PingServerManager.java index 04937680..2222db81 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/PingServerManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/PingServerManager.java @@ -8,7 +8,7 @@ import java.util.Map; public class PingServerManager { - public static long REPORT_EXPIRED_TIME = 20*1000; + public static final long REPORT_EXPIRED_TIME = 20*1000; public static class ServerInfoEntry { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java index e452a4dc..b9c7af11 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java @@ -7,7 +7,6 @@ import pro.gravit.launchserver.auth.AuthProviderPair; import pro.gravit.launchserver.dao.User; import pro.gravit.launchserver.socket.response.auth.AuthResponse; -import pro.gravit.utils.helper.LogHelper; import java.util.HashMap; import java.util.Map; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index 1e50772b..41850f60 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -38,7 +38,6 @@ import java.lang.reflect.Type; import java.util.concurrent.atomic.AtomicLong; import java.util.function.BiConsumer; -import java.util.function.Supplier; public class WebSocketService { public static final ProviderMap providers = new ProviderMap<>(); @@ -48,16 +47,16 @@ public class WebSocketService { private final Gson gson; //Statistic data - public AtomicLong shortRequestLatency = new AtomicLong(); - public AtomicLong shortRequestCounter = new AtomicLong(); + public final AtomicLong shortRequestLatency = new AtomicLong(); + public final AtomicLong shortRequestCounter = new AtomicLong(); - public AtomicLong middleRequestLatency = new AtomicLong(); - public AtomicLong middleRequestCounter = new AtomicLong(); + public final AtomicLong middleRequestLatency = new AtomicLong(); + public final AtomicLong middleRequestCounter = new AtomicLong(); - public AtomicLong longRequestLatency = new AtomicLong(); - public AtomicLong longRequestCounter = new AtomicLong(); + public final AtomicLong longRequestLatency = new AtomicLong(); + public final AtomicLong longRequestCounter = new AtomicLong(); - public AtomicLong lastRequestTime = new AtomicLong(); + public final AtomicLong lastRequestTime = new AtomicLong(); public WebSocketService(ChannelGroup channels, LaunchServer server) { this.channels = channels; @@ -92,7 +91,6 @@ public static void registerResponses() { providers.register("profileByUsername", ProfileByUsername.class); providers.register("profileByUUID", ProfileByUUIDResponse.class); providers.register("getAvailabilityAuth", GetAvailabilityAuthResponse.class); - providers.register("register", RegisterResponse.class); providers.register("exit", ExitResponse.class); providers.register("getSecureLevelInfo", GetSecureLevelInfoResponse.class); providers.register("verifySecureLevelKey", VerifySecureLevelKeyResponse.class); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyWebAPIHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyWebAPIHandler.java index 39a657a3..d445473b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyWebAPIHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyWebAPIHandler.java @@ -1,23 +1,12 @@ package pro.gravit.launchserver.socket.handlers; -import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; -import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.handler.codec.http.*; -import io.netty.util.ReferenceCounted; import pro.gravit.launchserver.socket.NettyConnectContext; -import pro.gravit.utils.BiHookSet; -import pro.gravit.utils.HookSet; -import pro.gravit.utils.helper.LogHelper; -import java.net.URI; import java.util.*; -import static io.netty.handler.codec.http.HttpResponseStatus.NOT_MODIFIED; -import static io.netty.handler.codec.http.HttpResponseStatus.OK; -import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; - public class NettyWebAPIHandler extends SimpleChannelInboundHandler { private final NettyConnectContext context; @@ -38,7 +27,7 @@ public SeverletPathPair(String key, SimpleSeverletHandler callback) { this.callback = callback; } } - private static TreeSet severletList = new TreeSet<>(Comparator.comparingInt((e) -> -e.key.length())); + private static final TreeSet severletList = new TreeSet<>(Comparator.comparingInt((e) -> -e.key.length())); public static SeverletPathPair addNewSeverlet(String path, SimpleSeverletHandler callback) { SeverletPathPair pair = new SeverletPathPair("/webapi/".concat(path), callback); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java index 7af62164..c6950756 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java @@ -9,7 +9,6 @@ import pro.gravit.launchserver.socket.NettyConnectContext; import pro.gravit.launchserver.socket.WebSocketService; import pro.gravit.utils.BiHookSet; -import pro.gravit.utils.HookSet; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; @@ -17,14 +16,12 @@ import java.util.concurrent.TimeUnit; public class WebSocketFrameHandler extends SimpleChannelInboundHandler { - static { - } public final LaunchServer srv; public final WebSocketService service; private final UUID connectUUID = UUID.randomUUID(); public NettyConnectContext context; - public BiHookSet hooks = new BiHookSet<>(); + public final BiHookSet hooks = new BiHookSet<>(); private Client client; public WebSocketFrameHandler(NettyConnectContext context, LaunchServer srv, WebSocketService service) { @@ -53,9 +50,7 @@ public void channelActive(ChannelHandlerContext ctx) { client = new Client(null); Channel ch = ctx.channel(); service.registerClient(ch); - ctx.executor().scheduleAtFixedRate(() -> { - ch.writeAndFlush(new PingWebSocketFrame(), ch.voidPromise()); - }, 30L , 30L, TimeUnit.SECONDS); + ctx.executor().scheduleAtFixedRate(() -> ch.writeAndFlush(new PingWebSocketFrame(), ch.voidPromise()), 30L , 30L, TimeUnit.SECONDS); } @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java index dfd4c60a..7d9bf32b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java @@ -66,7 +66,7 @@ private static void sendListing(ChannelHandlerContext ctx, File dir, String dirP .append("
    ") .append("
  • ..
  • \r\n"); - for (File f : dir.listFiles()) { + for (File f : Objects.requireNonNull(dir.listFiles())) { if ((f.isHidden() && !showHidden) || !f.canRead()) { continue; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CurrentUserResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CurrentUserResponse.java index 8f445e28..5f5be740 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CurrentUserResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CurrentUserResponse.java @@ -2,7 +2,6 @@ import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.CurrentUserRequestEvent; -import pro.gravit.launcher.request.uuid.ProfileByUUIDRequest; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java deleted file mode 100644 index 79503396..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RegisterResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -package pro.gravit.launchserver.socket.response.auth; - -import io.netty.channel.ChannelHandlerContext; -import pro.gravit.launcher.ClientPermissions; -import pro.gravit.launchserver.dao.User; -import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.socket.response.SimpleResponse; - -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Arrays; - -public class RegisterResponse extends SimpleResponse { - public String login; - public String password; - public String email; - public byte[] verifyHash; - - public static byte[] registerHash(String login, String secret) throws NoSuchAlgorithmException { - String text = login.concat("+").concat(secret); - MessageDigest digest = MessageDigest.getInstance("SHA-256"); - return digest.digest(text.getBytes(StandardCharsets.UTF_8)); - } - - @Override - public void execute(ChannelHandlerContext ctx, Client client) throws Exception { - byte[] normalHash = registerHash(login, server.runtime.registerApiKey); - if (!(client.isAuth && client.permissions.isPermission(ClientPermissions.PermissionConsts.ADMIN)) && !Arrays.equals(normalHash, verifyHash)) { - sendError("Hash invalid"); - return; - } - User checkUser = server.config.dao.userDAO.findByUsername(login); - if (checkUser != null) { - sendError("User already register"); - return; - } - } - - @Override - public String getType() { - return "register"; - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/ServerStatusResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/ServerStatusResponse.java index d8631c80..d6e17c45 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/ServerStatusResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/ServerStatusResponse.java @@ -3,7 +3,6 @@ import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.ServerStatusRequestEvent; import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.socket.WebSocketService; import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.utils.helper.JVMHelper; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUsername.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUsername.java index 61651a6d..d63e21c0 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUsername.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUsername.java @@ -5,7 +5,6 @@ import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.launchserver.auth.AuthProviderPair; -import pro.gravit.utils.helper.LogHelper; import java.util.UUID; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java index 2365757a..05673e12 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java @@ -1,7 +1,6 @@ package pro.gravit.launchserver.socket.response.secure; import io.netty.channel.ChannelHandlerContext; -import pro.gravit.launcher.events.request.VerifySecureLevelKeyRequestEvent; import pro.gravit.launchserver.auth.protect.interfaces.SecureProtectHandler; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.SimpleResponse; diff --git a/LaunchServer/src/test/java/pro/gravit/launchserver/ASMTransformersTest.java b/LaunchServer/src/test/java/pro/gravit/launchserver/ASMTransformersTest.java index ae355c27..dce01ae2 100644 --- a/LaunchServer/src/test/java/pro/gravit/launchserver/ASMTransformersTest.java +++ b/LaunchServer/src/test/java/pro/gravit/launchserver/ASMTransformersTest.java @@ -25,6 +25,7 @@ public static void prepare() throws Throwable { classLoader = new ASMClassLoader(ASMTransformersTest.class.getClassLoader()); } + @SuppressWarnings("unchecked") @Test void testASM() throws Throwable { ClassReader reader = new ClassReader(JarHelper.getClassBytes(TestClass.class)); diff --git a/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java b/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java index f7b53b10..e316c999 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java +++ b/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java @@ -9,9 +9,9 @@ import pro.gravit.launcher.request.secure.HardwareReportRequest; public class HWIDProvider { - public SystemInfo systemInfo; - public OperatingSystem system; - public HardwareAbstractionLayer hardware; + public final SystemInfo systemInfo; + public final OperatingSystem system; + public final HardwareAbstractionLayer hardware; public HWIDProvider() { systemInfo = new SystemInfo(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java b/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java index 040b88a8..6ac38e6f 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java @@ -31,6 +31,7 @@ public ClientPermissions(long permissions, long flags) { public static ClientPermissions getSuperuserAccount() { ClientPermissions perm = new ClientPermissions(); + perm.setPermission(PermissionConsts.ADMIN, true); return perm; } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/CurrentUserRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/CurrentUserRequestEvent.java index 16aa3f7e..eed9b1a1 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/CurrentUserRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/CurrentUserRequestEvent.java @@ -10,7 +10,7 @@ public static class UserInfo { public String accessToken; public PlayerProfile playerProfile; } - public UserInfo userInfo; + public final UserInfo userInfo; public CurrentUserRequestEvent(UserInfo userInfo) { this.userInfo = userInfo; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ServerStatusRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ServerStatusRequestEvent.java index ddf97ba8..47a5a0db 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ServerStatusRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ServerStatusRequestEvent.java @@ -1,7 +1,6 @@ package pro.gravit.launcher.events.request; import pro.gravit.launcher.events.RequestEvent; -import pro.gravit.utils.helper.JVMHelper; public class ServerStatusRequestEvent extends RequestEvent { public final String projectName; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java index c2bf3b75..7e91dc0b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -173,13 +173,13 @@ public void updateOptionalGraph() { if (file.dependenciesFile != null) { file.dependencies = new OptionalFile[file.dependenciesFile.length]; for (int i = 0; i < file.dependenciesFile.length; ++i) { - file.dependencies[i] = getOptionalFile(file.dependenciesFile[i].name, file.dependenciesFile[i].type); + file.dependencies[i] = getOptionalFile(file.dependenciesFile[i].name); } } if (file.conflictFile != null) { file.conflict = new OptionalFile[file.conflictFile.length]; for (int i = 0; i < file.conflictFile.length; ++i) { - file.conflict[i] = getOptionalFile(file.conflictFile[i].name, file.conflictFile[i].type); + file.conflict[i] = getOptionalFile(file.conflictFile[i].name); } } } @@ -369,11 +369,6 @@ public void verify() { for (OptionalFile f : updateOptional) { if (f == null) throw new IllegalArgumentException("Found null entry in updateOptional"); if (f.name == null) throw new IllegalArgumentException("Optional: name must not be null"); - if (f.list == null) throw new IllegalArgumentException("Optional: list must not be null"); - for (String s : f.list) { - if (s == null) - throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.list", f.name)); - } if (f.conflictFile != null) for (OptionalDepend s : f.conflictFile) { if (s == null) throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.conflictFile", f.name)); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java index 6965ffcd..11bfb3be 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java @@ -145,8 +145,6 @@ public void clearAllWatchers() { public void watchEvent(boolean isMark) { if (watchList == null) return; - watchList.forEach((e) -> { - e.accept(this, isMark); - }); + watchList.forEach((e) -> e.accept(this, isMark)); } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalAction.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalAction.java index e6dd8483..fda3c137 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalAction.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalAction.java @@ -3,7 +3,7 @@ import pro.gravit.utils.ProviderMap; public class OptionalAction { - public static ProviderMap providers = new ProviderMap<>(); + public static final ProviderMap providers = new ProviderMap<>(); private static boolean registerProviders = false; public static void registerProviders() { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionFile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionFile.java index 1d58b053..a0005e38 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionFile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/actions/OptionalActionFile.java @@ -3,7 +3,6 @@ import pro.gravit.launcher.hasher.HashedDir; import pro.gravit.utils.helper.LogHelper; -import java.util.List; import java.util.Map; public class OptionalActionFile extends OptionalAction { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java index d475491a..4df1c875 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java @@ -4,7 +4,6 @@ import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.request.websockets.StdWebSocketService; import pro.gravit.launcher.request.websockets.WebSocketRequest; -import pro.gravit.utils.helper.SecurityHelper; import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java index 84e26e60..e8c79910 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java @@ -8,9 +8,9 @@ public final class CheckServerRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI - private final String username; + public final String username; @LauncherNetworkAPI - private final String serverID; + public final String serverID; public CheckServerRequest(String username, String serverID) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java index 031f78db..19e028cc 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java @@ -10,11 +10,11 @@ public final class JoinServerRequest extends Request imp // Instance @LauncherNetworkAPI - private final String username; + public final String username; @LauncherNetworkAPI - private final String accessToken; + public final String accessToken; @LauncherNetworkAPI - private final String serverID; + public final String serverID; public JoinServerRequest(String username, String accessToken, String serverID) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java index d5628055..9f82311b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java @@ -9,7 +9,7 @@ public final class UpdateRequest extends Request implements // Instance @LauncherNetworkAPI - private final String dirName; + public final String dirName; public UpdateRequest(String dirName) { this.dirName = dirName; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java index a583396f..f1038f48 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java @@ -11,7 +11,7 @@ public final class BatchProfileByUsernameRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI - private final Entry[] list; + public final Entry[] list; public BatchProfileByUsernameRequest(String... usernames) throws IOException { this.list = new Entry[usernames.length]; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUUIDRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUUIDRequest.java index 14d0849e..4531f85c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUUIDRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUUIDRequest.java @@ -10,7 +10,7 @@ public final class ProfileByUUIDRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI - private final UUID uuid; + public final UUID uuid; public ProfileByUUIDRequest(UUID uuid) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java index a3d889c1..9b7c1d8b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java @@ -8,7 +8,7 @@ public final class ProfileByUsernameRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI - private final String username; + public final String username; public ProfileByUsernameRequest(String username) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java index 1cbef121..6816ad64 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java @@ -104,7 +104,7 @@ public void eventHandle(T webSocketEvent) { } public CompletableFuture request(Request request) throws IOException { - CompletableFuture result = new CompletableFuture(); + CompletableFuture result = new CompletableFuture<>(); futureMap.put(request.requestUUID, result); sendObject(request, WebSocketRequest.class); return result; diff --git a/LauncherAuthlib/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilMinecraftSessionService.java b/LauncherAuthlib/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilMinecraftSessionService.java index 8e4dec29..2d95d0ff 100644 --- a/LauncherAuthlib/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilMinecraftSessionService.java +++ b/LauncherAuthlib/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilMinecraftSessionService.java @@ -28,7 +28,7 @@ import java.util.UUID; public class YggdrasilMinecraftSessionService extends BaseMinecraftSessionService { - public static final boolean NO_TEXTURES = Boolean.parseBoolean("launcher.com.mojang.authlib.noTextures"); + public static final boolean NO_TEXTURES = Boolean.getBoolean("launcher.com.mojang.authlib.noTextures"); public YggdrasilMinecraftSessionService(AuthenticationService service) { super(service); diff --git a/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedDir.java b/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedDir.java index 319b10a2..4b4d4ebe 100644 --- a/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedDir.java +++ b/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedDir.java @@ -107,9 +107,9 @@ public void moveTo(String elementName, HashedDir target, String targetElementNam } public static class FindRecursiveResult { - public HashedDir parent; - public HashedEntry entry; - public String name; + public final HashedDir parent; + public final HashedEntry entry; + public final String name; public FindRecursiveResult(HashedDir parent, HashedEntry entry, String name) { this.parent = parent; diff --git a/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedEntryAdapter.java b/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedEntryAdapter.java index 67be19cc..bc70cd91 100644 --- a/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedEntryAdapter.java +++ b/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedEntryAdapter.java @@ -19,7 +19,7 @@ public HashedEntry deserialize(JsonElement json, Type typeOfT, JsonDeserializati if (typename.equals("dir")) cls = HashedDir.class; if (typename.equals("file")) cls = HashedFile.class; - return (HashedEntry) context.deserialize(json, cls); + return context.deserialize(json, cls); } @Override diff --git a/LauncherCore/src/main/java/pro/gravit/utils/UniversalJsonAdapter.java b/LauncherCore/src/main/java/pro/gravit/utils/UniversalJsonAdapter.java index 1b289ce8..15c753cd 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/UniversalJsonAdapter.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/UniversalJsonAdapter.java @@ -1,7 +1,6 @@ package pro.gravit.utils; import com.google.gson.*; -import pro.gravit.utils.helper.LogHelper; import java.lang.reflect.Type; diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index 8c90e8c4..dca8527d 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -95,7 +95,7 @@ public enum Type { public static final Map unModTypes = Collections.unmodifiableMap(types); static { - Arrays.asList(values()).forEach(type -> types.put(type.name().substring(0, type.name().length() < 3 ? type.name().length() : 3).toLowerCase(Locale.ENGLISH), type)); + Arrays.asList(values()).forEach(type -> types.put(type.name().substring(0, Math.min(type.name().length(), 3)).toLowerCase(Locale.ENGLISH), type)); } } } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java b/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java index 14cf181a..bcb92bbd 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java @@ -23,15 +23,13 @@ public void println(String message) { }*/ private final Terminal terminal; - private final TerminalBuilder terminalBuilder; - private final Completer completer; private final LineReader reader; public JLineCommandHandler() throws IOException { super(); - terminalBuilder = TerminalBuilder.builder(); + TerminalBuilder terminalBuilder = TerminalBuilder.builder(); terminal = terminalBuilder.build(); - completer = new JLineConsoleCompleter(); + Completer completer = new JLineConsoleCompleter(); reader = LineReaderBuilder.builder() .terminal(terminal) .completer(completer) diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index ed652c70..9e598b09 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -7,10 +7,7 @@ import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; import java.lang.reflect.Type; -import java.util.Base64; -import java.util.Collection; -import java.util.LinkedList; -import java.util.Locale; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -51,7 +48,7 @@ public static String multiReplace(Pattern[] pattern, String from, String replace } public static ScriptEngine newScriptEngine() { - return nashornFactory.getScriptEngine(); + return Objects.requireNonNull(nashornFactory).getScriptEngine(); } public static Thread newThread(String name, boolean daemon, Runnable runnable) {