From 9f5325207d7055be4f0fab6212d37d5ef6890a10 Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Fri, 11 Jun 2021 06:43:40 -0500 Subject: [PATCH] Initial Spigot remap patches --- .../Convert-project-to-Gradle.patch | 76 +++++++++++++++ Spigot-Server-Patches/Decompile-fixes.patch | 77 +++++++++++++++ .../Setup-Gradle-project.patch | 95 +++++++++++++++++++ 3 files changed, 248 insertions(+) create mode 100644 Spigot-API-Patches/Convert-project-to-Gradle.patch create mode 100644 Spigot-Server-Patches/Decompile-fixes.patch create mode 100644 Spigot-Server-Patches/Setup-Gradle-project.patch diff --git a/Spigot-API-Patches/Convert-project-to-Gradle.patch b/Spigot-API-Patches/Convert-project-to-Gradle.patch new file mode 100644 index 0000000000..34d75bd8bb --- /dev/null +++ b/Spigot-API-Patches/Convert-project-to-Gradle.patch @@ -0,0 +1,76 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kyle Wood +Date: Thu, 10 Dec 2020 20:50:33 -0800 +Subject: [PATCH] Convert project to Gradle + + +diff --git a/.gitignore b/.gitignore +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -0,0 +0,0 @@ ++.gradle/ ++ + # Eclipse stuff + /.classpath + /.project +diff --git a/build.gradle.kts b/build.gradle.kts +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/build.gradle.kts +@@ -0,0 +0,0 @@ ++plugins { ++ `java-library` ++ checkstyle ++} ++ ++java { ++ withSourcesJar() ++ withJavadocJar() ++} ++ ++dependencies { ++ // api dependencies are listed transitively to API consumers ++ api("commons-lang:commons-lang:2.6") ++ api("com.google.guava:guava:21.0") ++ api("com.google.code.gson:gson:2.8.0") ++ api("net.md-5:bungeecord-chat:1.16-R0.4") ++ api("org.yaml:snakeyaml:1.29") ++ ++ compileOnly("org.apache.maven:maven-resolver-provider:3.8.1") ++ compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.0") ++ compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.0") ++ ++ val annotations = "org.jetbrains:annotations-java5:21.0.1" ++ compileOnly(annotations) ++ testCompileOnly(annotations) ++ ++ testImplementation("junit:junit:4.13.1") ++ testImplementation("org.hamcrest:hamcrest-library:1.3") ++ testImplementation("org.ow2.asm:asm-tree:9.1") ++ ++ checkstyle("com.puppycrawl.tools:checkstyle:8.39") ++} ++ ++tasks.jar { ++ manifest { ++ attributes += mapOf( ++ "Automatic-Module-Name" to "org.bukkit" ++ ) ++ } ++} ++ ++tasks.withType().configureEach { ++ (options as StandardJavadocDocletOptions).links( ++ "https://guava.dev/releases/21.0/api/docs/", ++ "https://javadoc.io/doc/org.yaml/snakeyaml/1.27/", ++ "https://javadoc.io/doc/org.jetbrains/annotations-java5/20.1.0/", ++ "https://javadoc.io/doc/net.md-5/bungeecord-chat/1.16-R0.4/" ++ ) ++} ++ ++checkstyle { ++ configFile = file("checkstyle.xml") ++ sourceSets = listOf(project.sourceSets.main.get(), project.sourceSets.test.get()) ++} diff --git a/Spigot-Server-Patches/Decompile-fixes.patch b/Spigot-Server-Patches/Decompile-fixes.patch new file mode 100644 index 0000000000..52f9bb43ff --- /dev/null +++ b/Spigot-Server-Patches/Decompile-fixes.patch @@ -0,0 +1,77 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kyle Wood +Date: Fri, 11 Jun 2021 05:25:03 -0500 +Subject: [PATCH] Decompile fixes + + +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { +- entity1.moveTo(pos.x, pos.y, pos.z, entity1.getYRot(), entity1.getXRot()); +- return entity1; ++ Entity entity1 = EntityType.loadEntityRecursive(nbttagcompound1, worldserver, (loadedEntity) -> { // Paper - decomp fix ++ loadedEntity.moveTo(pos.x, pos.y, pos.z, loadedEntity.getYRot(), loadedEntity.getXRot()); // Paper - decomp fix ++ return loadedEntity; // Paper - decomp fix + }); + + if (entity1 == null) { +diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java ++++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java +@@ -0,0 +0,0 @@ public class BehaviorUtils { + + return optional.map((uuid) -> { + return ((ServerLevel) entity.level).getEntity(uuid); +- }).map((entity) -> { +- return entity instanceof LivingEntity ? (LivingEntity) entity : null; ++ }).map((entity2) -> { // Paper - decomp fix ++ return entity2 instanceof LivingEntity ? (LivingEntity) entity2 : null; // Paper - decomp fix + }); + } + +diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java ++++ b/src/main/java/net/minecraft/world/entity/monster/Phantom.java +@@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy { + List list = Phantom.this.level.getNearbyPlayers(this.attackTargeting, (LivingEntity) Phantom.this, Phantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D)); + + if (!list.isEmpty()) { +- list.sort(Comparator.comparing(Entity::getY).reversed()); ++ list.sort(Comparator.comparing(Entity::getY).reversed()); // Paper - decomp fix + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { +diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java ++++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java +@@ -0,0 +0,0 @@ public class RecipeManager extends SimpleJsonResourceReloadListener { + Map, Object2ObjectLinkedOpenHashMap>> map = Maps.newHashMap(); // CraftBukkit + + recipes.forEach((irecipe) -> { +- Map> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes) -> { ++ Map> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes_) -> { // Paper - decomp fix + return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit + }); + Recipe irecipe1 = (Recipe) map1.put(irecipe.getId(), irecipe); diff --git a/Spigot-Server-Patches/Setup-Gradle-project.patch b/Spigot-Server-Patches/Setup-Gradle-project.patch new file mode 100644 index 0000000000..558615acb3 --- /dev/null +++ b/Spigot-Server-Patches/Setup-Gradle-project.patch @@ -0,0 +1,95 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kyle Wood +Date: Thu, 10 Dec 2020 20:54:19 -0800 +Subject: [PATCH] Setup Gradle project + + +diff --git a/.gitignore b/.gitignore +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -0,0 +0,0 @@ ++.gradle/ ++build/ ++ + # Eclipse stuff + /.classpath + /.project +diff --git a/build.gradle.kts b/build.gradle.kts +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/build.gradle.kts +@@ -0,0 +0,0 @@ ++import com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer ++import java.time.Instant ++ ++plugins { ++ java ++ id("com.github.johnrengelman.shadow") ++} ++ ++val packageVersion = providers.gradleProperty("packageVersion").forUseAtConfigurationTime().get() ++ ++repositories { ++ maven("https://libraries.minecraft.net/") ++} ++ ++dependencies { ++ implementation(project(":Paper-API")) ++ implementation("jline:jline:2.12.1") ++ implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") { ++ exclude(group = "org.apache.logging.log4j", module = "log4j-api") ++ } ++ implementation("org.ow2.asm:asm:9.1") ++ implementation("com.googlecode.json-simple:json-simple:1.1.1") { ++ // This includes junit transitively for whatever reason ++ isTransitive = false ++ } ++ runtimeOnly("org.xerial:sqlite-jdbc:3.34.0") ++ runtimeOnly("mysql:mysql-connector-java:5.1.49") ++ ++ runtimeOnly("org.apache.maven:maven-resolver-provider:3.8.1") ++ runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.0") ++ runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.0") ++ ++ testImplementation("junit:junit:4.13.1") ++ testImplementation("org.hamcrest:hamcrest-library:1.3") ++} ++ ++tasks.jar { ++ manifest { ++ attributes(mapOf( ++ "Main-Class" to "org.bukkit.craftbukkit.Main", ++ "Implementation-Title" to "CraftBukkit", ++ "Implementation-Vendor" to Instant.now().epochSecond, ++ "Specification-Title" to "Bukkit", ++ "Specification-Version" to project.version, ++ "Specification-Vendor" to "Bukkit Team" ++ )) ++ for (tld in listOf("net", "com", "org")) { ++ attributes(mapOf( ++ "Sealed" to "true" ++ ), "$tld/bukkit") ++ } ++ } ++} ++ ++tasks.shadowJar { ++ listOf( ++ "jline", "it.unimi", "org.apache.commons.codec", "org.apache.commons.io", ++ "org.apache.commons.lang3", "org.objectweb.asm" ++ ).forEach { pack -> ++ relocate(pack, "org.bukkit.craftbukkit.libs.$pack") ++ } ++ relocate("org.bukkit.craftbukkit", "org.bukkit.craftbukkit.v$packageVersion") { ++ exclude("org.bukkit.craftbukkit.Main*") ++ } ++ transform(AppendingTransformer::class.java) { ++ resource = "META-INF/services/java.sql.Driver" ++ } ++} ++ ++tasks.test { ++ exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") ++}