rename nonsense -> frog

This commit is contained in:
moehreag 2024-06-03 13:24:26 +02:00
parent 6ff44aac48
commit 621816c6d8
14 changed files with 61 additions and 61 deletions

View file

@ -7,12 +7,12 @@ import java.util.Optional;
import dev.frogmc.frogloader.api.env.Env;
import dev.frogmc.frogloader.api.mod.ModProperties;
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() {
return LoaderImpl.getInstance();
static FrogLoader getInstance() {
return FrogLoaderImpl.getInstance();
}
List<NonsensePlugin> getPlugins();

View file

@ -2,7 +2,7 @@ package dev.frogmc.frogloader.api.plugin;
import java.util.Collection;
import dev.frogmc.frogloader.api.Loader;
import dev.frogmc.frogloader.api.FrogLoader;
import dev.frogmc.frogloader.api.mod.ModProperties;
public interface NonsensePlugin extends Runnable {
@ -18,7 +18,7 @@ public interface NonsensePlugin extends Runnable {
return false;
}
default void init(Loader loader) throws Exception {
default void init(FrogLoader loader) throws Exception {
}
Collection<ModProperties> getMods();

View file

@ -11,7 +11,7 @@ import java.util.*;
import java.util.stream.Collectors;
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.mod.ModProperties;
import dev.frogmc.frogloader.api.plugin.NonsensePlugin;
@ -22,10 +22,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.asm.mixin.MixinEnvironment;
public class LoaderImpl implements Loader {
public class FrogLoaderImpl implements FrogLoader {
public static final String MOD_FILE_EXTENSION = ".frogmod";
@Getter
private static LoaderImpl instance;
private static FrogLoaderImpl instance;
private final boolean DEV_ENV = Boolean.getBoolean("frogmc.development");
@Getter
private final String[] args;
@ -49,7 +49,7 @@ public class LoaderImpl implements Loader {
private final Collection<String> modIds;
private LoaderImpl(String[] args, Env env) {
private FrogLoaderImpl(String[] args, Env env) {
instance = this;
this.classloader = (MixinClassLoader) this.getClass().getClassLoader();
this.args = args;
@ -82,7 +82,7 @@ public class LoaderImpl implements Loader {
throw new IllegalStateException("Loader was started multiple times!");
}
new LoaderImpl(args, env);
new FrogLoaderImpl(args, env);
}
private void advanceMixinState() {

View file

@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.List;
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.ModUtil;
import dev.frogmc.frogloader.impl.util.URLUtil;
@ -76,7 +76,7 @@ public class LoaderGui {
}
List<JButton> actions = new ArrayList<>();
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";
JButton urlButton = new JButton(new AbstractAction(name) {
@Override

View file

@ -7,15 +7,15 @@ import java.util.HashMap;
import java.util.Map;
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 org.spongepowered.asm.launch.MixinBootstrap;
import org.spongepowered.asm.service.IPropertyKey;
public class Launcher {
public class FrogLauncher {
@Getter
private static Launcher instance;
private static FrogLauncher instance;
@Getter
private final MixinClassLoader targetClassLoader;
@Getter
@ -24,7 +24,7 @@ public class Launcher {
@Getter
private final Env env;
public Launcher(String[] args, Env env) {
public FrogLauncher(String[] args, Env env) {
if (instance != null) {
throw new IllegalStateException();
}
@ -39,11 +39,11 @@ public class Launcher {
Thread.currentThread().setContextClassLoader(targetClassLoader);
System.setProperty("mixin.service", NonsenseMixinService.class.getName());
System.setProperty("mixin.service", FrogMixinService.class.getName());
MixinBootstrap.init();
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));
ctor.invoke(args, env);
} catch (Throwable e) {
@ -53,6 +53,6 @@ public class Launcher {
}
public static void run(String[] args, Env env) {
new Launcher(args, env);
new FrogLauncher(args, env);
}
}

View file

@ -9,7 +9,7 @@ import java.util.Collections;
import java.util.Enumeration;
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.spongepowered.asm.mixin.MixinEnvironment;
@ -43,7 +43,7 @@ public class MixinClassLoader extends URLClassLoader {
if (in == 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));
}
}

View file

@ -1,11 +1,11 @@
package dev.frogmc.frogloader.impl.launch.client;
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) {
Launcher.run(args, Env.CLIENT);
FrogLauncher.run(args, Env.CLIENT);
}
}

View file

@ -1,11 +1,11 @@
package dev.frogmc.frogloader.impl.launch.server;
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){
Launcher.run(args, Env.SERVER);
FrogLauncher.run(args, Env.SERVER);
}
}

View file

@ -1,10 +1,10 @@
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.IPropertyKey;
public class NonsenseGlobalPropertyService implements IGlobalPropertyService {
public class FrogGlobalPropertyService implements IGlobalPropertyService {
@Override
public IPropertyKey resolveKey(String name) {
return new IPropertyKey() {
@ -18,22 +18,22 @@ public class NonsenseGlobalPropertyService implements IGlobalPropertyService {
@SuppressWarnings("unchecked")
@Override
public <T> T getProperty(IPropertyKey key) {
return (T) Launcher.getInstance().getGlobalProperties().get(key);
return (T) FrogLauncher.getInstance().getGlobalProperties().get(key);
}
@Override
public void setProperty(IPropertyKey key, Object value) {
Launcher.getInstance().getGlobalProperties().put(key, value);
FrogLauncher.getInstance().getGlobalProperties().put(key, value);
}
@SuppressWarnings("unchecked")
@Override
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
public String getPropertyString(IPropertyKey key, String defaultValue) {
return Launcher.getInstance().getGlobalProperties().getOrDefault(key, defaultValue).toString();
return FrogLauncher.getInstance().getGlobalProperties().getOrDefault(key, defaultValue).toString();
}
}

View file

@ -10,17 +10,17 @@ import org.spongepowered.asm.logging.ILogger;
import org.spongepowered.asm.logging.Level;
import org.spongepowered.asm.logging.LoggerAdapterAbstract;
public class NonsenseMixinLogger extends LoggerAdapterAbstract {
private static final Map<String, NonsenseMixinLogger> LOGGERS = new ConcurrentHashMap<>();
public class FrogMixinLogger extends LoggerAdapterAbstract {
private static final Map<String, FrogMixinLogger> LOGGERS = new ConcurrentHashMap<>();
private final Logger log;
public NonsenseMixinLogger(String name) {
public FrogMixinLogger(String name) {
super(name);
log = LoggerFactory.getLogger("Nonsense Loader/" + name.substring(0, 1).toUpperCase(Locale.ROOT) + name.substring(1));
}
public static ILogger get(String name) {
return LOGGERS.computeIfAbsent(name, NonsenseMixinLogger::new);
return LOGGERS.computeIfAbsent(name, FrogMixinLogger::new);
}
@Override

View file

@ -7,7 +7,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import dev.frogmc.frogloader.impl.launch.Launcher;
import dev.frogmc.frogloader.impl.launch.FrogLauncher;
import lombok.Getter;
import org.objectweb.asm.ClassReader;
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.util.ReEntranceLock;
public class NonsenseMixinService implements IMixinService, IClassProvider, IClassBytecodeProvider, ITransformerProvider, IClassTracker {
public class FrogMixinService implements IMixinService, IClassProvider, IClassBytecodeProvider, ITransformerProvider, IClassTracker {
@Getter
static IMixinTransformer transformer;
private final ReEntranceLock lock = new ReEntranceLock(1);
@ -116,12 +116,12 @@ public class NonsenseMixinService implements IMixinService, IClassProvider, ICla
@Override
public InputStream getResourceAsStream(String name) {
return Launcher.getInstance().getTargetClassLoader().getResourceAsStream(name);
return FrogLauncher.getInstance().getTargetClassLoader().getResourceAsStream(name);
}
@Override
public String getSideName() {
return Launcher.getInstance().getEnv().getMixinName();
return FrogLauncher.getInstance().getEnv().getMixinName();
}
@Override
@ -136,7 +136,7 @@ public class NonsenseMixinService implements IMixinService, IClassProvider, ICla
@Override
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;
if (runTransformers && transformer != null) {
bytes = transformer.transformClass(MixinEnvironment.getCurrentEnvironment(), name,
Launcher.getInstance().getTargetClassLoader().getClassBytes(name));
FrogLauncher.getInstance().getTargetClassLoader().getClassBytes(name));
} else {
bytes = Launcher.getInstance().getTargetClassLoader().getClassBytes(name);
bytes = FrogLauncher.getInstance().getTargetClassLoader().getClassBytes(name);
}
ClassReader reader = new MixinClassReader(bytes, name);
ClassNode node = new ClassNode();
@ -168,17 +168,17 @@ public class NonsenseMixinService implements IMixinService, IClassProvider, ICla
@Override
public Class<?> findClass(String name) throws ClassNotFoundException {
return Class.forName(name, false, Launcher.getInstance().getTargetClassLoader());
return Class.forName(name, false, FrogLauncher.getInstance().getTargetClassLoader());
}
@Override
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
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
@ -188,7 +188,7 @@ public class NonsenseMixinService implements IMixinService, IClassProvider, ICla
@Override
public boolean isClassLoaded(String className) {
return Launcher.getInstance().getTargetClassLoader().isClassLoaded(className);
return FrogLauncher.getInstance().getTargetClassLoader().isClassLoaded(className);
}
@Override

View file

@ -5,7 +5,7 @@ import java.net.URI;
import java.nio.file.Files;
import java.util.Collection;
import dev.frogmc.frogloader.api.Loader;
import dev.frogmc.frogloader.api.FrogLoader;
import dev.frogmc.frogloader.api.mod.ModProperties;
public class ModUtil {
@ -34,7 +34,7 @@ public class ModUtil {
public static void installMod(String url) {
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) {
e.printStackTrace();
// TODO handle better than this

View file

@ -11,14 +11,14 @@ import java.nio.file.*;
import java.util.*;
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.mod.ModDependencies;
import dev.frogmc.frogloader.api.mod.ModExtensions;
import dev.frogmc.frogloader.api.mod.ModProperties;
import dev.frogmc.frogloader.api.plugin.NonsensePlugin;
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.mixin.AWProcessor;
import dev.frogmc.frogloader.impl.mod.*;
@ -47,7 +47,7 @@ public class Minecraft implements NonsensePlugin {
}
@Override
public void init(Loader loader) throws Exception {
public void init(FrogLoader loader) throws Exception {
if (gamePath == null) {
throw new IllegalStateException("Game not found yet!");
}
@ -70,7 +70,7 @@ public class Minecraft implements NonsensePlugin {
Collection<Path> mods = Discovery.find(loader.getModsDir(), 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();
classpathMods.stream().map(ModPropertiesReader::readFile).forEachOrdered(modProperties::add);
@ -97,7 +97,7 @@ public class Minecraft implements NonsensePlugin {
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}).forEach(LoaderImpl.getInstance().getClassloader()::addURL);
}).forEach(FrogLoaderImpl.getInstance().getClassloader()::addURL);
modProperties.forEach(props -> {
String name = props.extensions().get(BuiltinExtensions.MIXIN_CONFIG);
@ -115,7 +115,7 @@ public class Minecraft implements NonsensePlugin {
AWProcessor.load(modProperties);
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 {
@ -171,10 +171,10 @@ public class Minecraft implements NonsensePlugin {
}
try (FileSystem fs = FileSystems.newFileSystem(jar)) {
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);
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;
}
}
@ -194,7 +194,7 @@ public class Minecraft implements NonsensePlugin {
LOGGER.info("Launching main class: {}", foundMainClass);
Class<?> mainClass = Class.forName(foundMainClass);
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 {
LOGGER.warn("Failed to locate main class!");
}

View file

@ -1 +1 @@
dev.frogmc.frogloader.impl.mixin.NonsenseGlobalPropertyService
dev.frogmc.frogloader.impl.mixin.FrogGlobalPropertyService