mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Update to Architectury Plugin 3.1 to support detecting the api FabricLoader
Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "architectury-plugin" version "3.0.97"
|
id "architectury-plugin" version "3.1-SNAPSHOT"
|
||||||
id "forgified-fabric-loom" version "0.6.78" apply false
|
id "forgified-fabric-loom" version "0.6-SNAPSHOT" apply false
|
||||||
id "org.cadixdev.licenser" version "0.5.0"
|
id "org.cadixdev.licenser" version "0.5.0"
|
||||||
id "com.matthewprenger.cursegradle" version "1.4.0" apply false
|
id "com.matthewprenger.cursegradle" version "1.4.0" apply false
|
||||||
id "maven-publish"
|
id "maven-publish"
|
||||||
|
|||||||
@@ -19,39 +19,14 @@
|
|||||||
|
|
||||||
package me.shedaniel.architectury;
|
package me.shedaniel.architectury;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import me.shedaniel.architectury.targets.ArchitecturyTarget;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public class Architectury {
|
public class Architectury {
|
||||||
private static final String MOD_LOADER;
|
@Deprecated
|
||||||
private static final ImmutableMap<String,String> MOD_LOADERS = ImmutableMap.<String,String>builder()
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.0")
|
||||||
.put("net.fabricmc.loader.FabricLoader", "fabric")
|
|
||||||
.put("net.minecraftforge.fml.common.Mod", "forge")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
public static String getModLoader() {
|
public static String getModLoader() {
|
||||||
return MOD_LOADER;
|
return ArchitecturyTarget.getCurrentTarget();
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
List<String> loader = new ArrayList<>();
|
|
||||||
for (Map.Entry<String, String> entry : MOD_LOADERS.entrySet()) {
|
|
||||||
try {
|
|
||||||
Class.forName(entry.getKey(), false, Architectury.class.getClassLoader());
|
|
||||||
loader.add(entry.getValue());
|
|
||||||
break;
|
|
||||||
} catch (ClassNotFoundException ignored) {}
|
|
||||||
}
|
|
||||||
if (loader.isEmpty())
|
|
||||||
throw new IllegalStateException("No detected mod loader!");
|
|
||||||
if (loader.size() >= 2)
|
|
||||||
LogManager.getLogger().error("Detected multiple mod loaders! Something is wrong on the classpath! " + String.join(", ", loader));
|
|
||||||
MOD_LOADER = loader.get(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,11 @@ package me.shedaniel.architectury.platform;
|
|||||||
|
|
||||||
import me.shedaniel.architectury.Architectury;
|
import me.shedaniel.architectury.Architectury;
|
||||||
import me.shedaniel.architectury.annotations.ExpectPlatform;
|
import me.shedaniel.architectury.annotations.ExpectPlatform;
|
||||||
|
import me.shedaniel.architectury.targets.ArchitecturyTarget;
|
||||||
import me.shedaniel.architectury.utils.Env;
|
import me.shedaniel.architectury.utils.Env;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.minecraft.SharedConstants;
|
import net.minecraft.SharedConstants;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -37,8 +39,12 @@ public final class Platform {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the current mod loader, either "fabric" or "forge"
|
* @return the current mod loader, either "fabric" or "forge"
|
||||||
|
* @deprecated does not reflect the true mod loader, "quilt" is never returned,
|
||||||
|
* use {@link ArchitecturyTarget#getCurrentTarget()} instead.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.0")
|
||||||
public static String getModLoader() {
|
public static String getModLoader() {
|
||||||
return Architectury.getModLoader();
|
return Architectury.getModLoader();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
maven { url "https://maven.fabricmc.net/" }
|
maven { url "https://maven.fabricmc.net/" }
|
||||||
maven { url "https://maven.shedaniel.me/" }
|
maven { url "https://maven.architectury.dev/" }
|
||||||
maven { url "https://files.minecraftforge.net/maven/" }
|
maven { url "https://files.minecraftforge.net/maven/" }
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user