Skip to content

Commit cdd0b97

Browse files
committed
Fix log spam with Java 9 module files
1 parent 35ce2b3 commit cdd0b97

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

versions/src/main/java/org/polyfrost/oneconfig/internal/OneConfigMixinInit.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public List<String> getMixins() {
6868
if (version < 11300) {
6969
// legacy forge
7070
mixins.add("compat.OneConfigV0CompatMixin");
71+
mixins.add("forge.ASMModParserMixin");
72+
mixins.add("forge.JarDiscovererMixin");
7173
}
7274
} else {
7375
// fabric specific
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* This file is part of OneConfig.
3+
* OneConfig - Next Generation Config Library for Minecraft: Java Edition
4+
* Copyright (C) 2021~2024 Polyfrost.
5+
* <https://polyfrost.org> <https://github.com/Polyfrost/>
6+
*
7+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8+
*
9+
* OneConfig is licensed under the terms of version 3 of the GNU Lesser
10+
* General Public License as published by the Free Software Foundation, AND
11+
* under the Additional Terms Applicable to OneConfig, as published by Polyfrost,
12+
* either version 1.0 of the Additional Terms, or (at your option) any later
13+
* version.
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18+
* Lesser General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Lesser General Public
21+
* License. If not, see <https://www.gnu.org/licenses/>. You should
22+
* have also received a copy of the Additional Terms Applicable
23+
* to OneConfig, as published by Polyfrost. If not, see
24+
* <https://polyfrost.org/legal/oneconfig/additional-terms>
25+
*/
26+
27+
//#if FORGE && MC<=11202
28+
package org.polyfrost.oneconfig.internal.mixin.forge;
29+
30+
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
31+
import net.minecraftforge.fml.common.discovery.asm.ASMModParser;
32+
import org.apache.logging.log4j.Level;
33+
import org.spongepowered.asm.mixin.Mixin;
34+
import org.spongepowered.asm.mixin.injection.At;
35+
36+
@Mixin(value = ASMModParser.class, remap = false)
37+
public class ASMModParserMixin {
38+
39+
@WrapWithCondition(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLLog;log(Lorg/apache/logging/log4j/Level;Ljava/lang/Throwable;Ljava/lang/String;[Ljava/lang/Object;)V"))
40+
private boolean ignoreException(Level level, Throwable ex, String format, Object[] data) {
41+
return !(ex instanceof IllegalArgumentException);
42+
}
43+
}
44+
//#endif
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This file is part of OneConfig.
3+
* OneConfig - Next Generation Config Library for Minecraft: Java Edition
4+
* Copyright (C) 2021~2024 Polyfrost.
5+
* <https://polyfrost.org> <https://github.com/Polyfrost/>
6+
*
7+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8+
*
9+
* OneConfig is licensed under the terms of version 3 of the GNU Lesser
10+
* General Public License as published by the Free Software Foundation, AND
11+
* under the Additional Terms Applicable to OneConfig, as published by Polyfrost,
12+
* either version 1.0 of the Additional Terms, or (at your option) any later
13+
* version.
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18+
* Lesser General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Lesser General Public
21+
* License. If not, see <https://www.gnu.org/licenses/>. You should
22+
* have also received a copy of the Additional Terms Applicable
23+
* to OneConfig, as published by Polyfrost. If not, see
24+
* <https://polyfrost.org/legal/oneconfig/additional-terms>
25+
*/
26+
27+
//#if FORGE && MC<=11202
28+
package org.polyfrost.oneconfig.internal.mixin.forge;
29+
30+
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
31+
import net.minecraftforge.fml.common.LoaderException;
32+
import net.minecraftforge.fml.common.discovery.JarDiscoverer;
33+
import org.apache.logging.log4j.Level;
34+
import org.spongepowered.asm.mixin.Mixin;
35+
import org.spongepowered.asm.mixin.injection.At;
36+
37+
@Mixin(value = JarDiscoverer.class, remap = false)
38+
public class JarDiscovererMixin {
39+
40+
@WrapWithCondition(method =
41+
//#if MC<=10809
42+
"discover"
43+
//#else
44+
//$$ "findClassesASM"
45+
//#endif
46+
, at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLLog;log(Lorg/apache/logging/log4j/Level;Ljava/lang/Throwable;Ljava/lang/String;[Ljava/lang/Object;)V"))
47+
private boolean ignoreException(Level level, Throwable ex, String format, Object[] data) {
48+
if (ex instanceof LoaderException) {
49+
return !(ex.getCause() instanceof IllegalArgumentException);
50+
}
51+
return true;
52+
}
53+
}
54+
//#endif

0 commit comments

Comments
 (0)