From c65124a21e5ed0d2676b0cfa764214749b75c86d Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 24 Dec 2018 14:51:13 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=BE=D0=B2=20=D0=BD=D0=B0?= =?UTF-8?q?=20Json=20=D1=87=D0=B0=D1=81=D1=82=D1=8C=209=20=D0=9F=D0=BE?= =?UTF-8?q?=D1=80=D1=86=D0=B8=D1=8F=20=D1=84=D0=B8=D0=BA=D1=81=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D0=B5=D1=82!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/basic/TestCommand.java | 14 +++++ Launcher/runtime/dialog/dialog.js | 4 +- .../launcher/profiles/ClientProfile.java | 56 ++++++++++++++++--- 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java index c5a11aeb..16c359d7 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java @@ -1,9 +1,14 @@ 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.command.Command; import ru.gravit.launchserver.socket.NettyServerSocketHandler; import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.IOHelper; + +import java.io.Writer; public class TestCommand extends Command { public TestCommand(LaunchServer server) { @@ -29,6 +34,15 @@ public void invoke(String... args) throws Exception { handler = new NettyServerSocketHandler(server); if (args[0].equals("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")) { handler.close(); diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index 1d55b1d5..8d804430 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -230,7 +230,7 @@ var digest = profile.isUpdateFastCheck(); // Update asset dir update.resetOverlay("Обновление файлов ресурсов"); - var assetDirName = profile.block.getEntryValue("assetDir", StringConfigEntryClass); + var assetDirName = profile.getAssetDir(); var assetDir = settings.updatesDir.resolve(assetDirName); var assetMatcher = profile.getAssetUpdateMatcher(); makeSetProfileRequest(profile, function() { @@ -240,7 +240,7 @@ var digest = profile.isUpdateFastCheck(); // Update client dir update.resetOverlay("Обновление файлов клиента"); - var clientDirName = profile.block.getEntryValue("dir", StringConfigEntryClass); + var clientDirName = profile.getDir(); var clientDir = settings.updatesDir.resolve(clientDirName); var clientMatcher = profile.getClientUpdateMatcher(); makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java index b47ef4c3..2d3d090b 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java @@ -12,6 +12,21 @@ @SuppressWarnings("ComparableImplementedButEqualsNotOverridden") public final class ClientProfile implements Comparable { + 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 public enum Version { MC147("1.4.7", 51), @@ -60,14 +75,23 @@ public String toString() { private static final FileNameMatcher ASSET_MATCHER = new FileNameMatcher( new String[0], new String[]{"indexes", "objects"}, new String[0]); // Version + @LauncherAPI private String version; - + @LauncherAPI 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; public static class MarkedString { @@ -101,20 +125,30 @@ public int hashCode() { } // Updater and client watch service + @LauncherAPI private final List update = new ArrayList<>(); + @LauncherAPI private final List updateExclusions = new ArrayList<>(); + @LauncherAPI private final List updateShared = new ArrayList<>(); + @LauncherAPI private final List updateVerify = new ArrayList<>(); + @LauncherAPI private final Set updateOptional = new HashSet<>(); + @LauncherAPI private boolean updateFastCheck; - + @LauncherAPI private boolean useWhitelist; // Client launcher + @LauncherAPI private String mainClass; + @LauncherAPI private final List jvmArgs = new ArrayList<>(); + @LauncherAPI private final List classPath = new ArrayList<>(); + @LauncherAPI private final List clientArgs = new ArrayList<>(); - + @LauncherAPI private final List whitelist = new ArrayList<>(); @Override @@ -141,6 +175,14 @@ public String[] getClassPath() { public String[] getClientArgs() { return clientArgs.toArray(new String[0]); } + @LauncherAPI + public String getDir() { + return dir; + } + @LauncherAPI + public String getAssetDir() { + return assetDir; + } @LauncherAPI public FileNameMatcher getClientUpdateMatcher(/*boolean excludeOptional*/) {