Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.google.common.io.Closeables;
import org.spongepowered.asm.logging.Level;
import org.spongepowered.asm.logging.ILogger;
import org.spongepowered.asm.launch.MixinInitialisationError;
Expand Down Expand Up @@ -1381,13 +1382,15 @@ public int compareTo(MixinConfig other) {
* @return new Config
*/
static Config create(String configFile, MixinEnvironment outer, IMixinConfigSource source) {
InputStreamReader reader = null;
try {
IMixinService service = MixinService.getService();
InputStream resource = service.getResourceAsStream(configFile);
if (resource == null) {
throw new IllegalArgumentException(String.format("The specified resource '%s' was invalid or could not be read", configFile));
}
MixinConfig config = new Gson().fromJson(new InputStreamReader(resource), MixinConfig.class);
reader = new InputStreamReader(resource);
MixinConfig config = new Gson().fromJson(reader, MixinConfig.class);
if (config.onLoad(service, configFile, outer, source)) {
return config.getHandle();
}
Expand All @@ -1396,6 +1399,8 @@ static Config create(String configFile, MixinEnvironment outer, IMixinConfigSour
throw ex;
} catch (Exception ex) {
throw new IllegalArgumentException(String.format("The specified resource '%s' was invalid or could not be read", configFile), ex);
} finally {
Closeables.closeQuietly(reader);
}
}

Expand Down