diff --git a/build.gradle b/build.gradle index b6a38df..5691c40 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ plugins { id "com.github.gmazzo.buildconfig" version "5.2.0" } -def legacyVersion = "1.7.6" +def legacyVersion = "1.7.7" group 'net.legacyfabric' version '1.5.3' diff --git a/src/main/java/net/fabricmc/meta/FabricMeta.java b/src/main/java/net/fabricmc/meta/FabricMeta.java index c762695..a3462a6 100644 --- a/src/main/java/net/fabricmc/meta/FabricMeta.java +++ b/src/main/java/net/fabricmc/meta/FabricMeta.java @@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit; import com.google.gson.stream.JsonReader; +import net.legacyfabric.meta.data.LegacyVersionDatabase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/net/fabricmc/meta/web/ProfileHandler.java b/src/main/java/net/fabricmc/meta/web/ProfileHandler.java index 80fbe24..104b2d0 100644 --- a/src/main/java/net/fabricmc/meta/web/ProfileHandler.java +++ b/src/main/java/net/fabricmc/meta/web/ProfileHandler.java @@ -36,6 +36,7 @@ import com.google.gson.JsonObject; import net.fabricmc.meta.data.VersionDatabase; import net.legacyfabric.meta.data.LegacyVersionDatabase; +import net.legacyfabric.meta.utils.LegacyReference; import org.apache.commons.io.IOUtils; import net.fabricmc.meta.utils.Reference; @@ -116,7 +117,7 @@ private static JsonObject buildProfileJson(LoaderInfoV2 info, String side) { JsonObject librariesObject = launcherMeta.get("libraries").getAsJsonObject(); // Build the libraries array with the existing libs + loader and intermediary JsonArray libraries = (JsonArray) librariesObject.get("common"); - libraries.add(formatLibrary(info.getIntermediary().getMaven(), LegacyVersionDatabase.MAVEN_URL)); + libraries.add(formatLibrary(info.getIntermediary().getMaven(), LegacyReference.LEGACY_FABRIC_MAVEN_URL)); libraries.add(formatLibrary(info.getLoader().getMaven(), Reference.FABRIC_MAVEN_URL)); if (librariesObject.has(side)) { diff --git a/src/main/java/net/fabricmc/meta/web/ServerBootstrap.java b/src/main/java/net/fabricmc/meta/web/ServerBootstrap.java index 4db1d41..b16a406 100644 --- a/src/main/java/net/fabricmc/meta/web/ServerBootstrap.java +++ b/src/main/java/net/fabricmc/meta/web/ServerBootstrap.java @@ -39,6 +39,7 @@ import io.javalin.http.Context; import io.javalin.http.Handler; import io.javalin.http.InternalServerErrorResponse; +import net.legacyfabric.meta.utils.LegacyReference; import org.apache.commons.io.FileUtils; import net.fabricmc.meta.FabricMeta; @@ -198,7 +199,6 @@ private static int getCacheDuration(Context ctx) { } private static String getInstallerURL() { - // Reference.LOCAL_FABRIC_MAVEN_URL+"net/fabricmc/fabric-installer/%1$s/fabric-installer-%1$s-server.jar" - return "https://maven.legacyfabric.net/net/legacyfabric/fabric-installer/%1$s/fabric-installer-%1$s-server.jar"; + return LegacyReference.LOCAL_LEGACY_FABRIC_MAVEN_URL + "net/legacyfabric/fabric-installer/%1$s/fabric-installer-%1$s-server.jar"; } } diff --git a/src/main/java/net/legacyfabric/meta/LegacyConstants.java b/src/main/java/net/legacyfabric/meta/LegacyConstants.java deleted file mode 100644 index 06ad534..0000000 --- a/src/main/java/net/legacyfabric/meta/LegacyConstants.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2021-2024 Legacy Fabric - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.legacyfabric.meta; - -public class LegacyConstants { -} diff --git a/src/main/java/net/legacyfabric/meta/data/LegacyVersionDatabase.java b/src/main/java/net/legacyfabric/meta/data/LegacyVersionDatabase.java index 6aa53a4..6ff2632 100644 --- a/src/main/java/net/legacyfabric/meta/data/LegacyVersionDatabase.java +++ b/src/main/java/net/legacyfabric/meta/data/LegacyVersionDatabase.java @@ -21,6 +21,7 @@ import net.fabricmc.meta.web.models.BaseVersion; import net.fabricmc.meta.web.models.MavenBuildVersion; import net.fabricmc.meta.web.models.MavenUrlVersion; +import net.legacyfabric.meta.utils.LegacyReference; import net.legacyfabric.meta.web.models.LegacyMavenUrlVersion; import java.util.List; @@ -28,11 +29,9 @@ import java.util.stream.Collectors; public class LegacyVersionDatabase extends VersionDatabase { - public static final String MAVEN_URL = "https://repo.legacyfabric.net/repository/legacyfabric/"; - - public static final PomParser MAPPINGS_PARSER = new PomParser(MAVEN_URL + "net/legacyfabric/yarn/maven-metadata.xml"); - public static final PomParser INTERMEDIARY_PARSER = new PomParser(MAVEN_URL + "net/legacyfabric/intermediary/maven-metadata.xml"); - public static final PomParser INSTALLER_PARSER = new PomParser(MAVEN_URL + "net/legacyfabric/fabric-installer/maven-metadata.xml"); + public static final PomParser MAPPINGS_PARSER = new PomParser(LegacyReference.LOCAL_LEGACY_FABRIC_MAVEN_URL + "net/legacyfabric/yarn/maven-metadata.xml"); + public static final PomParser INTERMEDIARY_PARSER = new PomParser(LegacyReference.LOCAL_LEGACY_FABRIC_MAVEN_URL + "net/legacyfabric/intermediary/maven-metadata.xml"); + public static final PomParser INSTALLER_PARSER = new PomParser(LegacyReference.LOCAL_LEGACY_FABRIC_MAVEN_URL + "net/legacyfabric/fabric-installer/maven-metadata.xml"); public PomParser getMappingsParser() { return MAPPINGS_PARSER; diff --git a/src/main/java/net/legacyfabric/meta/utils/LegacyReference.java b/src/main/java/net/legacyfabric/meta/utils/LegacyReference.java new file mode 100644 index 0000000..44869dc --- /dev/null +++ b/src/main/java/net/legacyfabric/meta/utils/LegacyReference.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021-2024 Legacy Fabric + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.meta.utils; + +import net.fabricmc.meta.FabricMeta; + +public class LegacyReference { + /** + * Legacy Fabric maven url to expose to the user. + * + *
This shouldn't be directly accessed by this meta server instance! + */ + public static final String LEGACY_FABRIC_MAVEN_URL = "https://repo.legacyfabric.net/repository/legacyfabric/"; + + /** + * Legacy Fabric maven url to access from this meta server instance. + * + *
This is not to be included in any output data! + */ + public static final String LOCAL_LEGACY_FABRIC_MAVEN_URL = FabricMeta.getConfig().getOrDefault("localLegacyFabricMavenUrl", LEGACY_FABRIC_MAVEN_URL); +} diff --git a/src/main/java/net/legacyfabric/meta/web/models/LegacyMavenUrlVersion.java b/src/main/java/net/legacyfabric/meta/web/models/LegacyMavenUrlVersion.java index 49ce510..eeb34cd 100644 --- a/src/main/java/net/legacyfabric/meta/web/models/LegacyMavenUrlVersion.java +++ b/src/main/java/net/legacyfabric/meta/web/models/LegacyMavenUrlVersion.java @@ -18,6 +18,7 @@ import net.fabricmc.meta.web.models.MavenUrlVersion; import net.legacyfabric.meta.data.LegacyVersionDatabase; +import net.legacyfabric.meta.utils.LegacyReference; public class LegacyMavenUrlVersion extends MavenUrlVersion { public LegacyMavenUrlVersion(String maven) { @@ -26,6 +27,6 @@ public LegacyMavenUrlVersion(String maven) { @Override public String getMavenUrl() { - return LegacyVersionDatabase.MAVEN_URL; + return LegacyReference.LEGACY_FABRIC_MAVEN_URL; } }