Перевод конфигов на Json часть 9

Порция фиксов
Теперь работает!
This commit is contained in:
Gravit 2018-12-24 14:51:13 +07:00
parent 08d7f61a19
commit c65124a21e
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
3 changed files with 65 additions and 9 deletions

View file

@ -1,9 +1,14 @@
package ru.gravit.launchserver.command.basic; package ru.gravit.launchserver.command.basic;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.Command;
import ru.gravit.launchserver.socket.NettyServerSocketHandler; import ru.gravit.launchserver.socket.NettyServerSocketHandler;
import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.IOHelper;
import java.io.Writer;
public class TestCommand extends Command { public class TestCommand extends Command {
public TestCommand(LaunchServer server) { public TestCommand(LaunchServer server) {
@ -29,6 +34,15 @@ public void invoke(String... args) throws Exception {
handler = new NettyServerSocketHandler(server); handler = new NettyServerSocketHandler(server);
if (args[0].equals("start")) { if (args[0].equals("start")) {
CommonHelper.newThread("Netty Server", true, handler).start(); CommonHelper.newThread("Netty Server", true, handler).start();
}
if (args[0].equals("profile")) {
ClientProfile profile = new ClientProfile("1.7.10","asset1.7.10",0,"Test1.7.10","localhost",25535,true,false,"net.minecraft.launchwrapper.Launch");
try(Writer writer = IOHelper.newWriter(LaunchServer.server.dir.resolve("profiles").resolve("Test.cfg")))
{
Launcher.gson.toJson(profile,writer);
}
} }
if (args[0].equals("stop")) { if (args[0].equals("stop")) {
handler.close(); handler.close();

View file

@ -230,7 +230,7 @@ var digest = profile.isUpdateFastCheck();
// Update asset dir // Update asset dir
update.resetOverlay("Обновление файлов ресурсов"); update.resetOverlay("Обновление файлов ресурсов");
var assetDirName = profile.block.getEntryValue("assetDir", StringConfigEntryClass); var assetDirName = profile.getAssetDir();
var assetDir = settings.updatesDir.resolve(assetDirName); var assetDir = settings.updatesDir.resolve(assetDirName);
var assetMatcher = profile.getAssetUpdateMatcher(); var assetMatcher = profile.getAssetUpdateMatcher();
makeSetProfileRequest(profile, function() { makeSetProfileRequest(profile, function() {
@ -240,7 +240,7 @@ var digest = profile.isUpdateFastCheck();
// Update client dir // Update client dir
update.resetOverlay("Обновление файлов клиента"); update.resetOverlay("Обновление файлов клиента");
var clientDirName = profile.block.getEntryValue("dir", StringConfigEntryClass); var clientDirName = profile.getDir();
var clientDir = settings.updatesDir.resolve(clientDirName); var clientDir = settings.updatesDir.resolve(clientDirName);
var clientMatcher = profile.getClientUpdateMatcher(); var clientMatcher = profile.getClientUpdateMatcher();
makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) { makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) {

View file

@ -12,6 +12,21 @@
@SuppressWarnings("ComparableImplementedButEqualsNotOverridden") @SuppressWarnings("ComparableImplementedButEqualsNotOverridden")
public final class ClientProfile implements Comparable<ClientProfile> { public final class ClientProfile implements Comparable<ClientProfile> {
public ClientProfile(String version, String assetIndex, int sortIndex, String title, String serverAddress, int serverPort, boolean updateFastCheck, boolean useWhitelist, String mainClass) {
this.version = version;
this.assetIndex = assetIndex;
this.sortIndex = sortIndex;
this.title = title;
this.serverAddress = serverAddress;
this.serverPort = serverPort;
this.updateFastCheck = updateFastCheck;
this.useWhitelist = useWhitelist;
this.mainClass = mainClass;
}
public ClientProfile() {
}
@LauncherAPI @LauncherAPI
public enum Version { public enum Version {
MC147("1.4.7", 51), MC147("1.4.7", 51),
@ -60,14 +75,23 @@ public String toString() {
private static final FileNameMatcher ASSET_MATCHER = new FileNameMatcher( private static final FileNameMatcher ASSET_MATCHER = new FileNameMatcher(
new String[0], new String[]{"indexes", "objects"}, new String[0]); new String[0], new String[]{"indexes", "objects"}, new String[0]);
// Version // Version
@LauncherAPI
private String version; private String version;
@LauncherAPI
private String assetIndex; private String assetIndex;
// Client
private int sortIndex;
private String title;
private String serverAddress;
@LauncherAPI
private String dir;
@LauncherAPI
private String assetDir;
// Client
@LauncherAPI
private int sortIndex;
@LauncherAPI
private String title;
@LauncherAPI
private String serverAddress;
@LauncherAPI
private int serverPort; private int serverPort;
public static class MarkedString { public static class MarkedString {
@ -101,20 +125,30 @@ public int hashCode() {
} }
// Updater and client watch service // Updater and client watch service
@LauncherAPI
private final List<String> update = new ArrayList<>(); private final List<String> update = new ArrayList<>();
@LauncherAPI
private final List<String> updateExclusions = new ArrayList<>(); private final List<String> updateExclusions = new ArrayList<>();
@LauncherAPI
private final List<String> updateShared = new ArrayList<>(); private final List<String> updateShared = new ArrayList<>();
@LauncherAPI
private final List<String> updateVerify = new ArrayList<>(); private final List<String> updateVerify = new ArrayList<>();
@LauncherAPI
private final Set<MarkedString> updateOptional = new HashSet<>(); private final Set<MarkedString> updateOptional = new HashSet<>();
@LauncherAPI
private boolean updateFastCheck; private boolean updateFastCheck;
@LauncherAPI
private boolean useWhitelist; private boolean useWhitelist;
// Client launcher // Client launcher
@LauncherAPI
private String mainClass; private String mainClass;
@LauncherAPI
private final List<String> jvmArgs = new ArrayList<>(); private final List<String> jvmArgs = new ArrayList<>();
@LauncherAPI
private final List<String> classPath = new ArrayList<>(); private final List<String> classPath = new ArrayList<>();
@LauncherAPI
private final List<String> clientArgs = new ArrayList<>(); private final List<String> clientArgs = new ArrayList<>();
@LauncherAPI
private final List<String> whitelist = new ArrayList<>(); private final List<String> whitelist = new ArrayList<>();
@Override @Override
@ -141,6 +175,14 @@ public String[] getClassPath() {
public String[] getClientArgs() { public String[] getClientArgs() {
return clientArgs.toArray(new String[0]); return clientArgs.toArray(new String[0]);
} }
@LauncherAPI
public String getDir() {
return dir;
}
@LauncherAPI
public String getAssetDir() {
return assetDir;
}
@LauncherAPI @LauncherAPI
public FileNameMatcher getClientUpdateMatcher(/*boolean excludeOptional*/) { public FileNameMatcher getClientUpdateMatcher(/*boolean excludeOptional*/) {