mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-19 01:29:14 +00:00
Annotate all the things
This commit is contained in:
63 files changed
+623
-369
No files matched your search
@@ -32,41 +32,54 @@ import java.util.function.Supplier;
|
||||
@StableAPI(since = "0.8.0")
|
||||
public interface IMixin {
|
||||
|
||||
@StableAPI.Expose
|
||||
String getMixin();
|
||||
|
||||
@StableAPI.Expose
|
||||
Side getSide();
|
||||
|
||||
@StableAPI.Expose
|
||||
Predicate<List<ITargetedMod>> getFilter();
|
||||
|
||||
default boolean shouldLoad(List<ITargetedMod> loadedMods) {
|
||||
val side = getSide();
|
||||
return (side == Side.COMMON || side == Side.SERVER && FMLLaunchHandler.side().isServer() ||
|
||||
side == Side.CLIENT && FMLLaunchHandler.side().isClient()) && getFilter().test(loadedMods);
|
||||
}
|
||||
|
||||
Side getSide();
|
||||
|
||||
Predicate<List<ITargetedMod>> getFilter();
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
enum Side {
|
||||
@StableAPI.Expose
|
||||
COMMON,
|
||||
@StableAPI.Expose
|
||||
CLIENT,
|
||||
@StableAPI.Expose
|
||||
SERVER
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
final class PredicateHelpers {
|
||||
@StableAPI.Expose
|
||||
public static Predicate<List<ITargetedMod>> never() {
|
||||
return (list) -> false;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<List<ITargetedMod>> condition(Supplier<Boolean> condition) {
|
||||
return (list) -> condition.get();
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<List<ITargetedMod>> always() {
|
||||
return (list) -> true;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<List<ITargetedMod>> require(ITargetedMod mod) {
|
||||
return (list) -> list.contains(mod);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<List<ITargetedMod>> avoid(ITargetedMod mod) {
|
||||
return (list) -> !list.contains(mod);
|
||||
}
|
||||
|
||||
@@ -45,12 +45,15 @@ import static java.nio.file.Files.walk;
|
||||
|
||||
@StableAPI(since = "0.8.0")
|
||||
public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
@StableAPI.Expose
|
||||
Path MODS_DIRECTORY_PATH = FileUtil.getMinecraftHome().toPath().resolve("mods");
|
||||
|
||||
@StableAPI.Expose
|
||||
static Logger createLogger(String modName) {
|
||||
return LogManager.getLogger(modName + " Mixin Loader");
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
static File findJarOf(final ITargetedMod mod) {
|
||||
try (val stream = walk(MODS_DIRECTORY_PATH)) {
|
||||
return stream.filter(mod::isMatchingJar).map(Path::toFile).findFirst().orElse(null);
|
||||
@@ -60,6 +63,15 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
Logger getLogger();
|
||||
|
||||
@StableAPI.Expose
|
||||
IMixin[] getMixinEnumValues();
|
||||
|
||||
@StableAPI.Expose
|
||||
ITargetedMod[] getTargetedModEnumValues();
|
||||
|
||||
@Override
|
||||
default void onLoad(String mixinPackage) {
|
||||
|
||||
@@ -107,8 +119,6 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return mixins;
|
||||
}
|
||||
|
||||
ITargetedMod[] getTargetedModEnumValues();
|
||||
|
||||
default boolean loadJarOf(final ITargetedMod mod) {
|
||||
boolean success = false;
|
||||
try {
|
||||
@@ -130,10 +140,6 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return success;
|
||||
}
|
||||
|
||||
Logger getLogger();
|
||||
|
||||
IMixin[] getMixinEnumValues();
|
||||
|
||||
@Override
|
||||
default void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
|
||||
@@ -29,11 +29,14 @@ import java.util.function.Predicate;
|
||||
@StableAPI(since = "0.8.0")
|
||||
public interface ITargetedMod {
|
||||
|
||||
@StableAPI.Expose
|
||||
String getModName();
|
||||
|
||||
@StableAPI.Expose
|
||||
boolean isLoadInDevelopment();
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
@StableAPI.Expose
|
||||
default boolean isMatchingJar(Path path) {
|
||||
String pathString = path.toString();
|
||||
String nameLowerCase = Files.getNameWithoutExtension(pathString).toLowerCase();
|
||||
@@ -41,18 +44,22 @@ public interface ITargetedMod {
|
||||
|
||||
return "jar".equals(fileExtension) && getCondition().test(nameLowerCase);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
Predicate<String> getCondition();
|
||||
|
||||
@StableAPI(since = "0.5.0")
|
||||
final class PredicateHelpers {
|
||||
@StableAPI.Expose
|
||||
public static Predicate<String> startsWith(String subString) {
|
||||
return (name) -> name.startsWith(subString.toLowerCase());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<String> contains(String subString) {
|
||||
return (name) -> name.contains(subString.toLowerCase());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<String> matches(String regex) {
|
||||
return (name) -> name.matches(regex);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.val;
|
||||
@@ -38,6 +39,7 @@ import java.net.URL;
|
||||
* Also added Grimoire protection.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public final class MinecraftURLClassPath {
|
||||
/**
|
||||
* Utility to manipulate the minecraft URL ClassPath
|
||||
@@ -93,6 +95,7 @@ public final class MinecraftURLClassPath {
|
||||
* Adds a Jar to the Minecraft URL ClassPath - Needed when using mixins on classes outside of Minecraft or other
|
||||
* coremods
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static void addJar(File pathToJar) throws Exception {
|
||||
if (!GRIMOIRE) {
|
||||
addURL.invoke(ucp, pathToJar.toURI().toURL());
|
||||
|
||||
Reference in new issue
Block a user