Use different classifier for dependency files with Bukkit-Legacy remappings

This commit is contained in:
Luck 2021-07-08 22:53:43 +01:00
parent 563b5be9b2
commit cfb298f69b
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 15 additions and 5 deletions

View File

@ -313,8 +313,13 @@ public enum Dependency {
return s.replace("{}", "."); return s.replace("{}", ".");
} }
public String getFileName() { public String getFileName(String classifier) {
return name().toLowerCase().replace('_', '-') + "-" + this.version; String name = name().toLowerCase().replace('_', '-');
String extra = classifier == null || classifier.isEmpty()
? ""
: "-" + classifier;
return name + "-" + this.version + extra + ".jar";
} }
String getMavenRepoPath() { String getMavenRepoPath() {

View File

@ -155,7 +155,7 @@ public class DependencyManager {
} }
private Path downloadDependency(Dependency dependency) throws DependencyDownloadException { 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 the file already exists, don't attempt to re-download it.
if (Files.exists(file)) { if (Files.exists(file)) {
@ -185,7 +185,7 @@ public class DependencyManager {
return normalFile; 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 the remapped source exists already, just use that.
if (Files.exists(remappedFile)) { if (Files.exists(remappedFile)) {

View File

@ -99,7 +99,7 @@ public class DependencyRegistry {
Platform.Type type = this.plugin.getBootstrap().getType(); Platform.Type type = this.plugin.getBootstrap().getType();
// support for LuckPerms legacy (bukkit 1.7.10) // 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("guava", "com{}google{}common"));
relocations.add(Relocation.of("gson", "com{}google{}gson")); 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) { private static boolean classExists(String className) {
try { try {
Class.forName(className); Class.forName(className);