Commit 5cdae378f44c34cbd6283d0ae33c5a4eb1bdd816
1 parent
b36a1152
LiteLoader 1.6.4 - fixed NPE when no --version is specified, moved debug to alte…
…rnate src tree to avoid having to exclude it from all downstream build scripts
Showing
6 changed files
with
62 additions
and
2 deletions
.classpath
| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | <classpath> |
| 3 | 3 | <classpathentry kind="src" path="java"/> |
| 4 | 4 | <classpathentry kind="src" path="res"/> |
| 5 | + <classpathentry kind="src" path="debug"/> | |
| 5 | 6 | <classpathentry combineaccessrules="false" kind="src" path="/Client"/> |
| 6 | 7 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
| 7 | 8 | <classpathentry kind="lib" path="/Client/jars/libraries/org/lwjgl/lwjgl/lwjgl/2.9.0/lwjgl-2.9.0.jar"/> | ... | ... |
java/com/mumfrey/liteloader/debug/AuthenticationRequest.java renamed to debug/com/mumfrey/liteloader/debug/AuthenticationRequest.java
java/com/mumfrey/liteloader/debug/Start.java renamed to debug/com/mumfrey/liteloader/debug/Start.java
res/minecraft.key renamed to debug/minecraft.key
No preview for this file type
java/com/mumfrey/liteloader/core/EnabledModsList.java
| ... | ... | @@ -11,20 +11,47 @@ import java.util.TreeMap; |
| 11 | 11 | import com.google.gson.Gson; |
| 12 | 12 | import com.google.gson.GsonBuilder; |
| 13 | 13 | |
| 14 | +/** | |
| 15 | + * Serialisable (via GSON) object which stores list of enabled/disabled mods for each profile | |
| 16 | + * | |
| 17 | + * @author Adam Mummery-Smith | |
| 18 | + */ | |
| 14 | 19 | public class EnabledModsList |
| 15 | 20 | { |
| 21 | + @SuppressWarnings("unused") | |
| 22 | + private static transient final long serialVersionUID = -6449451105617763769L; | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * Gson object for serialisation/deserialisation | |
| 26 | + */ | |
| 16 | 27 | private static transient Gson gson = new GsonBuilder().setPrettyPrinting().create(); |
| 17 | 28 | |
| 29 | + /** | |
| 30 | + * This is the node which gets serialised | |
| 31 | + */ | |
| 18 | 32 | private TreeMap<String, TreeMap<String, Boolean>> mods; |
| 19 | 33 | |
| 34 | + /** | |
| 35 | + * By default, when we discover a mod which is NOT in the list for the current profile, we will ENABLE the | |
| 36 | + * mod and add it to the list. However, when we receive a list of mods on the command line, we instead want | |
| 37 | + * to DISABLE any additional unlisted mods, we also don't want to save the mods list because the command line | |
| 38 | + * is supposed to be an override rather than a new mask. These two values provide this behaviour. | |
| 39 | + */ | |
| 20 | 40 | private transient Boolean defaultEnabledValue = Boolean.TRUE; |
| 21 | - | |
| 22 | 41 | private transient boolean allowSave = true; |
| 23 | 42 | |
| 24 | 43 | private EnabledModsList() |
| 25 | 44 | { |
| 45 | + // Private because we are always instanced by the static createFrom() method below | |
| 26 | 46 | } |
| 27 | 47 | |
| 48 | + /** | |
| 49 | + * Check whether a particular mod is enabled | |
| 50 | + * | |
| 51 | + * @param profileName | |
| 52 | + * @param name | |
| 53 | + * @return | |
| 54 | + */ | |
| 28 | 55 | public boolean isEnabled(String profileName, String name) |
| 29 | 56 | { |
| 30 | 57 | Map<String, Boolean> profile = this.getProfile(profileName); |
| ... | ... | @@ -38,6 +65,13 @@ public class EnabledModsList |
| 38 | 65 | return profile.get(name); |
| 39 | 66 | } |
| 40 | 67 | |
| 68 | + /** | |
| 69 | + * Set the enablement state of a mod in the specified profile | |
| 70 | + * | |
| 71 | + * @param profileName | |
| 72 | + * @param name | |
| 73 | + * @param enabled | |
| 74 | + */ | |
| 41 | 75 | public void setEnabled(String profileName, String name, boolean enabled) |
| 42 | 76 | { |
| 43 | 77 | Map<String, Boolean> profile = this.getProfile(profileName); |
| ... | ... | @@ -46,6 +80,12 @@ public class EnabledModsList |
| 46 | 80 | this.allowSave = true; |
| 47 | 81 | } |
| 48 | 82 | |
| 83 | + /** | |
| 84 | + * Reads the mods list passed in on the command line | |
| 85 | + * | |
| 86 | + * @param profileName | |
| 87 | + * @param modNameFilter | |
| 88 | + */ | |
| 49 | 89 | public void processModsList(String profileName, List<String> modNameFilter) |
| 50 | 90 | { |
| 51 | 91 | Map<String, Boolean> profile = this.getProfile(profileName); |
| ... | ... | @@ -75,8 +115,15 @@ public class EnabledModsList |
| 75 | 115 | } |
| 76 | 116 | } |
| 77 | 117 | |
| 118 | + /** | |
| 119 | + * Internal method which returns the map for the specified profile | |
| 120 | + * | |
| 121 | + * @param profileName | |
| 122 | + * @return | |
| 123 | + */ | |
| 78 | 124 | private Map<String, Boolean> getProfile(String profileName) |
| 79 | 125 | { |
| 126 | + if (profileName == null) profileName = "default"; | |
| 80 | 127 | if (this.mods == null) this.mods = new TreeMap<String, TreeMap<String,Boolean>>(); |
| 81 | 128 | |
| 82 | 129 | if (!this.mods.containsKey(profileName)) |
| ... | ... | @@ -87,6 +134,13 @@ public class EnabledModsList |
| 87 | 134 | return this.mods.get(profileName); |
| 88 | 135 | } |
| 89 | 136 | |
| 137 | + /** | |
| 138 | + * Factory method which tries to deserialise the enablement list from the file or if failing creates | |
| 139 | + * and returns a new instance. | |
| 140 | + * | |
| 141 | + * @param file | |
| 142 | + * @return | |
| 143 | + */ | |
| 90 | 144 | public static EnabledModsList createFrom(File file) |
| 91 | 145 | { |
| 92 | 146 | if (file.exists()) |
| ... | ... | @@ -120,6 +174,11 @@ public class EnabledModsList |
| 120 | 174 | return new EnabledModsList(); |
| 121 | 175 | } |
| 122 | 176 | |
| 177 | + /** | |
| 178 | + * Save the enablement list to the specified file | |
| 179 | + * | |
| 180 | + * @param file | |
| 181 | + */ | |
| 123 | 182 | public void saveTo(File file) |
| 124 | 183 | { |
| 125 | 184 | if (!this.allowSave) return; | ... | ... |
java/com/mumfrey/liteloader/launch/LiteLoaderTweaker.java
| ... | ... | @@ -48,7 +48,7 @@ public class LiteLoaderTweaker implements ITweaker |
| 48 | 48 | |
| 49 | 49 | LiteLoaderTransformer.gameDirectory = gameDirectory; |
| 50 | 50 | LiteLoaderTransformer.assetsDirectory = assetsDirectory; |
| 51 | - LiteLoaderTransformer.profile = profile; | |
| 51 | + LiteLoaderTransformer.profile = profile != null ? profile : VERSION; | |
| 52 | 52 | |
| 53 | 53 | OptionParser optionParser = new OptionParser(); |
| 54 | 54 | this.modsOption = optionParser.accepts("mods", "Comma-separated list of mods to load").withRequiredArg().ofType(String.class).withValuesSeparatedBy(','); | ... | ... |