mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-13 19:57:29 +03:00
[ANY] IDEA code inspect
This commit is contained in:
parent
689478ee0f
commit
a7abb9cbfc
49 changed files with 88 additions and 143 deletions
|
@ -2,7 +2,6 @@
|
|||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launcher.base.Launcher;
|
||||
import pro.gravit.launcher.base.events.RequestEvent;
|
||||
import pro.gravit.launcher.base.events.request.ProfilesRequestEvent;
|
||||
import pro.gravit.launcher.base.modules.events.ClosePhase;
|
||||
|
@ -23,20 +22,16 @@
|
|||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.SocketCommandServer;
|
||||
import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler;
|
||||
import pro.gravit.launchserver.socket.response.auth.ProfilesResponse;
|
||||
import pro.gravit.launchserver.socket.response.auth.RestoreResponse;
|
||||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.command.CommandHandler;
|
||||
import pro.gravit.utils.command.SubCommand;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.security.KeyStore;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
import java.nio.file.Path;
|
||||
import java.security.Security;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LaunchServerStarter {
|
||||
|
|
|
@ -174,7 +174,7 @@ public AuthManager.AuthReport sudo(User user, boolean shadow) throws IOException
|
|||
}
|
||||
|
||||
@Override
|
||||
public User checkServer(Client client, String username, String serverID) throws IOException {
|
||||
public User checkServer(Client client, String username, String serverID) {
|
||||
SQLUser user = (SQLUser) getUserByUsername(username);
|
||||
if (user == null) {
|
||||
return null;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package pro.gravit.launchserver.auth.core;
|
||||
|
||||
import pro.gravit.launcher.base.ClientPermissions;
|
||||
import pro.gravit.launcher.base.request.secure.HardwareReportRequest;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
|
|
|
@ -41,12 +41,12 @@ public AuthManager.AuthReport authorize(String login, AuthResponse.AuthContext c
|
|||
}
|
||||
|
||||
@Override
|
||||
public User checkServer(Client client, String username, String serverID) throws IOException {
|
||||
public User checkServer(Client client, String username, String serverID) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) throws IOException {
|
||||
public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,7 @@
|
|||
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportHardware;
|
||||
import pro.gravit.launchserver.auth.core.interfaces.session.UserSessionSupportHardware;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.util.Base64;
|
||||
|
@ -85,7 +83,7 @@ protected SQLUser constructUser(ResultSet set) throws SQLException {
|
|||
set.getString(accessTokenColumn), set.getString(serverIDColumn), set.getString(passwordColumn), set.getLong(hardwareIdColumn)) : null;
|
||||
}
|
||||
|
||||
private SQLUserHardware fetchHardwareInfo(ResultSet set) throws SQLException, IOException {
|
||||
private SQLUserHardware fetchHardwareInfo(ResultSet set) throws SQLException {
|
||||
HardwareReportRequest.HardwareInfo hardwareInfo = new HardwareReportRequest.HardwareInfo();
|
||||
hardwareInfo.hwDiskId = set.getString("hwDiskId");
|
||||
hardwareInfo.baseboardSerialNumber = set.getString("baseboardSerialNumber");
|
||||
|
@ -126,7 +124,7 @@ public UserHardware getHardwareInfoByPublicKey(byte[] publicKey) {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
} catch (SQLException | IOException throwables) {
|
||||
} catch (SQLException throwables) {
|
||||
logger.error("SQL Error", throwables);
|
||||
return null;
|
||||
}
|
||||
|
@ -149,7 +147,7 @@ public UserHardware getHardwareInfoByData(HardwareReportRequest.HardwareInfo inf
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException | IOException throwables) {
|
||||
} catch (SQLException throwables) {
|
||||
logger.error("SQL Error", throwables);
|
||||
}
|
||||
return null;
|
||||
|
@ -170,7 +168,7 @@ public UserHardware getHardwareInfoById(String id) {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
} catch (SQLException | IOException throwables) {
|
||||
} catch (SQLException throwables) {
|
||||
logger.error("SQL Error", throwables);
|
||||
return null;
|
||||
}
|
||||
|
@ -294,7 +292,7 @@ protected AbstractSQLCoreProvider.SQLUserSession createSession(AbstractSQLCorePr
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserSession extendedCheckServer(Client client, String username, String serverID) throws IOException {
|
||||
public UserSession extendedCheckServer(Client client, String username, String serverID) {
|
||||
AbstractSQLCoreProvider.SQLUser user = (AbstractSQLCoreProvider.SQLUser) getUserByUsername(username);
|
||||
if (user == null) {
|
||||
return null;
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
import java.io.IOException;
|
||||
|
||||
public interface AuthSupportExtendedCheckServer {
|
||||
UserSession extendedCheckServer(Client client, String username, String serverID) throws IOException;
|
||||
UserSession extendedCheckServer(Client client, String username, String serverID);
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ public void init(LaunchServer server, AuthProviderPair pair) {
|
|||
}
|
||||
|
||||
@Override
|
||||
public User checkServer(Client client, String username, String serverID) throws IOException {
|
||||
public User checkServer(Client client, String username, String serverID) {
|
||||
var savedServerId = sqlSessionStore.getServerIdByUsername(username);
|
||||
if (!serverID.equals(savedServerId)) {
|
||||
return null;
|
||||
|
@ -153,7 +153,7 @@ public User checkServer(Client client, String username, String serverID) throws
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) throws IOException {
|
||||
public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) {
|
||||
User user;
|
||||
try {
|
||||
user = createUserFromMinecraftToken(accessToken);
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
import pro.gravit.launchserver.auth.SQLSourceConfig;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launchserver.binary.tasks.LauncherBuildTask;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -56,7 +56,7 @@ public final byte[] getDigest() {
|
|||
public void init() {
|
||||
}
|
||||
|
||||
public final boolean sync() throws IOException {
|
||||
public final boolean sync() {
|
||||
try {
|
||||
var target = syncBinaryFile.toString();
|
||||
var path = server.config.updatesProvider.download(null, List.of(target)).get(target);
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
import pro.gravit.utils.command.CommandException;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -2,17 +2,13 @@
|
|||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launcher.base.Launcher;
|
||||
import pro.gravit.launcher.base.profiles.ClientProfile;
|
||||
import pro.gravit.launcher.base.profiles.ClientProfileBuilder;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
import pro.gravit.launcher.base.profiles.ClientProfile;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DeleteProfileCommand extends Command {
|
||||
|
|
|
@ -22,7 +22,7 @@ public String getUsageDescription() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
public void invoke(String... args) {
|
||||
for(var profile : server.getProfiles()) {
|
||||
logger.info("{} ({}) {}", profile.getTitle(), profile.getVersion().toString(), profile.isLimited() ? "limited" : "");
|
||||
}
|
||||
|
|
|
@ -2,14 +2,10 @@
|
|||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launcher.base.Launcher;
|
||||
import pro.gravit.launcher.base.profiles.ClientProfile;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.launchserver.helper.MakeProfileHelper;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.Writer;
|
||||
|
||||
public class MakeProfileCommand extends Command {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
|
|
@ -2,17 +2,10 @@
|
|||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launcher.base.Launcher;
|
||||
import pro.gravit.launcher.base.profiles.ClientProfile;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SaveProfilesCommand extends Command {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package pro.gravit.launchserver.config;
|
||||
|
||||
import io.netty.channel.epoll.Epoll;
|
||||
import io.netty.handler.logging.LogLevel;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
package pro.gravit.launchserver.manangers;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launcher.core.hasher.HashedDir;
|
||||
import pro.gravit.launcher.core.serialize.HInput;
|
||||
import pro.gravit.launcher.core.serialize.HOutput;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.modules.events.LaunchServerUpdatesSyncEvent;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class UpdatesManager {
|
||||
private final LaunchServer server;
|
||||
|
@ -24,12 +14,12 @@ public UpdatesManager(LaunchServer server) {
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public void readUpdatesFromCache() throws IOException {
|
||||
public void readUpdatesFromCache() {
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void readUpdatesDir() throws IOException {
|
||||
public void readUpdatesDir() {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.epoll.Epoll;
|
||||
import io.netty.channel.group.DefaultChannelGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.handler.codec.http.HttpObjectAggregator;
|
||||
|
|
|
@ -5,10 +5,8 @@
|
|||
import io.netty.channel.MultiThreadIoEventLoopGroup;
|
||||
import io.netty.channel.ServerChannel;
|
||||
import io.netty.channel.epoll.Epoll;
|
||||
import io.netty.channel.epoll.EpollEventLoopGroup;
|
||||
import io.netty.channel.epoll.EpollIoHandler;
|
||||
import io.netty.channel.epoll.EpollServerSocketChannel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.nio.NioIoHandler;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.channel.uring.IoUring;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import pro.gravit.launchserver.config.log4j.LogAppender;
|
||||
import pro.gravit.utils.command.CommandHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.StandardProtocolFamily;
|
||||
import java.net.UnixDomainSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -64,29 +63,28 @@ public void run() {
|
|||
ByteBuffer buffer = ByteBuffer.allocate(1024);
|
||||
while (true) {
|
||||
SocketChannel channel = serverChannel.accept();
|
||||
channel.configureBlocking(true);
|
||||
String command = null;
|
||||
try {
|
||||
try (channel) {
|
||||
channel.configureBlocking(true);
|
||||
String command = null;
|
||||
mark:
|
||||
while (true) {
|
||||
int bytesRead = channel.read(buffer);
|
||||
if (bytesRead < 0) {
|
||||
break;
|
||||
}
|
||||
for (var i=0;i<buffer.limit();i++) {
|
||||
if(buffer.get(i) == '\n') {
|
||||
for (var i = 0; i < buffer.limit(); i++) {
|
||||
if (buffer.get(i) == '\n') {
|
||||
command = new String(buffer.array(), 0, i);
|
||||
break mark;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(command != null) {
|
||||
if (command != null) {
|
||||
runCommand(channel, command);
|
||||
}
|
||||
} finally {
|
||||
buffer.clear();
|
||||
channel.close();
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoField;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.time.temporal.UnsupportedTemporalTypeException;
|
||||
import java.util.Arrays;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
public interface WebSocketServerResponse extends WebSocketRequest {
|
||||
String getType();
|
||||
|
||||
void execute(ChannelHandlerContext ctx, Client client) throws Exception;
|
||||
void execute(ChannelHandlerContext ctx, Client client);
|
||||
|
||||
default ThreadSafeStatus getThreadSafeStatus() {
|
||||
return ThreadSafeStatus.READ;
|
||||
|
|
|
@ -23,7 +23,7 @@ public String getType() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||
sendResult(new CurrentUserRequestEvent(collectUserInfoFromClient(server, client)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public String getType() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||
if (accessToken == null && !client.isAuth && needUserInfo) {
|
||||
sendError("Invalid request");
|
||||
return;
|
||||
|
|
|
@ -12,7 +12,7 @@ public String getType() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||
if(!client.isAuth || client.auth == null || client.getUser() == null) {
|
||||
sendError("Access denied");
|
||||
return;
|
||||
|
|
|
@ -14,7 +14,7 @@ public String getType() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||
if(!client.isAuth || client.auth == null || client.getUser() == null) {
|
||||
sendError("Access denied");
|
||||
return;
|
||||
|
|
|
@ -12,7 +12,7 @@ public String getType() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||
sendResult(new GetConnectUUIDRequestEvent(connectUUID, server.shardId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ClientLauncherProcess {
|
||||
public final List<String> pre = new LinkedList<>();
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
public final class ClientProfile implements Comparable<ClientProfile> {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import java.io.IOException;
|
||||
|
||||
public final class RequestException extends IOException {
|
||||
private static final long serialVersionUID = 7558237657082664821L;
|
||||
|
||||
|
||||
public RequestException(String message) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
public interface RequestService {
|
||||
<T extends WebSocketEvent> CompletableFuture<T> request(Request<T> request) throws IOException;
|
||||
void open() throws Exception;
|
||||
void open();
|
||||
|
||||
void registerEventHandler(EventHandler handler);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public abstract class ClientJSONPoint implements WebSocket.Listener {
|
|||
private final Object sendSyncObject = new Object();
|
||||
private volatile StringBuilder builder = new StringBuilder();
|
||||
|
||||
public ClientJSONPoint(final String uri) throws SSLException {
|
||||
public ClientJSONPoint(final String uri) {
|
||||
this(URI.create(uri));
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ public void send(String text) {
|
|||
|
||||
abstract void onOpen();
|
||||
|
||||
public void close() throws InterruptedException {
|
||||
public void close() {
|
||||
webSocket.abort();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public abstract class ClientWebSocketService extends ClientJSONPoint {
|
|||
public OnCloseCallback onCloseCallback;
|
||||
public ReconnectCallback reconnectCallback;
|
||||
|
||||
public ClientWebSocketService(String address) throws SSLException {
|
||||
public ClientWebSocketService(String address) {
|
||||
super(createURL(address));
|
||||
this.gson = Launcher.gsonManager.gson;
|
||||
this.onConnect = true;
|
||||
|
|
|
@ -40,11 +40,7 @@ public static CompletableFuture<StdWebSocketService> initWebSockets(String addre
|
|||
service.openAsync(() -> {
|
||||
future.complete(service);
|
||||
JVMHelper.RUNTIME.addShutdownHook(new Thread(() -> {
|
||||
try {
|
||||
service.close();
|
||||
} catch (InterruptedException e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
service.close();
|
||||
}));
|
||||
}, future::completeExceptionally);
|
||||
return future;
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
public class ClientVersionTest {
|
||||
@Test
|
||||
public void parseTest() {
|
||||
Assertions.assertEquals(ClientProfile.Version.of("1.0.0").toCleanString(), "1.0.0");
|
||||
Assertions.assertEquals(ClientProfile.Version.of("1.0.0-1").toCleanString(), "1.0.0.1");
|
||||
Assertions.assertEquals(ClientProfile.Version.of("-----1.0.0").toCleanString(), "1.0.0");
|
||||
Assertions.assertEquals("1.0.0", ClientProfile.Version.of("1.0.0").toCleanString());
|
||||
Assertions.assertEquals("1.0.0.1", ClientProfile.Version.of("1.0.0-1").toCleanString());
|
||||
Assertions.assertEquals("1.0.0", ClientProfile.Version.of("-----1.0.0").toCleanString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -49,12 +49,12 @@ public void dependenciesTest() {
|
|||
moduleManager.loadModule(new Depend3Module());
|
||||
moduleManager.loadModule(new MainModule());
|
||||
moduleManager.initModules(null);
|
||||
Assertions.assertEquals(moduleManager.getModule("depend1").getInitStatus(), LauncherModule.InitStatus.FINISH);
|
||||
Assertions.assertEquals(moduleManager.getModule("depend2").getInitStatus(), LauncherModule.InitStatus.FINISH);
|
||||
Assertions.assertEquals(moduleManager.getModule("depend3").getInitStatus(), LauncherModule.InitStatus.FINISH);
|
||||
Assertions.assertEquals(moduleManager.getModule("internal").getInitStatus(), LauncherModule.InitStatus.FINISH);
|
||||
Assertions.assertEquals(moduleManager.getModule("virtual").getInitStatus(), LauncherModule.InitStatus.FINISH);
|
||||
Assertions.assertEquals(moduleManager.getModule("main").getInitStatus(), LauncherModule.InitStatus.FINISH);
|
||||
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("depend1").getInitStatus());
|
||||
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("depend2").getInitStatus());
|
||||
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("depend3").getInitStatus());
|
||||
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("internal").getInitStatus());
|
||||
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("virtual").getInitStatus());
|
||||
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("main").getInitStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -62,7 +62,7 @@ public void cyclicTest() {
|
|||
moduleManager.loadModule(new CyclicDependModule());
|
||||
moduleManager.loadModule(new Cyclic2DependModule());
|
||||
moduleManager.initModules(null);
|
||||
Assertions.assertEquals(moduleManager.getModule("cyclic1").getInitStatus(), LauncherModule.InitStatus.FINISH);
|
||||
Assertions.assertEquals(moduleManager.getModule("cyclic2").getInitStatus(), LauncherModule.InitStatus.FINISH);
|
||||
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("cyclic1").getInitStatus());
|
||||
Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("cyclic2").getInitStatus());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ public Depend1Module() {
|
|||
@Override
|
||||
public void init(LauncherInitContext initContext) {
|
||||
InternalModule module = modulesManager.getModule(InternalModule.class);
|
||||
Assertions.assertEquals(module.getInitStatus(), InitStatus.FINISH);
|
||||
Assertions.assertEquals(InitStatus.FINISH, module.getInitStatus());
|
||||
Depend3Module module1 = modulesManager.getModule(Depend3Module.class);
|
||||
Assertions.assertEquals(module1.getInitStatus(), InitStatus.FINISH);
|
||||
Assertions.assertEquals(InitStatus.FINISH, module1.getInitStatus());
|
||||
VirtualInterface virtualInterface = modulesManager.getModuleByInterface(VirtualInterface.class);
|
||||
Assertions.assertEquals(((LauncherModule) virtualInterface).getInitStatus(), InitStatus.FINISH);
|
||||
Assertions.assertEquals(InitStatus.FINISH, ((LauncherModule) virtualInterface).getInitStatus());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ public MainModule() {
|
|||
@Override
|
||||
public void init(LauncherInitContext initContext) {
|
||||
Depend1Module module = modulesManager.getModule(Depend1Module.class);
|
||||
Assertions.assertEquals(module.getInitStatus(), InitStatus.FINISH);
|
||||
Assertions.assertEquals(InitStatus.FINISH, module.getInitStatus());
|
||||
Depend2Module module2 = modulesManager.getModule(Depend2Module.class);
|
||||
Assertions.assertEquals(module2.getInitStatus(), InitStatus.FINISH);
|
||||
Assertions.assertEquals(InitStatus.FINISH, module2.getInitStatus());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ private static void realMain(String[] args) throws Throwable {
|
|||
LogHelper.dev("Classpath entry %s", e);
|
||||
}
|
||||
}
|
||||
List<URL> classpathURLs = classpath.stream().map(IOHelper::toURL).collect(Collectors.toList());
|
||||
List<URL> classpathURLs = classpath.stream().map(IOHelper::toURL).toList();
|
||||
// Start client with WatchService monitoring
|
||||
RequestService service;
|
||||
if (params.offlineMode) {
|
||||
|
|
|
@ -282,7 +282,7 @@ public enum WalkAction {
|
|||
|
||||
@FunctionalInterface
|
||||
public interface WalkCallback {
|
||||
WalkAction walked(String path, String name, HashedEntry entry) throws IOException;
|
||||
WalkAction walked(String path, String name, HashedEntry entry);
|
||||
}
|
||||
|
||||
public static class FindRecursiveResult {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package pro.gravit.utils;
|
||||
|
||||
public class HookException extends RuntimeException {
|
||||
private static final long serialVersionUID = -529141998961943161L;
|
||||
|
||||
public HookException(String message) {
|
||||
super(message);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package pro.gravit.utils.command;
|
||||
|
||||
public final class CommandException extends Exception {
|
||||
private static final long serialVersionUID = -6588814993972117772L;
|
||||
|
||||
|
||||
public CommandException(String message) {
|
||||
|
|
|
@ -221,37 +221,39 @@ public static ArgsParseResult parseJavaArgs(List<String> args) {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if(arg.equals("--module-path") || arg.equals("-p")) {
|
||||
prevArgType = PrevArgType.MODULE_PATH;
|
||||
continue;
|
||||
}
|
||||
if(arg.equals("--classpath") || arg.equals("-cp")) {
|
||||
prevArgType = PrevArgType.CLASSPATH;
|
||||
continue;
|
||||
}
|
||||
if(arg.equals("--add-modules")) {
|
||||
prevArgType = PrevArgType.ADD_MODULES;
|
||||
continue;
|
||||
}
|
||||
if(arg.equals("--add-opens")) {
|
||||
prevArgType = PrevArgType.ADD_OPENS;
|
||||
continue;
|
||||
}
|
||||
if(arg.equals("--add-exports")) {
|
||||
prevArgType = PrevArgType.ADD_EXPORTS;
|
||||
continue;
|
||||
}
|
||||
if(arg.equals("--add-reads")) {
|
||||
prevArgType = PrevArgType.ADD_READS;
|
||||
continue;
|
||||
}
|
||||
if(arg.equals("--module") || arg.equals("-m")) {
|
||||
prevArgType = PrevArgType.MODULE;
|
||||
continue;
|
||||
}
|
||||
if(arg.equals("-jar")) {
|
||||
prevArgType = PrevArgType.JAR;
|
||||
continue;
|
||||
switch (arg) {
|
||||
case "--module-path", "-p" -> {
|
||||
prevArgType = PrevArgType.MODULE_PATH;
|
||||
continue;
|
||||
}
|
||||
case "--classpath", "-cp" -> {
|
||||
prevArgType = PrevArgType.CLASSPATH;
|
||||
continue;
|
||||
}
|
||||
case "--add-modules" -> {
|
||||
prevArgType = PrevArgType.ADD_MODULES;
|
||||
continue;
|
||||
}
|
||||
case "--add-opens" -> {
|
||||
prevArgType = PrevArgType.ADD_OPENS;
|
||||
continue;
|
||||
}
|
||||
case "--add-exports" -> {
|
||||
prevArgType = PrevArgType.ADD_EXPORTS;
|
||||
continue;
|
||||
}
|
||||
case "--add-reads" -> {
|
||||
prevArgType = PrevArgType.ADD_READS;
|
||||
continue;
|
||||
}
|
||||
case "--module", "-m" -> {
|
||||
prevArgType = PrevArgType.MODULE;
|
||||
continue;
|
||||
}
|
||||
case "-jar" -> {
|
||||
prevArgType = PrevArgType.JAR;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
jvmArgs.add(arg);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public static byte[] getClassBytes(Class<?> clazz, ClassLoader classLoader) thro
|
|||
return IOHelper.read(classLoader.getResourceAsStream(getClassFile(clazz)));
|
||||
}
|
||||
|
||||
public static InputStream getClassBytesStream(Class<?> clazz) throws IOException {
|
||||
public static InputStream getClassBytesStream(Class<?> clazz) {
|
||||
return getClassBytesStream(clazz, clazz.getClassLoader());
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public void addTransformer(ClassTransformer transformer) {
|
|||
}
|
||||
instrumentation.addTransformer(new ClassFileTransformer() {
|
||||
@Override
|
||||
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
|
||||
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) {
|
||||
if(transformer.filter(null, className)) {
|
||||
return transformer.transform(null, className, protectionDomain, classfileBuffer);
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ public void main() {
|
|||
String json2 = gson.toJson(new MyTestClass2("BBBB"), TestInterface.class);
|
||||
TestInterface test1 = gson.fromJson(json, TestInterface.class);
|
||||
TestInterface test2 = gson.fromJson(json2, TestInterface.class);
|
||||
Assertions.assertEquals(test1.get(), "AAAA");
|
||||
Assertions.assertEquals(test2.get(), "BBBB");
|
||||
Assertions.assertEquals("AAAA", test1.get());
|
||||
Assertions.assertEquals("BBBB", test2.get());
|
||||
}
|
||||
|
||||
public interface TestInterface {
|
||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
|||
Subproject commit aa5ab332d65dd14ce5321453aa809e30b87a186d
|
||||
Subproject commit 00b275f82f52b9bbfebe4649b8c96a438365aecd
|
Loading…
Reference in a new issue