From d8be0e795b467a444b1c35cac5a0a01877a7c475 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 4 Nov 2022 22:16:57 -0700 Subject: [PATCH] Update Commodore modifications (#8542) * Handle ldc insn for getOriginalOrRewrite in Commodore * Remove fastutil rewrite It's no longer relocated upstream --- patches/server/Add-more-advancement-API.patch | 2 +- .../server/Hook-into-CB-plugin-rewrites.patch | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/patches/server/Add-more-advancement-API.patch b/patches/server/Add-more-advancement-API.patch index e9a8952960..2d394b3f8f 100644 --- a/patches/server/Add-more-advancement-API.patch +++ b/patches/server/Add-more-advancement-API.patch @@ -154,8 +154,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper start - Plugin rewrites + private static final String CB_PACKAGE = org.bukkit.Bukkit.getServer().getClass().getPackageName().replace('.', '/'); private static final Map SEARCH_AND_REMOVE = initReplacementsMap(); - private static final java.util.jar.Manifest manifest = io.papermc.paper.util.JarManifests.manifest(Commodore.class); private static Map initReplacementsMap() + { @@ -0,0 +0,0 @@ public class Commodore { desc = getOriginalOrRewrite(desc); diff --git a/patches/server/Hook-into-CB-plugin-rewrites.patch b/patches/server/Hook-into-CB-plugin-rewrites.patch index 78b4e47e5f..2b4b38125c 100644 --- a/patches/server/Hook-into-CB-plugin-rewrites.patch +++ b/patches/server/Hook-into-CB-plugin-rewrites.patch @@ -43,13 +43,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Plugin rewrites + private static final Map SEARCH_AND_REMOVE = initReplacementsMap(); -+ private static final java.util.jar.Manifest manifest = io.papermc.paper.util.JarManifests.manifest(Commodore.class); + private static Map initReplacementsMap() + { + Map 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 + ++ final java.util.jar.Manifest manifest = io.papermc.paper.util.JarManifests.manifest(Commodore.class); + if ( Boolean.getBoolean( "debug.rewriteForIde" ) && manifest != null) + { + // unversion incoming calls for pre-relocate debug work @@ -182,3 +181,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if ( modern ) { if ( owner.equals( "org/bukkit/Material" ) ) +@@ -0,0 +0,0 @@ public class Commodore + @Override + public void visitLdcInsn(Object value) + { ++ // Paper start ++ if (value instanceof Type type) { ++ if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { ++ value = Type.getType(getOriginalOrRewrite(type.getDescriptor())); ++ } ++ } ++ // Paper end + if ( value instanceof String && ( (String) value ).equals( "com.mysql.jdbc.Driver" ) ) + { + super.visitLdcInsn( "com.mysql.cj.jdbc.Driver" );