Use different classifier for dependency files with Bukkit-Legacy remappings

This commit is contained in:
Luck committed 2021-07-08 22:54:04 +01:00
1 parent 563b5be9b2
commit cfb298f69b
3 files changed
+15 -5

No files matched your search

@@ -313,8 +313,13 @@ public enum Dependency {
return s.replace("{}", ".");
}
public String getFileName() {
return name().toLowerCase().replace('_', '-') + "-" + this.version;
public String getFileName(String classifier) {
String name = name().toLowerCase().replace('_', '-');
String extra = classifier == null || classifier.isEmpty()
? ""
: "-" + classifier;
return name + "-" + this.version + extra + ".jar";
}
String getMavenRepoPath() {
@@ -155,7 +155,7 @@ public class DependencyManager {
}
private Path downloadDependency(Dependency dependency) throws DependencyDownloadException {
Path file = this.cacheDirectory.resolve(dependency.getFileName() + ".jar");
Path file = this.cacheDirectory.resolve(dependency.getFileName(null));
// if the file already exists, don't attempt to re-download it.
if (Files.exists(file)) {
@@ -185,7 +185,7 @@ public class DependencyManager {
return normalFile;
}
Path remappedFile = this.cacheDirectory.resolve(dependency.getFileName() + "-remapped.jar");
Path remappedFile = this.cacheDirectory.resolve(dependency.getFileName(DependencyRegistry.isGsonRelocated() ? "remapped-legacy" : "remapped"));
// if the remapped source exists already, just use that.
if (Files.exists(remappedFile)) {
@@ -99,7 +99,7 @@ public class DependencyRegistry {
Platform.Type type = this.plugin.getBootstrap().getType();
// support for LuckPerms legacy (bukkit 1.7.10)
if (!RelocationHandler.DEPENDENCIES.contains(dependency) && JsonElement.class.getName().startsWith("me.lucko")) {
if (!RelocationHandler.DEPENDENCIES.contains(dependency) && isGsonRelocated()) {
relocations.add(Relocation.of("guava", "com{}google{}common"));
relocations.add(Relocation.of("gson", "com{}google{}gson"));
}
@@ -125,6 +125,11 @@ public class DependencyRegistry {
}
}
@SuppressWarnings("ConstantConditions")
public static boolean isGsonRelocated() {
return JsonElement.class.getName().startsWith("me.lucko");
}
private static boolean classExists(String className) {
try {
Class.forName(className);