Compare commits

..

No commits in common. "ebf25a65f7aced4527b2b60fbde472fb921bdc52" and "fbaf9ab87f238785eaf49f12be972c8823ad0ea5" have entirely different histories.

3 changed files with 24 additions and 26 deletions

View file

@ -40,11 +40,11 @@ public String getUsageDescription() {
@Override
public void invoke(String... args) throws Exception {
verifyArgs(args, 1);
verifyArgs(args, 2);
//Version version = Version.byName(args[0]);
String versionName = args[0];
String dirName = IOHelper.verifyFileName(args[1] != null ? args[1] : "assets");
String type = args.length > 2 ? args[2] : "mojang";
String dirName = IOHelper.verifyFileName(args[1]);
Path assetDir = server.updatesDir.resolve(dirName);
// Create asset dir

View file

@ -41,14 +41,18 @@ public void invoke(String... args) throws IOException, CommandException {
verifyArgs(args, 2);
//Version version = Version.byName(args[0]);
String versionName = args[0];
String dirName = IOHelper.verifyFileName(args[1] != null ? args[1] : args[0]);
Path clientDir = server.updatesDir.resolve(dirName);
String dirName = IOHelper.verifyFileName(args[1]);
Path clientDir = server.updatesDir.resolve(args[1]);
boolean isMirrorClientDownload = false;
if (args.length > 2) {
isMirrorClientDownload = args[2].equals("mirror");
}
// Create client dir
logger.info("Creating client dir: '{}'", dirName);
Files.createDirectory(clientDir);
// Download required client
logger.info("Downloading client, it may take some time");
//HttpDownloader.downloadZip(server.mirrorManager.getDefaultMirror().getClientsURL(version.name), clientDir);
@ -56,25 +60,7 @@ public void invoke(String... args) throws IOException, CommandException {
// Create profile file
logger.info("Creaing profile file: '{}'", dirName);
ClientProfile clientProfile = null;
if (isMirrorClientDownload) {
try {
JsonElement clientJson = server.mirrorManager.jsonRequest(null, "GET", "clients/%s.json", versionName);
clientProfile = Launcher.gsonManager.configGson.fromJson(clientJson, ClientProfile.class);
clientProfile.setTitle(dirName);
clientProfile.setDir(dirName);
clientProfile.setUUID(UUID.randomUUID());
if (clientProfile.getServers() != null) {
ClientProfile.ServerProfile serverProfile = clientProfile.getDefaultServerProfile();
if (serverProfile != null) {
serverProfile.name = dirName;
}
}
} catch (Exception e) {
logger.error("Filed download clientProfile from mirror: '{}' Generation through MakeProfileHelper", versionName);
isMirrorClientDownload = false;
}
}
ClientProfile client = null;
if (!isMirrorClientDownload) {
try {
String internalVersion = versionName;
@ -89,14 +75,27 @@ public void invoke(String... args) throws IOException, CommandException {
for (MakeProfileHelper.MakeProfileOption option : options) {
logger.debug("Detected option {}", option.getClass().getSimpleName());
}
clientProfile = MakeProfileHelper.makeProfile(version, dirName, options);
client = MakeProfileHelper.makeProfile(version, dirName, options);
} catch (Throwable e) {
isMirrorClientDownload = true;
}
}
if (isMirrorClientDownload) {
JsonElement clientJson = server.mirrorManager.jsonRequest(null, "GET", "clients/%s.json", versionName);
client = Launcher.gsonManager.configGson.fromJson(clientJson, ClientProfile.class);
client.setTitle(dirName);
client.setDir(dirName);
client.setUUID(UUID.randomUUID());
if (client.getServers() != null) {
ClientProfile.ServerProfile serverProfile = client.getDefaultServerProfile();
if (serverProfile != null) {
serverProfile.name = dirName;
}
}
}
try (BufferedWriter writer = IOHelper.newWriter(IOHelper.resolveIncremental(server.profilesDir,
dirName, "json"))) {
Launcher.gsonManager.configGson.toJson(clientProfile, writer);
Launcher.gsonManager.configGson.toJson(client, writer);
}
// Finished

View file

@ -56,7 +56,6 @@ public static void downloadFile(URL url, Path file, Consumer<Integer> chanheTrac
public static void downloadZip(URL url, Path dir) throws IOException {
try (ZipInputStream input = IOHelper.newZipInput(url)) {
Files.createDirectory(dir);
for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) {
if (entry.isDirectory()) {
Files.createDirectory(dir.resolve(IOHelper.toPath(entry.getName())));