rename nonsense -> frog
This commit is contained in:
parent
6ff44aac48
commit
621816c6d8
|
@ -7,12 +7,12 @@ import java.util.Optional;
|
||||||
import dev.frogmc.frogloader.api.env.Env;
|
import dev.frogmc.frogloader.api.env.Env;
|
||||||
import dev.frogmc.frogloader.api.mod.ModProperties;
|
import dev.frogmc.frogloader.api.mod.ModProperties;
|
||||||
import dev.frogmc.frogloader.api.plugin.NonsensePlugin;
|
import dev.frogmc.frogloader.api.plugin.NonsensePlugin;
|
||||||
import dev.frogmc.frogloader.impl.LoaderImpl;
|
import dev.frogmc.frogloader.impl.FrogLoaderImpl;
|
||||||
|
|
||||||
public interface Loader {
|
public interface FrogLoader {
|
||||||
|
|
||||||
static Loader getInstance() {
|
static FrogLoader getInstance() {
|
||||||
return LoaderImpl.getInstance();
|
return FrogLoaderImpl.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NonsensePlugin> getPlugins();
|
List<NonsensePlugin> getPlugins();
|
|
@ -2,7 +2,7 @@ package dev.frogmc.frogloader.api.plugin;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import dev.frogmc.frogloader.api.Loader;
|
import dev.frogmc.frogloader.api.FrogLoader;
|
||||||
import dev.frogmc.frogloader.api.mod.ModProperties;
|
import dev.frogmc.frogloader.api.mod.ModProperties;
|
||||||
|
|
||||||
public interface NonsensePlugin extends Runnable {
|
public interface NonsensePlugin extends Runnable {
|
||||||
|
@ -18,7 +18,7 @@ public interface NonsensePlugin extends Runnable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default void init(Loader loader) throws Exception {
|
default void init(FrogLoader loader) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<ModProperties> getMods();
|
Collection<ModProperties> getMods();
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import dev.frogmc.frogloader.api.Loader;
|
import dev.frogmc.frogloader.api.FrogLoader;
|
||||||
import dev.frogmc.frogloader.api.env.Env;
|
import dev.frogmc.frogloader.api.env.Env;
|
||||||
import dev.frogmc.frogloader.api.mod.ModProperties;
|
import dev.frogmc.frogloader.api.mod.ModProperties;
|
||||||
import dev.frogmc.frogloader.api.plugin.NonsensePlugin;
|
import dev.frogmc.frogloader.api.plugin.NonsensePlugin;
|
||||||
|
@ -22,10 +22,10 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||||
|
|
||||||
public class LoaderImpl implements Loader {
|
public class FrogLoaderImpl implements FrogLoader {
|
||||||
public static final String MOD_FILE_EXTENSION = ".frogmod";
|
public static final String MOD_FILE_EXTENSION = ".frogmod";
|
||||||
@Getter
|
@Getter
|
||||||
private static LoaderImpl instance;
|
private static FrogLoaderImpl instance;
|
||||||
private final boolean DEV_ENV = Boolean.getBoolean("frogmc.development");
|
private final boolean DEV_ENV = Boolean.getBoolean("frogmc.development");
|
||||||
@Getter
|
@Getter
|
||||||
private final String[] args;
|
private final String[] args;
|
||||||
|
@ -49,7 +49,7 @@ public class LoaderImpl implements Loader {
|
||||||
private final Collection<String> modIds;
|
private final Collection<String> modIds;
|
||||||
|
|
||||||
|
|
||||||
private LoaderImpl(String[] args, Env env) {
|
private FrogLoaderImpl(String[] args, Env env) {
|
||||||
instance = this;
|
instance = this;
|
||||||
this.classloader = (MixinClassLoader) this.getClass().getClassLoader();
|
this.classloader = (MixinClassLoader) this.getClass().getClassLoader();
|
||||||
this.args = args;
|
this.args = args;
|
||||||
|
@ -82,7 +82,7 @@ public class LoaderImpl implements Loader {
|
||||||
throw new IllegalStateException("Loader was started multiple times!");
|
throw new IllegalStateException("Loader was started multiple times!");
|
||||||
}
|
}
|
||||||
|
|
||||||
new LoaderImpl(args, env);
|
new FrogLoaderImpl(args, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void advanceMixinState() {
|
private void advanceMixinState() {
|
|
@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
import dev.frogmc.frogloader.impl.LoaderImpl;
|
import dev.frogmc.frogloader.impl.FrogLoaderImpl;
|
||||||
import dev.frogmc.frogloader.impl.mod.ModDependencyResolver;
|
import dev.frogmc.frogloader.impl.mod.ModDependencyResolver;
|
||||||
import dev.frogmc.frogloader.impl.mod.ModUtil;
|
import dev.frogmc.frogloader.impl.mod.ModUtil;
|
||||||
import dev.frogmc.frogloader.impl.util.URLUtil;
|
import dev.frogmc.frogloader.impl.util.URLUtil;
|
||||||
|
@ -76,7 +76,7 @@ public class LoaderGui {
|
||||||
}
|
}
|
||||||
List<JButton> actions = new ArrayList<>();
|
List<JButton> actions = new ArrayList<>();
|
||||||
if (e.link() != null) {
|
if (e.link() != null) {
|
||||||
boolean install = e.link().endsWith(LoaderImpl.MOD_FILE_EXTENSION);
|
boolean install = e.link().endsWith(FrogLoaderImpl.MOD_FILE_EXTENSION);
|
||||||
String name = install ? "Install" : "Open mod page";
|
String name = install ? "Install" : "Open mod page";
|
||||||
JButton urlButton = new JButton(new AbstractAction(name) {
|
JButton urlButton = new JButton(new AbstractAction(name) {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,15 +7,15 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import dev.frogmc.frogloader.api.env.Env;
|
import dev.frogmc.frogloader.api.env.Env;
|
||||||
import dev.frogmc.frogloader.impl.mixin.NonsenseMixinService;
|
import dev.frogmc.frogloader.impl.mixin.FrogMixinService;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
import org.spongepowered.asm.launch.MixinBootstrap;
|
||||||
import org.spongepowered.asm.service.IPropertyKey;
|
import org.spongepowered.asm.service.IPropertyKey;
|
||||||
|
|
||||||
public class Launcher {
|
public class FrogLauncher {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static Launcher instance;
|
private static FrogLauncher instance;
|
||||||
@Getter
|
@Getter
|
||||||
private final MixinClassLoader targetClassLoader;
|
private final MixinClassLoader targetClassLoader;
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -24,7 +24,7 @@ public class Launcher {
|
||||||
@Getter
|
@Getter
|
||||||
private final Env env;
|
private final Env env;
|
||||||
|
|
||||||
public Launcher(String[] args, Env env) {
|
public FrogLauncher(String[] args, Env env) {
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,11 @@ public class Launcher {
|
||||||
|
|
||||||
Thread.currentThread().setContextClassLoader(targetClassLoader);
|
Thread.currentThread().setContextClassLoader(targetClassLoader);
|
||||||
|
|
||||||
System.setProperty("mixin.service", NonsenseMixinService.class.getName());
|
System.setProperty("mixin.service", FrogMixinService.class.getName());
|
||||||
MixinBootstrap.init();
|
MixinBootstrap.init();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = targetClassLoader.findClass("dev.frogmc.frogloader.impl.LoaderImpl");
|
Class<?> clazz = targetClassLoader.findClass("dev.frogmc.frogloader.impl.FrogLoaderImpl");
|
||||||
MethodHandle ctor = MethodHandles.publicLookup().findStatic(clazz, "run", MethodType.methodType(void.class, String[].class, Env.class));
|
MethodHandle ctor = MethodHandles.publicLookup().findStatic(clazz, "run", MethodType.methodType(void.class, String[].class, Env.class));
|
||||||
ctor.invoke(args, env);
|
ctor.invoke(args, env);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -53,6 +53,6 @@ public class Launcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void run(String[] args, Env env) {
|
public static void run(String[] args, Env env) {
|
||||||
new Launcher(args, env);
|
new FrogLauncher(args, env);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import dev.frogmc.frogloader.impl.mixin.NonsenseMixinService;
|
import dev.frogmc.frogloader.impl.mixin.FrogMixinService;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class MixinClassLoader extends URLClassLoader {
|
||||||
if (in == null)
|
if (in == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return NonsenseMixinService.getTransformer().transformClass(MixinEnvironment.getCurrentEnvironment(), name, AccessWidener.processClass(in.readAllBytes(), binName));
|
return FrogMixinService.getTransformer().transformClass(MixinEnvironment.getCurrentEnvironment(), name, AccessWidener.processClass(in.readAllBytes(), binName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package dev.frogmc.frogloader.impl.launch.client;
|
package dev.frogmc.frogloader.impl.launch.client;
|
||||||
|
|
||||||
import dev.frogmc.frogloader.api.env.Env;
|
import dev.frogmc.frogloader.api.env.Env;
|
||||||
import dev.frogmc.frogloader.impl.launch.Launcher;
|
import dev.frogmc.frogloader.impl.launch.FrogLauncher;
|
||||||
|
|
||||||
public class NonsenseClient {
|
public class FrogClient {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Launcher.run(args, Env.CLIENT);
|
FrogLauncher.run(args, Env.CLIENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
package dev.frogmc.frogloader.impl.launch.server;
|
package dev.frogmc.frogloader.impl.launch.server;
|
||||||
|
|
||||||
import dev.frogmc.frogloader.api.env.Env;
|
import dev.frogmc.frogloader.api.env.Env;
|
||||||
import dev.frogmc.frogloader.impl.launch.Launcher;
|
import dev.frogmc.frogloader.impl.launch.FrogLauncher;
|
||||||
|
|
||||||
public class NonsenseServer {
|
public class FrogServer {
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
Launcher.run(args, Env.SERVER);
|
FrogLauncher.run(args, Env.SERVER);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package dev.frogmc.frogloader.impl.mixin;
|
package dev.frogmc.frogloader.impl.mixin;
|
||||||
|
|
||||||
import dev.frogmc.frogloader.impl.launch.Launcher;
|
import dev.frogmc.frogloader.impl.launch.FrogLauncher;
|
||||||
import org.spongepowered.asm.service.IGlobalPropertyService;
|
import org.spongepowered.asm.service.IGlobalPropertyService;
|
||||||
import org.spongepowered.asm.service.IPropertyKey;
|
import org.spongepowered.asm.service.IPropertyKey;
|
||||||
|
|
||||||
public class NonsenseGlobalPropertyService implements IGlobalPropertyService {
|
public class FrogGlobalPropertyService implements IGlobalPropertyService {
|
||||||
@Override
|
@Override
|
||||||
public IPropertyKey resolveKey(String name) {
|
public IPropertyKey resolveKey(String name) {
|
||||||
return new IPropertyKey() {
|
return new IPropertyKey() {
|
||||||
|
@ -18,22 +18,22 @@ public class NonsenseGlobalPropertyService implements IGlobalPropertyService {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <T> T getProperty(IPropertyKey key) {
|
public <T> T getProperty(IPropertyKey key) {
|
||||||
return (T) Launcher.getInstance().getGlobalProperties().get(key);
|
return (T) FrogLauncher.getInstance().getGlobalProperties().get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setProperty(IPropertyKey key, Object value) {
|
public void setProperty(IPropertyKey key, Object value) {
|
||||||
Launcher.getInstance().getGlobalProperties().put(key, value);
|
FrogLauncher.getInstance().getGlobalProperties().put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <T> T getProperty(IPropertyKey key, T defaultValue) {
|
public <T> T getProperty(IPropertyKey key, T defaultValue) {
|
||||||
return (T) Launcher.getInstance().getGlobalProperties().getOrDefault(key, defaultValue);
|
return (T) FrogLauncher.getInstance().getGlobalProperties().getOrDefault(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPropertyString(IPropertyKey key, String defaultValue) {
|
public String getPropertyString(IPropertyKey key, String defaultValue) {
|
||||||
return Launcher.getInstance().getGlobalProperties().getOrDefault(key, defaultValue).toString();
|
return FrogLauncher.getInstance().getGlobalProperties().getOrDefault(key, defaultValue).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,17 +10,17 @@ import org.spongepowered.asm.logging.ILogger;
|
||||||
import org.spongepowered.asm.logging.Level;
|
import org.spongepowered.asm.logging.Level;
|
||||||
import org.spongepowered.asm.logging.LoggerAdapterAbstract;
|
import org.spongepowered.asm.logging.LoggerAdapterAbstract;
|
||||||
|
|
||||||
public class NonsenseMixinLogger extends LoggerAdapterAbstract {
|
public class FrogMixinLogger extends LoggerAdapterAbstract {
|
||||||
private static final Map<String, NonsenseMixinLogger> LOGGERS = new ConcurrentHashMap<>();
|
private static final Map<String, FrogMixinLogger> LOGGERS = new ConcurrentHashMap<>();
|
||||||
private final Logger log;
|
private final Logger log;
|
||||||
|
|
||||||
public NonsenseMixinLogger(String name) {
|
public FrogMixinLogger(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
log = LoggerFactory.getLogger("Nonsense Loader/" + name.substring(0, 1).toUpperCase(Locale.ROOT) + name.substring(1));
|
log = LoggerFactory.getLogger("Nonsense Loader/" + name.substring(0, 1).toUpperCase(Locale.ROOT) + name.substring(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ILogger get(String name) {
|
public static ILogger get(String name) {
|
||||||
return LOGGERS.computeIfAbsent(name, NonsenseMixinLogger::new);
|
return LOGGERS.computeIfAbsent(name, FrogMixinLogger::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -7,7 +7,7 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import dev.frogmc.frogloader.impl.launch.Launcher;
|
import dev.frogmc.frogloader.impl.launch.FrogLauncher;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
@ -21,7 +21,7 @@ import org.spongepowered.asm.service.*;
|
||||||
import org.spongepowered.asm.transformers.MixinClassReader;
|
import org.spongepowered.asm.transformers.MixinClassReader;
|
||||||
import org.spongepowered.asm.util.ReEntranceLock;
|
import org.spongepowered.asm.util.ReEntranceLock;
|
||||||
|
|
||||||
public class NonsenseMixinService implements IMixinService, IClassProvider, IClassBytecodeProvider, ITransformerProvider, IClassTracker {
|
public class FrogMixinService implements IMixinService, IClassProvider, IClassBytecodeProvider, ITransformerProvider, IClassTracker {
|
||||||
@Getter
|
@Getter
|
||||||
static IMixinTransformer transformer;
|
static IMixinTransformer transformer;
|
||||||
private final ReEntranceLock lock = new ReEntranceLock(1);
|
private final ReEntranceLock lock = new ReEntranceLock(1);
|
||||||
|
@ -116,12 +116,12 @@ public class NonsenseMixinService implements IMixinService, IClassProvider, ICla
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getResourceAsStream(String name) {
|
public InputStream getResourceAsStream(String name) {
|
||||||
return Launcher.getInstance().getTargetClassLoader().getResourceAsStream(name);
|
return FrogLauncher.getInstance().getTargetClassLoader().getResourceAsStream(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSideName() {
|
public String getSideName() {
|
||||||
return Launcher.getInstance().getEnv().getMixinName();
|
return FrogLauncher.getInstance().getEnv().getMixinName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,7 +136,7 @@ public class NonsenseMixinService implements IMixinService, IClassProvider, ICla
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ILogger getLogger(String name) {
|
public ILogger getLogger(String name) {
|
||||||
return NonsenseMixinLogger.get(name);
|
return FrogMixinLogger.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,9 +150,9 @@ public class NonsenseMixinService implements IMixinService, IClassProvider, ICla
|
||||||
byte[] bytes;
|
byte[] bytes;
|
||||||
if (runTransformers && transformer != null) {
|
if (runTransformers && transformer != null) {
|
||||||
bytes = transformer.transformClass(MixinEnvironment.getCurrentEnvironment(), name,
|
bytes = transformer.transformClass(MixinEnvironment.getCurrentEnvironment(), name,
|
||||||
Launcher.getInstance().getTargetClassLoader().getClassBytes(name));
|
FrogLauncher.getInstance().getTargetClassLoader().getClassBytes(name));
|
||||||
} else {
|
} else {
|
||||||
bytes = Launcher.getInstance().getTargetClassLoader().getClassBytes(name);
|
bytes = FrogLauncher.getInstance().getTargetClassLoader().getClassBytes(name);
|
||||||
}
|
}
|
||||||
ClassReader reader = new MixinClassReader(bytes, name);
|
ClassReader reader = new MixinClassReader(bytes, name);
|
||||||
ClassNode node = new ClassNode();
|
ClassNode node = new ClassNode();
|
||||||
|
@ -168,17 +168,17 @@ public class NonsenseMixinService implements IMixinService, IClassProvider, ICla
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> findClass(String name) throws ClassNotFoundException {
|
public Class<?> findClass(String name) throws ClassNotFoundException {
|
||||||
return Class.forName(name, false, Launcher.getInstance().getTargetClassLoader());
|
return Class.forName(name, false, FrogLauncher.getInstance().getTargetClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> findClass(String name, boolean initialize) throws ClassNotFoundException {
|
public Class<?> findClass(String name, boolean initialize) throws ClassNotFoundException {
|
||||||
return Class.forName(name, initialize, Launcher.getInstance().getTargetClassLoader());
|
return Class.forName(name, initialize, FrogLauncher.getInstance().getTargetClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> findAgentClass(String name, boolean initialize) throws ClassNotFoundException {
|
public Class<?> findAgentClass(String name, boolean initialize) throws ClassNotFoundException {
|
||||||
return Class.forName(name, initialize, Launcher.getInstance().getTargetClassLoader());
|
return Class.forName(name, initialize, FrogLauncher.getInstance().getTargetClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -188,7 +188,7 @@ public class NonsenseMixinService implements IMixinService, IClassProvider, ICla
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClassLoaded(String className) {
|
public boolean isClassLoaded(String className) {
|
||||||
return Launcher.getInstance().getTargetClassLoader().isClassLoaded(className);
|
return FrogLauncher.getInstance().getTargetClassLoader().isClassLoaded(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -5,7 +5,7 @@ import java.net.URI;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import dev.frogmc.frogloader.api.Loader;
|
import dev.frogmc.frogloader.api.FrogLoader;
|
||||||
import dev.frogmc.frogloader.api.mod.ModProperties;
|
import dev.frogmc.frogloader.api.mod.ModProperties;
|
||||||
|
|
||||||
public class ModUtil {
|
public class ModUtil {
|
||||||
|
@ -34,7 +34,7 @@ public class ModUtil {
|
||||||
|
|
||||||
public static void installMod(String url) {
|
public static void installMod(String url) {
|
||||||
try {
|
try {
|
||||||
Files.copy(URI.create(url).toURL().openStream(), Loader.getInstance().getModsDir().resolve(url.substring(url.lastIndexOf("/" + 1))));
|
Files.copy(URI.create(url).toURL().openStream(), FrogLoader.getInstance().getModsDir().resolve(url.substring(url.lastIndexOf("/" + 1))));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
// TODO handle better than this
|
// TODO handle better than this
|
||||||
|
|
|
@ -11,14 +11,14 @@ import java.nio.file.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import dev.frogmc.frogloader.api.Loader;
|
import dev.frogmc.frogloader.api.FrogLoader;
|
||||||
import dev.frogmc.frogloader.api.extensions.PreLaunchExtension;
|
import dev.frogmc.frogloader.api.extensions.PreLaunchExtension;
|
||||||
import dev.frogmc.frogloader.api.mod.ModDependencies;
|
import dev.frogmc.frogloader.api.mod.ModDependencies;
|
||||||
import dev.frogmc.frogloader.api.mod.ModExtensions;
|
import dev.frogmc.frogloader.api.mod.ModExtensions;
|
||||||
import dev.frogmc.frogloader.api.mod.ModProperties;
|
import dev.frogmc.frogloader.api.mod.ModProperties;
|
||||||
import dev.frogmc.frogloader.api.plugin.NonsensePlugin;
|
import dev.frogmc.frogloader.api.plugin.NonsensePlugin;
|
||||||
import dev.frogmc.frogloader.impl.Discovery;
|
import dev.frogmc.frogloader.impl.Discovery;
|
||||||
import dev.frogmc.frogloader.impl.LoaderImpl;
|
import dev.frogmc.frogloader.impl.FrogLoaderImpl;
|
||||||
import dev.frogmc.frogloader.impl.gui.LoaderGui;
|
import dev.frogmc.frogloader.impl.gui.LoaderGui;
|
||||||
import dev.frogmc.frogloader.impl.mixin.AWProcessor;
|
import dev.frogmc.frogloader.impl.mixin.AWProcessor;
|
||||||
import dev.frogmc.frogloader.impl.mod.*;
|
import dev.frogmc.frogloader.impl.mod.*;
|
||||||
|
@ -47,7 +47,7 @@ public class Minecraft implements NonsensePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Loader loader) throws Exception {
|
public void init(FrogLoader loader) throws Exception {
|
||||||
if (gamePath == null) {
|
if (gamePath == null) {
|
||||||
throw new IllegalStateException("Game not found yet!");
|
throw new IllegalStateException("Game not found yet!");
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class Minecraft implements NonsensePlugin {
|
||||||
|
|
||||||
Collection<Path> mods = Discovery.find(loader.getModsDir(), path ->
|
Collection<Path> mods = Discovery.find(loader.getModsDir(), path ->
|
||||||
version.equals(path.getFileName().toString()), path ->
|
version.equals(path.getFileName().toString()), path ->
|
||||||
path.getFileName().toString().endsWith(LoaderImpl.MOD_FILE_EXTENSION));
|
path.getFileName().toString().endsWith(FrogLoaderImpl.MOD_FILE_EXTENSION));
|
||||||
Collection<URL> classpathMods = this.getClass().getClassLoader().resources(ModPropertiesReader.PROPERTIES_FILE_NAME).distinct().toList();
|
Collection<URL> classpathMods = this.getClass().getClassLoader().resources(ModPropertiesReader.PROPERTIES_FILE_NAME).distinct().toList();
|
||||||
|
|
||||||
classpathMods.stream().map(ModPropertiesReader::readFile).forEachOrdered(modProperties::add);
|
classpathMods.stream().map(ModPropertiesReader::readFile).forEachOrdered(modProperties::add);
|
||||||
|
@ -97,7 +97,7 @@ public class Minecraft implements NonsensePlugin {
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}).forEach(LoaderImpl.getInstance().getClassloader()::addURL);
|
}).forEach(FrogLoaderImpl.getInstance().getClassloader()::addURL);
|
||||||
|
|
||||||
modProperties.forEach(props -> {
|
modProperties.forEach(props -> {
|
||||||
String name = props.extensions().get(BuiltinExtensions.MIXIN_CONFIG);
|
String name = props.extensions().get(BuiltinExtensions.MIXIN_CONFIG);
|
||||||
|
@ -115,7 +115,7 @@ public class Minecraft implements NonsensePlugin {
|
||||||
AWProcessor.load(modProperties);
|
AWProcessor.load(modProperties);
|
||||||
|
|
||||||
var runtimePath = loader.isDevelopment() ? gamePath : remappedGamePath;
|
var runtimePath = loader.isDevelopment() ? gamePath : remappedGamePath;
|
||||||
LoaderImpl.getInstance().getClassloader().addURL(runtimePath.toUri().toURL());
|
FrogLoaderImpl.getInstance().getClassloader().addURL(runtimePath.toUri().toURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void findJiJMods(Path mod, Collection<Path> mods, Map<Path, ModProperties> modPaths) throws IOException {
|
protected void findJiJMods(Path mod, Collection<Path> mods, Map<Path, ModProperties> modPaths) throws IOException {
|
||||||
|
@ -171,10 +171,10 @@ public class Minecraft implements NonsensePlugin {
|
||||||
}
|
}
|
||||||
try (FileSystem fs = FileSystems.newFileSystem(jar)) {
|
try (FileSystem fs = FileSystems.newFileSystem(jar)) {
|
||||||
for (String n : MINECRAFT_CLASSES) {
|
for (String n : MINECRAFT_CLASSES) {
|
||||||
if (Files.exists(fs.getPath(n)) && n.contains(LoaderImpl.getInstance().getEnv().getIdentifier())) {
|
if (Files.exists(fs.getPath(n)) && n.contains(FrogLoaderImpl.getInstance().getEnv().getIdentifier())) {
|
||||||
LOGGER.info("Found game: {}", jar);
|
LOGGER.info("Found game: {}", jar);
|
||||||
foundMainClass = n.substring(0, n.length() - 6).replace("/", ".");
|
foundMainClass = n.substring(0, n.length() - 6).replace("/", ".");
|
||||||
version = LoaderImpl.getInstance().getGson().fromJson(Files.readString(fs.getPath("version.json")), JsonObject.class).get("id").getAsString();
|
version = FrogLoaderImpl.getInstance().getGson().fromJson(Files.readString(fs.getPath("version.json")), JsonObject.class).get("id").getAsString();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ public class Minecraft implements NonsensePlugin {
|
||||||
LOGGER.info("Launching main class: {}", foundMainClass);
|
LOGGER.info("Launching main class: {}", foundMainClass);
|
||||||
Class<?> mainClass = Class.forName(foundMainClass);
|
Class<?> mainClass = Class.forName(foundMainClass);
|
||||||
MethodHandle main = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class));
|
MethodHandle main = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class));
|
||||||
main.invoke((Object) LoaderImpl.getInstance().getArgs());
|
main.invoke((Object) FrogLoaderImpl.getInstance().getArgs());
|
||||||
} else {
|
} else {
|
||||||
LOGGER.warn("Failed to locate main class!");
|
LOGGER.warn("Failed to locate main class!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
dev.frogmc.frogloader.impl.mixin.NonsenseGlobalPropertyService
|
dev.frogmc.frogloader.impl.mixin.FrogGlobalPropertyService
|
Loading…
Reference in a new issue