Compare commits

...

6 Commits
v1.0.0 ... dev

Author SHA1 Message Date
CPTProgrammer
888b801ac7 Update README.md 2025-07-09 18:42:38 +08:00
CPTProgrammer
84b925d05c Bump version to 1.0.1 2025-06-25 15:38:38 +08:00
CPTProgrammer
f02b2acde5 Fix #10
Use `ASM` instead of `Class.forName` to check `shouldApplyMixin`
2025-06-24 21:49:43 +08:00
CPTProgrammer
e43426128a Update README.md 2025-06-19 01:40:02 +08:00
CPTProgrammer
bcd52a866f Update .gitattributes
Spelling mistake
2025-06-13 07:16:59 +08:00
CPTProgrammer
be8e0d1cab Update build.gradle
Some checks failed
build / build (push) Has been cancelled
Fail buildAll task when any sub build task fails
2025-04-21 21:57:38 +08:00
5 changed files with 23 additions and 12 deletions

2
.gitattributes vendored
View File

@ -4,7 +4,7 @@
# Linux start script should use lf
/gradlew text eol=lf
* test=auto eol=lf
* text=auto eol=lf
# These are Windows script files and should use crlf
*.bat text eol=crlf

View File

@ -42,7 +42,7 @@ _* Other mods may work without explicit support. Report compatibility requests v
| 1.19.3 | 1.19.3 - 1.19.4 |
| 1.20 | 1.20 - 1.20.2 |
| 1.20.3 | 1.20.3 - 1.20.6 |
| 1.21 | 1.21 - 1.21.5 |
| 1.21 | 1.21 - 1.21.7 |

View File

@ -119,6 +119,8 @@ tasks.register("buildAll") {
logger.lifecycle("Using Java ${javaToolchain.metadata.javaRuntimeVersion} (path=\"${projectJavaHome}\")")
def failedVersions = new ArrayList<String>()
project.minecraftVersions.each { version ->
logger.lifecycle("================ Building for Minecraft ${version} ================")
// TODO: Refactor this (is there a better approach?)
@ -131,11 +133,14 @@ tasks.register("buildAll") {
def result = execOutput.result.get()
def output = execOutput.standardOutput.asText.get()
def error = execOutput.standardError.asText.get()
logger.lifecycle("[Minecraft ${version}] BUILD ${result.exitValue == 0 ? "SUCCESS" : "FAILED"}. Process exited with code: ${result.exitValue}")
logger.lifecycle("[Minecraft ${version}] BUILD ${result.exitValue == 0 ? "SUCCESSFUL" : "FAILED"}. Process exited with code: ${result.exitValue}")
if (result.exitValue != 0) {
failedVersions.addLast(version as String)
logger.lifecycle("[Minecraft ${version}] Error: ${error}")
}
}
if (!failedVersions.isEmpty()) throw new GradleException("Build failed for Minecraft versions: ${failedVersions.join(", ")}")
}
}

View File

@ -6,7 +6,7 @@ org.gradle.parallel=true
version_properties_path=./properties
# Mod Properties
mod_version=1.0.0
mod_version=1.0.1
maven_group=cn.revaria.chatplus
archives_base_name=chat-plus

View File

@ -2,11 +2,14 @@ package cn.revaria.chatplus.plugin;
import cn.revaria.chatplus.plugin.annotation.DisableIfModsLoaded;
import net.fabricmc.loader.api.FabricLoader;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import org.spongepowered.asm.service.MixinService;
import org.spongepowered.asm.util.Annotations;
import java.util.Arrays;
import java.io.IOException;
import java.util.List;
import java.util.Set;
@ -23,14 +26,17 @@ public class MixinConfigPlugin implements IMixinConfigPlugin {
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
try {
Class<?> mixinClass = Class.forName(mixinClassName);
DisableIfModsLoaded annotation = mixinClass.getAnnotation(DisableIfModsLoaded.class);
if (annotation != null) {
return Arrays.stream(annotation.value()).noneMatch(modId -> FabricLoader.getInstance().isModLoaded(modId));
ClassNode classNode = MixinService.getService().getBytecodeProvider().getClassNode(mixinClassName);
AnnotationNode annotationNode = Annotations.getVisible(classNode, DisableIfModsLoaded.class);
if (annotationNode == null) {
return true;
}
return true;
} catch (Exception e) {
return true;
List<String> modIds = Annotations.getValue(annotationNode);
return modIds.stream().noneMatch(modId -> FabricLoader.getInstance().isModLoaded(modId));
} catch (IOException | ClassNotFoundException e) {
return false;
}
}