move things around for better organisation
This commit is contained in:
parent
8a75f71ab4
commit
530797fcdb
|
@ -3,7 +3,7 @@ package io.github.moehreag.nonsense.loader.api;
|
|||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.moehreag.nonsense.loader.impl.Env;
|
||||
import io.github.moehreag.nonsense.loader.api.env.Env;
|
||||
import io.github.moehreag.nonsense.loader.impl.LoaderImpl;
|
||||
import io.github.moehreag.nonsense.loader.impl.plugin.NonsensePlugin;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package io.github.moehreag.nonsense.loader.impl;
|
||||
package io.github.moehreag.nonsense.loader.api.env;
|
||||
|
||||
import lombok.Getter;
|
||||
|
|
@ -10,6 +10,8 @@ import java.nio.file.Paths;
|
|||
import java.util.*;
|
||||
|
||||
import io.github.moehreag.nonsense.loader.api.Loader;
|
||||
import io.github.moehreag.nonsense.loader.api.env.Env;
|
||||
import io.github.moehreag.nonsense.loader.impl.launch.MixinClassloader;
|
||||
import io.github.moehreag.nonsense.loader.impl.plugin.NonsensePlugin;
|
||||
import lombok.Getter;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -84,24 +86,25 @@ public class LoaderImpl implements Loader {
|
|||
});
|
||||
LOGGER.info("Found plugins: \n{}", String.join("\t\n", classes));
|
||||
|
||||
classes.stream().map((String className) -> {
|
||||
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).forEach(c -> {
|
||||
}).filter(NonsensePlugin.class::isAssignableFrom).toList()){
|
||||
try {
|
||||
MethodHandle ctor = MethodHandles.publicLookup().findConstructor(c, MethodType.methodType(void.class));
|
||||
NonsensePlugin plugin = (NonsensePlugin) ctor.invoke();
|
||||
plugins.add(plugin);
|
||||
plugin.init(this);
|
||||
if (plugin.init(this)){
|
||||
break;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("Failed to instantiate plugin: ", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public String getArgument(String name){
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package io.github.moehreag.nonsense.loader.impl.client;
|
||||
|
||||
import io.github.moehreag.nonsense.loader.impl.Launcher;
|
||||
import io.github.moehreag.nonsense.loader.impl.Env;
|
||||
|
||||
public class NonsenseClient {
|
||||
|
||||
public static void main(String[] args){
|
||||
Launcher.run(args, Env.CLIENT);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package io.github.moehreag.nonsense.loader.impl;
|
||||
package io.github.moehreag.nonsense.loader.impl.launch;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
@ -14,6 +14,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.github.moehreag.nonsense.loader.api.env.Env;
|
||||
import io.github.moehreag.nonsense.loader.impl.mixin.NonsenseMixinService;
|
||||
import lombok.Getter;
|
||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
|
@ -1,4 +1,4 @@
|
|||
package io.github.moehreag.nonsense.loader.impl;
|
||||
package io.github.moehreag.nonsense.loader.impl.launch;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
|
@ -0,0 +1,11 @@
|
|||
package io.github.moehreag.nonsense.loader.impl.launch.client;
|
||||
|
||||
import io.github.moehreag.nonsense.loader.impl.launch.Launcher;
|
||||
import io.github.moehreag.nonsense.loader.api.env.Env;
|
||||
|
||||
public class NonsenseClient {
|
||||
|
||||
public static void main(String[] args){
|
||||
Launcher.run(args, Env.CLIENT);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package io.github.moehreag.nonsense.loader.impl.launch.server;
|
||||
|
||||
import io.github.moehreag.nonsense.loader.impl.launch.Launcher;
|
||||
import io.github.moehreag.nonsense.loader.api.env.Env;
|
||||
|
||||
public class NonsenseServer {
|
||||
|
||||
public static void main(String[] args){
|
||||
Launcher.run(args, Env.SERVER);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package io.github.moehreag.nonsense.loader.impl.mixin;
|
||||
|
||||
import io.github.moehreag.nonsense.loader.impl.Launcher;
|
||||
import io.github.moehreag.nonsense.loader.impl.launch.Launcher;
|
||||
import org.spongepowered.asm.service.IGlobalPropertyService;
|
||||
import org.spongepowered.asm.service.IPropertyKey;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package io.github.moehreag.nonsense.loader.impl.mixin;
|
||||
|
||||
import io.github.moehreag.nonsense.loader.impl.Launcher;
|
||||
import io.github.moehreag.nonsense.loader.impl.launch.Launcher;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.launch.platform.container.ContainerHandleVirtual;
|
||||
|
|
|
@ -8,7 +8,7 @@ public interface NonsensePlugin extends Runnable {
|
|||
|
||||
}
|
||||
|
||||
default void init(LoaderImpl loader) {
|
||||
|
||||
default boolean init(LoaderImpl loader) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,13 @@ public class Minecraft implements NonsensePlugin {
|
|||
private String foundMainClass;
|
||||
|
||||
@Override
|
||||
public void init(LoaderImpl loader) {
|
||||
public boolean init(LoaderImpl loader) {
|
||||
Path gameJar = findGame();
|
||||
if (gameJar == null){
|
||||
return false;
|
||||
//throw new IllegalStateException("Could not find game jar!");
|
||||
}
|
||||
|
||||
version = loader.getArgument("version");
|
||||
remappedGamePath = loader.getGameDir().resolve(".nonsense/remappedJars").resolve(version).resolve("game-"+version+"-remapped.jar");
|
||||
|
||||
|
@ -57,10 +63,6 @@ public class Minecraft implements NonsensePlugin {
|
|||
}).forEach(LoaderImpl.getInstance().getClassloader()::addURL);
|
||||
LOGGER.info("Found {} mods", mods.size());
|
||||
|
||||
Path gameJar = findGame();
|
||||
if (gameJar == null){
|
||||
throw new IllegalStateException("Could not find game jar!");
|
||||
}
|
||||
if (!Files.exists(remappedGamePath)){
|
||||
try {
|
||||
|
||||
|
@ -75,7 +77,7 @@ public class Minecraft implements NonsensePlugin {
|
|||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Path findGame() {
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package io.github.moehreag.nonsense.loader.impl.server;
|
||||
|
||||
import io.github.moehreag.nonsense.loader.impl.Launcher;
|
||||
import io.github.moehreag.nonsense.loader.impl.Env;
|
||||
|
||||
public class NonsenseServer {
|
||||
|
||||
public static void main(String[] args){
|
||||
Launcher.run(args, Env.SERVER);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue