Update the rewriteForIde for new cb package version (#7242)

This commit is contained in:
Jake Potrebic 2022-05-30 22:18:45 -07:00
parent cee484c458
commit 04acf65b3c
3 changed files with 6 additions and 5 deletions

View file

@ -35,6 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
"Specification-Vendor" to "Bukkit Team",
+ "Git-Branch" to gitBranch, // Paper
+ "Git-Commit" to gitHash, // Paper
+ "CraftBukkit-Package-Version" to craftbukkitPackageVersion, // Paper
)
for (tld in setOf("net", "com", "org")) {
attributes("$tld/bukkit", "Sealed" to true)

View file

@ -43,18 +43,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - Plugin rewrites
+ private static final Map<String, String> SEARCH_AND_REMOVE = initReplacementsMap();
+ private static final java.util.jar.Manifest manifest = io.papermc.paper.util.JarManifests.manifest(Commodore.class);
+ private static Map<String, String> initReplacementsMap()
+ {
+ Map<String, String> getAndRemove = new HashMap<>();
+ // Be wary of maven shade's relocations
+ getAndRemove.put( "org/bukkit/".concat( "craftbukkit/libs/it/unimi/dsi/fastutil/" ), "org/bukkit/".concat( "craftbukkit/libs/" ) ); // Remap fastutil to our location
+
+ if ( Boolean.getBoolean( "debug.rewriteForIde" ) )
+ if ( Boolean.getBoolean( "debug.rewriteForIde" ) && manifest != null)
+ {
+ // unversion incoming calls for pre-relocate debug work
+ final String NMS_REVISION_PACKAGE = "v1_16_R3/";
+ final String NMS_REVISION_PACKAGE = "v" + manifest.getMainAttributes().getValue("CraftBukkit-Package-Version") + "/";
+
+ getAndRemove.put( "net/minecraft/".concat( "server/" + NMS_REVISION_PACKAGE ), NMS_REVISION_PACKAGE );
+ getAndRemove.put( "org/bukkit/".concat( "craftbukkit/" + NMS_REVISION_PACKAGE ), NMS_REVISION_PACKAGE );
+ }
+

View file

@ -58,6 +58,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ testImplementation("org.hamcrest:hamcrest-library:1.3")
+}
+
+val craftbukkitPackageVersion = "1_18_R2" // Paper
+tasks.jar {
+ archiveClassifier.set("dev")
+
@ -89,8 +90,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+relocation {
+ // Order matters here - e.g. craftbukkit proper must be relocated before any of the libs are relocated into the cb package
+ val packageVersion = "1_18_R2"
+ relocate("org.bukkit.craftbukkit" to "org.bukkit.craftbukkit.v$packageVersion") {
+ relocate("org.bukkit.craftbukkit" to "org.bukkit.craftbukkit.v$craftbukkitPackageVersion") {
+ exclude("org.bukkit.craftbukkit.Main*")
+ }
+}