mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
Merge branch 'dev' of github.com:GravitLauncher/Launcher into dev
This commit is contained in:
commit
833cc9ae8e
15 changed files with 280 additions and 110 deletions
|
@ -1,41 +1,49 @@
|
|||
image: frekele/java
|
||||
image: docker:latest
|
||||
services:
|
||||
- docker:dind
|
||||
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
CI_VERSION: '6.6.$CI_PIPELINE_IID'
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
before_script:
|
||||
# - echo `pwd` # debug
|
||||
# - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug
|
||||
- export GRADLE_USER_HOME=`pwd`/.gradle
|
||||
- apt-get update -qq && apt-get install -y -qq git git-core
|
||||
|
||||
cache:
|
||||
key: ${CI_COMMIT_REF_NAME}
|
||||
paths:
|
||||
- .gradle/wrapper
|
||||
- .gradle/caches
|
||||
- build
|
||||
- test
|
||||
|
||||
build:
|
||||
image: frekele/java
|
||||
stage: build
|
||||
before_script:
|
||||
- apt-get -y update
|
||||
- apt-get -y install zip git
|
||||
- export GRADLE_USER_HOME=`pwd`/.gradle
|
||||
- chmod +x gradlew
|
||||
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
|
||||
- git submodule sync
|
||||
- git submodule update --init --recursive
|
||||
script:
|
||||
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
|
||||
- git submodule sync
|
||||
- git submodule update --init --recursive
|
||||
- ./gradlew assemble
|
||||
- mv LaunchServer/build/libs/*.jar LaunchServer
|
||||
- mv ServerWrapper/build/libs/*.jar ServerWrapper
|
||||
- mv modules/*_module/build/libs/*.jar modules
|
||||
artifacts:
|
||||
- ./gradlew assemble
|
||||
after_script:
|
||||
- mkdir -p artifacts/modules
|
||||
- cd LaunchServer/build/libs/
|
||||
- zip -r -9 ../../../artifacts/libraries.zip * -x "LaunchServer.jar" -x "LaunchServer-clean.jar"
|
||||
- mv LaunchServer.jar ../../../artifacts/LaunchServer.jar
|
||||
- cd ../../../ServerWrapper/build/libs
|
||||
- mv ServerWrapper.jar ../../../artifacts/ServerWrapper.jar
|
||||
- cd ../../../
|
||||
- mv modules/*_module/build/libs/*.jar artifacts/modules
|
||||
- mv modules/*_swmodule/build/libs/*.jar artifacts/modules
|
||||
- mv modules/*_lmodule/build/libs/*.jar artifacts/modules
|
||||
cache:
|
||||
paths:
|
||||
- LaunchServer/*.jar
|
||||
- ServerWrapper/*.jar
|
||||
- modules/*.jar
|
||||
- .gradle
|
||||
artifacts:
|
||||
expire_in: 6 week
|
||||
paths:
|
||||
- artifacts
|
||||
|
||||
test:
|
||||
image: frekele/java
|
||||
stage: test
|
||||
script:
|
||||
- ./gradlew check
|
||||
|
||||
after_script:
|
||||
- echo "End CI"
|
||||
- ./gradlew check
|
|
@ -31,9 +31,9 @@ public void invoke(String... args) throws Exception {
|
|||
return;
|
||||
}
|
||||
LogHelper.info("[%s] UUID: %s", user.username, user.uuid.toString());
|
||||
for(UserHWID hwid : user.hwids)
|
||||
{
|
||||
LogHelper.info("[%s] HWID: memory: %d | serial %s | hwdiskserial: %s | processorID %s | macAddr %s", user.username, hwid.totalMemory, hwid.serialNumber, hwid.HWDiskSerial, hwid.processorID, hwid.macAddr);
|
||||
}
|
||||
//for(UserHWID hwid : user.hwids)
|
||||
//{
|
||||
// LogHelper.info("[%s] HWID: memory: %d | serial %s | hwdiskserial: %s | processorID %s | macAddr %s", user.username, hwid.totalMemory, hwid.serialNumber, hwid.HWDiskSerial, hwid.processorID, hwid.macAddr);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,12 +39,6 @@ public class User {
|
|||
public String serverID;
|
||||
private String password_salt;
|
||||
public long permissions;
|
||||
//TODO: заменить EAGER на LASY и придумать способ сохранить сессию
|
||||
// [ERROR] org.hibernate.LazyInitializationException:
|
||||
// failed to lazily initialize a collection of role: pro.gravit.launchserver.dao.User.hwids, could not initialize proxy - no Session
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "user_id")
|
||||
public Collection<UserHWID> hwids;
|
||||
public void setPassword(String password)
|
||||
{
|
||||
password_salt = SecurityHelper.randomStringAESKey();
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
-keepattributes Signature
|
||||
-adaptresourcefilecontents META-INF/MANIFEST.MF
|
||||
|
||||
-keeppackagenames com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.client.api.**
|
||||
-keeppackagenames com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.api.**
|
||||
|
||||
-keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.client.api.** {
|
||||
-keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.api.** {
|
||||
*;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
import pro.gravit.launcher.LauncherEngine;
|
||||
import pro.gravit.launcher.api.AuthService;
|
||||
import pro.gravit.launcher.api.ClientService;
|
||||
import pro.gravit.launcher.client.events.ClientLaunchPhase;
|
||||
import pro.gravit.launcher.client.events.ClientLauncherInitPhase;
|
||||
import pro.gravit.launcher.client.events.ClientLauncherPostInitPhase;
|
||||
import pro.gravit.launcher.guard.LauncherGuardManager;
|
||||
import pro.gravit.launcher.gui.JSRuntimeProvider;
|
||||
import pro.gravit.launcher.hasher.FileNameMatcher;
|
||||
|
@ -436,6 +438,21 @@ public static Process launch(
|
|||
clientStarted = false;
|
||||
return process;
|
||||
}
|
||||
public static class ClientLaunchContext
|
||||
{
|
||||
public final Params params;
|
||||
public final ClientProfile profile;
|
||||
public final HashedDir assetHDir, clientHDir;
|
||||
public DirWatcher assetWatcher, clientWatcher;
|
||||
|
||||
|
||||
public ClientLaunchContext(Params params, ClientProfile profile, HashedDir assetHDir, HashedDir clientHDir) {
|
||||
this.params = params;
|
||||
this.profile = profile;
|
||||
this.assetHDir = assetHDir;
|
||||
this.clientHDir = clientHDir;
|
||||
}
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public static void main(String... args) throws Throwable {
|
||||
|
@ -476,11 +493,12 @@ public static void main(String... args) throws Throwable {
|
|||
System.exit(-98);
|
||||
return;
|
||||
}
|
||||
ClientLaunchContext context = new ClientLaunchContext(params, profile, assetHDir, clientHDir);
|
||||
Launcher.profile = profile;
|
||||
playerProfile = params.pp;
|
||||
Request.setSession(params.session);
|
||||
checkJVMBitsAndVersion();
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientLauncherInitPhase());
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientLauncherInitPhase(context));
|
||||
// Verify ClientLauncher sign and classpath
|
||||
LogHelper.debug("Verifying ClientLauncher sign and classpath");
|
||||
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.getClassPath());
|
||||
|
@ -536,13 +554,16 @@ public static void main(String... args) throws Throwable {
|
|||
// if (params.updateOptional.contains(s)) s.mark = true;
|
||||
// else hdir.removeR(s.file);
|
||||
//}
|
||||
context.assetWatcher = assetWatcher;
|
||||
context.clientWatcher = clientWatcher;
|
||||
Launcher.profile.pushOptionalFile(clientHDir, false);
|
||||
LauncherEngine.modulesManager.invokeEvent(new PostInitPhase());
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientLauncherPostInitPhase(context));
|
||||
// Start WatchService, and only then client
|
||||
CommonHelper.newThread("Asset Directory Watcher", true, assetWatcher).start();
|
||||
CommonHelper.newThread("Client Directory Watcher", true, clientWatcher).start();
|
||||
verifyHDir(params.assetDir, assetHDir, assetMatcher, digest);
|
||||
verifyHDir(params.clientDir, clientHDir, clientMatcher, digest);
|
||||
LauncherEngine.modulesManager.invokeEvent(new ClientLaunchPhase(context));
|
||||
launch(profile, params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package pro.gravit.launcher.client.events;
|
||||
|
||||
import pro.gravit.launcher.client.ClientLauncher;
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
|
||||
public class ClientLaunchPhase extends LauncherModule.Event {
|
||||
public final ClientLauncher.ClientLaunchContext context;
|
||||
|
||||
public ClientLaunchPhase(ClientLauncher.ClientLaunchContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,12 @@
|
|||
package pro.gravit.launcher.client.events;
|
||||
|
||||
import pro.gravit.launcher.client.ClientLauncher;
|
||||
import pro.gravit.launcher.modules.events.InitPhase;
|
||||
|
||||
public class ClientLauncherInitPhase extends InitPhase {
|
||||
public final ClientLauncher.ClientLaunchContext context;
|
||||
|
||||
public ClientLauncherInitPhase(ClientLauncher.ClientLaunchContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package pro.gravit.launcher.client.events;
|
||||
|
||||
import pro.gravit.launcher.client.ClientLauncher;
|
||||
import pro.gravit.launcher.modules.events.PostInitPhase;
|
||||
|
||||
public class ClientLauncherPostInitPhase extends PostInitPhase {
|
||||
public final ClientLauncher.ClientLaunchContext context;
|
||||
|
||||
public ClientLauncherPostInitPhase(ClientLauncher.ClientLaunchContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
}
|
|
@ -102,9 +102,4 @@ public void loadHDirStore() throws IOException {
|
|||
public void saveHDirStore() throws IOException {
|
||||
saveHDirStore(DirBridge.dirProjectStore);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Type type) {
|
||||
super.setType(type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,19 +11,9 @@
|
|||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public abstract class JsonConfigurable<T> {
|
||||
private Type type;
|
||||
protected Path configPath;
|
||||
|
||||
@LauncherAPI
|
||||
public void saveConfig() throws IOException {
|
||||
saveConfig(configPath);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public void loadConfig() throws IOException {
|
||||
loadConfig(configPath);
|
||||
}
|
||||
public abstract class JsonConfigurable<T> implements JsonConfigurableInterface<T> {
|
||||
private transient final Type type;
|
||||
protected transient final Path configPath;
|
||||
|
||||
@LauncherAPI
|
||||
public JsonConfigurable(Type type, Path configPath) {
|
||||
|
@ -31,55 +21,14 @@ public JsonConfigurable(Type type, Path configPath) {
|
|||
this.configPath = configPath;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public void saveConfig(Path configPath) throws IOException {
|
||||
try (BufferedWriter writer = IOHelper.newWriter(configPath)) {
|
||||
Launcher.gsonManager.configGson.toJson(getConfig(), type, writer);
|
||||
}
|
||||
@Override
|
||||
public Path getPath() {
|
||||
return configPath;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public void loadConfig(Path configPath) throws IOException {
|
||||
if (generateConfigIfNotExists(configPath)) return;
|
||||
try (BufferedReader reader = IOHelper.newReader(configPath)) {
|
||||
setConfig(Launcher.gsonManager.configGson.fromJson(reader, type));
|
||||
} catch (Exception e)
|
||||
{
|
||||
LogHelper.error(e);
|
||||
resetConfig(configPath);
|
||||
}
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public void resetConfig() throws IOException {
|
||||
setConfig(getDefaultConfig());
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public void resetConfig(Path newPath) throws IOException {
|
||||
setConfig(getDefaultConfig());
|
||||
saveConfig(newPath);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public boolean generateConfigIfNotExists(Path path) throws IOException {
|
||||
if (IOHelper.isFile(path))
|
||||
return false;
|
||||
resetConfig(path);
|
||||
return true;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public boolean generateConfigIfNotExists() throws IOException {
|
||||
if (IOHelper.isFile(configPath))
|
||||
return false;
|
||||
resetConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void setType(Type type) {
|
||||
this.type = type;
|
||||
@Override
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package pro.gravit.launcher.config;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface JsonConfigurableInterface<T> {
|
||||
default void saveConfig() throws IOException {
|
||||
saveConfig(getPath());
|
||||
}
|
||||
|
||||
default void loadConfig() throws IOException {
|
||||
loadConfig(getPath());
|
||||
}
|
||||
|
||||
default void saveConfig(Gson gson, Path configPath) throws IOException {
|
||||
try (BufferedWriter writer = IOHelper.newWriter(configPath)) {
|
||||
gson.toJson(getConfig(), getType(), writer);
|
||||
}
|
||||
}
|
||||
|
||||
default void loadConfig(Gson gson, Path configPath) throws IOException {
|
||||
if (generateConfigIfNotExists(configPath)) return;
|
||||
try (BufferedReader reader = IOHelper.newReader(configPath)) {
|
||||
setConfig(gson.fromJson(reader, getType()));
|
||||
} catch (Exception e)
|
||||
{
|
||||
LogHelper.error(e);
|
||||
resetConfig(configPath);
|
||||
}
|
||||
}
|
||||
|
||||
default void saveConfig(Path configPath) throws IOException {
|
||||
saveConfig(Launcher.gsonManager.configGson, configPath);
|
||||
}
|
||||
|
||||
default void loadConfig(Path configPath) throws IOException {
|
||||
loadConfig(Launcher.gsonManager.configGson, configPath);
|
||||
}
|
||||
|
||||
default void resetConfig() throws IOException {
|
||||
setConfig(getDefaultConfig());
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
default void resetConfig(Path newPath) throws IOException {
|
||||
setConfig(getDefaultConfig());
|
||||
saveConfig(newPath);
|
||||
}
|
||||
|
||||
default boolean generateConfigIfNotExists(Path path) throws IOException {
|
||||
if (IOHelper.isFile(path))
|
||||
return false;
|
||||
resetConfig(path);
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean generateConfigIfNotExists() throws IOException {
|
||||
if (IOHelper.isFile(getPath()))
|
||||
return false;
|
||||
resetConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
T getConfig();
|
||||
|
||||
T getDefaultConfig();
|
||||
|
||||
void setConfig(T config);
|
||||
|
||||
Path getPath();
|
||||
|
||||
Type getType();
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package pro.gravit.launcher.config;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public abstract class SimpleConfig<T> implements JsonConfigurableInterface<T> {
|
||||
private transient final Class<T> type;
|
||||
protected transient final Path configPath;
|
||||
|
||||
protected SimpleConfig(Class<T> type, Path configPath) {
|
||||
this.type = type;
|
||||
this.configPath = configPath;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T getConfig() {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getDefaultConfig() {
|
||||
try {
|
||||
return type.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getPath() {
|
||||
return configPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package pro.gravit.launcher.config;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class SimpleConfigurable<T> extends JsonConfigurable<T> {
|
||||
public T config;
|
||||
private final Class<T> tClass;
|
||||
|
||||
public SimpleConfigurable(Class<T> type, Path configPath) {
|
||||
super(type, configPath);
|
||||
tClass = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getDefaultConfig() {
|
||||
try {
|
||||
return tClass.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(T config) {
|
||||
this.config = config;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import pro.gravit.launcher.config.SimpleConfigurable;
|
||||
import pro.gravit.launcher.modules.ModulesConfigManager;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
@ -34,4 +35,9 @@ public Path getModuleConfigDir(String moduleName) {
|
|||
}
|
||||
return configDir.resolve(moduleName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> SimpleConfigurable<T> getConfigurable(Class<T> tClass, Path configPath) {
|
||||
return new SimpleConfigurable<>(tClass, configPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package pro.gravit.launcher.modules;
|
||||
|
||||
import pro.gravit.launcher.config.SimpleConfigurable;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface ModulesConfigManager {
|
||||
|
@ -8,4 +10,16 @@ public interface ModulesConfigManager {
|
|||
Path getModuleConfig(String moduleName, String configName);
|
||||
|
||||
Path getModuleConfigDir(String moduleName);
|
||||
|
||||
<T> SimpleConfigurable<T> getConfigurable(Class<T> tClass, Path configPath);
|
||||
|
||||
default <T> SimpleConfigurable<T> getConfigurable(Class<T> tClass, String moduleName)
|
||||
{
|
||||
return getConfigurable(tClass, getModuleConfig(moduleName));
|
||||
}
|
||||
|
||||
default <T> SimpleConfigurable<T> getConfigurable(Class<T> tClass, String moduleName, String configName)
|
||||
{
|
||||
return getConfigurable(tClass, getModuleConfig(moduleName, configName));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue