mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-20 05:19:37 +00:00
Deprecate the StableAPI annotations, switch to JB annotations
This commit is contained in:
96 files changed
+1079
-762
No files matched your search
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.val;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
@@ -30,16 +29,9 @@ import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
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) {
|
||||
@@ -49,36 +41,35 @@ public interface IMixin {
|
||||
|| side == Side.CLIENT && FMLLaunchHandler.side().isClient()) && getFilter().test(loadedMods);
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
enum Side {
|
||||
@StableAPI.Expose COMMON,
|
||||
@StableAPI.Expose CLIENT,
|
||||
@StableAPI.Expose SERVER
|
||||
COMMON,
|
||||
CLIENT,
|
||||
SERVER
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
@@ -21,12 +21,11 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.DeprecationDetails;
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.util.FileUtil;
|
||||
import lombok.val;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
@@ -47,19 +46,14 @@ import java.util.stream.Collectors;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@DeprecationDetails(deprecatedSince = "1.4.0")
|
||||
@StableAPI.Expose
|
||||
@Deprecated(since = "1.4.0")
|
||||
static File findJarOf(final ITargetedMod mod) {
|
||||
File result = null;
|
||||
try (val stream = walk(MODS_DIRECTORY_PATH)) {
|
||||
@@ -85,7 +79,9 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return result;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "1.4.0")
|
||||
/**
|
||||
* @since 1.4.0
|
||||
*/
|
||||
static Set<File> findJarsOf(IMixinPlugin self, final ITargetedMod mod) {
|
||||
if (!self.useNewFindJar()) {
|
||||
val jar = findJarOf(mod);
|
||||
@@ -111,46 +107,45 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return results;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
Logger getLogger();
|
||||
|
||||
@StableAPI.Expose
|
||||
IMixin[] getMixinEnumValues();
|
||||
|
||||
@StableAPI.Expose
|
||||
ITargetedMod[] getTargetedModEnumValues();
|
||||
|
||||
@StableAPI.Expose(since = "1.4.0")
|
||||
/**
|
||||
* @since 1.4.0
|
||||
*/
|
||||
default boolean useNewFindJar() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default void onLoad(String mixinPackage) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default List<String> getMixins() {
|
||||
val isDevelopmentEnvironment = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
|
||||
val targetedMods = getTargetedModEnumValues();
|
||||
@@ -185,7 +180,7 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return mixins;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default boolean loadJarOf(final ITargetedMod mod) {
|
||||
try {
|
||||
val jars = findJarsOf(this, mod);
|
||||
@@ -207,14 +202,14 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@Override
|
||||
@ApiStatus.Internal
|
||||
default void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@Override
|
||||
@ApiStatus.Internal
|
||||
default void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
@@ -21,23 +21,17 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import java.nio.file.Path;
|
||||
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();
|
||||
@@ -46,22 +40,17 @@ 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);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.impl.mixin.UCPImpl;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -32,11 +31,11 @@ import java.io.File;
|
||||
* Backport from spongemixins 1.3 for compat with the curseforge 1.2.0 version.
|
||||
* <p>
|
||||
* Also added Grimoire protection.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public final class MinecraftURLClassPath {
|
||||
@StableAPI.Expose
|
||||
public static void addJar(File pathToJar) throws Exception {
|
||||
UCPImpl.addJar(pathToJar);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
@@ -31,9 +31,10 @@ import net.minecraft.launchwrapper.Launch;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
@StableAPI(since = "0.10.2")
|
||||
/**
|
||||
* @since 0.10.2
|
||||
*/
|
||||
public final class MixinInfo {
|
||||
@StableAPI.Expose
|
||||
public static final MixinBootstrapperType mixinBootstrapper;
|
||||
|
||||
static {
|
||||
@@ -41,12 +42,10 @@ public final class MixinInfo {
|
||||
mixinBootstrapper = detect();
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static boolean isMixinsInstalled() {
|
||||
return mixinBootstrapper != MixinBootstrapperType.None;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static boolean isOfficialSpongeMixins() {
|
||||
return (mixinBootstrapper == MixinBootstrapperType.SpongeMixins) && getVerUnsafe().equals("0.7.11");
|
||||
}
|
||||
@@ -54,37 +53,36 @@ public final class MixinInfo {
|
||||
/**
|
||||
* The nh fork of spongemixins breaks some stuff since 1.5.0.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static boolean isTamperedSpongeMixins() {
|
||||
return (mixinBootstrapper == MixinBootstrapperType.SpongeMixins) && getVerUnsafe().equals("0.7.12");
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static boolean isGrimoire() {
|
||||
return mixinBootstrapper == MixinBootstrapperType.Grimoire;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static boolean isMixinBooterLegacy() {
|
||||
return mixinBootstrapper == MixinBootstrapperType.MixinBooterLegacy;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.14")
|
||||
/**
|
||||
* @since 0.10.14
|
||||
*/
|
||||
public static boolean isGasStation() {
|
||||
return mixinBootstrapper == MixinBootstrapperType.GasStation;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.15")
|
||||
/**
|
||||
* @since 0.10.15
|
||||
*/
|
||||
public static boolean isUniMixin() {
|
||||
return mixinBootstrapper == MixinBootstrapperType.UniMixin;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static MixinBootstrapperType bootstrapperType() {
|
||||
return mixinBootstrapper;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Optional<String> mixinVersion() {
|
||||
return mixinBootstrapper != MixinBootstrapperType.None ? Optional.of(getVerUnsafe()) : Optional.empty();
|
||||
}
|
||||
@@ -93,6 +91,7 @@ public final class MixinInfo {
|
||||
return MixinBootstrap.VERSION;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static boolean isClassPresentSafe(String clazz) {
|
||||
try {
|
||||
val bytes = Launch.classLoader.getClassBytes(clazz);
|
||||
@@ -130,14 +129,18 @@ public final class MixinInfo {
|
||||
return MixinBootstrapperType.Other;
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.2")
|
||||
/**
|
||||
* @since 0.10.2
|
||||
*/
|
||||
public enum MixinBootstrapperType {
|
||||
@StableAPI.Expose None,
|
||||
@StableAPI.Expose(since = "0.10.9") GasStation,
|
||||
@StableAPI.Expose SpongeMixins,
|
||||
@StableAPI.Expose Grimoire,
|
||||
@StableAPI.Expose MixinBooterLegacy,
|
||||
@StableAPI.Expose Other,
|
||||
@StableAPI.Expose(since = "0.10.15") UniMixin
|
||||
None,
|
||||
/** @since 0.10.9 */
|
||||
GasStation,
|
||||
SpongeMixins,
|
||||
Grimoire,
|
||||
MixinBooterLegacy,
|
||||
Other,
|
||||
/** @since 0.10.15 */
|
||||
UniMixin
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -32,20 +31,20 @@ import java.util.List;
|
||||
/**
|
||||
* This is a class you can use to interact with MixinInfo before it gets classloaded.
|
||||
* (Originally placed here for future unimixins compat in case they change the class names)
|
||||
*
|
||||
* @since 0.10.15
|
||||
*/
|
||||
@StableAPI(since = "0.10.15")
|
||||
public class MixinInfoCompatCompanion {
|
||||
/**
|
||||
* A list of all mixin classes that are candidates for unimixins.
|
||||
* This is used to determine if a mixin plugin is unimixins. Once MixinInfo is classloaded, this list has no effect.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static final List<String> UNIMIXIN_CANDIDATES = new ArrayList<>(Arrays.asList(
|
||||
"io.github.legacymoddingmc.unimixins.compat.CompatCore",
|
||||
"io.github.legacymoddingmc.unimixins.devcompat.DevCompatCore",
|
||||
"io.github.legacymoddingmc.unimixins.all.AllCore",
|
||||
"io.github.legacymoddingmc.unimixins.mixin.MixinModule"));
|
||||
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
static boolean mixinInfoClassLoaded = false;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.8.0
|
||||
*/
|
||||
package com.falsepattern.lib.mixin;
|
||||
Reference in new issue
Block a user