mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE][EXPERIMENTAL] Конвертация опциональных модов в новый формат
This commit is contained in:
parent
2271b91653
commit
72a8325a15
7 changed files with 77 additions and 5 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launcher.profiles.optional.OptionalFile;
|
||||
import pro.gravit.launcher.profiles.optional.actions.*;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
|
@ -12,6 +14,9 @@
|
|||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SaveProfilesCommand extends Command {
|
||||
|
@ -31,6 +36,37 @@ public static void saveProfile(ClientProfile profile, Path path) throws IOExcept
|
|||
serverProfile.serverPort = profile.getServerPort();
|
||||
profile.getServers().add(serverProfile);
|
||||
}
|
||||
for(OptionalFile file : profile.getOptional())
|
||||
{
|
||||
if(file.list != null)
|
||||
{
|
||||
String[] list = file.list;
|
||||
file.list = null;
|
||||
if(file.actions == null) file.actions = new ArrayList<>(2);
|
||||
OptionalAction action;
|
||||
switch (file.type)
|
||||
{
|
||||
case FILE:
|
||||
OptionalActionFile result = new OptionalActionFile(new HashMap<>());
|
||||
for(String s : list) result.files.put(s, "");
|
||||
action = result;
|
||||
break;
|
||||
case CLASSPATH:
|
||||
action = new OptionalActionClassPath(list);
|
||||
break;
|
||||
case JVMARGS:
|
||||
action = new OptionalActionJvmArgs(Arrays.asList(list));
|
||||
break;
|
||||
case CLIENTARGS:
|
||||
action = new OptionalActionClientArgs(Arrays.asList(list));
|
||||
break;
|
||||
default:
|
||||
LogHelper.warning("Not converted optional %s with type %s. Type unknown", file.name, file.type.toString());
|
||||
continue;
|
||||
}
|
||||
file.actions.add(action);
|
||||
}
|
||||
}
|
||||
try (Writer w = IOHelper.newWriter(path)) {
|
||||
Launcher.gsonManager.configGson.toJson(profile, w);
|
||||
}
|
||||
|
|
|
@ -184,16 +184,23 @@ public void updateOptionalGraph() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public OptionalFile getOptionalFile(String file, OptionalType type) {
|
||||
for (OptionalFile f : updateOptional)
|
||||
if (f.type.equals(type) && f.name.equals(file)) return f;
|
||||
return null;
|
||||
}
|
||||
|
||||
public OptionalFile getOptionalFile(String file) {
|
||||
for (OptionalFile f : updateOptional)
|
||||
if (f.name.equals(file)) return f;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Collection<String> getShared() {
|
||||
return updateShared;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void markOptional(OptionalFile file) {
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
import pro.gravit.launcher.profiles.optional.actions.OptionalAction;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class OptionalView {
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
package pro.gravit.launcher.profiles.optional.actions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OptionalActionClassPath extends OptionalAction {
|
||||
public String[] args;
|
||||
public boolean useAltClasspath = false;
|
||||
|
||||
public OptionalActionClassPath() {
|
||||
}
|
||||
|
||||
public OptionalActionClassPath(String[] args) {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public OptionalActionClassPath(String[] args, boolean useAltClasspath) {
|
||||
this.args = args;
|
||||
this.useAltClasspath = useAltClasspath;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,4 +4,11 @@
|
|||
|
||||
public class OptionalActionClientArgs extends OptionalAction {
|
||||
public List<String> args;
|
||||
|
||||
public OptionalActionClientArgs() {
|
||||
}
|
||||
|
||||
public OptionalActionClientArgs(List<String> args) {
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,4 +29,11 @@ public void disableInHashedDir(HashedDir dir)
|
|||
firstPath.parent.remove(firstPath.name);
|
||||
});
|
||||
}
|
||||
|
||||
public OptionalActionFile() {
|
||||
}
|
||||
|
||||
public OptionalActionFile(Map<String, String> files) {
|
||||
this.files = files;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,4 +4,11 @@
|
|||
|
||||
public class OptionalActionJvmArgs extends OptionalAction {
|
||||
public List<String> args;
|
||||
|
||||
public OptionalActionJvmArgs() {
|
||||
}
|
||||
|
||||
public OptionalActionJvmArgs(List<String> args) {
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue