Skip to content

Commit

Permalink
Fix last usages of ClassLoaderURLAppender
Browse files Browse the repository at this point in the history
ClassLoaderURLAppender used to exist for compatibility with Launchwrapper but since we no longer use launchwrapper it is safe to remove since we now control how our classloaders work
  • Loading branch information
ChachyDev committed Aug 4, 2021
1 parent c8cb340 commit fd86cf1
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 103 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ext {
}

group "org.bookmc"
version "0.6.0${local ? "+local" : ""}"
version "0.6.1${local ? "+local" : ""}"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.bookmc.loader.api.candidate;

import org.bookmc.loader.api.classloader.ClassLoaderURLAppender;
import org.bookmc.loader.api.classloader.IQuiltClassLoader;
import org.bookmc.loader.api.vessel.ModVessel;
import org.bookmc.loader.impl.candidate.ZipModCandidate;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.bookmc.loader.api.compat;

import org.bookmc.loader.api.classloader.ClassLoaderURLAppender;
import org.bookmc.loader.api.classloader.IQuiltClassLoader;

public interface CompatiblityLayer {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/bookmc/loader/impl/Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.apache.logging.log4j.Logger;
import org.bookmc.loader.api.ModResolver;
import org.bookmc.loader.api.candidate.ModCandidate;
import org.bookmc.loader.api.classloader.ClassLoaderURLAppender;
import org.bookmc.loader.api.classloader.IQuiltClassLoader;
import org.bookmc.loader.api.classloader.ModClassLoader;
import org.bookmc.loader.api.compat.CompatiblityLayer;
Expand Down Expand Up @@ -415,7 +414,7 @@ private static void sortClassLoaderDependsOn(ModDependency dependency, ModVessel
if (dependencyVessel.getAbstractedClassLoader() != vessel.getAbstractedClassLoader() && !dependencyVessel.isInternal()) {
URL[] urls = dependencyVessel.getAbstractedClassLoader().getClassLoader().getURLs();
for (URL url : urls) {
ClassLoaderURLAppender.add(vessel.getAbstractedClassLoader().getClassLoader(), url);
vessel.getAbstractedClassLoader().addURL(url);
}
dependencyVessel.setClassLoader(vessel.getAbstractedClassLoader());
for (ModDependency modDependency : dependencyVessel.getDependsOn()) {
Expand All @@ -431,7 +430,7 @@ private static void sortClassLoaderSuggests(ModDependency dependency, ModVessel
if (dependencyVessel.getAbstractedClassLoader() != vessel.getAbstractedClassLoader()) {
URL[] urls = dependencyVessel.getAbstractedClassLoader().getClassLoader().getURLs();
for (URL url : urls) {
ClassLoaderURLAppender.add(vessel.getAbstractedClassLoader().getClassLoader(), url);
vessel.getAbstractedClassLoader().addURL(url);
}
dependencyVessel.setClassLoader(vessel.getAbstractedClassLoader());
for (ModDependency modDependency : dependencyVessel.getSuggestions()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bookmc.loader.api.candidate.ModCandidate;
import org.bookmc.loader.api.classloader.ClassLoaderURLAppender;
import org.bookmc.loader.api.classloader.IQuiltClassLoader;
import org.bookmc.loader.api.vessel.ModVessel;
import org.bookmc.loader.impl.launch.Launcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bookmc.loader.api.candidate.ModCandidate;
import org.bookmc.loader.api.classloader.ClassLoaderURLAppender;
import org.bookmc.loader.api.classloader.IQuiltClassLoader;
import org.bookmc.loader.api.vessel.ModVessel;
import org.bookmc.loader.impl.launch.Launcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bookmc.loader.api.candidate.ModCandidate;
import org.bookmc.loader.api.classloader.ClassLoaderURLAppender;
import org.bookmc.loader.api.classloader.IQuiltClassLoader;
import org.bookmc.loader.api.vessel.ModVessel;
import org.bookmc.loader.impl.vessel.JsonModVessel;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/bookmc/loader/impl/launch/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public static File getModsFolder() {
* We first use the parent ({@link QuiltClassLoader}) to check for the resource.
* If it's not available we then iterate through our vessels and ask them for the
* resource and if they return the resource when use that.
*
* @param name The name of the resource to look for.
* @return The looked up resource.
*/
Expand Down Expand Up @@ -103,6 +104,7 @@ public static Map<String, Object> getProperties() {
* If they were to exist then we are simply not in the development
* environment because they would be deobfuscated in the development
* environment.
*
* @return Whether we are in the development environment or not
*/
public static boolean isDevelopment() {
Expand All @@ -116,7 +118,8 @@ public static boolean isDevelopment() {
* We first use the parent {@link QuiltClassLoader} and search for the class. If it isn't available there
* when then move onto our mod vessels and we iterate through them to try find the resource
* through their classloaders.
* @param name The name of the class we want to locate
*
* @param name The name of the class we want to locate
* @param transform Whether we want the transformed version or not of the class
* @return The bytes of the discovered class.
*/
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/bookmc/loader/impl/launch/Quilt.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.bookmc.loader.impl.Loader;
import org.bookmc.loader.impl.launch.provider.ArgumentHandler;
import org.bookmc.loader.impl.launch.provider.DefaultGameProvider;
import org.bookmc.loader.impl.launch.provider.GameProvider;
import org.bookmc.loader.impl.launch.transform.QuiltClassLoader;
import org.bookmc.loader.impl.vessel.dummy.BookLoaderVessel;
import org.bookmc.loader.impl.vessel.dummy.JavaModVessel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,6 @@
import java.util.ArrayList;

public class ClasspathModResolver implements ModResolver {
@Override
public void resolve(File[] files) {
URL[] classpath = getClasspathURLs();
if (classpath == null) {
return;
}

for (URL url : classpath) {
try {
File file = new File(url.toURI());
String name = file.getName();

if (!name.endsWith(Constants.DISABLED_SUFFIX)) {
if (ZipUtils.isZipFile(file)) {
Loader.registerCandidate(new ZipModCandidate(new File(url.toURI())));
} else if (file.isDirectory()) {
Loader.registerCandidate(new DirectoryModCandidate(file));
}
}
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}

@SuppressWarnings("unchecked")
public static URL[] getClasspathURLs() {
ClassLoader classLoader = Quilt.class.getClassLoader();
Expand Down Expand Up @@ -78,4 +53,29 @@ public static URL[] getClasspathURLs() {
}
return null;
}

@Override
public void resolve(File[] files) {
URL[] classpath = getClasspathURLs();
if (classpath == null) {
return;
}

for (URL url : classpath) {
try {
File file = new File(url.toURI());
String name = file.getName();

if (!name.endsWith(Constants.DISABLED_SUFFIX)) {
if (ZipUtils.isZipFile(file)) {
Loader.registerCandidate(new ZipModCandidate(new File(url.toURI())));
} else if (file.isDirectory()) {
Loader.registerCandidate(new DirectoryModCandidate(file));
}
}
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.bookmc.loader.impl.vessel.dummy.candidate;

import org.bookmc.loader.api.candidate.ModCandidate;
import org.bookmc.loader.api.classloader.ClassLoaderURLAppender;
import org.bookmc.loader.api.classloader.IQuiltClassLoader;
import org.bookmc.loader.api.vessel.ModVessel;

Expand Down

0 comments on commit fd86cf1

Please sign in to comment.