update code, require java 21
This commit is contained in:
parent
1897ccd1c3
commit
a2b632bf2d
|
@ -22,14 +22,16 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.ecorous.esnesnon:mojmap-patcher:1.0.0-SNAPSHOT")
|
||||
implementation("org.ecorous.esnesnon:nonsense-remapper:1.0.0-SNAPSHOT")
|
||||
implementation("net.fabricmc:sponge-mixin:0.13.4+mixin.0.8.5")
|
||||
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:3.0.0-beta2")
|
||||
implementation("org.apache.logging.log4j:log4j-api:3.0.0-beta2")
|
||||
implementation("org.apache.logging.log4j:log4j-core:3.0.0-beta2")
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package org.ecorous.esnesnon.nonsense.loader.impl;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -18,8 +15,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class LoaderImpl implements Loader {
|
||||
|
||||
private static final String PLUGIN_SERVICE_FILE_LOCATION = "META-INF/services/org.ecorous.esnesnon.nonsense.loader.impl.plugin.NonsensePlugin";
|
||||
// TODO decide this
|
||||
public static final String MOD_FILE_EXTENSION = ".nonsense";
|
||||
|
||||
|
@ -75,35 +70,9 @@ public class LoaderImpl implements Loader {
|
|||
}
|
||||
|
||||
private void discoverPlugins() {
|
||||
List<String> classes = new ArrayList<>();
|
||||
this.getClass().getClassLoader().resources(PLUGIN_SERVICE_FILE_LOCATION).distinct().forEach(url -> {
|
||||
try (InputStream inputStream = url.openStream()) {
|
||||
new BufferedReader(new InputStreamReader(inputStream)).lines().forEach(classes::add);
|
||||
} catch (IOException e) {
|
||||
// TODO error handling
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
});
|
||||
LOGGER.info("Found plugins: \n{}", String.join("\t\n", classes));
|
||||
|
||||
for (Class<?> c : classes.stream().map((String className) -> {
|
||||
try {
|
||||
return classloader.findClass(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// TODO error handling
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}).filter(NonsensePlugin.class::isAssignableFrom).toList()){
|
||||
try {
|
||||
MethodHandle ctor = MethodHandles.publicLookup().findConstructor(c, MethodType.methodType(void.class));
|
||||
NonsensePlugin plugin = (NonsensePlugin) ctor.invoke();
|
||||
for (NonsensePlugin plugin : ServiceLoader.load(NonsensePlugin.class, classloader)) {
|
||||
plugin.init(this);
|
||||
plugins.add(plugin);
|
||||
if (plugin.init(this)){
|
||||
break;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Failed to instantiate plugin: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.ecorous.esnesnon.nonsense.loader.impl.plugin.game;
|
|||
import org.ecorous.esnesnon.nonsense.loader.impl.Discovery;
|
||||
import org.ecorous.esnesnon.nonsense.loader.impl.LoaderImpl;
|
||||
import org.ecorous.esnesnon.nonsense.loader.impl.plugin.NonsensePlugin;
|
||||
import org.ecorous.esnesnon.mojmap_patcher.MojMapPatcher;
|
||||
import org.ecorous.esnesnon.nonsense_remapper.NonsenseRemapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -65,8 +65,7 @@ public class Minecraft implements NonsensePlugin {
|
|||
|
||||
if (!Files.exists(remappedGamePath)){
|
||||
try {
|
||||
|
||||
MojMapPatcher.run(version, gameJar, remappedGamePath);
|
||||
NonsenseRemapper.run(version, gameJar, remappedGamePath, true, false);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue