mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FIX] IDEA Code Inspect
This commit is contained in:
parent
2a56594534
commit
ae34a06a5f
12 changed files with 11 additions and 20 deletions
|
@ -954,9 +954,6 @@ public void registerObject(String name, Object object) {
|
||||||
if (object instanceof NeedGarbageCollection) {
|
if (object instanceof NeedGarbageCollection) {
|
||||||
GarbageManager.registerNeedGC((NeedGarbageCollection) object);
|
GarbageManager.registerNeedGC((NeedGarbageCollection) object);
|
||||||
}
|
}
|
||||||
if (object instanceof JsonConfigurable) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterObject(String name, Object object) {
|
public void unregisterObject(String name, Object object) {
|
||||||
|
@ -969,9 +966,6 @@ public void unregisterObject(String name, Object object) {
|
||||||
if (object instanceof NeedGarbageCollection) {
|
if (object instanceof NeedGarbageCollection) {
|
||||||
GarbageManager.unregisterNeedGC((NeedGarbageCollection) object);
|
GarbageManager.unregisterNeedGC((NeedGarbageCollection) object);
|
||||||
}
|
}
|
||||||
if (object instanceof JsonConfigurable) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fullyRestart() {
|
public void fullyRestart() {
|
||||||
|
|
|
@ -59,7 +59,7 @@ public void acceptVisitor(String className, ClassVisitor visitor) throws IOExcep
|
||||||
public byte[] getClassData(String className) throws IOException {
|
public byte[] getClassData(String className) throws IOException {
|
||||||
for (JarFile f : cp) {
|
for (JarFile f : cp) {
|
||||||
if (f.getEntry(className + ".class") != null) {
|
if (f.getEntry(className + ".class") != null) {
|
||||||
byte[] bytes = null;
|
byte[] bytes;
|
||||||
try (InputStream in = f.getInputStream(f.getEntry(className + ".class"))) {
|
try (InputStream in = f.getInputStream(f.getEntry(className + ".class"))) {
|
||||||
bytes = IOHelper.read(in);
|
bytes = IOHelper.read(in);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public static void apply(Path inputFile, Path addFile, ZipOutputStream output, L
|
||||||
String filename = e.getName();
|
String filename = e.getName();
|
||||||
output.putNextEntry(IOHelper.newZipEntry(e));
|
output.putNextEntry(IOHelper.newZipEntry(e));
|
||||||
if (filename.endsWith(".class")) {
|
if (filename.endsWith(".class")) {
|
||||||
byte[] bytes = null;
|
byte[] bytes;
|
||||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) {
|
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) {
|
||||||
IOHelper.transfer(input, outputStream);
|
IOHelper.transfer(input, outputStream);
|
||||||
bytes = outputStream.toByteArray();
|
bytes = outputStream.toByteArray();
|
||||||
|
|
|
@ -50,8 +50,8 @@ public void invoke(String... args) throws Exception {
|
||||||
LogHelper.subInfo("Write %d entryCache, %d usernameCache", entryCache.size(), usernamesCache.size());
|
LogHelper.subInfo("Write %d entryCache, %d usernameCache", entryCache.size(), usernamesCache.size());
|
||||||
} else if (args[0].equals("load")) {
|
} else if (args[0].equals("load")) {
|
||||||
LogHelper.info("CachedAuthHandler read from %s", args[1]);
|
LogHelper.info("CachedAuthHandler read from %s", args[1]);
|
||||||
int size_entry = 0;
|
int size_entry;
|
||||||
int size_username = 0;
|
int size_username;
|
||||||
try (Reader reader = IOHelper.newReader(Paths.get(args[1]))) {
|
try (Reader reader = IOHelper.newReader(Paths.get(args[1]))) {
|
||||||
EntryAndUsername entryAndUsername = Launcher.gsonManager.configGson.fromJson(reader, EntryAndUsername.class);
|
EntryAndUsername entryAndUsername = Launcher.gsonManager.configGson.fromJson(reader, EntryAndUsername.class);
|
||||||
size_entry = entryAndUsername.entryCache.size();
|
size_entry = entryAndUsername.entryCache.size();
|
||||||
|
|
|
@ -43,7 +43,7 @@ public void invoke(String... args) throws Exception {
|
||||||
LogHelper.subInfo("Write %d sessions", clientSet.size());
|
LogHelper.subInfo("Write %d sessions", clientSet.size());
|
||||||
} else if (args[0].equals("load")) {
|
} else if (args[0].equals("load")) {
|
||||||
LogHelper.info("Sessions read from %s", args[1]);
|
LogHelper.info("Sessions read from %s", args[1]);
|
||||||
int size = 0;
|
int size;
|
||||||
try (Reader reader = IOHelper.newReader(Paths.get(args[1]))) {
|
try (Reader reader = IOHelper.newReader(Paths.get(args[1]))) {
|
||||||
Type setType = new TypeToken<HashSet<Client>>() {
|
Type setType = new TypeToken<HashSet<Client>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
|
|
|
@ -69,7 +69,6 @@ public WebSocketService(ChannelGroup channels, LaunchServer server, GsonBuilder
|
||||||
private final Gson gson;
|
private final Gson gson;
|
||||||
private final GsonBuilder gsonBuiler;
|
private final GsonBuilder gsonBuiler;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client, String ip) {
|
void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client, String ip) {
|
||||||
String request = frame.text();
|
String request = frame.text();
|
||||||
JsonResponseInterface response = gson.fromJson(request, JsonResponseInterface.class);
|
JsonResponseInterface response = gson.fromJson(request, JsonResponseInterface.class);
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||||
import io.netty.handler.codec.http.HttpUtil;
|
import io.netty.handler.codec.http.HttpUtil;
|
||||||
import io.netty.handler.codec.http.LastHttpContent;
|
import io.netty.handler.codec.http.LastHttpContent;
|
||||||
import io.netty.handler.ssl.SslHandler;
|
|
||||||
import io.netty.handler.stream.ChunkedFile;
|
import io.netty.handler.stream.ChunkedFile;
|
||||||
import io.netty.util.CharsetUtil;
|
import io.netty.util.CharsetUtil;
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public static void premain(String agentArgument, Instrumentation instrumentation
|
||||||
if (trimmedArg.contains("r")) rt = false;
|
if (trimmedArg.contains("r")) rt = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (System.getProperty("java.vm.name").toUpperCase(Locale.US).indexOf("HOTSPOT") != -1)
|
if (System.getProperty("java.vm.name").toUpperCase(Locale.US).contains("HOTSPOT"))
|
||||||
try {
|
try {
|
||||||
if (ManagementFactory.getOperatingSystemMXBean().getName().startsWith("Windows")) replaceClasses(pb, rt);
|
if (ManagementFactory.getOperatingSystemMXBean().getName().startsWith("Windows")) replaceClasses(pb, rt);
|
||||||
else replaceClasses(false, false);
|
else replaceClasses(false, false);
|
||||||
|
@ -170,7 +170,7 @@ private static byte[] transformClass(String className, byte[] classBytes) {
|
||||||
private static byte[] getClassFile(Class<?> clazz) throws IOException {
|
private static byte[] getClassFile(Class<?> clazz) throws IOException {
|
||||||
try (InputStream is = clazz.getResourceAsStream("/" + clazz.getName().replace('.', '/') + ".class");
|
try (InputStream is = clazz.getResourceAsStream("/" + clazz.getName().replace('.', '/') + ".class");
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||||
int r = 0;
|
int r;
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
while ((r = is.read(buffer)) >= 0) {
|
while ((r = is.read(buffer)) >= 0) {
|
||||||
baos.write(buffer, 0, r);
|
baos.write(buffer, 0, r);
|
||||||
|
|
|
@ -33,7 +33,7 @@ public abstract class ClientJSONPoint {
|
||||||
protected WebSocketClientHandler webSocketClientHandler;
|
protected WebSocketClientHandler webSocketClientHandler;
|
||||||
protected Bootstrap bootstrap = new Bootstrap();
|
protected Bootstrap bootstrap = new Bootstrap();
|
||||||
protected boolean ssl = false;
|
protected boolean ssl = false;
|
||||||
protected int port = -1;
|
protected int port;
|
||||||
public boolean isClosed;
|
public boolean isClosed;
|
||||||
|
|
||||||
public ClientJSONPoint(final String uri) throws SSLException {
|
public ClientJSONPoint(final String uri) throws SSLException {
|
||||||
|
|
|
@ -111,8 +111,7 @@ public static StandartClientWebSocketService initWebSockets(String address, bool
|
||||||
try {
|
try {
|
||||||
service = new StandartClientWebSocketService(CommonHelper.newBuilder(), address, 5000);
|
service = new StandartClientWebSocketService(CommonHelper.newBuilder(), address, 5000);
|
||||||
} catch (SSLException e) {
|
} catch (SSLException e) {
|
||||||
LogHelper.error(e);
|
throw new SecurityException(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
service.registerResults();
|
service.registerResults();
|
||||||
service.registerRequests();
|
service.registerRequests();
|
||||||
|
|
|
@ -63,7 +63,7 @@ public static void premain(String agentArgument, Instrumentation instrumentation
|
||||||
proxyClass = Class.forName(proxyClassName);
|
proxyClass = Class.forName(proxyClassName);
|
||||||
MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(proxyClass, "premain", MethodType.methodType(void.class, String.class, Instrumentation.class));
|
MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(proxyClass, "premain", MethodType.methodType(void.class, String.class, Instrumentation.class));
|
||||||
Object[] args = {agentArgument, instrumentation};
|
Object[] args = {agentArgument, instrumentation};
|
||||||
mainMethod.invoke(args);
|
mainMethod.invoke(null, args);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public void run() throws IOException {
|
||||||
System.out.println("Print jar filename:");
|
System.out.println("Print jar filename:");
|
||||||
String jarName = commands.commandHandler.readLine();
|
String jarName = commands.commandHandler.readLine();
|
||||||
Path jarPath = Paths.get(jarName);
|
Path jarPath = Paths.get(jarName);
|
||||||
String mainClassName = null;
|
String mainClassName;
|
||||||
try (JarFile file = new JarFile(jarPath.toFile())) {
|
try (JarFile file = new JarFile(jarPath.toFile())) {
|
||||||
URL jarURL = jarPath.toUri().toURL();
|
URL jarURL = jarPath.toUri().toURL();
|
||||||
urlClassLoader = new PublicURLClassLoader(new URL[]{jarURL});
|
urlClassLoader = new PublicURLClassLoader(new URL[]{jarURL});
|
||||||
|
|
Loading…
Reference in a new issue