[FIX] IDEA Inspect and bug fixes

This commit is contained in:
Gravit 2020-09-25 22:44:39 +07:00
parent 9efcd7af26
commit 8ce5b4179c
No known key found for this signature in database
GPG key ID: 98A079490768CCE5
47 changed files with 70 additions and 162 deletions

View file

@ -21,7 +21,7 @@ public static boolean isAgentStarted() {
public static void premain(String agentArgument, Instrumentation inst) { public static void premain(String agentArgument, Instrumentation inst) {
StarterAgent.inst = 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; isStarted = true;
try { try {
Files.walkFileTree(libraries, Collections.singleton(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new StarterVisitor()); 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); DPERMS = Collections.unmodifiableSet(perms);
} }
private final Path filef;
private final boolean fixLib; private final boolean fixLib;
private StarterVisitor() { 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"); this.fixLib = !Files.exists(filef) && !Boolean.getBoolean("launcher.noLibrariesPosixPermsFix");
if (fixLib) { if (fixLib) {
try { try {

View file

@ -79,7 +79,7 @@ private static void visit(ClassNode classNode, Map<String, Object> values) {
return; return;
} }
field.invisibleAnnotations.remove(valueAnnotation); field.invisibleAnnotations.remove(valueAnnotation);
AtomicReference<String> valueName = new AtomicReference<String>(null); AtomicReference<String> valueName = new AtomicReference<>(null);
valueAnnotation.accept(new AnnotationVisitor(Opcodes.ASM7) { valueAnnotation.accept(new AnnotationVisitor(Opcodes.ASM7) {
@Override @Override
public void visit(final String name, final Object value) { 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) { private static Serializer<?> serializerClass(int opcode) {
return new Serializer<Number>() { return (Serializer<Number>) value -> {
@Override InsnList ret = new InsnList();
public InsnList serialize(Number value) { ret.add(NodeUtils.push(value.intValue()));
InsnList ret = new InsnList(); ret.add(new InsnNode(opcode));
ret.add(NodeUtils.push(value.intValue())); return ret;
ret.add(new InsnNode(opcode));
return ret;
}
}; };
} }

View file

@ -1,7 +1,6 @@
package pro.gravit.launchserver.auth.handler; package pro.gravit.launchserver.auth.handler;
import pro.gravit.launchserver.dao.User; import pro.gravit.launchserver.dao.User;
import pro.gravit.utils.helper.LogHelper;
import java.util.UUID; import java.util.UUID;

View file

@ -73,7 +73,7 @@ public HardwareReportRequest.HardwareInfo findHardwareInfoByPublicKey(byte[] pub
if(e.banned) throw new HWIDException("You HWID banned"); if(e.banned) throw new HWIDException("You HWID banned");
return e.hardware; return e.hardware;
} }
}; }
return null; return null;
} }

View file

@ -1,6 +1,5 @@
package pro.gravit.launchserver.auth.provider; package pro.gravit.launchserver.auth.provider;
import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import pro.gravit.launcher.ClientPermissions; import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launcher.HTTPRequest; import pro.gravit.launcher.HTTPRequest;

View file

@ -14,8 +14,8 @@
import java.util.Map; import java.util.Map;
public final class RejectAuthProvider extends AuthProvider implements Reconfigurable { public final class RejectAuthProvider extends AuthProvider implements Reconfigurable {
private String message; public String message;
private ArrayList<String> whitelist = new ArrayList<>(); public ArrayList<String> whitelist = new ArrayList<>();
public RejectAuthProvider() { public RejectAuthProvider() {
} }

View file

@ -52,19 +52,19 @@ public String[] buildConfig(Path inputJar, Path outputJar) {
List<String> confStrs = new ArrayList<>(); List<String> confStrs = new ArrayList<>();
prepare(false); prepare(false);
if (srv.config.launcher.proguardGenMappings) if (srv.config.launcher.proguardGenMappings)
confStrs.add("-printmapping \'" + mappings.toFile().getName() + "\'"); confStrs.add("-printmapping '" + mappings.toFile().getName() + "'");
confStrs.add("-obfuscationdictionary \'" + words.toFile().getName() + "\'"); confStrs.add("-obfuscationdictionary '" + words.toFile().getName() + "'");
confStrs.add("-injar \'" + inputJar.toAbsolutePath() + "\'"); confStrs.add("-injar '" + inputJar.toAbsolutePath() + "'");
confStrs.add("-outjar \'" + outputJar.toAbsolutePath() + "\'"); confStrs.add("-outjar '" + outputJar.toAbsolutePath() + "'");
Collections.addAll(confStrs, JVMHelper.JVM_VERSION >= 9 ? JAVA9_OPTS : JAVA8_OPTS); Collections.addAll(confStrs, JVMHelper.JVM_VERSION >= 9 ? JAVA9_OPTS : JAVA8_OPTS);
srv.launcherBinary.coreLibs.stream() srv.launcherBinary.coreLibs.stream()
.map(e -> "-libraryjars \'" + e.toAbsolutePath().toString() + "\'") .map(e -> "-libraryjars '" + e.toAbsolutePath().toString() + "'")
.forEach(confStrs::add); .forEach(confStrs::add);
srv.launcherBinary.addonLibs.stream() srv.launcherBinary.addonLibs.stream()
.map(e -> "-libraryjars \'" + e.toAbsolutePath().toString() + "\'") .map(e -> "-libraryjars '" + e.toAbsolutePath().toString() + "'")
.forEach(confStrs::add); .forEach(confStrs::add);
confStrs.add("-classobfuscationdictionary \'" + words.toFile().getName() + "\'"); confStrs.add("-classobfuscationdictionary '" + words.toFile().getName() + "'");
confStrs.add("@".concat(config.toFile().getName())); confStrs.add("@".concat(config.toFile().getName()));
return confStrs.toArray(new String[0]); return confStrs.toArray(new String[0]);
} }

View file

@ -35,7 +35,7 @@ public class CertificateAutogenTask implements LauncherBuildTask {
public X509Certificate certificate; public X509Certificate certificate;
public X509CertificateHolder bcCertificate; public X509CertificateHolder bcCertificate;
public CMSSignedDataGenerator signedDataGenerator; public CMSSignedDataGenerator signedDataGenerator;
private LaunchServer server; private final LaunchServer server;
public CertificateAutogenTask(LaunchServer server) { public CertificateAutogenTask(LaunchServer server) {
this.server = server; this.server = server;

View file

@ -29,11 +29,11 @@
public class MainBuildTask implements LauncherBuildTask { public class MainBuildTask implements LauncherBuildTask {
public final ClassMetadataReader reader; public final ClassMetadataReader reader;
private final LaunchServer server; private final LaunchServer server;
public Set<String> blacklist = new HashSet<>(); public final Set<String> blacklist = new HashSet<>();
public List<Transformer> transformers = new ArrayList<>(); public final List<Transformer> transformers = new ArrayList<>();
public IOHookSet<BuildContext> preBuildHook = new IOHookSet<>(); public final IOHookSet<BuildContext> preBuildHook = new IOHookSet<>();
public IOHookSet<BuildContext> postBuildHook = new IOHookSet<>(); public final IOHookSet<BuildContext> postBuildHook = new IOHookSet<>();
public Map<String, Object> properties = new HashMap<>(); public final Map<String, Object> properties = new HashMap<>();
public MainBuildTask(LaunchServer srv) { public MainBuildTask(LaunchServer srv) {
server = srv; server = srv;
@ -123,14 +123,13 @@ protected void initProps() {
public byte[] transformClass(byte[] bytes, String classname, BuildContext context) { public byte[] transformClass(byte[] bytes, String classname, BuildContext context) {
byte[] result = bytes; byte[] result = bytes;
ClassReader cr = null; ClassWriter writer;
ClassWriter writer = null;
ClassNode cn = null; ClassNode cn = null;
for (Transformer t : transformers) { for (Transformer t : transformers) {
if (t instanceof ASMTransformer) { if (t instanceof ASMTransformer) {
ASMTransformer asmTransformer = (ASMTransformer) t; ASMTransformer asmTransformer = (ASMTransformer) t;
if (cn == null) { if (cn == null) {
cr = new ClassReader(result); ClassReader cr = new ClassReader(result);
cn = new ClassNode(); cn = new ClassNode();
cr.accept(cn, 0); cr.accept(cn, 0);
} }
@ -144,7 +143,6 @@ public byte[] transformClass(byte[] bytes, String classname, BuildContext contex
byte[] old_result = result; byte[] old_result = result;
result = t.transform(result, classname, context); result = t.transform(result, classname, context);
if (old_result != result) { if (old_result != result) {
cr = null;
cn = null; cn = null;
} }
} }

View file

@ -24,7 +24,7 @@ public SaveProfilesCommand(LaunchServer server) {
super(server); super(server);
} }
@SuppressWarnings("deprecated") @SuppressWarnings("deprecation")
public static void saveProfile(ClientProfile profile, Path path) throws IOException { public static void saveProfile(ClientProfile profile, Path path) throws IOException {
if (profile.getUUID() == null) profile.setUUID(UUID.randomUUID()); if (profile.getUUID() == null) profile.setUUID(UUID.randomUUID());
if(profile.getServers().size() == 0) if(profile.getServers().size() == 0)

View file

@ -39,7 +39,7 @@ public void invoke(String... args) throws Exception {
} }
private class SignJarVisitor extends SimpleFileVisitor<Path> { private class SignJarVisitor extends SimpleFileVisitor<Path> {
private SignJarTask task; private final SignJarTask task;
public SignJarVisitor(SignJarTask task) { public SignJarVisitor(SignJarTask task) {
this.task = task; this.task = task;

View file

@ -1,7 +1,5 @@
package pro.gravit.launchserver.helper; package pro.gravit.launchserver.helper;
import java.util.Arrays;
public class DamerauHelper { public class DamerauHelper {
//Расстояние Дамерау Левенштейна. GitHub https://github.com/crwohlfeil/damerau-levenshtein //Расстояние Дамерау Левенштейна. GitHub https://github.com/crwohlfeil/damerau-levenshtein
public static int calculateDistance(CharSequence source, CharSequence target) { public static int calculateDistance(CharSequence source, CharSequence target) {

View file

@ -8,7 +8,7 @@
import java.util.Map; import java.util.Map;
public class PingServerManager { public class PingServerManager {
public static long REPORT_EXPIRED_TIME = 20*1000; public static final long REPORT_EXPIRED_TIME = 20*1000;
public static class ServerInfoEntry public static class ServerInfoEntry
{ {

View file

@ -7,7 +7,6 @@
import pro.gravit.launchserver.auth.AuthProviderPair; import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.dao.User; import pro.gravit.launchserver.dao.User;
import pro.gravit.launchserver.socket.response.auth.AuthResponse; import pro.gravit.launchserver.socket.response.auth.AuthResponse;
import pro.gravit.utils.helper.LogHelper;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View file

@ -38,7 +38,6 @@
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Supplier;
public class WebSocketService { public class WebSocketService {
public static final ProviderMap<WebSocketServerResponse> providers = new ProviderMap<>(); public static final ProviderMap<WebSocketServerResponse> providers = new ProviderMap<>();
@ -48,16 +47,16 @@ public class WebSocketService {
private final Gson gson; private final Gson gson;
//Statistic data //Statistic data
public AtomicLong shortRequestLatency = new AtomicLong(); public final AtomicLong shortRequestLatency = new AtomicLong();
public AtomicLong shortRequestCounter = new AtomicLong(); public final AtomicLong shortRequestCounter = new AtomicLong();
public AtomicLong middleRequestLatency = new AtomicLong(); public final AtomicLong middleRequestLatency = new AtomicLong();
public AtomicLong middleRequestCounter = new AtomicLong(); public final AtomicLong middleRequestCounter = new AtomicLong();
public AtomicLong longRequestLatency = new AtomicLong(); public final AtomicLong longRequestLatency = new AtomicLong();
public AtomicLong longRequestCounter = 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) { public WebSocketService(ChannelGroup channels, LaunchServer server) {
this.channels = channels; this.channels = channels;
@ -92,7 +91,6 @@ public static void registerResponses() {
providers.register("profileByUsername", ProfileByUsername.class); providers.register("profileByUsername", ProfileByUsername.class);
providers.register("profileByUUID", ProfileByUUIDResponse.class); providers.register("profileByUUID", ProfileByUUIDResponse.class);
providers.register("getAvailabilityAuth", GetAvailabilityAuthResponse.class); providers.register("getAvailabilityAuth", GetAvailabilityAuthResponse.class);
providers.register("register", RegisterResponse.class);
providers.register("exit", ExitResponse.class); providers.register("exit", ExitResponse.class);
providers.register("getSecureLevelInfo", GetSecureLevelInfoResponse.class); providers.register("getSecureLevelInfo", GetSecureLevelInfoResponse.class);
providers.register("verifySecureLevelKey", VerifySecureLevelKeyResponse.class); providers.register("verifySecureLevelKey", VerifySecureLevelKeyResponse.class);

View file

@ -1,23 +1,12 @@
package pro.gravit.launchserver.socket.handlers; package pro.gravit.launchserver.socket.handlers;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.http.*; import io.netty.handler.codec.http.*;
import io.netty.util.ReferenceCounted;
import pro.gravit.launchserver.socket.NettyConnectContext; 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 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> { public class NettyWebAPIHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
private final NettyConnectContext context; private final NettyConnectContext context;
@ -38,7 +27,7 @@ public SeverletPathPair(String key, SimpleSeverletHandler callback) {
this.callback = 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) public static SeverletPathPair addNewSeverlet(String path, SimpleSeverletHandler callback)
{ {
SeverletPathPair pair = new SeverletPathPair("/webapi/".concat(path), callback); SeverletPathPair pair = new SeverletPathPair("/webapi/".concat(path), callback);

View file

@ -9,7 +9,6 @@
import pro.gravit.launchserver.socket.NettyConnectContext; import pro.gravit.launchserver.socket.NettyConnectContext;
import pro.gravit.launchserver.socket.WebSocketService; import pro.gravit.launchserver.socket.WebSocketService;
import pro.gravit.utils.BiHookSet; import pro.gravit.utils.BiHookSet;
import pro.gravit.utils.HookSet;
import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
@ -17,14 +16,12 @@
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class WebSocketFrameHandler extends SimpleChannelInboundHandler<WebSocketFrame> { public class WebSocketFrameHandler extends SimpleChannelInboundHandler<WebSocketFrame> {
static {
}
public final LaunchServer srv; public final LaunchServer srv;
public final WebSocketService service; public final WebSocketService service;
private final UUID connectUUID = UUID.randomUUID(); private final UUID connectUUID = UUID.randomUUID();
public NettyConnectContext context; public NettyConnectContext context;
public BiHookSet<ChannelHandlerContext, WebSocketFrame> hooks = new BiHookSet<>(); public final BiHookSet<ChannelHandlerContext, WebSocketFrame> hooks = new BiHookSet<>();
private Client client; private Client client;
public WebSocketFrameHandler(NettyConnectContext context, LaunchServer srv, WebSocketService service) { public WebSocketFrameHandler(NettyConnectContext context, LaunchServer srv, WebSocketService service) {
@ -53,9 +50,7 @@ public void channelActive(ChannelHandlerContext ctx) {
client = new Client(null); client = new Client(null);
Channel ch = ctx.channel(); Channel ch = ctx.channel();
service.registerClient(ch); service.registerClient(ch);
ctx.executor().scheduleAtFixedRate(() -> { ctx.executor().scheduleAtFixedRate(() -> ch.writeAndFlush(new PingWebSocketFrame(), ch.voidPromise()), 30L , 30L, TimeUnit.SECONDS);
ch.writeAndFlush(new PingWebSocketFrame(), ch.voidPromise());
}, 30L , 30L, TimeUnit.SECONDS);
} }
@Override @Override

View file

@ -66,7 +66,7 @@ private static void sendListing(ChannelHandlerContext ctx, File dir, String dirP
.append("<ul>") .append("<ul>")
.append("<li><a href=\"../\">..</a></li>\r\n"); .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()) { if ((f.isHidden() && !showHidden) || !f.canRead()) {
continue; continue;
} }

View file

@ -2,7 +2,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.CurrentUserRequestEvent; 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.Client;
import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.launchserver.socket.response.SimpleResponse;
import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse; import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse;

View file

@ -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";
}
}

View file

@ -3,7 +3,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.ServerStatusRequestEvent; import pro.gravit.launcher.events.request.ServerStatusRequestEvent;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.WebSocketService;
import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.launchserver.socket.response.SimpleResponse;
import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.JVMHelper;

View file

@ -5,7 +5,6 @@
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.launchserver.socket.response.SimpleResponse;
import pro.gravit.launchserver.auth.AuthProviderPair; import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.utils.helper.LogHelper;
import java.util.UUID; import java.util.UUID;

View file

@ -1,7 +1,6 @@
package pro.gravit.launchserver.socket.response.secure; package pro.gravit.launchserver.socket.response.secure;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.VerifySecureLevelKeyRequestEvent;
import pro.gravit.launchserver.auth.protect.interfaces.SecureProtectHandler; import pro.gravit.launchserver.auth.protect.interfaces.SecureProtectHandler;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.launchserver.socket.response.SimpleResponse;

View file

@ -25,6 +25,7 @@ public static void prepare() throws Throwable {
classLoader = new ASMClassLoader(ASMTransformersTest.class.getClassLoader()); classLoader = new ASMClassLoader(ASMTransformersTest.class.getClassLoader());
} }
@SuppressWarnings("unchecked")
@Test @Test
void testASM() throws Throwable { void testASM() throws Throwable {
ClassReader reader = new ClassReader(JarHelper.getClassBytes(TestClass.class)); ClassReader reader = new ClassReader(JarHelper.getClassBytes(TestClass.class));

View file

@ -9,9 +9,9 @@
import pro.gravit.launcher.request.secure.HardwareReportRequest; import pro.gravit.launcher.request.secure.HardwareReportRequest;
public class HWIDProvider { public class HWIDProvider {
public SystemInfo systemInfo; public final SystemInfo systemInfo;
public OperatingSystem system; public final OperatingSystem system;
public HardwareAbstractionLayer hardware; public final HardwareAbstractionLayer hardware;
public HWIDProvider() { public HWIDProvider() {
systemInfo = new SystemInfo(); systemInfo = new SystemInfo();

View file

@ -31,6 +31,7 @@ public ClientPermissions(long permissions, long flags) {
public static ClientPermissions getSuperuserAccount() { public static ClientPermissions getSuperuserAccount() {
ClientPermissions perm = new ClientPermissions(); ClientPermissions perm = new ClientPermissions();
perm.setPermission(PermissionConsts.ADMIN, true);
return perm; return perm;
} }

View file

@ -10,7 +10,7 @@ public static class UserInfo {
public String accessToken; public String accessToken;
public PlayerProfile playerProfile; public PlayerProfile playerProfile;
} }
public UserInfo userInfo; public final UserInfo userInfo;
public CurrentUserRequestEvent(UserInfo userInfo) { public CurrentUserRequestEvent(UserInfo userInfo) {
this.userInfo = userInfo; this.userInfo = userInfo;

View file

@ -1,7 +1,6 @@
package pro.gravit.launcher.events.request; package pro.gravit.launcher.events.request;
import pro.gravit.launcher.events.RequestEvent; import pro.gravit.launcher.events.RequestEvent;
import pro.gravit.utils.helper.JVMHelper;
public class ServerStatusRequestEvent extends RequestEvent { public class ServerStatusRequestEvent extends RequestEvent {
public final String projectName; public final String projectName;

View file

@ -173,13 +173,13 @@ public void updateOptionalGraph() {
if (file.dependenciesFile != null) { if (file.dependenciesFile != null) {
file.dependencies = new OptionalFile[file.dependenciesFile.length]; file.dependencies = new OptionalFile[file.dependenciesFile.length];
for (int i = 0; i < file.dependenciesFile.length; ++i) { 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) { if (file.conflictFile != null) {
file.conflict = new OptionalFile[file.conflictFile.length]; file.conflict = new OptionalFile[file.conflictFile.length];
for (int i = 0; i < file.conflictFile.length; ++i) { 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) { for (OptionalFile f : updateOptional) {
if (f == null) throw new IllegalArgumentException("Found null entry in 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.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 (f.conflictFile != null) for (OptionalDepend s : f.conflictFile) {
if (s == null) if (s == null)
throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.conflictFile", f.name)); throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.conflictFile", f.name));

View file

@ -145,8 +145,6 @@ public void clearAllWatchers() {
public void watchEvent(boolean isMark) { public void watchEvent(boolean isMark) {
if (watchList == null) return; if (watchList == null) return;
watchList.forEach((e) -> { watchList.forEach((e) -> e.accept(this, isMark));
e.accept(this, isMark);
});
} }
} }

View file

@ -3,7 +3,7 @@
import pro.gravit.utils.ProviderMap; import pro.gravit.utils.ProviderMap;
public class OptionalAction { public class OptionalAction {
public static ProviderMap<OptionalAction> providers = new ProviderMap<>(); public static final ProviderMap<OptionalAction> providers = new ProviderMap<>();
private static boolean registerProviders = false; private static boolean registerProviders = false;
public static void registerProviders() public static void registerProviders()
{ {

View file

@ -3,7 +3,6 @@
import pro.gravit.launcher.hasher.HashedDir; import pro.gravit.launcher.hasher.HashedDir;
import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
import java.util.List;
import java.util.Map; import java.util.Map;
public class OptionalActionFile extends OptionalAction { public class OptionalActionFile extends OptionalAction {

View file

@ -4,7 +4,6 @@
import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.LauncherNetworkAPI;
import pro.gravit.launcher.request.websockets.StdWebSocketService; import pro.gravit.launcher.request.websockets.StdWebSocketService;
import pro.gravit.launcher.request.websockets.WebSocketRequest; import pro.gravit.launcher.request.websockets.WebSocketRequest;
import pro.gravit.utils.helper.SecurityHelper;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;

View file

@ -8,9 +8,9 @@
public final class CheckServerRequest extends Request<CheckServerRequestEvent> implements WebSocketRequest { public final class CheckServerRequest extends Request<CheckServerRequestEvent> implements WebSocketRequest {
@LauncherNetworkAPI @LauncherNetworkAPI
private final String username; public final String username;
@LauncherNetworkAPI @LauncherNetworkAPI
private final String serverID; public final String serverID;
public CheckServerRequest(String username, String serverID) { public CheckServerRequest(String username, String serverID) {

View file

@ -10,11 +10,11 @@ public final class JoinServerRequest extends Request<JoinServerRequestEvent> imp
// Instance // Instance
@LauncherNetworkAPI @LauncherNetworkAPI
private final String username; public final String username;
@LauncherNetworkAPI @LauncherNetworkAPI
private final String accessToken; public final String accessToken;
@LauncherNetworkAPI @LauncherNetworkAPI
private final String serverID; public final String serverID;
public JoinServerRequest(String username, String accessToken, String serverID) { public JoinServerRequest(String username, String accessToken, String serverID) {

View file

@ -9,7 +9,7 @@ public final class UpdateRequest extends Request<UpdateRequestEvent> implements
// Instance // Instance
@LauncherNetworkAPI @LauncherNetworkAPI
private final String dirName; public final String dirName;
public UpdateRequest(String dirName) { public UpdateRequest(String dirName) {
this.dirName = dirName; this.dirName = dirName;

View file

@ -11,7 +11,7 @@
public final class BatchProfileByUsernameRequest extends Request<BatchProfileByUsernameRequestEvent> implements WebSocketRequest { public final class BatchProfileByUsernameRequest extends Request<BatchProfileByUsernameRequestEvent> implements WebSocketRequest {
@LauncherNetworkAPI @LauncherNetworkAPI
private final Entry[] list; public final Entry[] list;
public BatchProfileByUsernameRequest(String... usernames) throws IOException { public BatchProfileByUsernameRequest(String... usernames) throws IOException {
this.list = new Entry[usernames.length]; this.list = new Entry[usernames.length];

View file

@ -10,7 +10,7 @@
public final class ProfileByUUIDRequest extends Request<ProfileByUUIDRequestEvent> implements WebSocketRequest { public final class ProfileByUUIDRequest extends Request<ProfileByUUIDRequestEvent> implements WebSocketRequest {
@LauncherNetworkAPI @LauncherNetworkAPI
private final UUID uuid; public final UUID uuid;
public ProfileByUUIDRequest(UUID uuid) { public ProfileByUUIDRequest(UUID uuid) {

View file

@ -8,7 +8,7 @@
public final class ProfileByUsernameRequest extends Request<ProfileByUsernameRequestEvent> implements WebSocketRequest { public final class ProfileByUsernameRequest extends Request<ProfileByUsernameRequestEvent> implements WebSocketRequest {
@LauncherNetworkAPI @LauncherNetworkAPI
private final String username; public final String username;
public ProfileByUsernameRequest(String username) { public ProfileByUsernameRequest(String username) {

View file

@ -104,7 +104,7 @@ public <T extends WebSocketEvent> void eventHandle(T webSocketEvent) {
} }
public <T extends WebSocketEvent> CompletableFuture<T> request(Request<T> request) throws IOException { 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); futureMap.put(request.requestUUID, result);
sendObject(request, WebSocketRequest.class); sendObject(request, WebSocketRequest.class);
return result; return result;

View file

@ -28,7 +28,7 @@
import java.util.UUID; import java.util.UUID;
public class YggdrasilMinecraftSessionService extends BaseMinecraftSessionService { 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) { public YggdrasilMinecraftSessionService(AuthenticationService service) {
super(service); super(service);

View file

@ -107,9 +107,9 @@ public void moveTo(String elementName, HashedDir target, String targetElementNam
} }
public static class FindRecursiveResult public static class FindRecursiveResult
{ {
public HashedDir parent; public final HashedDir parent;
public HashedEntry entry; public final HashedEntry entry;
public String name; public final String name;
public FindRecursiveResult(HashedDir parent, HashedEntry entry, String name) { public FindRecursiveResult(HashedDir parent, HashedEntry entry, String name) {
this.parent = parent; this.parent = parent;

View file

@ -19,7 +19,7 @@ public HashedEntry deserialize(JsonElement json, Type typeOfT, JsonDeserializati
if (typename.equals("dir")) cls = HashedDir.class; if (typename.equals("dir")) cls = HashedDir.class;
if (typename.equals("file")) cls = HashedFile.class; if (typename.equals("file")) cls = HashedFile.class;
return (HashedEntry) context.deserialize(json, cls); return context.deserialize(json, cls);
} }
@Override @Override

View file

@ -1,7 +1,6 @@
package pro.gravit.utils; package pro.gravit.utils;
import com.google.gson.*; import com.google.gson.*;
import pro.gravit.utils.helper.LogHelper;
import java.lang.reflect.Type; import java.lang.reflect.Type;

View file

@ -95,7 +95,7 @@ public enum Type {
public static final Map<String, Type> unModTypes = Collections.unmodifiableMap(types); public static final Map<String, Type> unModTypes = Collections.unmodifiableMap(types);
static { 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));
} }
} }
} }

View file

@ -23,15 +23,13 @@ public void println(String message) {
}*/ }*/
private final Terminal terminal; private final Terminal terminal;
private final TerminalBuilder terminalBuilder;
private final Completer completer;
private final LineReader reader; private final LineReader reader;
public JLineCommandHandler() throws IOException { public JLineCommandHandler() throws IOException {
super(); super();
terminalBuilder = TerminalBuilder.builder(); TerminalBuilder terminalBuilder = TerminalBuilder.builder();
terminal = terminalBuilder.build(); terminal = terminalBuilder.build();
completer = new JLineConsoleCompleter(); Completer completer = new JLineConsoleCompleter();
reader = LineReaderBuilder.builder() reader = LineReaderBuilder.builder()
.terminal(terminal) .terminal(terminal)
.completer(completer) .completer(completer)

View file

@ -7,10 +7,7 @@
import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager; import javax.script.ScriptEngineManager;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.Base64; import java.util.*;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Locale;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -51,7 +48,7 @@ public static String multiReplace(Pattern[] pattern, String from, String replace
} }
public static ScriptEngine newScriptEngine() { public static ScriptEngine newScriptEngine() {
return nashornFactory.getScriptEngine(); return Objects.requireNonNull(nashornFactory).getScriptEngine();
} }
public static Thread newThread(String name, boolean daemon, Runnable runnable) { public static Thread newThread(String name, boolean daemon, Runnable runnable) {