diff --git a/main.py b/main.py index 7b3e56b188..b237d452bb 100644 --- a/main.py +++ b/main.py @@ -25,7 +25,7 @@ for file in files: description = match.group(2) # Calculate the new number - new_number = current_number + 4 + new_number = current_number + 1 # Construct the new file name new_file_name = f'{str(new_number).zfill(4)}-{description}' diff --git a/patches/unapplied/server/Hook-into-CB-plugin-rewrites.patch b/patches/server/Hook-into-CB-plugin-rewrites.patch similarity index 82% rename from patches/unapplied/server/Hook-into-CB-plugin-rewrites.patch rename to patches/server/Hook-into-CB-plugin-rewrites.patch index 10ba210053..be7eade974 100644 --- a/patches/unapplied/server/Hook-into-CB-plugin-rewrites.patch +++ b/patches/server/Hook-into-CB-plugin-rewrites.patch @@ -27,16 +27,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; -@@ -0,0 +0,0 @@ import org.bukkit.plugin.AuthorNagException; - import org.objectweb.asm.ClassReader; - import org.objectweb.asm.ClassVisitor; - import org.objectweb.asm.ClassWriter; -+import org.objectweb.asm.FieldVisitor; - import org.objectweb.asm.Handle; -+import org.objectweb.asm.Label; - import org.objectweb.asm.MethodVisitor; - import org.objectweb.asm.Opcodes; - import org.objectweb.asm.Type; @@ -0,0 +0,0 @@ public class Commodore { "org/spigotmc/event/entity/EntityDismountEvent", "org/bukkit/event/entity/EntityDismountEvent" ); @@ -75,31 +65,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end - Plugin rewrites + - public static void main(String[] args) { - OptionParser parser = new OptionParser(); - OptionSpec inputFlag = parser.acceptsAll(Arrays.asList("i", "input")).withRequiredArg().ofType(File.class).required(); -@@ -0,0 +0,0 @@ public class Commodore { - ClassWriter cw = new ClassWriter(cr, 0); + private static final Map FIELD_RENAME_METHOD_REROUTE = RerouteBuilder.buildFromClass(FieldRename.class); - cr.accept(new ClassRemapper(new ClassVisitor(Opcodes.ASM9, cw) { -+ -+ // Paper start - Rewrite plugins -+ @Override -+ public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) -+ { -+ desc = getOriginalOrRewrite(desc); -+ if ( signature != null ) { -+ signature = getOriginalOrRewrite(signature); -+ } -+ -+ return super.visitField( access, name, desc, signature, value) ; -+ } -+ // Paper end -+ + public static void main(String[] args) { +@@ -0,0 +0,0 @@ public class Commodore { @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { return new MethodVisitor(this.api, super.visitMethod(access, name, desc, signature, exceptions)) { - + // Paper start - Plugin rewrites + @Override + public void visitTypeInsn(int opcode, String type) { @@ -133,8 +105,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + super.visitLocalVariable(name, descriptor, signature, start, end, index); + } -+ // Paper end -+ ++ // Paper end - Plugin rewrites + @Override public void visitFieldInsn(int opcode, String owner, String name, String desc) { + // Paper start - Rewrite plugins @@ -143,20 +115,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + desc = getOriginalOrRewrite(desc); + } + // Paper end - if (owner.equals("org/bukkit/block/Biome")) { - switch (name) { - case "NETHER": + name = FieldRename.rename(pluginVersion, owner, name); + + if (modern) { @@ -0,0 +0,0 @@ public class Commodore { + return; } - // Paper start - Rewrite plugins ++ // Paper start - Rewrite plugins + owner = getOriginalOrRewrite(owner) ; + if (desc != null) { + desc = getOriginalOrRewrite(desc); + } - if ((owner.equals("org/bukkit/OfflinePlayer") || owner.equals("org/bukkit/entity/Player")) && name.equals("getPlayerProfile") && desc.equals("()Lorg/bukkit/profile/PlayerProfile;")) { - super.visitMethodInsn(opcode, owner, name, "()Lcom/destroystokyo/paper/profile/PlayerProfile;", itf); - return; ++ // Paper end - Rewrite plugins ++ + if (modern) { + if (owner.equals("org/bukkit/Material") || (instantiatedMethodType != null && instantiatedMethodType.getDescriptor().startsWith("(Lorg/bukkit/Material;)"))) { + switch (name) { @@ -0,0 +0,0 @@ public class Commodore { @Override @@ -195,3 +170,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 }, implMethod.getTag(), implMethod.getOwner(), implMethod.getName(), implMethod.getDesc(), implMethod.isInterface(), samMethodType, instantiatedMethodType); return; } +@@ -0,0 +0,0 @@ public class Commodore { + + @Override + public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) { ++ // Paper start - Rewrite plugins ++ descriptor = getOriginalOrRewrite(descriptor); ++ if ( signature != null ) { ++ signature = getOriginalOrRewrite(signature); ++ } ++ // Paper end + return new FieldVisitor(this.api, super.visitField(access, name, descriptor, signature, value)) { + @Override + public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) { diff --git a/patches/server/Remap-reflection-calls-in-plugins-using-internals.patch b/patches/server/Remap-reflection-calls-in-plugins-using-internals.patch index 8fcd746466..097006530b 100644 --- a/patches/server/Remap-reflection-calls-in-plugins-using-internals.patch +++ b/patches/server/Remap-reflection-calls-in-plugins-using-internals.patch @@ -657,3 +657,60 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 boolean runNext(Level world); } +diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +@@ -0,0 +0,0 @@ public class Commodore { + ); + + // Paper start - Plugin rewrites +- private static final Map SEARCH_AND_REMOVE = initReplacementsMap(); +- private static Map initReplacementsMap() { +- Map getAndRemove = new HashMap<>(); +- // Be wary of maven shade's relocations +- +- 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 +- final String NMS_REVISION_PACKAGE = "v" + manifest.getMainAttributes().getValue("CraftBukkit-Package-Version") + "/"; +- +- getAndRemove.put("org/bukkit/".concat("craftbukkit/" + NMS_REVISION_PACKAGE), NMS_REVISION_PACKAGE); +- } +- +- return getAndRemove; +- } ++ private static final String CB_PACKAGE_PREFIX = "org/bukkit/".concat("craftbukkit/"); ++ private static final String LEGACY_CB_PACKAGE_PREFIX = CB_PACKAGE_PREFIX + io.papermc.paper.util.MappingEnvironment.LEGACY_CB_VERSION + "/"; + + @Nonnull + private static String getOriginalOrRewrite(@Nonnull String original) + { +- String rewrite = null; +- for ( Map.Entry entry : SEARCH_AND_REMOVE.entrySet() ) +- { +- if ( original.contains( entry.getKey() ) ) +- { +- rewrite = original.replace( entry.getValue(), "" ); ++ // Relocation is applied in reobf, and when mappings are present they handle the relocation ++ if (!io.papermc.paper.util.MappingEnvironment.reobf() && !io.papermc.paper.util.MappingEnvironment.hasMappings()) { ++ if (original.contains(LEGACY_CB_PACKAGE_PREFIX)) { ++ original = original.replace(LEGACY_CB_PACKAGE_PREFIX, CB_PACKAGE_PREFIX); + } + } + +- return rewrite != null ? rewrite : original; ++ return original; + } + // Paper end - Plugin rewrites + +@@ -0,0 +0,0 @@ public class Commodore { + ClassReader cr = new ClassReader(b); + ClassWriter cw = new ClassWriter(cr, 0); + +- cr.accept(new ClassRemapper(new ClassVisitor(Opcodes.ASM9, cw) { ++ cr.accept(new ClassRemapper(new ClassVisitor(Opcodes.ASM9, io.papermc.paper.pluginremap.reflect.ReflectionRemapper.visitor(cw)) { // Paper + final Set rerouteMethodData = new HashSet<>(); + String className; + boolean isInterface;