mirror of
https://github.com/zaaarf/lillero-loader.git
synced 2024-11-21 20:44:48 +01:00
chore: javadocs, version bump
This commit is contained in:
parent
ada687335a
commit
8ca249715d
2 changed files with 106 additions and 20 deletions
13
build.gradle
13
build.gradle
|
@ -6,7 +6,12 @@ plugins {
|
||||||
archivesBaseName = 'loader'
|
archivesBaseName = 'loader'
|
||||||
version = gitVersion()
|
version = gitVersion()
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
withSourcesJar()
|
||||||
|
withJavadocJar()
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url = 'https://maven.minecraftforge.net/' }
|
maven { url = 'https://maven.minecraftforge.net/' }
|
||||||
|
@ -15,11 +20,11 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.apache.logging.log4j:log4j-api:2.15.0'
|
implementation 'org.apache.logging.log4j:log4j-api:2.17.1'
|
||||||
implementation 'org.apache.logging.log4j:log4j-core:2.15.0'
|
implementation 'org.apache.logging.log4j:log4j-core:2.17.1'
|
||||||
implementation 'org.ow2.asm:asm-commons:9.4'
|
implementation 'org.ow2.asm:asm-commons:9.4'
|
||||||
implementation 'cpw.mods:modlauncher:8.1.3'
|
implementation 'cpw.mods:modlauncher:8.1.3'
|
||||||
implementation 'ftbsc:lll:0.3.0'
|
implementation 'ftbsc:lll:0.3.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
|
|
@ -20,35 +20,84 @@ import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the {@link ILaunchPluginService} interface to create
|
||||||
|
* a loader for Lillero patches ({@link IInjector}).
|
||||||
|
*/
|
||||||
public class LilleroLoader implements ILaunchPluginService {
|
public class LilleroLoader implements ILaunchPluginService {
|
||||||
|
/**
|
||||||
|
* A Log4j logger instance.
|
||||||
|
*/
|
||||||
private static final Logger LOGGER = LogManager.getLogger(LilleroLoader.class.getCanonicalName());
|
private static final Logger LOGGER = LogManager.getLogger(LilleroLoader.class.getCanonicalName());
|
||||||
private static final Marker INIT = MarkerManager.getMarker("INIT");
|
|
||||||
private static final Marker RESOURCE = MarkerManager.getMarker("RESOURCE");
|
|
||||||
private static final Marker HANDLER = MarkerManager.getMarker("HANDLER");
|
|
||||||
private static final Marker PATCHER = MarkerManager.getMarker("PATCHER");
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Marker for the logger, used during the initialisation phase.
|
||||||
|
*/
|
||||||
|
private static final Marker INIT = MarkerManager.getMarker("INIT");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Marker for the logger, used during the resource processing phase.
|
||||||
|
*/
|
||||||
|
private static final Marker RESOURCE = MarkerManager.getMarker("RESOURCE");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Marker for the logger, used during class inspection.
|
||||||
|
*/
|
||||||
|
private static final Marker HANDLER = MarkerManager.getMarker("HANDLER");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Marker for the logger, used during the patching phase.
|
||||||
|
*/
|
||||||
|
private static final Marker PATCHER = MarkerManager.getMarker("PATCHER");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unique identifier assigned to this plugin.
|
||||||
|
*/
|
||||||
public static final String NAME = "lll-loader";
|
public static final String NAME = "lll-loader";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Set used to hold declared injectors.
|
||||||
|
*/
|
||||||
private final Set<IInjector> injectors = new HashSet<>();
|
private final Set<IInjector> injectors = new HashSet<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Set used to hold the fully-qualified names of target classes.
|
||||||
|
* Used to improve performance.
|
||||||
|
*/
|
||||||
private final Set<String> targetClasses = new HashSet<>();
|
private final Set<String> targetClasses = new HashSet<>();
|
||||||
|
|
||||||
public LilleroLoader() {
|
public LilleroLoader() {
|
||||||
LOGGER.info(INIT, "Patch Loader initialized");
|
LOGGER.info(INIT, "Patch Loader initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unique name of this plugin, used by the launcher and other systems to find it.
|
||||||
|
* @return the name of the plugin
|
||||||
|
* @see ILaunchPluginService#name()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
// Load mods requesting patches from resources
|
* Adds a resource to this plugin for processing by it.
|
||||||
|
* In our implementation, it does nothing but log that it happened.
|
||||||
|
* @param resource The resource to be considered by this plugin.
|
||||||
|
* @param name A name for this resource.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void offerResource(Path resource, String name) {
|
public void offerResource(Path resource, String name) {
|
||||||
LOGGER.warn(RESOURCE, "Resource offered to us ({}@{}) but no action was taken", name, resource.toString());
|
LOGGER.warn(RESOURCE, "Resource offered to us ({}@{}) but no action was taken", name, resource.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offer scan results from TransformationServices to this plugin.
|
||||||
|
* In practice, the paths of Forge mod JARs are offered to our processor here. In the method, we look for
|
||||||
|
* service provider files for {@link IInjector} and load them. We also memorise in a set the fully qualified
|
||||||
|
* name of classes that are to be patched.
|
||||||
|
* @param resources A collection of all the results
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addResources(List<Map.Entry<String, Path>> resources) {
|
public void addResources(List<Map.Entry<String, Path>> resources) {
|
||||||
LOGGER.debug(RESOURCE, "Resources being added:");
|
LOGGER.debug(RESOURCE, "Resources being added:");
|
||||||
|
@ -69,16 +118,40 @@ public class LilleroLoader implements ILaunchPluginService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Filter only classes we need to patch
|
/**
|
||||||
|
* What is returned when the class being processed is to be patched.
|
||||||
@Override
|
*/
|
||||||
public EnumSet<Phase> handlesClass(Type classType, final boolean isEmpty) {
|
|
||||||
throw new IllegalStateException("Outdated ModLauncher"); //mixin does it
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.BEFORE);
|
private static final EnumSet<Phase> YAY = EnumSet.of(Phase.BEFORE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What is returned when the class being processed is of no interest to any patch.
|
||||||
|
*/
|
||||||
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legacy method - only called by outdated ModLauncher versions. Since we don't really use
|
||||||
|
* the reason, however, we can support it.
|
||||||
|
* @param classType the class to consider
|
||||||
|
* @param isEmpty if the class is empty at present (indicates no backing file found)
|
||||||
|
* @return the set of {@link Phase}s the plugin wishes to be called back with
|
||||||
|
* @see LilleroLoader#handlesClass(Type, boolean, String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public EnumSet<Phase> handlesClass(Type classType, final boolean isEmpty) {
|
||||||
|
return handlesClass(classType, isEmpty, "unspecified");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each class loaded is offered to the plugin for processing the plugin replies whether it's interested or not.
|
||||||
|
* The loader is only interested if the class's fully qualified name was earlier placed in the set.
|
||||||
|
* @param classType the class to consider
|
||||||
|
* @param isEmpty if the class is empty at present (indicates no backing file found)
|
||||||
|
* @param reason Reason for transformation request.
|
||||||
|
* "classloading" - cpw.mods.modlauncher.api.ITransformerActivity#CLASSLOADING_REASON
|
||||||
|
* "computing_frames" - cpw.mods.modlauncher.api.ITransformerActivity#COMPUTING_FRAMES_REASON
|
||||||
|
* or the name of an {@link ILaunchPluginService}
|
||||||
|
* @return the set of {@link Phase}s the plugin wishes to be called back with
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public EnumSet<Phase> handlesClass(Type classType, final boolean isEmpty, final String reason) {
|
public EnumSet<Phase> handlesClass(Type classType, final boolean isEmpty, final String reason) {
|
||||||
if (isEmpty) return NAY;
|
if (isEmpty) return NAY;
|
||||||
|
@ -91,8 +164,16 @@ public class LilleroLoader implements ILaunchPluginService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Process classes and inject methods
|
/**
|
||||||
|
* Each class loaded is offered to the plugin for processing.
|
||||||
|
* This is where the actual injection happens: the loader calls the {@link IInjector#inject(ClassNode, MethodNode)}
|
||||||
|
* method with the appropriate parameters, after finding them..
|
||||||
|
* @param phase The phase of the supplied class node
|
||||||
|
* @param classNode the classnode to process
|
||||||
|
* @param classType the name of the class
|
||||||
|
* @param reason Reason for transformation. "classloading" or the name of an {@link ILaunchPluginService}
|
||||||
|
* @return the {@link ComputeFlags} for this class
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int processClassWithFlags(Phase phase, ClassNode classNode, Type classType, String reason) {
|
public int processClassWithFlags(Phase phase, ClassNode classNode, Type classType, String reason) {
|
||||||
LOGGER.debug(PATCHER, "Processing class {} in phase {} of {}", classType.getClassName(), phase.name(), reason);
|
LOGGER.debug(PATCHER, "Processing class {} in phase {} of {}", classType.getClassName(), phase.name(), reason);
|
||||||
|
|
Loading…
Reference in a new issue