Skip to content

Commit

Permalink
Updated Upstream (Paper, Purpur)
Browse files Browse the repository at this point in the history
Upstream has released updates that appear to apply and compile correctly.

[Purpur Changes]
PlazmaMC/Purpur@69d3bb4: Updated Upstream (Paper)
PlazmaMC/Purpur@ad32b22: fix version command throwing an exception
PlazmaMC/Purpur@9dcfdf1: [ci skip] missed this from the upstream
PlazmaMC/Purpur@88aa731: Updated Upstream (Paper)
PlazmaMC/Purpur@3d25693: Updated Upstream (Paper)
PlazmaMC/Purpur@248ba17: Updated Upstream (Paper)
PlazmaMC/Purpur@ed1e0ec: Updated Upstream (Paper)
PlazmaMC/Purpur@1bbb033: Updated Upstream (Paper)
PlazmaMC/Purpur@222387f: Updated Upstream (Paper)
PlazmaMC/Purpur@692ff89: [ci skip] specify purpur in version command
PlazmaMC/Purpur@7b850ef: [ci skip] Fix version inconsistency in README (#1517)
PlazmaMC/Purpur@22fc5f9: Updated Upstream (Paper)
PlazmaMC/Purpur@2842b97: Updated Upstream (Paper)
PlazmaMC/Purpur@ec1b4fa: Updated Upstream (Paper)
PlazmaMC/Purpur@b1464f3: Updated Upstream (Paper)
PlazmaMC/Purpur@ee56117: Updated Upstream (Paper)
PlazmaMC/Purpur@847719c: one punch!! improvements
PlazmaMC/Purpur@1af7456: [ci skip] document mods that patches took inspiration from
PlazmaMC/Purpur@224e7c7: Updated Upstream (Paper)
PlazmaMC/Purpur@7095128: Add back Pufferfish patches

[Paper Changes]
PaperMC/Paper@23fe116: Fix missing debug trace
PaperMC/Paper@b0c9b9c: Only remove worldgen block entity on changed block (#10794)
PaperMC/Paper@9c917fe: [ci skip] Clean up paperclip build-pr workflow (#10802)
PaperMC/Paper@9d6f2cc: [ci skip] Rebuild patches (#10803)
PaperMC/Paper@84f6e6e: Fix max temper API for llama (#10823)
PaperMC/Paper@672c077: handle BODY slot for non-mobs (#10822)
PaperMC/Paper@716b868: Use RegistryOps for loadAdvancement (#10799)
PaperMC/Paper@d9e659a: Allow firework effects with no colors (#10814)
PaperMC/Paper@7e2b682: Fix skipping custom block entity tag (#10812)
PaperMC/Paper@ed85aac: Flatten namespaced vanilla command alias redirects (#10821)
PaperMC/Paper@a31dc90: Several fixes and new api for experience merging/stacking (#9242)
PaperMC/Paper@efd91e5: Add registry-related argument types (#10770)
PaperMC/Paper@27d2ed8: Extend fishing API (#10634)
PaperMC/Paper@0fcf3e3: Deprecate InvAction#HOTBAR_MOVE_AND_READD (#10784)
PaperMC/Paper@8e6554a: Fix sending disconnect packet in phases where it doesn't exist
PaperMC/Paper@06e69c8: Use CommandSourceStack in AsyncPlayerSendCommandsEvent (#10826)
PaperMC/Paper@a47e11d: fix knockback events (#10831)
PaperMC/Paper@3181470: Add entity heal API (#10267)
PaperMC/Paper@0513374: Fire TabCompleteEvent for legacy commands (#10834)
PaperMC/Paper@5d8e53d: Fix CommandSourceStack#bypassSelectorPermissions (#10837)
  • Loading branch information
AlphaKR93 committed Jun 2, 2024
1 parent b099ccc commit 4f2deab
Show file tree
Hide file tree
Showing 25 changed files with 744 additions and 405 deletions.
14 changes: 7 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ paperweight {

alwaysUpToDate {

paperRepoName.set("paperRepo")
paperBranchName.set("paperBranch")
paperRepo.set("https://github.com/PaperMC/Paper")
paperRef.set("master")
paperCommitName.set("paperCommit")

purpurRepoName.set("purpurRepo")
purpurBranchName.set("purpurBranch")
purpurRepo.set("https://github.com/PlazmaMC/Purpur")
purpurRef.set("ver/1.20.6")
purpurCommitName.set("purpurCommit")

pufferfishRepoName.set("pufferfishRepo")
pufferfishBranchName.set("pufferfishBranch")
pufferfishToggleName.set("usePufferfish")
pufferfishRepo.set("https://github.com/PlazmaMC/Pufferfish")
pufferfishRef.set("ver/1.20")
usePufferfish.set(true)

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,72 @@
package org.plazmamc.alwaysuptodate

import io.papermc.paperweight.util.Git
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.plazmamc.alwaysuptodate.tasks.CheckPaperCommitTask
import org.plazmamc.alwaysuptodate.tasks.CheckPurpurCommitTask
import org.plazmamc.alwaysuptodate.tasks.PaperUpdateTask
import org.gradle.api.provider.Property
import org.plazmamc.alwaysuptodate.utils.*
import org.plazmamc.alwaysuptodate.tasks.CheckUpstreamCommit
import org.plazmamc.alwaysuptodate.tasks.SimpleUpstreamUpdateTask
import org.plazmamc.alwaysuptodate.tasks.CreateCompareComment
import org.plazmamc.alwaysuptodate.tasks.PurpurUpdateTask

class AlwaysUpToDate : Plugin<Project> {

override fun apply(target: Project) = with(target) {
override fun apply(target: Project): Unit = with(target) {

extensions.create("alwaysUpToDate", AlwaysUpToDateExtension::class.java)
Git.checkForGit()

arrayOf(
"updatePaper" to PaperUpdateTask::class.java,
"updatePurpur" to PurpurUpdateTask::class.java,
"checkPaperCommit" to CheckPaperCommitTask::class.java,
"checkPurpurCommit" to CheckPurpurCommitTask::class.java,
).forEach { tasks.register(it.first, it.second) }
val extension = extensions.create("alwaysUpToDate", AlwaysUpToDateExtension::class.java)

val git = configureTask<CheckGitTask>("checkGitStatus", "Verify that Git is available")

fun generateTasks(
upstream: String,
provider: AlwaysUpToDateExtension.() -> Pair<Pair<Property<String>, Property<String>>, Property<String>>
) {
registerTask<CheckUpstreamCommit>("check$upstream", "Check if the $upstream commit is up to date") {
dependsOn(git)
val (repo, ref, commitProperty) = extension.provider().flatten()
this.repo.set(repo)
this.ref.set(ref)
this.commitPropertyName.set(commitProperty)
}

registerTask<CreateCompareComment>("compare$upstream", "Create a comment comparing the $upstream commit") {
dependsOn(git)
val (repo, ref, commitProperty) = extension.provider().flatten()
this.repo.set(repo)
this.ref.set(ref)
this.commitPropertyName.set(commitProperty)
this.clear.set(false)
}

registerTask<CreateCompareComment>("cleanCompare$upstream", "Create a comment comparing the $upstream commit") {
dependsOn(git)
val (repo, ref, commitProperty) = extension.provider().flatten()
this.repo.set(repo)
this.ref.set(ref)
this.commitPropertyName.set(commitProperty)
this.clear.set(true)
}
}

generateTasks("Paper") { paperRepo to paperRef to paperCommitName }
generateTasks("Purpur") { purpurRepo to purpurRef to purpurCommitName }

registerTask<SimpleUpstreamUpdateTask>("updateUpstream", "Update the upstream commit") {
dependsOn(git)
repo.convention(extension.paperRepo)
ref.convention(extension.paperRef)
commitPropertyName.convention(extension.paperCommitName)
workDir.set(layout.projectDirectory)
regex.convention("paperCommit = ")
}

registerTask<PurpurUpdateTask>("updateImplementation", "Update the implementation commit") {
dependsOn(git)
workDir.set(layout.projectDirectory)
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import org.gradle.api.provider.Property

interface AlwaysUpToDateExtension {

val paperBranchName: Property<String>
val paperRepoName: Property<String>
val paperCommitName: Property<String>
val paperRepo: Property<String>
val paperRef: Property<String>

val purpurRepo: Property<String>
val purpurRef: Property<String>

val pufferfishToggleName: Property<String>
val pufferfishBranchName: Property<String>
val pufferfishRepoName: Property<String>
val pufferfishRepo: Property<String>
val pufferfishRef: Property<String>
val usePufferfish: Property<Boolean>

val purpurBranchName: Property<String>
val purpurRepoName: Property<String>
val paperCommitName: Property<String>
val purpurCommitName: Property<String>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.plazmamc.alwaysuptodate.tasks

import org.gradle.api.Project
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
import org.plazmamc.alwaysuptodate.AlwaysUpToDateException
import org.plazmamc.alwaysuptodate.AlwaysUpToDateExtension
import org.plazmamc.alwaysuptodate.utils.*

abstract class CheckUpstreamCommit : Task() {

@get:Input
abstract val repo: Property<String>

@get:Input
abstract val ref: Property<String>

@get:Input
abstract val commitPropertyName: Property<String>

@TaskAction
fun check() = with(project) { println(checkCommitFor { repo to ref to commitPropertyName }) }

}

private fun Project.getLatest(repository: String, branch: String) =
git("ls-remote", repository).readText()?.lines()
?.first("[a-z0-9]{40}\trefs/heads/$branch".toRegex()::matches)?.split("\t")?.first()
?: throw AlwaysUpToDateException("Failed to get latest commit of $repository")

fun Project.checkCommitFor(block: AlwaysUpToDateExtension.() -> Pair<Pair<Property<String>, Property<String>>, Property<String>>): Boolean =
extension.block().flatten().let { getLatest(extension { it.first }, extension { it.second }) == property { it.third } }

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.plazmamc.alwaysuptodate.tasks

import io.papermc.paperweight.util.fromJson
import io.papermc.paperweight.util.gson
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
import org.plazmamc.alwaysuptodate.utils.property
import paper.libs.com.google.gson.JsonObject
import java.net.URI

abstract class CreateCompareComment : Task() {

@get:Input
abstract val clear: Property<Boolean>

@get:Input
abstract val repo: Property<String>

@get:Input
abstract val ref: Property<String>

@get:Input
abstract val commitPropertyName: Property<String>

@TaskAction
fun create() = with(project) {
val builder = StringBuilder()
val rawRepo = URI.create(repo.get()).path.substring(1)

if (clear.get() || !file("compare.txt").exists())
builder.append("\n\nUpstream has released updates that appear to apply and compile correctly.")
else
builder.append(file("compare.txt").readText())

builder.append("\n\n[${rawRepo.split("/").last()} Changes]\n")

gson.fromJson<JsonObject>(
URI.create("https://api.github.com/repos/$rawRepo/compare/${property { commitPropertyName }}...${ref.get()}")
.toURL().readText())["commits"].asJsonArray.forEach { obj ->
obj.asJsonObject.let { builder.append("$rawRepo@${it["sha"].asString.subSequence(0, 7)}: ${it["commit"].asJsonObject["message"].asString.split("\n")[0]}\n") }
}
file("compare.txt").writeText(builder.toString())
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.plazmamc.alwaysuptodate.tasks

import io.papermc.paperweight.util.Git
import io.papermc.paperweight.util.path
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import org.plazmamc.alwaysuptodate.utils.addCommit
import java.io.File

abstract class GenerateMergedAPIPatch : Task() {

@get:InputDirectory
abstract val inputDir: DirectoryProperty

@get:Internal
abstract val workDir: DirectoryProperty

@get:Input
abstract val commitTitle: Property<String>

@get:Input
abstract val author: Property<String>

@get:Input
abstract val license: Property<String>

@TaskAction
fun generate() = with(workDir.path) {
val dotGit = resolve(".git").toFile().also(java.io.File::deleteRecursively)

inputDir.path.toFile().copyRecursively(dotGit, overwrite = true)
Git(this).addCommit("${commitTitle.get()}\n\n${license.get()}", "--author=${author.get()}")
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.plazmamc.alwaysuptodate.tasks

import io.papermc.paperweight.util.Git
import io.papermc.paperweight.util.path
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import org.plazmamc.alwaysuptodate.utils.addCommit
import java.io.File
import java.nio.file.Path

abstract class GenerateMergedServerPatch : Task() {

@get:Internal
abstract val workDir: DirectoryProperty

@get:Input
abstract val commitTitle: Property<String>

@get:Input
abstract val author: Property<String>

@get:Input
abstract val license: Property<String>

@TaskAction
fun generate() = with(workDir.path) {
val dotGit = resolve(".git").toFile().also(java.io.File::deleteRecursively)

copySource(this)

val paper = resolve("../.gradle/caches/paperweight/upstreams/paper/Paper-Server")
copySource(paper)

Git(paper).addCommit("Vanilla Sources", "--author=Automated <[email protected]>")

paper.resolve(".git").toFile().copyRecursively(dotGit, overwrite = true)
Git(this).addCommit("${commitTitle.get()}\n\n${license.get()}", "--author=${author.get()}")
}

}

internal fun copySource(dir: Path) = with(dir.resolve(".gradle/caches/paperweight/mc-dev-sources")) {
val target = dir.resolve("src/main")
resolve("net").toFile().copyRecursively(target.resolve("java/net").toFile(), overwrite = true)
resolve("com").toFile().copyRecursively(target.resolve("java/com").toFile(), overwrite = true)
resolve("data").toFile().copyRecursively(target.resolve("resources/data").toFile(), overwrite = true)
resolve("assets").toFile().copyRecursively(target.resolve("resources/assets").toFile(), overwrite = true)
}
Loading

0 comments on commit 4f2deab

Please sign in to comment.