Commit b36a1152480f6cbb7ec354f8810015cb28e837ff
1 parent
6bcb9901
LiteLoader 1.6.4 - modified tweaker to support new argument list contract
Showing
1 changed file
with
27 additions
and
31 deletions
java/com/mumfrey/liteloader/launch/LiteLoaderTweaker.java
... | ... | @@ -29,15 +29,16 @@ public class LiteLoaderTweaker implements ITweaker |
29 | 29 | |
30 | 30 | private String profile; |
31 | 31 | |
32 | - private List<String> unClassifiedArgs = new ArrayList<String>(); | |
32 | + private List<String> singularLaunchArgs = new ArrayList<String>(); | |
33 | 33 | |
34 | - private Map<String, String> classifiedArgs = new HashMap<String, String>(); | |
34 | + private Map<String, String> launchArgs; | |
35 | 35 | |
36 | 36 | private ArgumentAcceptingOptionSpec<String> modsOption; |
37 | 37 | private OptionSet parsedOptions; |
38 | 38 | |
39 | 39 | private List<String> passThroughArgs; |
40 | 40 | |
41 | + @SuppressWarnings("unchecked") | |
41 | 42 | @Override |
42 | 43 | public void acceptOptions(List<String> args, File gameDirectory, File assetsDirectory, String profile) |
43 | 44 | { |
... | ... | @@ -57,6 +58,13 @@ public class LiteLoaderTweaker implements ITweaker |
57 | 58 | this.parsedOptions = optionParser.parse(args.toArray(new String[args.size()])); |
58 | 59 | this.passThroughArgs = this.parsedOptions.valuesOf(nonOptions); |
59 | 60 | |
61 | + this.launchArgs = (Map<String, String>)Launch.blackboard.get("launchArgs"); | |
62 | + if (this.launchArgs == null) | |
63 | + { | |
64 | + this.launchArgs = new HashMap<String, String>(); | |
65 | + Launch.blackboard.put("launchArgs", this.launchArgs); | |
66 | + } | |
67 | + | |
60 | 68 | // Parse out the arguments ourself because joptsimple doesn't really provide a good way to |
61 | 69 | // add arguments to the unparsed argument list after parsing |
62 | 70 | this.parseArgs(this.passThroughArgs); |
... | ... | @@ -76,29 +84,14 @@ public class LiteLoaderTweaker implements ITweaker |
76 | 84 | */ |
77 | 85 | public void provideRequiredArgs(File gameDirectory, File assetsDirectory) |
78 | 86 | { |
79 | - @SuppressWarnings("unchecked") | |
80 | - final List<String> argumentList = (List<String>)Launch.blackboard.get("ArgumentList"); | |
87 | + if (!this.launchArgs.containsKey("--version")) | |
88 | + this.addClassifiedArg("--version", this.VERSION); | |
81 | 89 | |
82 | - if (argumentList != null) | |
83 | - { | |
84 | - if (!argumentList.contains("--version")) | |
85 | - { | |
86 | - argumentList.add("--version"); | |
87 | - argumentList.add(this.VERSION); | |
88 | - } | |
89 | - | |
90 | - if (!argumentList.contains("--gameDir") && gameDirectory != null) | |
91 | - { | |
92 | - argumentList.add("--gameDir"); | |
93 | - argumentList.add(gameDirectory.getAbsolutePath()); | |
94 | - } | |
95 | - | |
96 | - if (!argumentList.contains("--assetsDir") && assetsDirectory != null) | |
97 | - { | |
98 | - argumentList.add("--assetsDir"); | |
99 | - argumentList.add(assetsDirectory.getAbsolutePath()); | |
100 | - } | |
101 | - } | |
90 | + if (!this.launchArgs.containsKey("--gameDir") && gameDirectory != null) | |
91 | + this.addClassifiedArg("--gameDir", gameDirectory.getAbsolutePath()); | |
92 | + | |
93 | + if (!this.launchArgs.containsKey("--assetsDir") && assetsDirectory != null) | |
94 | + this.addClassifiedArg("--assetsDir", assetsDirectory.getAbsolutePath()); | |
102 | 95 | } |
103 | 96 | |
104 | 97 | private void parseArgs(List<String> args) |
... | ... | @@ -121,14 +114,14 @@ public class LiteLoaderTweaker implements ITweaker |
121 | 114 | if (classifier != null) |
122 | 115 | classifier = this.addClassifiedArg(classifier, arg); |
123 | 116 | else |
124 | - this.unClassifiedArgs.add(arg); | |
117 | + this.singularLaunchArgs.add(arg); | |
125 | 118 | } |
126 | 119 | } |
127 | 120 | } |
128 | 121 | |
129 | 122 | private String addClassifiedArg(String classifiedArg, String arg) |
130 | 123 | { |
131 | - this.classifiedArgs.put(classifiedArg, arg); | |
124 | + this.launchArgs.put(classifiedArg, arg); | |
132 | 125 | return null; |
133 | 126 | } |
134 | 127 | |
... | ... | @@ -136,7 +129,7 @@ public class LiteLoaderTweaker implements ITweaker |
136 | 129 | public void injectIntoClassLoader(LaunchClassLoader classLoader) |
137 | 130 | { |
138 | 131 | LiteLoaderTransformer.launchClassLoader = classLoader; |
139 | - classLoader.registerTransformer("com.mumfrey.liteloader.launch.LiteLoaderTransformer"); | |
132 | + classLoader.registerTransformer(LiteLoaderTransformer.class.getName()); | |
140 | 133 | } |
141 | 134 | |
142 | 135 | @Override |
... | ... | @@ -150,15 +143,18 @@ public class LiteLoaderTweaker implements ITweaker |
150 | 143 | { |
151 | 144 | List<String> args = new ArrayList<String>(); |
152 | 145 | |
153 | - for (String unClassifiedArg : this.unClassifiedArgs) | |
146 | + for (String unClassifiedArg : this.singularLaunchArgs) | |
154 | 147 | args.add(unClassifiedArg); |
155 | 148 | |
156 | - for (Entry<String, String> classifiedArg : this.classifiedArgs.entrySet()) | |
149 | + for (Entry<String, String> launchArg : this.launchArgs.entrySet()) | |
157 | 150 | { |
158 | - args.add(classifiedArg.getKey().trim()); | |
159 | - args.add(classifiedArg.getValue().trim()); | |
151 | + args.add(launchArg.getKey().trim()); | |
152 | + args.add(launchArg.getValue().trim()); | |
160 | 153 | } |
161 | 154 | |
155 | + this.singularLaunchArgs.clear(); | |
156 | + this.launchArgs.clear(); | |
157 | + | |
162 | 158 | return args.toArray(new String[args.size()]); |
163 | 159 | } |
164 | 160 | ... | ... |