mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 03:48:01 +01:00
Improve update helper task
This commit is contained in:
parent
2d702b9bad
commit
6aedc2af5d
@ -4,6 +4,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
|||||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
import java.util.regex.Pattern
|
||||||
import kotlin.io.path.*
|
import kotlin.io.path.*
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
@ -177,37 +178,82 @@ abstract class RebasePatches : BaseTask() {
|
|||||||
private fun unapplied(): List<Path> =
|
private fun unapplied(): List<Path> =
|
||||||
unappliedPatches.path.listDirectoryEntries("*.patch").sortedBy { it.name }
|
unappliedPatches.path.listDirectoryEntries("*.patch").sortedBy { it.name }
|
||||||
|
|
||||||
|
private fun appliedLoc(patch: Path): Path = appliedPatches.path.resolve(unappliedPatches.path.relativize(patch))
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val regex = Pattern.compile("Patch failed at ([0-9]{4}) (.*)")
|
||||||
|
const val subjectPrefix = "Subject: [PATCH] "
|
||||||
|
}
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun run() {
|
fun run() {
|
||||||
for (patch in unapplied()) {
|
val unapplied = unapplied()
|
||||||
val appliedLoc = appliedPatches.path.resolve(unappliedPatches.path.relativize(patch))
|
for (patch in unapplied) {
|
||||||
patch.copyTo(appliedLoc)
|
patch.copyTo(appliedLoc(patch))
|
||||||
|
}
|
||||||
|
|
||||||
val out = ByteArrayOutputStream()
|
val out = ByteArrayOutputStream()
|
||||||
|
val proc = ProcessBuilder()
|
||||||
|
.directory(projectDir.path)
|
||||||
|
.command("./gradlew", "applyServerPatches")
|
||||||
|
.redirectErrorStream(true)
|
||||||
|
.start()
|
||||||
|
|
||||||
val proc = ProcessBuilder()
|
redirect(proc.inputStream, out)
|
||||||
|
|
||||||
|
val exit = proc.waitFor()
|
||||||
|
|
||||||
|
if (exit != 0) {
|
||||||
|
val outStr = String(out.toByteArray())
|
||||||
|
val matcher = regex.matcher(outStr)
|
||||||
|
if (!matcher.find()) error("Could not determine failure point")
|
||||||
|
val failedSubjectFragment = matcher.group(2)
|
||||||
|
val failed = unapplied.single { p ->
|
||||||
|
p.useLines { lines ->
|
||||||
|
val subjectLine = lines.single { it.startsWith(subjectPrefix) }
|
||||||
|
.substringAfter(subjectPrefix)
|
||||||
|
subjectLine.startsWith(failedSubjectFragment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete successful & failure point from unapplied patches dir
|
||||||
|
for (path in unapplied) {
|
||||||
|
path.deleteIfExists()
|
||||||
|
if (path == failed) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete failed from patches dir
|
||||||
|
var started = false
|
||||||
|
for (path in unapplied) {
|
||||||
|
if (path == failed) {
|
||||||
|
started = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (started) {
|
||||||
|
appliedLoc(path).deleteIfExists()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply again to reset the am session (so it ends on the failed patch, to allow us to rebuild after fixing it)
|
||||||
|
val apply2 = ProcessBuilder()
|
||||||
.directory(projectDir.path)
|
.directory(projectDir.path)
|
||||||
.command("./gradlew", "applyServerPatches")
|
.command("./gradlew", "applyServerPatches")
|
||||||
.redirectErrorStream(true)
|
.redirectErrorStream(true)
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
redirect(proc.inputStream, out)
|
redirect(apply2.inputStream, System.out)
|
||||||
|
|
||||||
val exit = proc.waitFor()
|
logger.lifecycle(outStr)
|
||||||
|
logger.lifecycle("Patch failed at $failed; See Git output above.")
|
||||||
patch.deleteIfExists()
|
} else {
|
||||||
|
unapplied.forEach { it.deleteIfExists() }
|
||||||
if (exit != 0) {
|
logger.lifecycle("All patches applied!")
|
||||||
logger.lifecycle("Patch failed at $patch; Git output:")
|
|
||||||
logger.lifecycle(String(out.toByteArray()))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
val git = Git(projectDir.path)
|
|
||||||
git("add", appliedPatches.path.toString() + "/*").runSilently()
|
|
||||||
git("add", unappliedPatches.path.toString() + "/*").runSilently()
|
|
||||||
|
|
||||||
logger.lifecycle("Applied $patch")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val git = Git(projectDir.path)
|
||||||
|
git("add", appliedPatches.path.toString() + "/*").runSilently()
|
||||||
|
git("add", unappliedPatches.path.toString() + "/*").runSilently()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||||
} else {
|
} else {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
worldserver = shapedetectorshape.world;
|
worldserver = shapedetectorshape.world;
|
||||||
@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
if (worldserver == this.level) {
|
if (worldserver == this.level) {
|
||||||
// SPIGOT-6782: Just move the entity if a plugin changed the world to the one the entity is already in
|
// SPIGOT-6782: Just move the entity if a plugin changed the world to the one the entity is already in
|
||||||
this.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot);
|
this.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot);
|
||||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||||
|
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
entity.restoreFrom(this);
|
entity.restoreFrom(this);
|
||||||
@ -45,6 +45,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
- entity.setDeltaMovement(shapedetectorshape.speed);
|
- entity.setDeltaMovement(shapedetectorshape.speed);
|
||||||
+ entity.moveTo(position.x, position.y, position.z, yaw, pitch); // Paper - use EntityPortalExitEvent values
|
+ entity.moveTo(position.x, position.y, position.z, yaw, pitch); // Paper - use EntityPortalExitEvent values
|
||||||
+ entity.setDeltaMovement(velocity); // Paper - use EntityPortalExitEvent values
|
+ entity.setDeltaMovement(velocity); // Paper - use EntityPortalExitEvent values
|
||||||
worldserver.addDuringTeleport(entity);
|
// CraftBukkit start - Don't spawn the new entity if the current entity isn't spawned
|
||||||
if (worldserver.getTypeKey() == LevelStem.END) { // CraftBukkit
|
if (this.inWorld) {
|
||||||
ServerLevel.makeObsidianPlatform(worldserver, this); // CraftBukkit
|
worldserver.addDuringTeleport(entity);
|
Loading…
Reference in New Issue
Block a user