> patches) {
this.patches = patches.apply(this);
}
diff --git a/src/main/java/net/fabricmc/loader/gui/FabricGuiEntry.java b/src/main/java/net/fabricmc/loader/impl/gui/FabricGuiEntry.java
similarity index 84%
rename from src/main/java/net/fabricmc/loader/gui/FabricGuiEntry.java
rename to src/main/java/net/fabricmc/loader/impl/gui/FabricGuiEntry.java
index 05b6e7a9f..075d58b8c 100644
--- a/src/main/java/net/fabricmc/loader/gui/FabricGuiEntry.java
+++ b/src/main/java/net/fabricmc/loader/impl/gui/FabricGuiEntry.java
@@ -14,16 +14,16 @@
* limitations under the License.
*/
-package net.fabricmc.loader.gui;
+package net.fabricmc.loader.impl.gui;
import java.awt.GraphicsEnvironment;
import java.util.HashSet;
import java.util.Set;
-import net.fabricmc.loader.FabricLoader;
-import net.fabricmc.loader.game.GameProvider;
-import net.fabricmc.loader.gui.FabricStatusTree.FabricStatusNode;
-import net.fabricmc.loader.gui.FabricStatusTree.FabricStatusTab;
+import net.fabricmc.loader.impl.FabricLoaderImpl;
+import net.fabricmc.loader.impl.game.GameProvider;
+import net.fabricmc.loader.impl.gui.FabricStatusTree.FabricStatusNode;
+import net.fabricmc.loader.impl.gui.FabricStatusTree.FabricStatusTab;
/** The main entry point for all fabric-based stuff. */
public final class FabricGuiEntry {
@@ -40,11 +40,10 @@ private static void openWindow(FabricStatusTree tree, boolean shouldWait) throws
/** @param exitAfter If true then this will call {@link System#exit(int)} after showing the gui, otherwise this will
* return normally. */
- @SuppressWarnings("deprecation")
public static void displayCriticalError(Throwable exception, boolean exitAfter) {
- FabricLoader.INSTANCE.getLogger().fatal("A critical error occurred", exception);
+ FabricLoaderImpl.INSTANCE.getLogger().fatal("A critical error occurred", exception);
- GameProvider provider = FabricLoader.INSTANCE.getGameProvider();
+ GameProvider provider = FabricLoaderImpl.INSTANCE.getGameProvider();
if ((provider == null || provider.canOpenErrorGui()) && !GraphicsEnvironment.isHeadless()) {
FabricStatusTree tree = new FabricStatusTree();
@@ -61,7 +60,7 @@ public static void displayCriticalError(Throwable exception, boolean exitAfter)
open(tree);
} catch (Exception e) {
if (exitAfter) {
- FabricLoader.INSTANCE.getLogger().warn("Failed to open the error gui!", e);
+ FabricLoaderImpl.INSTANCE.getLogger().warn("Failed to open the error gui!", e);
} else {
throw new RuntimeException("Failed to open the error gui!", e);
}
diff --git a/src/main/java/net/fabricmc/loader/gui/FabricMainWindow.java b/src/main/java/net/fabricmc/loader/impl/gui/FabricMainWindow.java
similarity index 97%
rename from src/main/java/net/fabricmc/loader/gui/FabricMainWindow.java
rename to src/main/java/net/fabricmc/loader/impl/gui/FabricMainWindow.java
index e41ebe179..2473a9f2b 100644
--- a/src/main/java/net/fabricmc/loader/gui/FabricMainWindow.java
+++ b/src/main/java/net/fabricmc/loader/impl/gui/FabricMainWindow.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.gui;
+package net.fabricmc.loader.impl.gui;
import java.awt.BorderLayout;
import java.awt.Component;
@@ -60,10 +60,10 @@
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
-import net.fabricmc.loader.gui.FabricStatusTree.FabricStatusButton;
-import net.fabricmc.loader.gui.FabricStatusTree.FabricStatusNode;
-import net.fabricmc.loader.gui.FabricStatusTree.FabricStatusTab;
-import net.fabricmc.loader.gui.FabricStatusTree.FabricTreeWarningLevel;
+import net.fabricmc.loader.impl.gui.FabricStatusTree.FabricStatusButton;
+import net.fabricmc.loader.impl.gui.FabricStatusTree.FabricStatusNode;
+import net.fabricmc.loader.impl.gui.FabricStatusTree.FabricStatusTab;
+import net.fabricmc.loader.impl.gui.FabricStatusTree.FabricTreeWarningLevel;
class FabricMainWindow {
static Icon missingIcon = null;
diff --git a/src/main/java/net/fabricmc/loader/gui/FabricStatusTree.java b/src/main/java/net/fabricmc/loader/impl/gui/FabricStatusTree.java
similarity index 99%
rename from src/main/java/net/fabricmc/loader/gui/FabricStatusTree.java
rename to src/main/java/net/fabricmc/loader/impl/gui/FabricStatusTree.java
index 178bb8cc9..2423786b9 100644
--- a/src/main/java/net/fabricmc/loader/gui/FabricStatusTree.java
+++ b/src/main/java/net/fabricmc/loader/impl/gui/FabricStatusTree.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.gui;
+package net.fabricmc.loader.impl.gui;
import java.io.PrintWriter;
import java.io.StringWriter;
diff --git a/src/main/java/net/fabricmc/loader/gui/package-info.java b/src/main/java/net/fabricmc/loader/impl/gui/package-info.java
similarity index 95%
rename from src/main/java/net/fabricmc/loader/gui/package-info.java
rename to src/main/java/net/fabricmc/loader/impl/gui/package-info.java
index 7619e925d..b95ee014c 100644
--- a/src/main/java/net/fabricmc/loader/gui/package-info.java
+++ b/src/main/java/net/fabricmc/loader/impl/gui/package-info.java
@@ -19,4 +19,4 @@
*
* This could potentially be useful for showing an tree-like structure while in-game, however this usecase is rather
* limited. */
-package net.fabricmc.loader.gui;
+package net.fabricmc.loader.impl.gui;
diff --git a/src/main/java/net/fabricmc/loader/impl/launch/FabricLauncher.java b/src/main/java/net/fabricmc/loader/impl/launch/FabricLauncher.java
new file mode 100644
index 000000000..5ad6005ca
--- /dev/null
+++ b/src/main/java/net/fabricmc/loader/impl/launch/FabricLauncher.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016 FabricMC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.fabricmc.loader.impl.launch;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collection;
+
+import net.fabricmc.api.EnvType;
+
+public interface FabricLauncher {
+ MappingConfiguration getMappingConfiguration();
+
+ void propose(URL url);
+
+ EnvType getEnvironmentType();
+
+ boolean isClassLoaded(String name);
+
+ InputStream getResourceAsStream(String name);
+
+ ClassLoader getTargetClassLoader();
+
+ /**
+ * Gets the byte array for a particular class.
+ *
+ * @param name The name of the class to retrieve
+ * @param runTransformers Whether to run all transformers except mixin on the class
+ */
+ byte[] getClassByteArray(String name, boolean runTransformers) throws IOException;
+
+ boolean isDevelopment();
+
+ String getEntrypoint();
+
+ String getTargetNamespace();
+
+ Collection getLoadTimeDependencies();
+}
diff --git a/src/main/java/net/fabricmc/loader/impl/launch/FabricLauncherBase.java b/src/main/java/net/fabricmc/loader/impl/launch/FabricLauncherBase.java
new file mode 100644
index 000000000..155d3c771
--- /dev/null
+++ b/src/main/java/net/fabricmc/loader/impl/launch/FabricLauncherBase.java
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2016 FabricMC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.fabricmc.loader.impl.launch;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URL;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarFile;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.spongepowered.asm.mixin.MixinEnvironment;
+
+import net.fabricmc.api.EnvType;
+import net.fabricmc.loader.impl.util.Arguments;
+import net.fabricmc.loader.impl.util.UrlConversionException;
+import net.fabricmc.loader.impl.util.UrlUtil;
+import net.fabricmc.loader.impl.util.mappings.TinyRemapperMappingsHelper;
+import net.fabricmc.mapping.tree.TinyTree;
+import net.fabricmc.tinyremapper.OutputConsumerPath;
+import net.fabricmc.tinyremapper.TinyRemapper;
+
+public abstract class FabricLauncherBase implements FabricLauncher {
+ public static Path minecraftJar;
+
+ protected static Logger LOGGER = LogManager.getFormatterLogger("FabricLoader");
+ private static boolean mixinReady;
+ private static Map properties;
+ private static FabricLauncher launcher;
+ private static MappingConfiguration mappingConfiguration = new MappingConfiguration();
+
+ protected FabricLauncherBase() {
+ setLauncher(this);
+ }
+
+ public static File getLaunchDirectory(Arguments argMap) {
+ return new File(argMap.getOrDefault("gameDir", "."));
+ }
+
+ public static Class> getClass(String className) throws ClassNotFoundException {
+ return Class.forName(className, true, getLauncher().getTargetClassLoader());
+ }
+
+ @Override
+ public MappingConfiguration getMappingConfiguration() {
+ return mappingConfiguration;
+ }
+
+ private static boolean emittedInfo = false;
+
+ protected static Path deobfuscate(String gameId, String gameVersion, Path gameDir, Path jarFile, FabricLauncher launcher) {
+ if (!Files.exists(jarFile)) {
+ throw new RuntimeException("Could not locate Minecraft: " + jarFile + " not found");
+ }
+
+ LOGGER.debug("Requesting deobfuscation of " + jarFile.getFileName());
+
+ if (!launcher.isDevelopment()) { // in-dev is already deobfuscated
+ Path deobfJarDir = gameDir.resolve(".fabric").resolve("remappedJars");
+
+ if (!gameId.isEmpty()) {
+ String versionedId = gameVersion.isEmpty() ? gameId : String.format("%s-%s", gameId, gameVersion);
+ deobfJarDir = deobfJarDir.resolve(versionedId);
+ }
+
+ String targetNamespace = mappingConfiguration.getTargetNamespace();
+ // TODO: allow versioning mappings?
+ String deobfJarFilename = targetNamespace + "-" + jarFile.getFileName();
+ Path deobfJarFile = deobfJarDir.resolve(deobfJarFilename);
+ Path deobfJarFileTmp = deobfJarDir.resolve(deobfJarFilename + ".tmp");
+
+ if (Files.exists(deobfJarFileTmp)) { // previous unfinished remap attempt
+ LOGGER.warn("Incomplete remapped file found! This means that the remapping process failed on the previous launch. If this persists, make sure to let us at Fabric know!");
+
+ try {
+ Files.deleteIfExists(deobfJarFile);
+ Files.deleteIfExists(deobfJarFileTmp);
+ } catch (IOException e) {
+ throw new RuntimeException("can't delete incompletely remapped files", e);
+ }
+ }
+
+ TinyTree mappings;
+
+ if (!Files.exists(deobfJarFile)
+ && (mappings = mappingConfiguration.getMappings()) != null
+ && mappings.getMetadata().getNamespaces().contains(targetNamespace)) {
+ LOGGER.debug("Fabric mapping file detected, applying...");
+
+ if (!emittedInfo) {
+ LOGGER.info("Fabric is preparing JARs on first launch, this may take a few seconds...");
+ emittedInfo = true;
+ }
+
+ try {
+ deobfuscate0(jarFile, deobfJarFile, deobfJarFileTmp, mappings, targetNamespace);
+ } catch (IOException e) {
+ throw new RuntimeException("error remapping game jar "+jarFile, e);
+ }
+ }
+
+ jarFile = deobfJarFile;
+ }
+
+ try {
+ launcher.propose(UrlUtil.asUrl(jarFile));
+ } catch (UrlConversionException e) {
+ throw new RuntimeException(e);
+ }
+
+ if (minecraftJar == null) {
+ minecraftJar = jarFile;
+ }
+
+ return jarFile;
+ }
+
+ private static void deobfuscate0(Path jarFile, Path deobfJarFile, Path deobfJarFileTmp, TinyTree mappings, String targetNamespace) throws IOException {
+ Files.createDirectories(deobfJarFile.getParent());
+
+ boolean found;
+
+ do {
+ TinyRemapper remapper = TinyRemapper.newRemapper()
+ .withMappings(TinyRemapperMappingsHelper.create(mappings, "official", targetNamespace))
+ .rebuildSourceFilenames(true)
+ .build();
+
+ Set depPaths = new HashSet<>();
+
+ for (URL url : launcher.getLoadTimeDependencies()) {
+ try {
+ Path path = UrlUtil.asPath(url);
+
+ if (!Files.exists(path)) {
+ throw new RuntimeException("Path does not exist: " + path);
+ }
+
+ if (!path.equals(jarFile)) {
+ depPaths.add(path);
+ }
+ } catch (UrlConversionException e) {
+ throw new RuntimeException("Failed to convert '" + url + "' to path!", e);
+ }
+ }
+
+ try (OutputConsumerPath outputConsumer = new OutputConsumerPath.Builder(deobfJarFileTmp)
+ // force jar despite the .tmp extension
+ .assumeArchive(true)
+ // don't accept class names from a blacklist of dependencies that Fabric itself utilizes
+ // TODO: really could use a better solution, as always...
+ .filter(clsName -> !clsName.startsWith("com/google/common/")
+ && !clsName.startsWith("com/google/gson/")
+ && !clsName.startsWith("com/google/thirdparty/")
+ && !clsName.startsWith("org/apache/logging/log4j/"))
+ .build()) {
+ for (Path path : depPaths) {
+ LOGGER.debug("Appending '" + path + "' to remapper classpath");
+ remapper.readClassPath(path);
+ }
+
+ remapper.readInputs(jarFile);
+ remapper.apply(outputConsumer);
+ } finally {
+ remapper.finish();
+ }
+
+ // Minecraft doesn't tend to check if a ZipFileSystem is already present,
+ // so we clean up here.
+
+ depPaths.add(deobfJarFileTmp);
+
+ for (Path p : depPaths) {
+ try {
+ p.getFileSystem().close();
+ } catch (Exception e) {
+ // pass
+ }
+
+ try {
+ FileSystems.getFileSystem(new URI("jar:" + p.toUri())).close();
+ } catch (Exception e) {
+ // pass
+ }
+ }
+
+ try (JarFile jar = new JarFile(deobfJarFileTmp.toFile())) {
+ found = jar.stream().anyMatch((e) -> e.getName().endsWith(".class"));
+ }
+
+ if (!found) {
+ LOGGER.error("Generated deobfuscated JAR contains no classes! Trying again...");
+ Files.delete(deobfJarFileTmp);
+ } else {
+ Files.move(deobfJarFileTmp, deobfJarFile);
+ }
+ } while (!found);
+
+ if (!Files.exists(deobfJarFile)) {
+ throw new RuntimeException("Remapped .JAR file does not exist after remapping! Cannot continue!");
+ }
+ }
+
+ public static void processArgumentMap(Arguments argMap, EnvType envType) {
+ switch (envType) {
+ case CLIENT:
+ if (!argMap.containsKey("accessToken")) {
+ argMap.put("accessToken", "FabricMC");
+ }
+
+ if (!argMap.containsKey("version")) {
+ argMap.put("version", "Fabric");
+ }
+
+ String versionType = "";
+
+ if (argMap.containsKey("versionType") && !argMap.get("versionType").equalsIgnoreCase("release")) {
+ versionType = argMap.get("versionType") + "/";
+ }
+
+ argMap.put("versionType", versionType + "Fabric");
+
+ if (!argMap.containsKey("gameDir")) {
+ argMap.put("gameDir", getLaunchDirectory(argMap).getAbsolutePath());
+ }
+
+ break;
+ case SERVER:
+ argMap.remove("version");
+ argMap.remove("gameDir");
+ argMap.remove("assetsDir");
+ break;
+ }
+ }
+
+ protected static void setProperties(Map propertiesA) {
+ if (properties != null && properties != propertiesA) {
+ throw new RuntimeException("Duplicate setProperties call!");
+ }
+
+ properties = propertiesA;
+ }
+
+ private static void setLauncher(FabricLauncher launcherA) {
+ if (launcher != null && launcher != launcherA) {
+ throw new RuntimeException("Duplicate setLauncher call!");
+ }
+
+ launcher = launcherA;
+ }
+
+ public static FabricLauncher getLauncher() {
+ return launcher;
+ }
+
+ public static Map getProperties() {
+ return properties;
+ }
+
+ protected static void finishMixinBootstrapping() {
+ if (mixinReady) {
+ throw new RuntimeException("Must not call FabricLauncherBase.finishMixinBootstrapping() twice!");
+ }
+
+ try {
+ Method m = MixinEnvironment.class.getDeclaredMethod("gotoPhase", MixinEnvironment.Phase.class);
+ m.setAccessible(true);
+ m.invoke(null, MixinEnvironment.Phase.INIT);
+ m.invoke(null, MixinEnvironment.Phase.DEFAULT);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ mixinReady = true;
+ }
+
+ public static boolean isMixinReady() {
+ return mixinReady;
+ }
+}
diff --git a/src/main/java/net/fabricmc/loader/launch/common/FabricMixinBootstrap.java b/src/main/java/net/fabricmc/loader/impl/launch/FabricMixinBootstrap.java
similarity index 88%
rename from src/main/java/net/fabricmc/loader/launch/common/FabricMixinBootstrap.java
rename to src/main/java/net/fabricmc/loader/impl/launch/FabricMixinBootstrap.java
index 4dd9cc023..686644730 100644
--- a/src/main/java/net/fabricmc/loader/launch/common/FabricMixinBootstrap.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/FabricMixinBootstrap.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.common;
+package net.fabricmc.loader.impl.launch;
import java.util.List;
import java.util.Set;
@@ -27,10 +27,10 @@
import org.spongepowered.asm.mixin.Mixins;
import net.fabricmc.api.EnvType;
-import net.fabricmc.loader.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
-import net.fabricmc.loader.metadata.LoaderModMetadata;
-import net.fabricmc.loader.util.mappings.MixinIntermediaryDevRemapper;
+import net.fabricmc.loader.impl.FabricLoaderImpl;
+import net.fabricmc.loader.impl.metadata.LoaderModMetadata;
+import net.fabricmc.loader.impl.util.mappings.MixinIntermediaryDevRemapper;
import net.fabricmc.mapping.tree.TinyTree;
public final class FabricMixinBootstrap {
@@ -43,7 +43,7 @@ static void addConfiguration(String configuration) {
Mixins.addConfiguration(configuration);
}
- static Set getMixinConfigs(FabricLoader loader, EnvType type) {
+ static Set getMixinConfigs(FabricLoaderImpl loader, EnvType type) {
return loader.getAllMods().stream()
.map(ModContainer::getMetadata)
.filter((m) -> m instanceof LoaderModMetadata)
@@ -52,7 +52,7 @@ static Set getMixinConfigs(FabricLoader loader, EnvType type) {
.collect(Collectors.toSet());
}
- public static void init(EnvType side, FabricLoader loader) {
+ public static void init(EnvType side, FabricLoaderImpl loader) {
if (initialized) {
throw new RuntimeException("FabricMixinBootstrap has already been initialized!");
}
diff --git a/src/main/java/net/fabricmc/loader/impl/launch/MappingConfiguration.java b/src/main/java/net/fabricmc/loader/impl/launch/MappingConfiguration.java
new file mode 100644
index 000000000..6c2ea88e9
--- /dev/null
+++ b/src/main/java/net/fabricmc/loader/impl/launch/MappingConfiguration.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2016 FabricMC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.fabricmc.loader.impl.launch;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import net.fabricmc.mapping.tree.TinyMappingFactory;
+import net.fabricmc.mapping.tree.TinyTree;
+
+public class MappingConfiguration {
+ protected static Logger LOGGER = LogManager.getFormatterLogger("FabricLoader");
+
+ private static TinyTree mappings;
+ private static boolean checkedMappings;
+
+ public TinyTree getMappings() {
+ if (!checkedMappings) {
+ InputStream mappingStream = FabricLauncherBase.class.getClassLoader().getResourceAsStream("mappings/mappings.tiny");
+
+ if (mappingStream != null) {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(mappingStream))) {
+ long time = System.currentTimeMillis();
+ mappings = TinyMappingFactory.loadWithDetection(reader);
+ LOGGER.debug("Loading mappings took " + (System.currentTimeMillis() - time) + " ms");
+ } catch (IOException ee) {
+ ee.printStackTrace();
+ }
+
+ try {
+ mappingStream.close();
+ } catch (IOException ee) {
+ ee.printStackTrace();
+ }
+ }
+
+ if (mappings == null) {
+ LOGGER.info("Mappings not present!");
+ mappings = TinyMappingFactory.EMPTY_TREE;
+ }
+
+ checkedMappings = true;
+ }
+
+ return mappings;
+ }
+
+ public String getTargetNamespace() {
+ return FabricLauncherBase.getLauncher().isDevelopment() ? "named" : "intermediary";
+ }
+
+ public boolean requiresPackageAccessHack() {
+ // TODO
+ return getTargetNamespace().equals("named");
+ }
+}
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/DummyClassLoader.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/DummyClassLoader.java
similarity index 96%
rename from src/main/java/net/fabricmc/loader/launch/knot/DummyClassLoader.java
rename to src/main/java/net/fabricmc/loader/impl/launch/knot/DummyClassLoader.java
index 27055b8ed..77a9da076 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/DummyClassLoader.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/DummyClassLoader.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.knot;
+package net.fabricmc.loader.impl.launch.knot;
import java.io.IOException;
import java.net.URL;
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/FabricGlobalPropertyService.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/FabricGlobalPropertyService.java
similarity index 94%
rename from src/main/java/net/fabricmc/loader/launch/knot/FabricGlobalPropertyService.java
rename to src/main/java/net/fabricmc/loader/impl/launch/knot/FabricGlobalPropertyService.java
index a0387ffa6..e8eea25cc 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/FabricGlobalPropertyService.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/FabricGlobalPropertyService.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.knot;
+package net.fabricmc.loader.impl.launch.knot;
import org.spongepowered.asm.service.IGlobalPropertyService;
import org.spongepowered.asm.service.IPropertyKey;
-import net.fabricmc.loader.launch.common.FabricLauncherBase;
+import net.fabricmc.loader.impl.launch.FabricLauncherBase;
public class FabricGlobalPropertyService implements IGlobalPropertyService {
@Override
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/Knot.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/Knot.java
similarity index 86%
rename from src/main/java/net/fabricmc/loader/launch/knot/Knot.java
rename to src/main/java/net/fabricmc/loader/impl/launch/knot/Knot.java
index 52c32543a..8526ea042 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/Knot.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/Knot.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.knot;
+package net.fabricmc.loader.impl.launch.knot;
import java.io.File;
import java.io.IOException;
@@ -33,16 +33,16 @@
import org.spongepowered.asm.launch.MixinBootstrap;
import net.fabricmc.api.EnvType;
-import net.fabricmc.loader.FabricLoader;
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
-import net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointUtils;
-import net.fabricmc.loader.game.GameProvider;
-import net.fabricmc.loader.game.GameProviders;
-import net.fabricmc.loader.launch.common.FabricLauncherBase;
-import net.fabricmc.loader.launch.common.FabricMixinBootstrap;
-import net.fabricmc.loader.util.SystemProperties;
-import net.fabricmc.loader.util.UrlConversionException;
-import net.fabricmc.loader.util.UrlUtil;
+import net.fabricmc.loader.impl.FabricLoaderImpl;
+import net.fabricmc.loader.impl.entrypoint.EntrypointUtils;
+import net.fabricmc.loader.impl.game.GameProvider;
+import net.fabricmc.loader.impl.game.GameProviders;
+import net.fabricmc.loader.impl.launch.FabricLauncherBase;
+import net.fabricmc.loader.impl.launch.FabricMixinBootstrap;
+import net.fabricmc.loader.impl.util.SystemProperties;
+import net.fabricmc.loader.impl.util.UrlConversionException;
+import net.fabricmc.loader.impl.util.UrlUtil;
public final class Knot extends FabricLauncherBase {
protected Map properties = new HashMap<>();
@@ -53,12 +53,23 @@ public final class Knot extends FabricLauncherBase {
private final File gameJarFile;
private GameProvider provider;
+ public static void launch(String[] args, EnvType type) {
+ String gameJarPath = System.getProperty(SystemProperties.GAME_JAR_PATH);
+ Knot knot = new Knot(type, gameJarPath != null ? new File(gameJarPath) : null);
+ ClassLoader cl = knot.init(args);
+
+ if (knot.provider == null) {
+ throw new IllegalStateException("Game provider was not initialized! (Knot#init(String[]))");
+ }
+
+ knot.provider.launch(cl);
+ }
+
public Knot(EnvType type, File gameJarFile) {
this.envType = type;
this.gameJarFile = gameJarFile;
}
- @SuppressWarnings("deprecation")
protected ClassLoader init(String[] args) {
setProperties(properties);
@@ -127,12 +138,12 @@ protected ClassLoader init(String[] args) {
Thread.currentThread().setContextClassLoader(cl);
- FabricLoader loader = FabricLoader.INSTANCE;
+ FabricLoaderImpl loader = FabricLoaderImpl.INSTANCE;
loader.setGameProvider(provider);
loader.load();
loader.freeze();
- FabricLoader.INSTANCE.loadAccessWideners();
+ FabricLoaderImpl.INSTANCE.loadAccessWideners();
MixinBootstrap.init();
FabricMixinBootstrap.init(getEnvironmentType(), loader);
@@ -145,14 +156,6 @@ protected ClassLoader init(String[] args) {
return cl;
}
- public void launch(ClassLoader cl) {
- if (this.provider == null) {
- throw new IllegalStateException("Game provider was not initialized! (Knot#init(String[]))");
- }
-
- provider.launch(cl);
- }
-
@Override
public String getTargetNamespace() {
// TODO: Won't work outside of Yarn
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/KnotClassDelegate.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassDelegate.java
similarity index 94%
rename from src/main/java/net/fabricmc/loader/launch/knot/KnotClassDelegate.java
rename to src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassDelegate.java
index f301fa190..7f1f98fdb 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/KnotClassDelegate.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassDelegate.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.knot;
+package net.fabricmc.loader.impl.launch.knot;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -34,12 +34,12 @@
import org.spongepowered.asm.mixin.transformer.FabricMixinTransformerProxy;
import net.fabricmc.api.EnvType;
-import net.fabricmc.loader.game.GameProvider;
-import net.fabricmc.loader.launch.common.FabricLauncherBase;
-import net.fabricmc.loader.transformer.FabricTransformer;
-import net.fabricmc.loader.util.FileSystemUtil;
-import net.fabricmc.loader.util.UrlConversionException;
-import net.fabricmc.loader.util.UrlUtil;
+import net.fabricmc.loader.impl.game.GameProvider;
+import net.fabricmc.loader.impl.launch.FabricLauncherBase;
+import net.fabricmc.loader.impl.transformer.FabricTransformer;
+import net.fabricmc.loader.impl.util.FileSystemUtil;
+import net.fabricmc.loader.impl.util.UrlConversionException;
+import net.fabricmc.loader.impl.util.UrlUtil;
class KnotClassDelegate {
static class Metadata {
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/KnotClassLoader.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassLoader.java
similarity index 98%
rename from src/main/java/net/fabricmc/loader/launch/knot/KnotClassLoader.java
rename to src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassLoader.java
index 33da693f6..ff1510bae 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/KnotClassLoader.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassLoader.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.knot;
+package net.fabricmc.loader.impl.launch.knot;
import java.io.IOException;
import java.io.InputStream;
@@ -25,7 +25,7 @@
import java.util.Objects;
import net.fabricmc.api.EnvType;
-import net.fabricmc.loader.game.GameProvider;
+import net.fabricmc.loader.impl.game.GameProvider;
class KnotClassLoader extends SecureClassLoader implements KnotClassLoaderInterface {
private static class DynamicURLClassLoader extends URLClassLoader {
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/KnotClassLoaderInterface.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassLoaderInterface.java
similarity index 95%
rename from src/main/java/net/fabricmc/loader/launch/knot/KnotClassLoaderInterface.java
rename to src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassLoaderInterface.java
index 5f0e1a3d4..3aba2c007 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/KnotClassLoaderInterface.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassLoaderInterface.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.knot;
+package net.fabricmc.loader.impl.launch.knot;
import java.io.IOException;
import java.io.InputStream;
diff --git a/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClient.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClient.java
new file mode 100644
index 000000000..a44b8486c
--- /dev/null
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClient.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016 FabricMC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.fabricmc.loader.impl.launch.knot;
+
+import net.fabricmc.api.EnvType;
+
+public class KnotClient {
+ public static void main(String[] args) {
+ Knot.launch(args, EnvType.CLIENT);
+ }
+}
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/KnotCompatibilityClassLoader.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotCompatibilityClassLoader.java
similarity index 96%
rename from src/main/java/net/fabricmc/loader/launch/knot/KnotCompatibilityClassLoader.java
rename to src/main/java/net/fabricmc/loader/impl/launch/knot/KnotCompatibilityClassLoader.java
index e1f5c9734..a76dd3f49 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/KnotCompatibilityClassLoader.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotCompatibilityClassLoader.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.knot;
+package net.fabricmc.loader.impl.launch.knot;
import java.io.IOException;
import java.io.InputStream;
@@ -22,7 +22,7 @@
import java.net.URLClassLoader;
import net.fabricmc.api.EnvType;
-import net.fabricmc.loader.game.GameProvider;
+import net.fabricmc.loader.impl.game.GameProvider;
class KnotCompatibilityClassLoader extends URLClassLoader implements KnotClassLoaderInterface {
private final KnotClassDelegate delegate;
diff --git a/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotServer.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotServer.java
new file mode 100644
index 000000000..33c1e196a
--- /dev/null
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotServer.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016 FabricMC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.fabricmc.loader.impl.launch.knot;
+
+import net.fabricmc.api.EnvType;
+
+public class KnotServer {
+ public static void main(String[] args) {
+ Knot.launch(args, EnvType.SERVER);
+ }
+}
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/MixinContainerHandleMod.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/MixinContainerHandleMod.java
similarity index 95%
rename from src/main/java/net/fabricmc/loader/launch/knot/MixinContainerHandleMod.java
rename to src/main/java/net/fabricmc/loader/impl/launch/knot/MixinContainerHandleMod.java
index 72e31d525..ff81da71b 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/MixinContainerHandleMod.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/MixinContainerHandleMod.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.knot;
+package net.fabricmc.loader.impl.launch.knot;
import java.util.Collection;
import java.util.Collections;
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/MixinServiceKnot.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/MixinServiceKnot.java
similarity index 98%
rename from src/main/java/net/fabricmc/loader/launch/knot/MixinServiceKnot.java
rename to src/main/java/net/fabricmc/loader/impl/launch/knot/MixinServiceKnot.java
index 91de0aac8..07617d422 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/MixinServiceKnot.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/MixinServiceKnot.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.knot;
+package net.fabricmc.loader.impl.launch.knot;
import java.io.IOException;
import java.io.InputStream;
@@ -37,7 +37,7 @@
import org.spongepowered.asm.service.ITransformerProvider;
import org.spongepowered.asm.util.ReEntranceLock;
-import net.fabricmc.loader.launch.common.FabricLauncherBase;
+import net.fabricmc.loader.impl.launch.FabricLauncherBase;
public class MixinServiceKnot implements IMixinService, IClassProvider, IClassBytecodeProvider, ITransformerProvider, IClassTracker {
private final ReEntranceLock lock;
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/MixinServiceKnotBootstrap.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/MixinServiceKnotBootstrap.java
similarity index 89%
rename from src/main/java/net/fabricmc/loader/launch/knot/MixinServiceKnotBootstrap.java
rename to src/main/java/net/fabricmc/loader/impl/launch/knot/MixinServiceKnotBootstrap.java
index 530bb20e1..2024e157e 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/MixinServiceKnotBootstrap.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/MixinServiceKnotBootstrap.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.knot;
+package net.fabricmc.loader.impl.launch.knot;
import org.spongepowered.asm.service.IMixinServiceBootstrap;
@@ -26,7 +26,7 @@ public String getName() {
@Override
public String getServiceClassName() {
- return "net.fabricmc.loader.launch.knot.MixinServiceKnot";
+ return "net.fabricmc.loader.impl.launch.knot.MixinServiceKnot";
}
@Override
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/MixinStringPropertyKey.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/MixinStringPropertyKey.java
similarity index 96%
rename from src/main/java/net/fabricmc/loader/launch/knot/MixinStringPropertyKey.java
rename to src/main/java/net/fabricmc/loader/impl/launch/knot/MixinStringPropertyKey.java
index 6eb0fb43b..39fb744cf 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/MixinStringPropertyKey.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/MixinStringPropertyKey.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.knot;
+package net.fabricmc.loader.impl.launch.knot;
import java.util.Objects;
diff --git a/src/main/java/net/fabricmc/loader/launch/server/FabricServerLauncher.java b/src/main/java/net/fabricmc/loader/impl/launch/server/FabricServerLauncher.java
similarity index 93%
rename from src/main/java/net/fabricmc/loader/launch/server/FabricServerLauncher.java
rename to src/main/java/net/fabricmc/loader/impl/launch/server/FabricServerLauncher.java
index c9b516cd0..299b2a81a 100644
--- a/src/main/java/net/fabricmc/loader/launch/server/FabricServerLauncher.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/server/FabricServerLauncher.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.server;
+package net.fabricmc.loader.impl.launch.server;
import java.io.File;
import java.io.FileInputStream;
@@ -25,12 +25,13 @@
import java.net.URLClassLoader;
import java.util.Properties;
-import net.fabricmc.loader.util.SystemProperties;
-import net.fabricmc.loader.util.UrlUtil;
+import net.fabricmc.loader.impl.launch.knot.KnotServer;
+import net.fabricmc.loader.impl.util.SystemProperties;
+import net.fabricmc.loader.impl.util.UrlUtil;
public class FabricServerLauncher {
private static final ClassLoader parentLoader = FabricServerLauncher.class.getClassLoader();
- private static String mainClass = "net.fabricmc.loader.launch.knot.KnotServer";
+ private static String mainClass = KnotServer.class.getName();
public static void main(String[] args) {
URL propUrl = parentLoader.getResource("fabric-server-launch.properties");
diff --git a/src/main/java/net/fabricmc/loader/launch/server/InjectingURLClassLoader.java b/src/main/java/net/fabricmc/loader/impl/launch/server/InjectingURLClassLoader.java
similarity index 97%
rename from src/main/java/net/fabricmc/loader/launch/server/InjectingURLClassLoader.java
rename to src/main/java/net/fabricmc/loader/impl/launch/server/InjectingURLClassLoader.java
index cb49f4519..cd57e31af 100644
--- a/src/main/java/net/fabricmc/loader/launch/server/InjectingURLClassLoader.java
+++ b/src/main/java/net/fabricmc/loader/impl/launch/server/InjectingURLClassLoader.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.launch.server;
+package net.fabricmc.loader.impl.launch.server;
import java.net.URL;
import java.net.URLClassLoader;
diff --git a/src/main/java/net/fabricmc/loader/lib/gson/JsonReader.java b/src/main/java/net/fabricmc/loader/impl/lib/gson/JsonReader.java
similarity index 99%
rename from src/main/java/net/fabricmc/loader/lib/gson/JsonReader.java
rename to src/main/java/net/fabricmc/loader/impl/lib/gson/JsonReader.java
index 3faac7897..dd067bf3d 100644
--- a/src/main/java/net/fabricmc/loader/lib/gson/JsonReader.java
+++ b/src/main/java/net/fabricmc/loader/impl/lib/gson/JsonReader.java
@@ -17,7 +17,7 @@
* This file has been modified by the Fabric project (repackage, minor changes).
*/
-package net.fabricmc.loader.lib.gson;
+package net.fabricmc.loader.impl.lib.gson;
import java.io.Closeable;
import java.io.EOFException;
diff --git a/src/main/java/net/fabricmc/loader/lib/gson/JsonScope.java b/src/main/java/net/fabricmc/loader/impl/lib/gson/JsonScope.java
similarity index 97%
rename from src/main/java/net/fabricmc/loader/lib/gson/JsonScope.java
rename to src/main/java/net/fabricmc/loader/impl/lib/gson/JsonScope.java
index bc935a9d6..24add7b67 100644
--- a/src/main/java/net/fabricmc/loader/lib/gson/JsonScope.java
+++ b/src/main/java/net/fabricmc/loader/impl/lib/gson/JsonScope.java
@@ -17,7 +17,7 @@
* This file has been modified by the Fabric project (repackage, minor changes).
*/
-package net.fabricmc.loader.lib.gson;
+package net.fabricmc.loader.impl.lib.gson;
/**
* Lexical scoping elements within a JSON reader or writer.
diff --git a/src/main/java/net/fabricmc/loader/lib/gson/JsonToken.java b/src/main/java/net/fabricmc/loader/impl/lib/gson/JsonToken.java
similarity index 97%
rename from src/main/java/net/fabricmc/loader/lib/gson/JsonToken.java
rename to src/main/java/net/fabricmc/loader/impl/lib/gson/JsonToken.java
index 13d57e569..377517de0 100644
--- a/src/main/java/net/fabricmc/loader/lib/gson/JsonToken.java
+++ b/src/main/java/net/fabricmc/loader/impl/lib/gson/JsonToken.java
@@ -17,7 +17,7 @@
* This file has been modified by the Fabric project (repackage, minor changes).
*/
-package net.fabricmc.loader.lib.gson;
+package net.fabricmc.loader.impl.lib.gson;
/**
* A structure, name or value type in a JSON-encoded string.
diff --git a/src/main/java/net/fabricmc/loader/lib/gson/MalformedJsonException.java b/src/main/java/net/fabricmc/loader/impl/lib/gson/MalformedJsonException.java
similarity index 97%
rename from src/main/java/net/fabricmc/loader/lib/gson/MalformedJsonException.java
rename to src/main/java/net/fabricmc/loader/impl/lib/gson/MalformedJsonException.java
index 5ac35f8de..dcd018e58 100644
--- a/src/main/java/net/fabricmc/loader/lib/gson/MalformedJsonException.java
+++ b/src/main/java/net/fabricmc/loader/impl/lib/gson/MalformedJsonException.java
@@ -17,7 +17,7 @@
* This file has been modified by the Fabric project (repackage, minor changes).
*/
-package net.fabricmc.loader.lib.gson;
+package net.fabricmc.loader.impl.lib.gson;
import java.io.IOException;
diff --git a/src/main/java/net/fabricmc/loader/metadata/AbstractModMetadata.java b/src/main/java/net/fabricmc/loader/impl/metadata/AbstractModMetadata.java
similarity index 98%
rename from src/main/java/net/fabricmc/loader/metadata/AbstractModMetadata.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/AbstractModMetadata.java
index ee324aa29..338588872 100644
--- a/src/main/java/net/fabricmc/loader/metadata/AbstractModMetadata.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/AbstractModMetadata.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import java.util.Map;
diff --git a/src/main/java/net/fabricmc/loader/metadata/BuiltinModMetadata.java b/src/main/java/net/fabricmc/loader/impl/metadata/BuiltinModMetadata.java
similarity index 97%
rename from src/main/java/net/fabricmc/loader/metadata/BuiltinModMetadata.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/BuiltinModMetadata.java
index 83a29770a..19ea02f81 100644
--- a/src/main/java/net/fabricmc/loader/metadata/BuiltinModMetadata.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/BuiltinModMetadata.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import java.util.ArrayList;
import java.util.Collection;
@@ -33,7 +33,7 @@
import net.fabricmc.loader.api.metadata.ModEnvironment;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.fabricmc.loader.api.metadata.Person;
-import net.fabricmc.loader.util.version.VersionDeserializer;
+import net.fabricmc.loader.impl.util.version.VersionDeserializer;
public final class BuiltinModMetadata extends AbstractModMetadata {
private final String id;
@@ -295,7 +295,7 @@ public ContactInformation getContact() {
return contact;
}
- private final ContactInformation contact = contactMap.isEmpty() ? ContactInformation.EMPTY : new MapBackedContactInformation(contactMap);
+ private final ContactInformation contact = contactMap.isEmpty() ? ContactInformation.EMPTY : new ContactInformationImpl(contactMap);
};
}
}
diff --git a/src/main/java/net/fabricmc/loader/metadata/ContactInfoBackedPerson.java b/src/main/java/net/fabricmc/loader/impl/metadata/ContactInfoBackedPerson.java
similarity index 95%
rename from src/main/java/net/fabricmc/loader/metadata/ContactInfoBackedPerson.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/ContactInfoBackedPerson.java
index 96fece060..dda26c13d 100644
--- a/src/main/java/net/fabricmc/loader/metadata/ContactInfoBackedPerson.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/ContactInfoBackedPerson.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import net.fabricmc.loader.api.metadata.ContactInformation;
diff --git a/src/main/java/net/fabricmc/loader/impl/metadata/ContactInformationImpl.java b/src/main/java/net/fabricmc/loader/impl/metadata/ContactInformationImpl.java
new file mode 100644
index 000000000..efd7cb71c
--- /dev/null
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/ContactInformationImpl.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2016 FabricMC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.fabricmc.loader.impl.metadata;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+
+import net.fabricmc.loader.api.metadata.ContactInformation;
+
+public class ContactInformationImpl implements ContactInformation {
+ private final Map map;
+
+ public ContactInformationImpl(Map map) {
+ this.map = Collections.unmodifiableMap(map);
+ }
+
+ @Override
+ public Optional get(String key) {
+ return Optional.ofNullable(map.get(key));
+ }
+
+ @Override
+ public Map asMap() {
+ return map;
+ }
+}
diff --git a/src/main/java/net/fabricmc/loader/metadata/CustomValueImpl.java b/src/main/java/net/fabricmc/loader/impl/metadata/CustomValueImpl.java
similarity index 98%
rename from src/main/java/net/fabricmc/loader/metadata/CustomValueImpl.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/CustomValueImpl.java
index b5a6aa6af..f13427763 100644
--- a/src/main/java/net/fabricmc/loader/metadata/CustomValueImpl.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/CustomValueImpl.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import java.io.IOException;
import java.util.ArrayList;
@@ -27,7 +27,7 @@
import java.util.Objects;
import net.fabricmc.loader.api.metadata.CustomValue;
-import net.fabricmc.loader.lib.gson.JsonReader;
+import net.fabricmc.loader.impl.lib.gson.JsonReader;
abstract class CustomValueImpl implements CustomValue {
static final CustomValue BOOLEAN_TRUE = new BooleanImpl(true);
diff --git a/src/main/java/net/fabricmc/loader/metadata/DependencyOverrides.java b/src/main/java/net/fabricmc/loader/impl/metadata/DependencyOverrides.java
similarity index 95%
rename from src/main/java/net/fabricmc/loader/metadata/DependencyOverrides.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/DependencyOverrides.java
index 47f34fe33..f42d43ddc 100644
--- a/src/main/java/net/fabricmc/loader/metadata/DependencyOverrides.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/DependencyOverrides.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -30,10 +30,10 @@
import java.util.List;
import java.util.Map;
-import net.fabricmc.loader.FabricLoader;
import net.fabricmc.loader.api.metadata.ModDependency;
-import net.fabricmc.loader.lib.gson.JsonReader;
-import net.fabricmc.loader.lib.gson.JsonToken;
+import net.fabricmc.loader.impl.FabricLoaderImpl;
+import net.fabricmc.loader.impl.lib.gson.JsonReader;
+import net.fabricmc.loader.impl.lib.gson.JsonToken;
public final class DependencyOverrides {
private static final Collection ALLOWED_KEYS = new HashSet<>(Arrays.asList("depends", "recommends", "suggests", "conflicts", "breaks"));
@@ -43,8 +43,7 @@ public final class DependencyOverrides {
private final Map>> dependencyOverrides;
private DependencyOverrides() {
- @SuppressWarnings("deprecation")
- Path path = FabricLoader.INSTANCE.getConfigDir().resolve("fabric_loader_dependencies.json");
+ Path path = FabricLoaderImpl.INSTANCE.getConfigDir().resolve("fabric_loader_dependencies.json");
exists = Files.exists(path);
if (!exists) {
diff --git a/src/main/java/net/fabricmc/loader/impl/metadata/EntrypointMetadata.java b/src/main/java/net/fabricmc/loader/impl/metadata/EntrypointMetadata.java
new file mode 100644
index 000000000..8fb13b204
--- /dev/null
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/EntrypointMetadata.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016 FabricMC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.fabricmc.loader.impl.metadata;
+
+@SuppressWarnings("deprecation")
+public interface EntrypointMetadata extends net.fabricmc.loader.metadata.EntrypointMetadata {
+ @Override
+ String getAdapter();
+ @Override
+ String getValue();
+}
diff --git a/src/main/java/net/fabricmc/loader/impl/metadata/LoaderModMetadata.java b/src/main/java/net/fabricmc/loader/impl/metadata/LoaderModMetadata.java
new file mode 100644
index 000000000..c98c6b0c5
--- /dev/null
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/LoaderModMetadata.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2016 FabricMC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.fabricmc.loader.impl.metadata;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.logging.log4j.Logger;
+
+import net.fabricmc.api.EnvType;
+
+/**
+ * Internal variant of the ModMetadata interface.
+ */
+@SuppressWarnings("deprecation")
+public interface LoaderModMetadata extends net.fabricmc.loader.metadata.LoaderModMetadata {
+ int getSchemaVersion();
+
+ default String getOldStyleLanguageAdapter() {
+ return "net.fabricmc.loader.language.JavaLanguageAdapter";
+ }
+
+ Map getLanguageAdapterDefinitions();
+ Collection getJars();
+ Collection getMixinConfigs(EnvType type);
+ /* @Nullable */
+ String getAccessWidener();
+ @Override
+ boolean loadsInEnvironment(EnvType type);
+
+ Collection getOldInitializers();
+ @Override
+ List getEntrypoints(String type);
+ @Override
+ Collection getEntrypointKeys();
+
+ void emitFormatWarnings(Logger logger);
+}
diff --git a/src/main/java/net/fabricmc/loader/metadata/ModDependencyImpl.java b/src/main/java/net/fabricmc/loader/impl/metadata/ModDependencyImpl.java
similarity index 94%
rename from src/main/java/net/fabricmc/loader/metadata/ModDependencyImpl.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/ModDependencyImpl.java
index c37f3d865..080f06f5b 100644
--- a/src/main/java/net/fabricmc/loader/metadata/ModDependencyImpl.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/ModDependencyImpl.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import java.util.List;
import java.util.Set;
@@ -23,7 +23,7 @@
import net.fabricmc.loader.api.VersionParsingException;
import net.fabricmc.loader.api.VersionPredicate;
import net.fabricmc.loader.api.metadata.ModDependency;
-import net.fabricmc.loader.util.version.VersionPredicateParser;
+import net.fabricmc.loader.impl.util.version.VersionPredicateParser;
public final class ModDependencyImpl implements ModDependency {
private final String modId;
diff --git a/src/main/java/net/fabricmc/loader/metadata/ModMetadataParser.java b/src/main/java/net/fabricmc/loader/impl/metadata/ModMetadataParser.java
similarity index 97%
rename from src/main/java/net/fabricmc/loader/metadata/ModMetadataParser.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/ModMetadataParser.java
index bfee4ea6e..9f586bd09 100644
--- a/src/main/java/net/fabricmc/loader/metadata/ModMetadataParser.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/ModMetadataParser.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -27,8 +27,8 @@
import org.apache.logging.log4j.Logger;
import net.fabricmc.loader.api.FabricLoader;
-import net.fabricmc.loader.lib.gson.JsonReader;
-import net.fabricmc.loader.lib.gson.JsonToken;
+import net.fabricmc.loader.impl.lib.gson.JsonReader;
+import net.fabricmc.loader.impl.lib.gson.JsonToken;
public final class ModMetadataParser {
private static final Logger LOGGER = LogManager.getLogger();
diff --git a/src/main/java/net/fabricmc/loader/metadata/NestedJarEntry.java b/src/main/java/net/fabricmc/loader/impl/metadata/NestedJarEntry.java
similarity index 93%
rename from src/main/java/net/fabricmc/loader/metadata/NestedJarEntry.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/NestedJarEntry.java
index 040b9ec7e..fde1a4512 100644
--- a/src/main/java/net/fabricmc/loader/metadata/NestedJarEntry.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/NestedJarEntry.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
public interface NestedJarEntry {
String getFile();
diff --git a/src/main/java/net/fabricmc/loader/metadata/ParseMetadataException.java b/src/main/java/net/fabricmc/loader/impl/metadata/ParseMetadataException.java
similarity index 92%
rename from src/main/java/net/fabricmc/loader/metadata/ParseMetadataException.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/ParseMetadataException.java
index d219e24d3..d8d1f659a 100644
--- a/src/main/java/net/fabricmc/loader/metadata/ParseMetadataException.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/ParseMetadataException.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
-import net.fabricmc.loader.lib.gson.JsonReader;
+import net.fabricmc.loader.impl.lib.gson.JsonReader;
@SuppressWarnings("serial")
public class ParseMetadataException extends Exception {
diff --git a/src/main/java/net/fabricmc/loader/metadata/ParseWarning.java b/src/main/java/net/fabricmc/loader/impl/metadata/ParseWarning.java
similarity index 96%
rename from src/main/java/net/fabricmc/loader/metadata/ParseWarning.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/ParseWarning.java
index 5197c31de..035659a39 100644
--- a/src/main/java/net/fabricmc/loader/metadata/ParseWarning.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/ParseWarning.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
final class ParseWarning {
private final int line;
diff --git a/src/main/java/net/fabricmc/loader/metadata/SimplePerson.java b/src/main/java/net/fabricmc/loader/impl/metadata/SimplePerson.java
similarity index 96%
rename from src/main/java/net/fabricmc/loader/metadata/SimplePerson.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/SimplePerson.java
index b77a15399..b183c6c31 100644
--- a/src/main/java/net/fabricmc/loader/metadata/SimplePerson.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/SimplePerson.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import net.fabricmc.loader.api.metadata.ContactInformation;
import net.fabricmc.loader.api.metadata.Person;
diff --git a/src/main/java/net/fabricmc/loader/metadata/V0ModMetadata.java b/src/main/java/net/fabricmc/loader/impl/metadata/V0ModMetadata.java
similarity index 99%
rename from src/main/java/net/fabricmc/loader/metadata/V0ModMetadata.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/V0ModMetadata.java
index 23aa7be11..642bd6927 100644
--- a/src/main/java/net/fabricmc/loader/metadata/V0ModMetadata.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/V0ModMetadata.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/src/main/java/net/fabricmc/loader/metadata/V0ModMetadataParser.java b/src/main/java/net/fabricmc/loader/impl/metadata/V0ModMetadataParser.java
similarity index 96%
rename from src/main/java/net/fabricmc/loader/metadata/V0ModMetadataParser.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/V0ModMetadataParser.java
index a3a836b11..98d4ef3a8 100644
--- a/src/main/java/net/fabricmc/loader/metadata/V0ModMetadataParser.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/V0ModMetadataParser.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import java.io.IOException;
import java.util.ArrayList;
@@ -34,9 +34,9 @@
import net.fabricmc.loader.api.metadata.ModDependency;
import net.fabricmc.loader.api.metadata.ModEnvironment;
import net.fabricmc.loader.api.metadata.Person;
-import net.fabricmc.loader.lib.gson.JsonReader;
-import net.fabricmc.loader.lib.gson.JsonToken;
-import net.fabricmc.loader.util.version.VersionDeserializer;
+import net.fabricmc.loader.impl.lib.gson.JsonReader;
+import net.fabricmc.loader.impl.lib.gson.JsonToken;
+import net.fabricmc.loader.impl.util.version.VersionDeserializer;
final class V0ModMetadataParser {
private static final Pattern WEBSITE_PATTERN = Pattern.compile("\\((.+)\\)");
@@ -276,7 +276,7 @@ private static ContactInformation readLinks(List warnings, JsonRea
throw new ParseMetadataException("Expected links to be an object or string", reader);
}
- return new MapBackedContactInformation(contactInfo);
+ return new ContactInformationImpl(contactInfo);
}
private static V0ModMetadata.Mixins readMixins(List warnings, JsonReader reader) throws IOException, ParseMetadataException {
@@ -416,7 +416,7 @@ private static Person readPerson(List warnings, JsonReader reader)
name = String.join(" ", parts);
- return new ContactInfoBackedPerson(name, new MapBackedContactInformation(contactMap));
+ return new ContactInfoBackedPerson(name, new ContactInformationImpl(contactMap));
case BEGIN_OBJECT:
reader.beginObject();
@@ -452,7 +452,7 @@ private static Person readPerson(List warnings, JsonReader reader)
}
reader.endObject();
- return new ContactInfoBackedPerson(name, new MapBackedContactInformation(contactMap));
+ return new ContactInfoBackedPerson(name, new ContactInformationImpl(contactMap));
default:
throw new ParseMetadataException("Expected person to be a string or object", reader);
}
diff --git a/src/main/java/net/fabricmc/loader/metadata/V1ModMetadata.java b/src/main/java/net/fabricmc/loader/impl/metadata/V1ModMetadata.java
similarity index 99%
rename from src/main/java/net/fabricmc/loader/metadata/V1ModMetadata.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/V1ModMetadata.java
index 9d62e8f7f..0c434e740 100644
--- a/src/main/java/net/fabricmc/loader/metadata/V1ModMetadata.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/V1ModMetadata.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/src/main/java/net/fabricmc/loader/metadata/V1ModMetadataParser.java b/src/main/java/net/fabricmc/loader/impl/metadata/V1ModMetadataParser.java
similarity index 98%
rename from src/main/java/net/fabricmc/loader/metadata/V1ModMetadataParser.java
rename to src/main/java/net/fabricmc/loader/impl/metadata/V1ModMetadataParser.java
index b36af7c39..8e3ea7c93 100644
--- a/src/main/java/net/fabricmc/loader/metadata/V1ModMetadataParser.java
+++ b/src/main/java/net/fabricmc/loader/impl/metadata/V1ModMetadataParser.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.metadata;
+package net.fabricmc.loader.impl.metadata;
import java.io.IOException;
import java.util.ArrayList;
@@ -35,9 +35,9 @@
import net.fabricmc.loader.api.metadata.ModDependency;
import net.fabricmc.loader.api.metadata.ModEnvironment;
import net.fabricmc.loader.api.metadata.Person;
-import net.fabricmc.loader.lib.gson.JsonReader;
-import net.fabricmc.loader.lib.gson.JsonToken;
-import net.fabricmc.loader.util.version.VersionDeserializer;
+import net.fabricmc.loader.impl.lib.gson.JsonReader;
+import net.fabricmc.loader.impl.lib.gson.JsonToken;
+import net.fabricmc.loader.impl.util.version.VersionDeserializer;
final class V1ModMetadataParser {
/**
@@ -503,7 +503,7 @@ private static void readPeople(List warnings, JsonReader reader, L
personName = reader.nextString();
break;
- // Effectively optional
+ // Effectively optional
case "contact":
contactInformation = V1ModMetadataParser.readContactInfo(reader);
break;
@@ -556,7 +556,7 @@ private static ContactInformation readContactInfo(JsonReader reader) throws IOEx
reader.endObject();
// Map is wrapped as unmodifiable in the contact info impl
- return new MapBackedContactInformation(map);
+ return new ContactInformationImpl(map);
}
private static void readLicense(JsonReader reader, List license) throws IOException, ParseMetadataException {
diff --git a/src/main/java/net/fabricmc/loader/transformer/ClassStripper.java b/src/main/java/net/fabricmc/loader/impl/transformer/ClassStripper.java
similarity index 98%
rename from src/main/java/net/fabricmc/loader/transformer/ClassStripper.java
rename to src/main/java/net/fabricmc/loader/impl/transformer/ClassStripper.java
index 270785f3c..a70395994 100644
--- a/src/main/java/net/fabricmc/loader/transformer/ClassStripper.java
+++ b/src/main/java/net/fabricmc/loader/impl/transformer/ClassStripper.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.transformer;
+package net.fabricmc.loader.impl.transformer;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/src/main/java/net/fabricmc/loader/transformer/EnvironmentStrippingData.java b/src/main/java/net/fabricmc/loader/impl/transformer/EnvironmentStrippingData.java
similarity index 99%
rename from src/main/java/net/fabricmc/loader/transformer/EnvironmentStrippingData.java
rename to src/main/java/net/fabricmc/loader/impl/transformer/EnvironmentStrippingData.java
index 3c12f671f..78f40fff8 100644
--- a/src/main/java/net/fabricmc/loader/transformer/EnvironmentStrippingData.java
+++ b/src/main/java/net/fabricmc/loader/impl/transformer/EnvironmentStrippingData.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.transformer;
+package net.fabricmc.loader.impl.transformer;
import java.util.Collection;
import java.util.HashSet;
diff --git a/src/main/java/net/fabricmc/loader/transformer/FabricTransformer.java b/src/main/java/net/fabricmc/loader/impl/transformer/FabricTransformer.java
similarity index 79%
rename from src/main/java/net/fabricmc/loader/transformer/FabricTransformer.java
rename to src/main/java/net/fabricmc/loader/impl/transformer/FabricTransformer.java
index 50438feef..cb6c6503a 100644
--- a/src/main/java/net/fabricmc/loader/transformer/FabricTransformer.java
+++ b/src/main/java/net/fabricmc/loader/impl/transformer/FabricTransformer.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.transformer;
+package net.fabricmc.loader.impl.transformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
@@ -22,9 +22,9 @@
import net.fabricmc.accesswidener.AccessWidenerVisitor;
import net.fabricmc.api.EnvType;
-import net.fabricmc.loader.FabricLoader;
-import net.fabricmc.loader.game.MinecraftGameProvider;
-import net.fabricmc.loader.launch.common.FabricLauncherBase;
+import net.fabricmc.loader.impl.FabricLoaderImpl;
+import net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider;
+import net.fabricmc.loader.impl.launch.FabricLauncherBase;
public final class FabricTransformer {
public static byte[] lwTransformerHook(String name, String transformedName, byte[] bytes) {
@@ -44,12 +44,11 @@ public static byte[] lwTransformerHook(String name, String transformedName, byte
}
}
- @SuppressWarnings("deprecation")
public static byte[] transform(boolean isDevelopment, EnvType envType, String name, byte[] bytes) {
boolean isMinecraftClass = name.startsWith("net.minecraft.") || name.startsWith("com.mojang.blaze3d.") || name.indexOf('.') < 0;
boolean transformAccess = isMinecraftClass && FabricLauncherBase.getLauncher().getMappingConfiguration().requiresPackageAccessHack();
boolean environmentStrip = !isMinecraftClass || isDevelopment;
- boolean applyAccessWidener = isMinecraftClass && FabricLoader.INSTANCE.getAccessWidener().getTargets().contains(name);
+ boolean applyAccessWidener = isMinecraftClass && FabricLoaderImpl.INSTANCE.getAccessWidener().getTargets().contains(name);
if (!transformAccess && !environmentStrip && !applyAccessWidener) {
return bytes;
@@ -61,17 +60,17 @@ public static byte[] transform(boolean isDevelopment, EnvType envType, String na
int visitorCount = 0;
if (applyAccessWidener) {
- visitor = AccessWidenerVisitor.createClassVisitor(FabricLoader.ASM_VERSION, visitor, FabricLoader.INSTANCE.getAccessWidener());
+ visitor = AccessWidenerVisitor.createClassVisitor(FabricLoaderImpl.ASM_VERSION, visitor, FabricLoaderImpl.INSTANCE.getAccessWidener());
visitorCount++;
}
if (transformAccess) {
- visitor = new PackageAccessFixer(FabricLoader.ASM_VERSION, visitor);
+ visitor = new PackageAccessFixer(FabricLoaderImpl.ASM_VERSION, visitor);
visitorCount++;
}
if (environmentStrip) {
- EnvironmentStrippingData stripData = new EnvironmentStrippingData(FabricLoader.ASM_VERSION, envType.toString());
+ EnvironmentStrippingData stripData = new EnvironmentStrippingData(FabricLoaderImpl.ASM_VERSION, envType.toString());
classReader.accept(stripData, ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES);
if (stripData.stripEntireClass()) {
@@ -79,7 +78,7 @@ public static byte[] transform(boolean isDevelopment, EnvType envType, String na
}
if (!stripData.isEmpty()) {
- visitor = new ClassStripper(FabricLoader.ASM_VERSION, visitor, stripData.getStripInterfaces(), stripData.getStripFields(), stripData.getStripMethods());
+ visitor = new ClassStripper(FabricLoaderImpl.ASM_VERSION, visitor, stripData.getStripInterfaces(), stripData.getStripFields(), stripData.getStripMethods());
visitorCount++;
}
}
diff --git a/src/main/java/net/fabricmc/loader/transformer/PackageAccessFixer.java b/src/main/java/net/fabricmc/loader/impl/transformer/PackageAccessFixer.java
similarity index 97%
rename from src/main/java/net/fabricmc/loader/transformer/PackageAccessFixer.java
rename to src/main/java/net/fabricmc/loader/impl/transformer/PackageAccessFixer.java
index f8681e47c..1217e52e8 100644
--- a/src/main/java/net/fabricmc/loader/transformer/PackageAccessFixer.java
+++ b/src/main/java/net/fabricmc/loader/impl/transformer/PackageAccessFixer.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.transformer;
+package net.fabricmc.loader.impl.transformer;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
diff --git a/src/main/java/net/fabricmc/loader/util/Arguments.java b/src/main/java/net/fabricmc/loader/impl/util/Arguments.java
similarity index 98%
rename from src/main/java/net/fabricmc/loader/util/Arguments.java
rename to src/main/java/net/fabricmc/loader/impl/util/Arguments.java
index 453b015b0..efc248bf9 100644
--- a/src/main/java/net/fabricmc/loader/util/Arguments.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/Arguments.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util;
+package net.fabricmc.loader.impl.util;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/src/main/java/net/fabricmc/loader/impl/util/DefaultLanguageAdapter.java b/src/main/java/net/fabricmc/loader/impl/util/DefaultLanguageAdapter.java
new file mode 100644
index 000000000..9e3318b1f
--- /dev/null
+++ b/src/main/java/net/fabricmc/loader/impl/util/DefaultLanguageAdapter.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2016 FabricMC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.fabricmc.loader.impl.util;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandleProxies;
+import java.lang.invoke.MethodHandles;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.fabricmc.loader.api.LanguageAdapter;
+import net.fabricmc.loader.api.LanguageAdapterException;
+import net.fabricmc.loader.api.ModContainer;
+import net.fabricmc.loader.impl.launch.FabricLauncherBase;
+
+public final class DefaultLanguageAdapter implements LanguageAdapter {
+ public static final DefaultLanguageAdapter INSTANCE = new DefaultLanguageAdapter();
+
+ private DefaultLanguageAdapter() { }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T create(ModContainer mod, String value, Class type) throws LanguageAdapterException {
+ String[] methodSplit = value.split("::");
+
+ if (methodSplit.length >= 3) {
+ throw new LanguageAdapterException("Invalid handle format: " + value);
+ }
+
+ Class> c;
+
+ try {
+ c = Class.forName(methodSplit[0], true, FabricLauncherBase.getLauncher().getTargetClassLoader());
+ } catch (ClassNotFoundException e) {
+ throw new LanguageAdapterException(e);
+ }
+
+ if (methodSplit.length == 1) {
+ if (type.isAssignableFrom(c)) {
+ try {
+ return (T) c.getDeclaredConstructor().newInstance();
+ } catch (Exception e) {
+ throw new LanguageAdapterException(e);
+ }
+ } else {
+ throw new LanguageAdapterException("Class " + c.getName() + " cannot be cast to " + type.getName() + "!");
+ }
+ } else /* length == 2 */ {
+ List methodList = new ArrayList<>();
+
+ for (Method m : c.getDeclaredMethods()) {
+ if (!(m.getName().equals(methodSplit[1]))) {
+ continue;
+ }
+
+ methodList.add(m);
+ }
+
+ try {
+ Field field = c.getDeclaredField(methodSplit[1]);
+ Class> fType = field.getType();
+
+ if ((field.getModifiers() & Modifier.STATIC) == 0) {
+ throw new LanguageAdapterException("Field " + value + " must be static!");
+ }
+
+ if (!methodList.isEmpty()) {
+ throw new LanguageAdapterException("Ambiguous " + value + " - refers to both field and method!");
+ }
+
+ if (!type.isAssignableFrom(fType)) {
+ throw new LanguageAdapterException("Field " + value + " cannot be cast to " + type.getName() + "!");
+ }
+
+ return (T) field.get(null);
+ } catch (NoSuchFieldException e) {
+ // ignore
+ } catch (IllegalAccessException e) {
+ throw new LanguageAdapterException("Field " + value + " cannot be accessed!", e);
+ }
+
+ if (!type.isInterface()) {
+ throw new LanguageAdapterException("Cannot proxy method " + value + " to non-interface type " + type.getName() + "!");
+ }
+
+ if (methodList.isEmpty()) {
+ throw new LanguageAdapterException("Could not find " + value + "!");
+ } else if (methodList.size() >= 2) {
+ throw new LanguageAdapterException("Found multiple method entries of name " + value + "!");
+ }
+
+ final Method targetMethod = methodList.get(0);
+ Object object = null;
+
+ if ((targetMethod.getModifiers() & Modifier.STATIC) == 0) {
+ try {
+ object = c.getDeclaredConstructor().newInstance();
+ } catch (Exception e) {
+ throw new LanguageAdapterException(e);
+ }
+ }
+
+ MethodHandle handle;
+
+ try {
+ handle = MethodHandles.lookup()
+ .unreflect(targetMethod);
+ } catch (Exception ex) {
+ throw new LanguageAdapterException(ex);
+ }
+
+ if (object != null) {
+ handle = handle.bindTo(object);
+ }
+
+ // uses proxy as well, but this handles default and object methods
+ try {
+ return MethodHandleProxies.asInterfaceInstance(type, handle);
+ } catch (Exception ex) {
+ throw new LanguageAdapterException(ex);
+ }
+ }
+ }
+}
diff --git a/src/main/java/net/fabricmc/loader/util/FileSystemUtil.java b/src/main/java/net/fabricmc/loader/impl/util/FileSystemUtil.java
similarity index 98%
rename from src/main/java/net/fabricmc/loader/util/FileSystemUtil.java
rename to src/main/java/net/fabricmc/loader/impl/util/FileSystemUtil.java
index 107cf05c8..12e6855d3 100644
--- a/src/main/java/net/fabricmc/loader/util/FileSystemUtil.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/FileSystemUtil.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util;
+package net.fabricmc.loader.impl.util;
import java.io.File;
import java.io.IOException;
diff --git a/src/main/java/net/fabricmc/loader/util/StringUtil.java b/src/main/java/net/fabricmc/loader/impl/util/StringUtil.java
similarity index 95%
rename from src/main/java/net/fabricmc/loader/util/StringUtil.java
rename to src/main/java/net/fabricmc/loader/impl/util/StringUtil.java
index f2de33f90..2111f0c7c 100644
--- a/src/main/java/net/fabricmc/loader/util/StringUtil.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/StringUtil.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util;
+package net.fabricmc.loader.impl.util;
public final class StringUtil {
private StringUtil() { }
diff --git a/src/main/java/net/fabricmc/loader/util/SystemProperties.java b/src/main/java/net/fabricmc/loader/impl/util/SystemProperties.java
similarity index 96%
rename from src/main/java/net/fabricmc/loader/util/SystemProperties.java
rename to src/main/java/net/fabricmc/loader/impl/util/SystemProperties.java
index 25f6ec578..676fca227 100644
--- a/src/main/java/net/fabricmc/loader/util/SystemProperties.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/SystemProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util;
+package net.fabricmc.loader.impl.util;
public final class SystemProperties {
public static final String DEVELOPMENT = "fabric.development";
diff --git a/src/main/java/net/fabricmc/loader/impl/util/UrlConversionException.java b/src/main/java/net/fabricmc/loader/impl/util/UrlConversionException.java
new file mode 100644
index 000000000..9ab56be06
--- /dev/null
+++ b/src/main/java/net/fabricmc/loader/impl/util/UrlConversionException.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016 FabricMC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.fabricmc.loader.impl.util;
+
+@SuppressWarnings({ "serial", "deprecation" })
+public class UrlConversionException extends net.fabricmc.loader.util.UrlConversionException {
+ public UrlConversionException() {
+ super();
+ }
+
+ public UrlConversionException(String s) {
+ super(s);
+ }
+
+ public UrlConversionException(Throwable t) {
+ super(t);
+ }
+
+ public UrlConversionException(String s, Throwable t) {
+ super(s, t);
+ }
+}
diff --git a/src/main/java/net/fabricmc/loader/impl/util/UrlUtil.java b/src/main/java/net/fabricmc/loader/impl/util/UrlUtil.java
new file mode 100644
index 000000000..816e1b84f
--- /dev/null
+++ b/src/main/java/net/fabricmc/loader/impl/util/UrlUtil.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2016 FabricMC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.fabricmc.loader.impl.util;
+
+import java.io.File;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public final class UrlUtil {
+ private UrlUtil() { }
+
+ public static URL getSource(String filename, URL resourceURL) throws UrlConversionException {
+ URL codeSourceURL;
+
+ try {
+ URLConnection connection = resourceURL.openConnection();
+
+ if (connection instanceof JarURLConnection) {
+ codeSourceURL = ((JarURLConnection) connection).getJarFileURL();
+ } else {
+ String path = resourceURL.getPath();
+
+ if (path.endsWith(filename)) {
+ codeSourceURL = new URL(resourceURL.getProtocol(), resourceURL.getHost(), resourceURL.getPort(), path.substring(0, path.length() - filename.length()));
+ } else {
+ throw new UrlConversionException("Could not figure out code source for file '" + filename + "' and URL '" + resourceURL + "'!");
+ }
+ }
+ } catch (Exception e) {
+ throw new UrlConversionException(e);
+ }
+
+ return codeSourceURL;
+ }
+
+ public static File asFile(URL url) throws UrlConversionException {
+ try {
+ return new File(url.toURI());
+ } catch (URISyntaxException e) {
+ throw new UrlConversionException(e);
+ }
+ }
+
+ public static Path asPath(URL url) throws UrlConversionException {
+ if (url.getProtocol().equals("file")) {
+ // TODO: Is this required?
+ return asFile(url).toPath();
+ } else {
+ try {
+ return Paths.get(url.toURI());
+ } catch (URISyntaxException e) {
+ throw new UrlConversionException(e);
+ }
+ }
+ }
+
+ public static URL asUrl(File file) throws UrlConversionException {
+ try {
+ return file.toURI().toURL();
+ } catch (MalformedURLException e) {
+ throw new UrlConversionException(e);
+ }
+ }
+
+ public static URL asUrl(Path path) throws UrlConversionException {
+ try {
+ return new URL(null, path.toUri().toString());
+ } catch (MalformedURLException e) {
+ throw new UrlConversionException(e);
+ }
+ }
+}
diff --git a/src/main/java/net/fabricmc/loader/util/mappings/MixinIntermediaryDevRemapper.java b/src/main/java/net/fabricmc/loader/impl/util/mappings/MixinIntermediaryDevRemapper.java
similarity index 99%
rename from src/main/java/net/fabricmc/loader/util/mappings/MixinIntermediaryDevRemapper.java
rename to src/main/java/net/fabricmc/loader/impl/util/mappings/MixinIntermediaryDevRemapper.java
index 42e0bea52..99b9237c4 100644
--- a/src/main/java/net/fabricmc/loader/util/mappings/MixinIntermediaryDevRemapper.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/mappings/MixinIntermediaryDevRemapper.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util.mappings;
+package net.fabricmc.loader.impl.util.mappings;
import java.util.ArrayDeque;
import java.util.Collection;
diff --git a/src/main/java/net/fabricmc/loader/util/mappings/TinyRemapperMappingsHelper.java b/src/main/java/net/fabricmc/loader/impl/util/mappings/TinyRemapperMappingsHelper.java
similarity index 97%
rename from src/main/java/net/fabricmc/loader/util/mappings/TinyRemapperMappingsHelper.java
rename to src/main/java/net/fabricmc/loader/impl/util/mappings/TinyRemapperMappingsHelper.java
index 35b47032b..9a8aea652 100644
--- a/src/main/java/net/fabricmc/loader/util/mappings/TinyRemapperMappingsHelper.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/mappings/TinyRemapperMappingsHelper.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util.mappings;
+package net.fabricmc.loader.impl.util.mappings;
import net.fabricmc.mapping.tree.ClassDef;
import net.fabricmc.mapping.tree.FieldDef;
diff --git a/src/main/java/net/fabricmc/loader/util/version/SemanticVersionImpl.java b/src/main/java/net/fabricmc/loader/impl/util/version/SemanticVersionImpl.java
similarity index 99%
rename from src/main/java/net/fabricmc/loader/util/version/SemanticVersionImpl.java
rename to src/main/java/net/fabricmc/loader/impl/util/version/SemanticVersionImpl.java
index 1c36f8615..86f986635 100644
--- a/src/main/java/net/fabricmc/loader/util/version/SemanticVersionImpl.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/version/SemanticVersionImpl.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util.version;
+package net.fabricmc.loader.impl.util.version;
import java.util.Arrays;
import java.util.Objects;
diff --git a/src/main/java/net/fabricmc/loader/util/version/SemanticVersionPredicateParser.java b/src/main/java/net/fabricmc/loader/impl/util/version/SemanticVersionPredicateParser.java
similarity index 98%
rename from src/main/java/net/fabricmc/loader/util/version/SemanticVersionPredicateParser.java
rename to src/main/java/net/fabricmc/loader/impl/util/version/SemanticVersionPredicateParser.java
index bf7769c2b..68261adbe 100644
--- a/src/main/java/net/fabricmc/loader/util/version/SemanticVersionPredicateParser.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/version/SemanticVersionPredicateParser.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util.version;
+package net.fabricmc.loader.impl.util.version;
import java.util.ArrayList;
import java.util.LinkedHashMap;
diff --git a/src/main/java/net/fabricmc/loader/util/version/StringVersion.java b/src/main/java/net/fabricmc/loader/impl/util/version/StringVersion.java
similarity index 95%
rename from src/main/java/net/fabricmc/loader/util/version/StringVersion.java
rename to src/main/java/net/fabricmc/loader/impl/util/version/StringVersion.java
index 90354276b..b78316141 100644
--- a/src/main/java/net/fabricmc/loader/util/version/StringVersion.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/version/StringVersion.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util.version;
+package net.fabricmc.loader.impl.util.version;
import net.fabricmc.loader.api.Version;
diff --git a/src/main/java/net/fabricmc/loader/util/version/StringVersionPredicateParser.java b/src/main/java/net/fabricmc/loader/impl/util/version/StringVersionPredicateParser.java
similarity index 95%
rename from src/main/java/net/fabricmc/loader/util/version/StringVersionPredicateParser.java
rename to src/main/java/net/fabricmc/loader/impl/util/version/StringVersionPredicateParser.java
index 92aefcf88..b1231afaf 100644
--- a/src/main/java/net/fabricmc/loader/util/version/StringVersionPredicateParser.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/version/StringVersionPredicateParser.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util.version;
+package net.fabricmc.loader.impl.util.version;
import java.util.function.Predicate;
diff --git a/src/main/java/net/fabricmc/loader/util/version/VersionDeserializer.java b/src/main/java/net/fabricmc/loader/impl/util/version/VersionDeserializer.java
similarity index 96%
rename from src/main/java/net/fabricmc/loader/util/version/VersionDeserializer.java
rename to src/main/java/net/fabricmc/loader/impl/util/version/VersionDeserializer.java
index a2eb9ab46..9eb0cef64 100644
--- a/src/main/java/net/fabricmc/loader/util/version/VersionDeserializer.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/version/VersionDeserializer.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util.version;
+package net.fabricmc.loader.impl.util.version;
import net.fabricmc.loader.api.SemanticVersion;
import net.fabricmc.loader.api.Version;
diff --git a/src/main/java/net/fabricmc/loader/util/version/VersionPredicateParser.java b/src/main/java/net/fabricmc/loader/impl/util/version/VersionPredicateParser.java
similarity index 96%
rename from src/main/java/net/fabricmc/loader/util/version/VersionPredicateParser.java
rename to src/main/java/net/fabricmc/loader/impl/util/version/VersionPredicateParser.java
index 31d456de6..16d893d1b 100644
--- a/src/main/java/net/fabricmc/loader/util/version/VersionPredicateParser.java
+++ b/src/main/java/net/fabricmc/loader/impl/util/version/VersionPredicateParser.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package net.fabricmc.loader.util.version;
+package net.fabricmc.loader.impl.util.version;
import java.util.function.Predicate;
diff --git a/src/main/java/net/fabricmc/loader/language/JavaLanguageAdapter.java b/src/main/java/net/fabricmc/loader/language/JavaLanguageAdapter.java
index a630a4084..effbac296 100644
--- a/src/main/java/net/fabricmc/loader/language/JavaLanguageAdapter.java
+++ b/src/main/java/net/fabricmc/loader/language/JavaLanguageAdapter.java
@@ -25,7 +25,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
-import net.fabricmc.loader.launch.common.FabricLauncherBase;
+import net.fabricmc.loader.impl.launch.FabricLauncherBase;
@Deprecated
public class JavaLanguageAdapter implements LanguageAdapter {
diff --git a/src/main/java/net/fabricmc/loader/launch/FabricClientTweaker.java b/src/main/java/net/fabricmc/loader/launch/FabricClientTweaker.java
index 510d179f1..b9cccf286 100644
--- a/src/main/java/net/fabricmc/loader/launch/FabricClientTweaker.java
+++ b/src/main/java/net/fabricmc/loader/launch/FabricClientTweaker.java
@@ -16,16 +16,9 @@
package net.fabricmc.loader.launch;
-import net.fabricmc.api.EnvType;
-
-public final class FabricClientTweaker extends FabricTweaker {
- @Override
- public EnvType getEnvironmentType() {
- return EnvType.CLIENT;
- }
-
- @Override
- public String getLaunchTarget() {
- return "net.minecraft.client.main.Main";
- }
+/**
+ * @deprecated Use {@link net.fabricmc.loader.impl.game.minecraft.launchwrapper.FabricClientTweaker} instead
+ */
+@Deprecated
+public final class FabricClientTweaker extends net.fabricmc.loader.impl.game.minecraft.launchwrapper.FabricClientTweaker {
}
diff --git a/src/main/java/net/fabricmc/loader/launch/FabricServerTweaker.java b/src/main/java/net/fabricmc/loader/launch/FabricServerTweaker.java
index 615e5b940..653b7d182 100644
--- a/src/main/java/net/fabricmc/loader/launch/FabricServerTweaker.java
+++ b/src/main/java/net/fabricmc/loader/launch/FabricServerTweaker.java
@@ -16,16 +16,9 @@
package net.fabricmc.loader.launch;
-import net.fabricmc.api.EnvType;
-
-public final class FabricServerTweaker extends FabricTweaker {
- @Override
- public EnvType getEnvironmentType() {
- return EnvType.SERVER;
- }
-
- @Override
- public String getLaunchTarget() {
- return "net.minecraft.server.MinecraftServer";
- }
+/**
+ * @deprecated Use {@link net.fabricmc.loader.impl.game.minecraft.launchwrapper.FabricServerTweaker} instead
+ */
+@Deprecated
+public final class FabricServerTweaker extends net.fabricmc.loader.impl.game.minecraft.launchwrapper.FabricServerTweaker {
}
diff --git a/src/main/java/net/fabricmc/loader/launch/common/FabricLauncher.java b/src/main/java/net/fabricmc/loader/launch/common/FabricLauncher.java
index a141a8e90..9223f281a 100644
--- a/src/main/java/net/fabricmc/loader/launch/common/FabricLauncher.java
+++ b/src/main/java/net/fabricmc/loader/launch/common/FabricLauncher.java
@@ -23,32 +23,18 @@
import net.fabricmc.api.EnvType;
+/**
+ * @deprecated Internal API, do not use
+ */
+@Deprecated
public interface FabricLauncher {
MappingConfiguration getMappingConfiguration();
-
void propose(URL url);
-
EnvType getEnvironmentType();
-
boolean isClassLoaded(String name);
-
InputStream getResourceAsStream(String name);
-
ClassLoader getTargetClassLoader();
-
- /**
- * Gets the byte array for a particular class.
- *
- * @param name The name of the class to retrieve
- * @param runTransformers Whether to run all transformers except mixin on the class
- */
byte[] getClassByteArray(String name, boolean runTransformers) throws IOException;
-
boolean isDevelopment();
-
- String getEntrypoint();
-
- String getTargetNamespace();
-
Collection getLoadTimeDependencies();
}
diff --git a/src/main/java/net/fabricmc/loader/launch/common/FabricLauncherBase.java b/src/main/java/net/fabricmc/loader/launch/common/FabricLauncherBase.java
index bd31cc75c..2237fdc8d 100644
--- a/src/main/java/net/fabricmc/loader/launch/common/FabricLauncherBase.java
+++ b/src/main/java/net/fabricmc/loader/launch/common/FabricLauncherBase.java
@@ -16,287 +16,71 @@
package net.fabricmc.loader.launch.common;
-import java.io.File;
import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.URI;
+import java.io.InputStream;
import java.net.URL;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.jar.JarFile;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.spongepowered.asm.mixin.MixinEnvironment;
+import java.util.Collection;
import net.fabricmc.api.EnvType;
-import net.fabricmc.loader.util.Arguments;
-import net.fabricmc.loader.util.UrlConversionException;
-import net.fabricmc.loader.util.UrlUtil;
-import net.fabricmc.loader.util.mappings.TinyRemapperMappingsHelper;
-import net.fabricmc.mapping.tree.TinyTree;
-import net.fabricmc.tinyremapper.OutputConsumerPath;
-import net.fabricmc.tinyremapper.TinyRemapper;
-
-public abstract class FabricLauncherBase implements FabricLauncher {
- public static Path minecraftJar;
-
- protected static Logger LOGGER = LogManager.getFormatterLogger("FabricLoader");
- private static boolean mixinReady;
- private static Map properties;
- private static FabricLauncher launcher;
- private static MappingConfiguration mappingConfiguration = new MappingConfiguration();
-
- protected FabricLauncherBase() {
- setLauncher(this);
- }
+import net.fabricmc.loader.api.FabricLoader;
- public static File getLaunchDirectory(Arguments argMap) {
- return new File(argMap.getOrDefault("gameDir", "."));
- }
+/**
+ * @deprecated Internal API, do not use
+ */
+@Deprecated
+public class FabricLauncherBase implements FabricLauncher {
+ private final net.fabricmc.loader.impl.launch.FabricLauncher parent = net.fabricmc.loader.impl.launch.FabricLauncherBase.getLauncher();
public static Class> getClass(String className) throws ClassNotFoundException {
return Class.forName(className, true, getLauncher().getTargetClassLoader());
}
- @Override
- public MappingConfiguration getMappingConfiguration() {
- return mappingConfiguration;
+ public static FabricLauncher getLauncher() {
+ return new FabricLauncherBase();
}
- private static boolean emittedInfo = false;
-
- protected static Path deobfuscate(String gameId, String gameVersion, Path gameDir, Path jarFile, FabricLauncher launcher) {
- if (!Files.exists(jarFile)) {
- throw new RuntimeException("Could not locate Minecraft: " + jarFile + " not found");
- }
-
- LOGGER.debug("Requesting deobfuscation of " + jarFile.getFileName());
-
- if (!launcher.isDevelopment()) { // in-dev is already deobfuscated
- Path deobfJarDir = gameDir.resolve(".fabric").resolve("remappedJars");
-
- if (!gameId.isEmpty()) {
- String versionedId = gameVersion.isEmpty() ? gameId : String.format("%s-%s", gameId, gameVersion);
- deobfJarDir = deobfJarDir.resolve(versionedId);
- }
-
- String targetNamespace = mappingConfiguration.getTargetNamespace();
- // TODO: allow versioning mappings?
- String deobfJarFilename = targetNamespace + "-" + jarFile.getFileName();
- Path deobfJarFile = deobfJarDir.resolve(deobfJarFilename);
- Path deobfJarFileTmp = deobfJarDir.resolve(deobfJarFilename + ".tmp");
-
- if (Files.exists(deobfJarFileTmp)) { // previous unfinished remap attempt
- LOGGER.warn("Incomplete remapped file found! This means that the remapping process failed on the previous launch. If this persists, make sure to let us at Fabric know!");
-
- try {
- Files.deleteIfExists(deobfJarFile);
- Files.deleteIfExists(deobfJarFileTmp);
- } catch (IOException e) {
- throw new RuntimeException("can't delete incompletely remapped files", e);
- }
- }
-
- TinyTree mappings;
-
- if (!Files.exists(deobfJarFile)
- && (mappings = mappingConfiguration.getMappings()) != null
- && mappings.getMetadata().getNamespaces().contains(targetNamespace)) {
- LOGGER.debug("Fabric mapping file detected, applying...");
-
- if (!emittedInfo) {
- LOGGER.info("Fabric is preparing JARs on first launch, this may take a few seconds...");
- emittedInfo = true;
- }
-
- try {
- deobfuscate0(jarFile, deobfJarFile, deobfJarFileTmp, mappings, targetNamespace);
- } catch (IOException e) {
- throw new RuntimeException("error remapping game jar "+jarFile, e);
- }
- }
-
- jarFile = deobfJarFile;
- }
-
- try {
- launcher.propose(UrlUtil.asUrl(jarFile));
- } catch (UrlConversionException e) {
- throw new RuntimeException(e);
- }
-
- if (minecraftJar == null) {
- minecraftJar = jarFile;
- }
-
- return jarFile;
+ @Override
+ public MappingConfiguration getMappingConfiguration() {
+ return new MappingConfiguration();
}
- private static void deobfuscate0(Path jarFile, Path deobfJarFile, Path deobfJarFileTmp, TinyTree mappings, String targetNamespace) throws IOException {
- Files.createDirectories(deobfJarFile.getParent());
-
- boolean found;
-
- do {
- TinyRemapper remapper = TinyRemapper.newRemapper()
- .withMappings(TinyRemapperMappingsHelper.create(mappings, "official", targetNamespace))
- .rebuildSourceFilenames(true)
- .build();
-
- Set depPaths = new HashSet<>();
-
- for (URL url : launcher.getLoadTimeDependencies()) {
- try {
- Path path = UrlUtil.asPath(url);
-
- if (!Files.exists(path)) {
- throw new RuntimeException("Path does not exist: " + path);
- }
-
- if (!path.equals(jarFile)) {
- depPaths.add(path);
- }
- } catch (UrlConversionException e) {
- throw new RuntimeException("Failed to convert '" + url + "' to path!", e);
- }
- }
-
- try (OutputConsumerPath outputConsumer = new OutputConsumerPath.Builder(deobfJarFileTmp)
- // force jar despite the .tmp extension
- .assumeArchive(true)
- // don't accept class names from a blacklist of dependencies that Fabric itself utilizes
- // TODO: really could use a better solution, as always...
- .filter(clsName -> !clsName.startsWith("com/google/common/")
- && !clsName.startsWith("com/google/gson/")
- && !clsName.startsWith("com/google/thirdparty/")
- && !clsName.startsWith("org/apache/logging/log4j/"))
- .build()) {
- for (Path path : depPaths) {
- LOGGER.debug("Appending '" + path + "' to remapper classpath");
- remapper.readClassPath(path);
- }
-
- remapper.readInputs(jarFile);
- remapper.apply(outputConsumer);
- } finally {
- remapper.finish();
- }
-
- // Minecraft doesn't tend to check if a ZipFileSystem is already present,
- // so we clean up here.
-
- depPaths.add(deobfJarFileTmp);
-
- for (Path p : depPaths) {
- try {
- p.getFileSystem().close();
- } catch (Exception e) {
- // pass
- }
-
- try {
- FileSystems.getFileSystem(new URI("jar:" + p.toUri())).close();
- } catch (Exception e) {
- // pass
- }
- }
-
- try (JarFile jar = new JarFile(deobfJarFileTmp.toFile())) {
- found = jar.stream().anyMatch((e) -> e.getName().endsWith(".class"));
- }
-
- if (!found) {
- LOGGER.error("Generated deobfuscated JAR contains no classes! Trying again...");
- Files.delete(deobfJarFileTmp);
- } else {
- Files.move(deobfJarFileTmp, deobfJarFile);
- }
- } while (!found);
-
- if (!Files.exists(deobfJarFile)) {
- throw new RuntimeException("Remapped .JAR file does not exist after remapping! Cannot continue!");
- }
+ @Override
+ public void propose(URL url) {
+ parent.propose(url);
}
- public static void processArgumentMap(Arguments argMap, EnvType envType) {
- switch (envType) {
- case CLIENT:
- if (!argMap.containsKey("accessToken")) {
- argMap.put("accessToken", "FabricMC");
- }
-
- if (!argMap.containsKey("version")) {
- argMap.put("version", "Fabric");
- }
-
- String versionType = "";
-
- if (argMap.containsKey("versionType") && !argMap.get("versionType").equalsIgnoreCase("release")) {
- versionType = argMap.get("versionType") + "/";
- }
-
- argMap.put("versionType", versionType + "Fabric");
-
- if (!argMap.containsKey("gameDir")) {
- argMap.put("gameDir", getLaunchDirectory(argMap).getAbsolutePath());
- }
-
- break;
- case SERVER:
- argMap.remove("version");
- argMap.remove("gameDir");
- argMap.remove("assetsDir");
- break;
- }
+ @Override
+ public EnvType getEnvironmentType() {
+ return FabricLoader.getInstance().getEnvironmentType();
}
- protected static void setProperties(Map propertiesA) {
- if (properties != null && properties != propertiesA) {
- throw new RuntimeException("Duplicate setProperties call!");
- }
-
- properties = propertiesA;
+ @Override
+ public boolean isClassLoaded(String name) {
+ return parent.isClassLoaded(name);
}
- private static void setLauncher(FabricLauncher launcherA) {
- if (launcher != null && launcher != launcherA) {
- throw new RuntimeException("Duplicate setLauncher call!");
- }
-
- launcher = launcherA;
+ @Override
+ public InputStream getResourceAsStream(String name) {
+ return parent.getResourceAsStream(name);
}
- public static FabricLauncher getLauncher() {
- return launcher;
+ @Override
+ public ClassLoader getTargetClassLoader() {
+ return parent.getTargetClassLoader();
}
- public static Map getProperties() {
- return properties;
+ @Override
+ public byte[] getClassByteArray(String name, boolean runTransformers) throws IOException {
+ return parent.getClassByteArray(name, runTransformers);
}
- protected static void finishMixinBootstrapping() {
- if (mixinReady) {
- throw new RuntimeException("Must not call FabricLauncherBase.finishMixinBootstrapping() twice!");
- }
-
- try {
- Method m = MixinEnvironment.class.getDeclaredMethod("gotoPhase", MixinEnvironment.Phase.class);
- m.setAccessible(true);
- m.invoke(null, MixinEnvironment.Phase.INIT);
- m.invoke(null, MixinEnvironment.Phase.DEFAULT);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- mixinReady = true;
+ @Override
+ public boolean isDevelopment() {
+ return FabricLoader.getInstance().isDevelopmentEnvironment();
}
- public static boolean isMixinReady() {
- return mixinReady;
+ @Override
+ public Collection getLoadTimeDependencies() {
+ return parent.getLoadTimeDependencies();
}
}
diff --git a/src/main/java/net/fabricmc/loader/launch/common/MappingConfiguration.java b/src/main/java/net/fabricmc/loader/launch/common/MappingConfiguration.java
index a01b6b1de..715e7fd7c 100644
--- a/src/main/java/net/fabricmc/loader/launch/common/MappingConfiguration.java
+++ b/src/main/java/net/fabricmc/loader/launch/common/MappingConfiguration.java
@@ -16,60 +16,15 @@
package net.fabricmc.loader.launch.common;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import net.fabricmc.mapping.tree.TinyMappingFactory;
+import net.fabricmc.loader.impl.launch.FabricLauncherBase;
import net.fabricmc.mapping.tree.TinyTree;
+/**
+ * @deprecated Internal API, do not use
+ */
+@Deprecated
public class MappingConfiguration {
- protected static Logger LOGGER = LogManager.getFormatterLogger("FabricLoader");
-
- private static TinyTree mappings;
- private static boolean checkedMappings;
-
public TinyTree getMappings() {
- if (!checkedMappings) {
- InputStream mappingStream = FabricLauncherBase.class.getClassLoader().getResourceAsStream("mappings/mappings.tiny");
-
- if (mappingStream != null) {
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(mappingStream))) {
- long time = System.currentTimeMillis();
- mappings = TinyMappingFactory.loadWithDetection(reader);
- LOGGER.debug("Loading mappings took " + (System.currentTimeMillis() - time) + " ms");
- } catch (IOException ee) {
- ee.printStackTrace();
- }
-
- try {
- mappingStream.close();
- } catch (IOException ee) {
- ee.printStackTrace();
- }
- }
-
- if (mappings == null) {
- LOGGER.info("Mappings not present!");
- mappings = TinyMappingFactory.EMPTY_TREE;
- }
-
- checkedMappings = true;
- }
-
- return mappings;
- }
-
- public String getTargetNamespace() {
- return FabricLauncherBase.getLauncher().isDevelopment() ? "named" : "intermediary";
- }
-
- public boolean requiresPackageAccessHack() {
- // TODO
- return getTargetNamespace().equals("named");
+ return FabricLauncherBase.getLauncher().getMappingConfiguration().getMappings();
}
}
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/KnotClient.java b/src/main/java/net/fabricmc/loader/launch/knot/KnotClient.java
index 5b04512b1..a5526a4f6 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/KnotClient.java
+++ b/src/main/java/net/fabricmc/loader/launch/knot/KnotClient.java
@@ -16,15 +16,15 @@
package net.fabricmc.loader.launch.knot;
-import java.io.File;
-
import net.fabricmc.api.EnvType;
-import net.fabricmc.loader.util.SystemProperties;
+import net.fabricmc.loader.impl.launch.knot.Knot;
-public class KnotClient {
+/**
+ * @deprecated Use {@link net.fabricmc.loader.impl.launch.knot.KnotClient} instead
+ */
+@Deprecated
+public final class KnotClient {
public static void main(String[] args) {
- String gameJarPath = System.getProperty(SystemProperties.GAME_JAR_PATH);
- Knot knot = new Knot(EnvType.CLIENT, gameJarPath != null ? new File(gameJarPath) : null);
- knot.launch(knot.init(args));
+ Knot.launch(args, EnvType.CLIENT);
}
}
diff --git a/src/main/java/net/fabricmc/loader/launch/knot/KnotServer.java b/src/main/java/net/fabricmc/loader/launch/knot/KnotServer.java
index 972238bfd..b6dd3d422 100644
--- a/src/main/java/net/fabricmc/loader/launch/knot/KnotServer.java
+++ b/src/main/java/net/fabricmc/loader/launch/knot/KnotServer.java
@@ -16,15 +16,15 @@
package net.fabricmc.loader.launch.knot;
-import java.io.File;
-
import net.fabricmc.api.EnvType;
-import net.fabricmc.loader.util.SystemProperties;
+import net.fabricmc.loader.impl.launch.knot.Knot;
-public class KnotServer {
+/**
+ * @deprecated Use {@link net.fabricmc.loader.impl.launch.knot.KnotServer} instead
+ */
+@Deprecated
+public final class KnotServer {
public static void main(String[] args) {
- String gameJarPath = System.getProperty(SystemProperties.GAME_JAR_PATH);
- Knot knot = new Knot(EnvType.SERVER, gameJarPath != null ? new File(gameJarPath) : null);
- knot.launch(knot.init(args));
+ Knot.launch(args, EnvType.SERVER);
}
}
diff --git a/src/main/java/net/fabricmc/loader/metadata/EntrypointMetadata.java b/src/main/java/net/fabricmc/loader/metadata/EntrypointMetadata.java
index 8d6d4e655..46cdc46b1 100644
--- a/src/main/java/net/fabricmc/loader/metadata/EntrypointMetadata.java
+++ b/src/main/java/net/fabricmc/loader/metadata/EntrypointMetadata.java
@@ -16,6 +16,10 @@
package net.fabricmc.loader.metadata;
+/**
+ * @deprecated Internal API, do not use
+ */
+@Deprecated
public interface EntrypointMetadata {
String getAdapter();
String getValue();
diff --git a/src/main/java/net/fabricmc/loader/metadata/LoaderModMetadata.java b/src/main/java/net/fabricmc/loader/metadata/LoaderModMetadata.java
index 881abb33e..676db3086 100644
--- a/src/main/java/net/fabricmc/loader/metadata/LoaderModMetadata.java
+++ b/src/main/java/net/fabricmc/loader/metadata/LoaderModMetadata.java
@@ -18,33 +18,16 @@
import java.util.Collection;
import java.util.List;
-import java.util.Map;
-
-import org.apache.logging.log4j.Logger;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.metadata.ModMetadata;
/**
- * Internal variant of the ModMetadata interface.
+ * @deprecated Use {@link ModMetadata} instead
*/
+@Deprecated
public interface LoaderModMetadata extends ModMetadata {
- int getSchemaVersion();
-
- default String getOldStyleLanguageAdapter() {
- return "net.fabricmc.loader.language.JavaLanguageAdapter";
- }
-
- Map getLanguageAdapterDefinitions();
- Collection getJars();
- Collection getMixinConfigs(EnvType type);
- /* @Nullable */
- String getAccessWidener();
boolean loadsInEnvironment(EnvType type);
-
- Collection getOldInitializers();
- List getEntrypoints(String type);
+ List extends EntrypointMetadata> getEntrypoints(String type);
Collection getEntrypointKeys();
-
- void emitFormatWarnings(Logger logger);
}
diff --git a/src/main/java/net/fabricmc/loader/metadata/MapBackedContactInformation.java b/src/main/java/net/fabricmc/loader/metadata/MapBackedContactInformation.java
index 7f86381fc..b3d38f88a 100644
--- a/src/main/java/net/fabricmc/loader/metadata/MapBackedContactInformation.java
+++ b/src/main/java/net/fabricmc/loader/metadata/MapBackedContactInformation.java
@@ -22,6 +22,10 @@
import net.fabricmc.loader.api.metadata.ContactInformation;
+/**
+ * @deprecated Use {@link ContactInformation} instead
+ */
+@Deprecated
public class MapBackedContactInformation implements ContactInformation {
private final Map map;
diff --git a/src/main/java/net/fabricmc/loader/util/DefaultLanguageAdapter.java b/src/main/java/net/fabricmc/loader/util/DefaultLanguageAdapter.java
index c50213baa..eddb8e9d1 100644
--- a/src/main/java/net/fabricmc/loader/util/DefaultLanguageAdapter.java
+++ b/src/main/java/net/fabricmc/loader/util/DefaultLanguageAdapter.java
@@ -16,126 +16,19 @@
package net.fabricmc.loader.util;
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandleProxies;
-import java.lang.invoke.MethodHandles;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.List;
-
import net.fabricmc.loader.api.LanguageAdapter;
import net.fabricmc.loader.api.LanguageAdapterException;
import net.fabricmc.loader.api.ModContainer;
-import net.fabricmc.loader.launch.common.FabricLauncherBase;
+/**
+ * @deprecated Use {@link LanguageAdapter} instead.
+ */
+@Deprecated
public final class DefaultLanguageAdapter implements LanguageAdapter {
public static final DefaultLanguageAdapter INSTANCE = new DefaultLanguageAdapter();
- private DefaultLanguageAdapter() { }
-
- @SuppressWarnings("unchecked")
@Override
public T create(ModContainer mod, String value, Class type) throws LanguageAdapterException {
- String[] methodSplit = value.split("::");
-
- if (methodSplit.length >= 3) {
- throw new LanguageAdapterException("Invalid handle format: " + value);
- }
-
- Class> c;
-
- try {
- c = Class.forName(methodSplit[0], true, FabricLauncherBase.getLauncher().getTargetClassLoader());
- } catch (ClassNotFoundException e) {
- throw new LanguageAdapterException(e);
- }
-
- if (methodSplit.length == 1) {
- if (type.isAssignableFrom(c)) {
- try {
- return (T) c.getDeclaredConstructor().newInstance();
- } catch (Exception e) {
- throw new LanguageAdapterException(e);
- }
- } else {
- throw new LanguageAdapterException("Class " + c.getName() + " cannot be cast to " + type.getName() + "!");
- }
- } else /* length == 2 */ {
- List methodList = new ArrayList<>();
-
- for (Method m : c.getDeclaredMethods()) {
- if (!(m.getName().equals(methodSplit[1]))) {
- continue;
- }
-
- methodList.add(m);
- }
-
- try {
- Field field = c.getDeclaredField(methodSplit[1]);
- Class> fType = field.getType();
-
- if ((field.getModifiers() & Modifier.STATIC) == 0) {
- throw new LanguageAdapterException("Field " + value + " must be static!");
- }
-
- if (!methodList.isEmpty()) {
- throw new LanguageAdapterException("Ambiguous " + value + " - refers to both field and method!");
- }
-
- if (!type.isAssignableFrom(fType)) {
- throw new LanguageAdapterException("Field " + value + " cannot be cast to " + type.getName() + "!");
- }
-
- return (T) field.get(null);
- } catch (NoSuchFieldException e) {
- // ignore
- } catch (IllegalAccessException e) {
- throw new LanguageAdapterException("Field " + value + " cannot be accessed!", e);
- }
-
- if (!type.isInterface()) {
- throw new LanguageAdapterException("Cannot proxy method " + value + " to non-interface type " + type.getName() + "!");
- }
-
- if (methodList.isEmpty()) {
- throw new LanguageAdapterException("Could not find " + value + "!");
- } else if (methodList.size() >= 2) {
- throw new LanguageAdapterException("Found multiple method entries of name " + value + "!");
- }
-
- final Method targetMethod = methodList.get(0);
- Object object = null;
-
- if ((targetMethod.getModifiers() & Modifier.STATIC) == 0) {
- try {
- object = c.getDeclaredConstructor().newInstance();
- } catch (Exception e) {
- throw new LanguageAdapterException(e);
- }
- }
-
- MethodHandle handle;
-
- try {
- handle = MethodHandles.lookup()
- .unreflect(targetMethod);
- } catch (Exception ex) {
- throw new LanguageAdapterException(ex);
- }
-
- if (object != null) {
- handle = handle.bindTo(object);
- }
-
- // uses proxy as well, but this handles default and object methods
- try {
- return MethodHandleProxies.asInterfaceInstance(type, handle);
- } catch (Exception ex) {
- throw new LanguageAdapterException(ex);
- }
- }
+ return LanguageAdapter.getDefault().create(mod, value, type);
}
}
diff --git a/src/main/java/net/fabricmc/loader/util/UrlConversionException.java b/src/main/java/net/fabricmc/loader/util/UrlConversionException.java
index f058b5111..969017f37 100644
--- a/src/main/java/net/fabricmc/loader/util/UrlConversionException.java
+++ b/src/main/java/net/fabricmc/loader/util/UrlConversionException.java
@@ -16,7 +16,11 @@
package net.fabricmc.loader.util;
+/**
+ * @deprecated Internal API, do not use
+ */
@SuppressWarnings("serial")
+@Deprecated
public class UrlConversionException extends Exception {
public UrlConversionException() {
super();
diff --git a/src/main/java/net/fabricmc/loader/util/UrlUtil.java b/src/main/java/net/fabricmc/loader/util/UrlUtil.java
index 1b941bee5..5d0c0ce3c 100644
--- a/src/main/java/net/fabricmc/loader/util/UrlUtil.java
+++ b/src/main/java/net/fabricmc/loader/util/UrlUtil.java
@@ -16,76 +16,17 @@
package net.fabricmc.loader.util;
-import java.io.File;
-import java.net.JarURLConnection;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
import java.net.URL;
-import java.net.URLConnection;
import java.nio.file.Path;
-import java.nio.file.Paths;
+/**
+ * @deprecated Internal API, do not use
+ */
+@Deprecated
public final class UrlUtil {
private UrlUtil() { }
- public static URL getSource(String filename, URL resourceURL) throws UrlConversionException {
- URL codeSourceURL;
-
- try {
- URLConnection connection = resourceURL.openConnection();
-
- if (connection instanceof JarURLConnection) {
- codeSourceURL = ((JarURLConnection) connection).getJarFileURL();
- } else {
- String path = resourceURL.getPath();
-
- if (path.endsWith(filename)) {
- codeSourceURL = new URL(resourceURL.getProtocol(), resourceURL.getHost(), resourceURL.getPort(), path.substring(0, path.length() - filename.length()));
- } else {
- throw new UrlConversionException("Could not figure out code source for file '" + filename + "' and URL '" + resourceURL + "'!");
- }
- }
- } catch (Exception e) {
- throw new UrlConversionException(e);
- }
-
- return codeSourceURL;
- }
-
- public static File asFile(URL url) throws UrlConversionException {
- try {
- return new File(url.toURI());
- } catch (URISyntaxException e) {
- throw new UrlConversionException(e);
- }
- }
-
public static Path asPath(URL url) throws UrlConversionException {
- if (url.getProtocol().equals("file")) {
- // TODO: Is this required?
- return asFile(url).toPath();
- } else {
- try {
- return Paths.get(url.toURI());
- } catch (URISyntaxException e) {
- throw new UrlConversionException(e);
- }
- }
- }
-
- public static URL asUrl(File file) throws UrlConversionException {
- try {
- return file.toURI().toURL();
- } catch (MalformedURLException e) {
- throw new UrlConversionException(e);
- }
- }
-
- public static URL asUrl(Path path) throws UrlConversionException {
- try {
- return new URL(null, path.toUri().toString());
- } catch (MalformedURLException e) {
- throw new UrlConversionException(e);
- }
+ return net.fabricmc.loader.impl.util.UrlUtil.asPath(url);
}
}
diff --git a/src/main/resources/META-INF/services/org.spongepowered.asm.service.IGlobalPropertyService b/src/main/resources/META-INF/services/org.spongepowered.asm.service.IGlobalPropertyService
index 8e1d79d1f..43780be2c 100644
--- a/src/main/resources/META-INF/services/org.spongepowered.asm.service.IGlobalPropertyService
+++ b/src/main/resources/META-INF/services/org.spongepowered.asm.service.IGlobalPropertyService
@@ -1 +1 @@
-net.fabricmc.loader.launch.knot.FabricGlobalPropertyService
\ No newline at end of file
+net.fabricmc.loader.impl.launch.knot.FabricGlobalPropertyService
\ No newline at end of file
diff --git a/src/main/resources/META-INF/services/org.spongepowered.asm.service.IMixinService b/src/main/resources/META-INF/services/org.spongepowered.asm.service.IMixinService
index 5af564377..d810591e5 100644
--- a/src/main/resources/META-INF/services/org.spongepowered.asm.service.IMixinService
+++ b/src/main/resources/META-INF/services/org.spongepowered.asm.service.IMixinService
@@ -1 +1 @@
-net.fabricmc.loader.launch.knot.MixinServiceKnot
\ No newline at end of file
+net.fabricmc.loader.impl.launch.knot.MixinServiceKnot
\ No newline at end of file
diff --git a/src/main/resources/META-INF/services/org.spongepowered.asm.service.IMixinServiceBootstrap b/src/main/resources/META-INF/services/org.spongepowered.asm.service.IMixinServiceBootstrap
index 7bd3aaac8..3057481b1 100644
--- a/src/main/resources/META-INF/services/org.spongepowered.asm.service.IMixinServiceBootstrap
+++ b/src/main/resources/META-INF/services/org.spongepowered.asm.service.IMixinServiceBootstrap
@@ -1 +1 @@
-net.fabricmc.loader.launch.knot.MixinServiceKnotBootstrap
\ No newline at end of file
+net.fabricmc.loader.impl.launch.knot.MixinServiceKnotBootstrap
\ No newline at end of file
diff --git a/src/main/resources/fabric-installer.json b/src/main/resources/fabric-installer.json
index 8902e0384..884d122dc 100644
--- a/src/main/resources/fabric-installer.json
+++ b/src/main/resources/fabric-installer.json
@@ -59,7 +59,7 @@
]
},
"mainClass": {
- "client": "net.fabricmc.loader.launch.knot.KnotClient",
- "server": "net.fabricmc.loader.launch.knot.KnotServer"
+ "client": "net.fabricmc.loader.impl.launch.knot.KnotClient",
+ "server": "net.fabricmc.loader.impl.launch.knot.KnotServer"
}
}
diff --git a/src/main/resources/fabric-installer.launchwrapper.json b/src/main/resources/fabric-installer.launchwrapper.json
index 66fe02c09..fcb8e1162 100644
--- a/src/main/resources/fabric-installer.launchwrapper.json
+++ b/src/main/resources/fabric-installer.launchwrapper.json
@@ -76,12 +76,12 @@
"launchwrapper": {
"tweakers": {
"client": [
- "net.fabricmc.loader.launch.FabricClientTweaker"
+ "net.fabricmc.loader.impl.game.minecraft.launchwrapper.FabricClientTweaker"
],
"common": [
],
"server": [
- "net.fabricmc.loader.launch.FabricServerTweaker"
+ "net.fabricmc.loader.impl.game.minecraft.launchwrapper.FabricServerTweaker"
]
}
}
diff --git a/src/test/java/net/fabricmc/test/McVersionLookupTest.java b/src/test/java/net/fabricmc/test/McVersionLookupTest.java
index 7262e8977..6bcbd3580 100644
--- a/src/test/java/net/fabricmc/test/McVersionLookupTest.java
+++ b/src/test/java/net/fabricmc/test/McVersionLookupTest.java
@@ -27,8 +27,8 @@
import java.util.List;
import java.util.regex.Pattern;
-import net.fabricmc.loader.minecraft.McVersionLookup;
-import net.fabricmc.loader.minecraft.McVersion;
+import net.fabricmc.loader.impl.game.minecraft.McVersion;
+import net.fabricmc.loader.impl.game.minecraft.McVersionLookup;
public final class McVersionLookupTest {
public static void main(String[] args) throws IOException {
diff --git a/src/test/java/net/fabricmc/test/TestMod.java b/src/test/java/net/fabricmc/test/TestMod.java
index 0dcf71c09..b469537f6 100644
--- a/src/test/java/net/fabricmc/test/TestMod.java
+++ b/src/test/java/net/fabricmc/test/TestMod.java
@@ -26,7 +26,7 @@
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
-import net.fabricmc.loader.launch.common.FabricLauncherBase;
+import net.fabricmc.loader.impl.launch.FabricLauncherBase;
public class TestMod implements PreLaunchEntrypoint, ModInitializer {
private static final Logger LOGGER = LogManager.getFormatterLogger("TestMod");
diff --git a/src/test/java/net/fabricmc/test/V1ModJsonParsingTests.java b/src/test/java/net/fabricmc/test/V1ModJsonParsingTests.java
index bad80be08..134526389 100644
--- a/src/test/java/net/fabricmc/test/V1ModJsonParsingTests.java
+++ b/src/test/java/net/fabricmc/test/V1ModJsonParsingTests.java
@@ -34,9 +34,9 @@
import net.fabricmc.loader.api.SemanticVersion;
import net.fabricmc.loader.api.metadata.CustomValue;
-import net.fabricmc.loader.metadata.LoaderModMetadata;
-import net.fabricmc.loader.metadata.ModMetadataParser;
-import net.fabricmc.loader.metadata.ParseMetadataException;
+import net.fabricmc.loader.impl.metadata.LoaderModMetadata;
+import net.fabricmc.loader.impl.metadata.ModMetadataParser;
+import net.fabricmc.loader.impl.metadata.ParseMetadataException;
final class V1ModJsonParsingTests {
private static final Logger LOGGER = LogManager.getLogger();
@@ -69,12 +69,12 @@ public void testRequiredValues() throws IOException, ParseMetadataException {
// Required fields
final LoaderModMetadata metadata = ModMetadataParser.parseMetadata(LOGGER, specPath.resolve("required.json"));
assertNotNull(metadata, "Failed to read mod metadata!");
- this.validateRequiredValues(metadata);
+ validateRequiredValues(metadata);
// Required fields in different order to verify we don't have ordering issues
final LoaderModMetadata reversedMetadata = ModMetadataParser.parseMetadata(LOGGER, specPath.resolve("required_reversed.json"));
assertNotNull(reversedMetadata, "Failed to read mod metadata!");
- this.validateRequiredValues(reversedMetadata);
+ validateRequiredValues(reversedMetadata);
}
@Test
diff --git a/src/test/java/net/fabricmc/test/VersionParsingTests.java b/src/test/java/net/fabricmc/test/VersionParsingTests.java
index f47c51d52..93d959a8c 100644
--- a/src/test/java/net/fabricmc/test/VersionParsingTests.java
+++ b/src/test/java/net/fabricmc/test/VersionParsingTests.java
@@ -21,8 +21,8 @@
import org.jetbrains.annotations.Nullable;
import net.fabricmc.loader.api.VersionParsingException;
-import net.fabricmc.loader.util.version.SemanticVersionImpl;
-import net.fabricmc.loader.util.version.SemanticVersionPredicateParser;
+import net.fabricmc.loader.impl.util.version.SemanticVersionImpl;
+import net.fabricmc.loader.impl.util.version.SemanticVersionPredicateParser;
public class VersionParsingTests {
private static Exception tryParseSemantic(String s, boolean storeX) {