Improve error handling around access widener remapping. Closes #311

This commit is contained in:
modmuss50 2021-01-21 20:30:08 +00:00
parent d91b722c35
commit 34a9d2316c

View file

@ -32,6 +32,7 @@ import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.zip.ZipEntry;
@ -87,6 +88,12 @@ public class AccessWidenerJarProcessor implements JarProcessor {
//Remap accessWidener if its not named, allows for AE's to be written in intermediary
if (!accessWidener.getNamespace().equals("named")) {
try {
List<String> validNamespaces = loomGradleExtension.getMappingsProvider().getMappings().getMetadata().getNamespaces();
if (!validNamespaces.contains(accessWidener.getNamespace())) {
throw new UnsupportedOperationException(String.format("Access Widener namespace '%s' is not a valid namespace, it must be one of: '%s'", accessWidener.getNamespace(), String.join(", ", validNamespaces)));
}
TinyRemapper tinyRemapper = loomGradleExtension.getMinecraftMappedProvider().getTinyRemapper("official", "named");
tinyRemapper.readClassPath(loomGradleExtension.getMinecraftMappedProvider().getRemapClasspath());