Skip to content

Commit 0be4497

Browse files
committed
Merge branch '0.10-maintenance'
# Conflicts: # build.gradle
2 parents 4ef06d8 + 7fdfb52 commit 0be4497

File tree

5 files changed

+103
-25
lines changed

5 files changed

+103
-25
lines changed

build.gradle

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//version: 1656003793falsepattern60
1+
//version: 1656003793falsepattern62
22
/*
33
DO NOT CHANGE THIS FILE!
44
@@ -670,12 +670,13 @@ def getCredentials = {
670670
}
671671

672672
//Publishing
673-
publish.dependsOn(build)
674673
publishing {
675674
publications {
676675
maven(MavenPublication) {
677676
from components.java
678-
artifact source: usesShadowedDependencies.toBoolean() ? shadowJar : jar, classifier: ""
677+
if (usesShadowedDependencies.toBoolean()) {
678+
artifact source: shadowJar, classifier: ""
679+
}
679680
if (!project.hasProperty("noPublishedSources") || !noPublishedSources) {
680681
artifact source: sourcesJar, classifier: "sources"
681682
}
@@ -724,6 +725,12 @@ publishing {
724725
}
725726
}
726727

728+
tasks.withType(PublishToMavenRepository) { task ->
729+
dependsOn("build")
730+
}
731+
732+
publishToMavenLocal.dependsOn("build")
733+
727734
if (project.changelog == "") {
728735
File changelogFile = new File(System.getenv("CHANGELOG_FILE") ?: "CHANGELOG.md")
729736
if (changelogFile.exists()) {

src/main/java/com/falsepattern/lib/internal/impl/mixin/UCPImpl.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
package com.falsepattern.lib.internal.impl.mixin;
2323

2424
import lombok.val;
25-
import sun.misc.URLClassPath;
2625

2726
import net.minecraft.launchwrapper.Launch;
2827
import net.minecraft.launchwrapper.LaunchClassLoader;
@@ -31,7 +30,6 @@
3130
import java.io.IOException;
3231

3332
public final class UCPImpl {
34-
private static final URLClassPath ucp;
3533
private static final boolean GRIMOIRE;
3634

3735
static {
@@ -49,24 +47,14 @@ public final class UCPImpl {
4947
}
5048
}
5149
GRIMOIRE = grimoire;
52-
if (!GRIMOIRE) {
53-
try {
54-
val ucpField = LaunchClassLoader.class.getSuperclass().getDeclaredField("ucp");
55-
ucpField.setAccessible(true);
56-
57-
ucp = (URLClassPath) ucpField.get(Launch.classLoader);
58-
} catch (NoSuchFieldException | IllegalAccessException e) {
59-
throw new RuntimeException(e.getMessage());
60-
}
61-
} else {
62-
ucp = null;
63-
System.err.println("Grimoire detected, disabling jar loading utility");
64-
}
6550
}
6651

6752
public static void addJar(File pathToJar) throws Exception {
6853
if (!GRIMOIRE) {
69-
ucp.addURL(pathToJar.toURI().toURL());
54+
final LaunchClassLoader loader = Launch.classLoader;
55+
loader.addURL(pathToJar.toURI().toURL());
56+
// Act as-if we only added the mod to ucp
57+
loader.getSources().remove(loader.getSources().size() - 1);
7058
}
7159
}
7260
}

src/main/java/com/falsepattern/lib/mixin/IMixinPlugin.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333

3434
import java.io.File;
3535
import java.io.FileNotFoundException;
36-
import java.io.IOException;
36+
import java.net.URL;
3737
import java.nio.file.Path;
38+
import java.nio.file.Paths;
3839
import java.util.ArrayList;
3940
import java.util.Arrays;
4041
import java.util.List;
@@ -55,12 +56,29 @@ static Logger createLogger(String modName) {
5556

5657
@StableAPI.Expose
5758
static File findJarOf(final ITargetedMod mod) {
59+
File result = null;
5860
try (val stream = walk(MODS_DIRECTORY_PATH)) {
59-
return stream.filter(mod::isMatchingJar).map(Path::toFile).findFirst().orElse(null);
60-
} catch (IOException e) {
61+
result = stream.filter(mod::isMatchingJar)
62+
.map(Path::toFile)
63+
.findFirst()
64+
.orElse(null);
65+
} catch (Exception e) {
6166
e.printStackTrace();
62-
return null;
6367
}
68+
if (result == null) {
69+
try {
70+
result = Arrays.stream(Launch.classLoader.getURLs())
71+
.map(URL::getPath)
72+
.map(Paths::get)
73+
.filter(mod::isMatchingJar)
74+
.map(Path::toFile)
75+
.findFirst()
76+
.orElse(null);
77+
} catch (Exception e) {
78+
e.printStackTrace();
79+
}
80+
}
81+
return result;
6482
}
6583

6684
@StableAPI.Expose

src/main/java/com/falsepattern/lib/mixin/MixinInfo.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
@StableAPI(since = "0.10.2")
3434
public final class MixinInfo {
3535
@StableAPI.Expose
36-
public static final MixinBootstrapperType mixinBootstrapper = detect();
36+
public static final MixinBootstrapperType mixinBootstrapper;
37+
38+
static {
39+
MixinInfoCompatCompanion.mixinInfoClassLoaded = true;
40+
mixinBootstrapper = detect();
41+
}
3742

3843
@StableAPI.Expose
3944
public static boolean isMixinsInstalled() {
@@ -68,6 +73,11 @@ public static boolean isGasStation() {
6873
return mixinBootstrapper == MixinBootstrapperType.GasStation;
6974
}
7075

76+
@StableAPI.Expose(since = "0.10.15")
77+
public static boolean isUniMixin() {
78+
return mixinBootstrapper == MixinBootstrapperType.UniMixin;
79+
}
80+
7181
@StableAPI.Expose
7282
public static MixinBootstrapperType bootstrapperType() {
7383
return mixinBootstrapper;
@@ -97,6 +107,11 @@ public static boolean isClassPresentSafe(String clazz) {
97107
private static MixinBootstrapperType detect() {
98108
if (!isClassPresentSafe("org.spongepowered.asm.launch.MixinBootstrap"))
99109
return MixinBootstrapperType.None;
110+
for (val candidate: MixinInfoCompatCompanion.UNIMIXIN_CANDIDATES) {
111+
if (isClassPresentSafe(candidate)) {
112+
return MixinBootstrapperType.UniMixin;
113+
}
114+
}
100115
if (isClassPresentSafe("com.falsepattern.gasstation.GasStation"))
101116
return MixinBootstrapperType.GasStation;
102117
if (isClassPresentSafe("ru.timeconqueror.spongemixins.core.SpongeMixinsCore"))
@@ -115,6 +130,7 @@ public enum MixinBootstrapperType {
115130
@StableAPI.Expose SpongeMixins,
116131
@StableAPI.Expose Grimoire,
117132
@StableAPI.Expose MixinBooterLegacy,
118-
@StableAPI.Expose Other
133+
@StableAPI.Expose Other,
134+
@StableAPI.Expose(since = "0.10.15") UniMixin
119135
}
120136
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (C) 2022 FalsePattern
3+
* All Rights Reserved
4+
*
5+
* The above copyright notice, this permission notice and the word "SNEED"
6+
* shall be included in all copies or substantial portions of the Software.
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Lesser General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
package com.falsepattern.lib.mixin;
23+
24+
import com.falsepattern.lib.StableAPI;
25+
import lombok.Getter;
26+
27+
import java.util.ArrayList;
28+
import java.util.Arrays;
29+
import java.util.List;
30+
31+
/**
32+
* This is a class you can use to interact with MixinInfo before it gets classloaded.
33+
* (Originally placed here for future unimixins compat in case they change the class names)
34+
*/
35+
@StableAPI(since = "0.10.15")
36+
public class MixinInfoCompatCompanion {
37+
/**
38+
* A list of all mixin classes that are candidates for unimixins.
39+
* This is used to determine if a mixin plugin is unimixins. Once MixinInfo is classloaded, this list has no effect.
40+
*/
41+
@StableAPI.Expose
42+
public static final List<String> UNIMIXIN_CANDIDATES = new ArrayList<>(Arrays.asList("io.github.legacymoddingmc.unimixins.compat.CompatCore",
43+
"io.github.legacymoddingmc.unimixins.devcompat.DevCompatCore",
44+
"io.github.legacymoddingmc.unimixins.all.AllCore",
45+
"io.github.legacymoddingmc.unimixins.mixin.MixinModule"));
46+
47+
@Getter(onMethod_ = @StableAPI.Expose)
48+
static boolean mixinInfoClassLoaded = false;
49+
}

0 commit comments

Comments
 (0)