mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FIX] IDEA Inspect and bug fixes
This commit is contained in:
parent
9efcd7af26
commit
8ce5b4179c
47 changed files with 70 additions and 162 deletions
|
@ -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<Path> {
|
|||
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 {
|
||||
|
|
|
@ -79,7 +79,7 @@ private static void visit(ClassNode classNode, Map<String, Object> values) {
|
|||
return;
|
||||
}
|
||||
field.invisibleAnnotations.remove(valueAnnotation);
|
||||
AtomicReference<String> valueName = new AtomicReference<String>(null);
|
||||
AtomicReference<String> 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<Number>() {
|
||||
@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<Number>) value -> {
|
||||
InsnList ret = new InsnList();
|
||||
ret.add(NodeUtils.push(value.intValue()));
|
||||
ret.add(new InsnNode(opcode));
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public HardwareReportRequest.HardwareInfo findHardwareInfoByPublicKey(byte[] pub
|
|||
if(e.banned) throw new HWIDException("You HWID banned");
|
||||
return e.hardware;
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
import java.util.Map;
|
||||
|
||||
public final class RejectAuthProvider extends AuthProvider implements Reconfigurable {
|
||||
private String message;
|
||||
private ArrayList<String> whitelist = new ArrayList<>();
|
||||
public String message;
|
||||
public ArrayList<String> whitelist = new ArrayList<>();
|
||||
|
||||
public RejectAuthProvider() {
|
||||
}
|
||||
|
|
|
@ -52,19 +52,19 @@ public String[] buildConfig(Path inputJar, Path outputJar) {
|
|||
List<String> 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]);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
public class MainBuildTask implements LauncherBuildTask {
|
||||
public final ClassMetadataReader reader;
|
||||
private final LaunchServer server;
|
||||
public Set<String> blacklist = new HashSet<>();
|
||||
public List<Transformer> transformers = new ArrayList<>();
|
||||
public IOHookSet<BuildContext> preBuildHook = new IOHookSet<>();
|
||||
public IOHookSet<BuildContext> postBuildHook = new IOHookSet<>();
|
||||
public Map<String, Object> properties = new HashMap<>();
|
||||
public final Set<String> blacklist = new HashSet<>();
|
||||
public final List<Transformer> transformers = new ArrayList<>();
|
||||
public final IOHookSet<BuildContext> preBuildHook = new IOHookSet<>();
|
||||
public final IOHookSet<BuildContext> postBuildHook = new IOHookSet<>();
|
||||
public final Map<String, Object> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -39,7 +39,7 @@ public void invoke(String... args) throws Exception {
|
|||
}
|
||||
|
||||
private class SignJarVisitor extends SimpleFileVisitor<Path> {
|
||||
private SignJarTask task;
|
||||
private final SignJarTask task;
|
||||
|
||||
public SignJarVisitor(SignJarTask task) {
|
||||
this.task = task;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<WebSocketServerResponse> 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);
|
||||
|
|
|
@ -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<FullHttpRequest> {
|
||||
private final NettyConnectContext context;
|
||||
|
||||
|
@ -38,7 +27,7 @@ public SeverletPathPair(String key, SimpleSeverletHandler callback) {
|
|||
this.callback = callback;
|
||||
}
|
||||
}
|
||||
private static TreeSet<SeverletPathPair> severletList = new TreeSet<>(Comparator.comparingInt((e) -> -e.key.length()));
|
||||
private static final TreeSet<SeverletPathPair> 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);
|
||||
|
|
|
@ -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<WebSocketFrame> {
|
||||
static {
|
||||
}
|
||||
|
||||
public final LaunchServer srv;
|
||||
public final WebSocketService service;
|
||||
private final UUID connectUUID = UUID.randomUUID();
|
||||
public NettyConnectContext context;
|
||||
public BiHookSet<ChannelHandlerContext, WebSocketFrame> hooks = new BiHookSet<>();
|
||||
public final BiHookSet<ChannelHandlerContext, WebSocketFrame> 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
|
||||
|
|
|
@ -66,7 +66,7 @@ private static void sendListing(ChannelHandlerContext ctx, File dir, String dirP
|
|||
.append("<ul>")
|
||||
.append("<li><a href=\"../\">..</a></li>\r\n");
|
||||
|
||||
for (File f : dir.listFiles()) {
|
||||
for (File f : Objects.requireNonNull(dir.listFiles())) {
|
||||
if ((f.isHidden() && !showHidden) || !f.canRead()) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import pro.gravit.utils.ProviderMap;
|
||||
|
||||
public class OptionalAction {
|
||||
public static ProviderMap<OptionalAction> providers = new ProviderMap<>();
|
||||
public static final ProviderMap<OptionalAction> providers = new ProviderMap<>();
|
||||
private static boolean registerProviders = false;
|
||||
public static void registerProviders()
|
||||
{
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
public final class CheckServerRequest extends Request<CheckServerRequestEvent> 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) {
|
||||
|
|
|
@ -10,11 +10,11 @@ public final class JoinServerRequest extends Request<JoinServerRequestEvent> 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) {
|
||||
|
|
|
@ -9,7 +9,7 @@ public final class UpdateRequest extends Request<UpdateRequestEvent> implements
|
|||
|
||||
// Instance
|
||||
@LauncherNetworkAPI
|
||||
private final String dirName;
|
||||
public final String dirName;
|
||||
|
||||
public UpdateRequest(String dirName) {
|
||||
this.dirName = dirName;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
public final class BatchProfileByUsernameRequest extends Request<BatchProfileByUsernameRequestEvent> implements WebSocketRequest {
|
||||
@LauncherNetworkAPI
|
||||
private final Entry[] list;
|
||||
public final Entry[] list;
|
||||
|
||||
public BatchProfileByUsernameRequest(String... usernames) throws IOException {
|
||||
this.list = new Entry[usernames.length];
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
public final class ProfileByUUIDRequest extends Request<ProfileByUUIDRequestEvent> implements WebSocketRequest {
|
||||
@LauncherNetworkAPI
|
||||
private final UUID uuid;
|
||||
public final UUID uuid;
|
||||
|
||||
|
||||
public ProfileByUUIDRequest(UUID uuid) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
public final class ProfileByUsernameRequest extends Request<ProfileByUsernameRequestEvent> implements WebSocketRequest {
|
||||
@LauncherNetworkAPI
|
||||
private final String username;
|
||||
public final String username;
|
||||
|
||||
|
||||
public ProfileByUsernameRequest(String username) {
|
||||
|
|
|
@ -104,7 +104,7 @@ public <T extends WebSocketEvent> void eventHandle(T webSocketEvent) {
|
|||
}
|
||||
|
||||
public <T extends WebSocketEvent> CompletableFuture<T> request(Request<T> request) throws IOException {
|
||||
CompletableFuture<T> result = new CompletableFuture<T>();
|
||||
CompletableFuture<T> result = new CompletableFuture<>();
|
||||
futureMap.put(request.requestUUID, result);
|
||||
sendObject(request, WebSocketRequest.class);
|
||||
return result;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package pro.gravit.utils;
|
||||
|
||||
import com.google.gson.*;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ public enum Type {
|
|||
public static final Map<String, Type> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue