mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 10:35:38 +01:00
Improve update helper task
This commit is contained in:
parent
fc12258f24
commit
2053d6ace7
@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ Subject: [PATCH] Make EntityUnleashEvent cancellable
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
index 2e8b1d7b81e212a7b06f4844d0633241dc4b77bf..1e997c1758ed86dc563983317ceb17e626b8dba7 100644
|
index 764a5dd85e3fb581b1e713ce9b148be1874d55be..16d84042e2575418880897c728a99d1b8bbcdd15 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
@@ -1549,7 +1549,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
@@ -1550,7 +1550,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||||
if (flag1 && this.isLeashed()) {
|
if (flag1 && this.isLeashed()) {
|
||||||
// Paper start - drop leash variable
|
// Paper start - drop leash variable
|
||||||
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.UNKNOWN, true);
|
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.UNKNOWN, true);
|
@ -5,7 +5,7 @@ Subject: [PATCH] Clear bucket NBT after dispense
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||||
index d500de41d0a61d67aff523fe436da06e625687dd..b5ea499b78970ec1575893e3b52900bf34feb3ec 100644
|
index 8c8d2e81f0866dc1441e181f2580852d87263bcc..9f220c99d7374ab3d9db222346694342d3e926c1 100644
|
||||||
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||||
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||||
@@ -650,8 +650,7 @@ public interface DispenseItemBehavior {
|
@@ -650,8 +650,7 @@ public interface DispenseItemBehavior {
|
@ -5,10 +5,10 @@ Subject: [PATCH] Add BlockBreakBlockEvent
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||||
index 36b196c8834c4eb873bfca0b12f1fc2b421ea071..9522e646529f3d849471931b4b3c0d133e7fcfc5 100644
|
index 2c190473b98899e86d8bcd5a81c72bbc0a85b2a9..f0a85f1b48a911ffd8740df5ebe869e8f0371a58 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||||
@@ -319,6 +319,23 @@ public class Block extends BlockBehaviour implements ItemLike {
|
@@ -326,6 +326,23 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -33,10 +33,10 @@ index 36b196c8834c4eb873bfca0b12f1fc2b421ea071..9522e646529f3d849471931b4b3c0d13
|
|||||||
public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) {
|
public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) {
|
||||||
if (world instanceof ServerLevel) {
|
if (world instanceof ServerLevel) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||||
index 929241e479a42011f073fb9d144739b6504132b1..b9896fd8e96a908637ce1edf9413166192903ce7 100644
|
index 565da027ca7c395f9b965505cbe9e85e62367834..cda90023ad662e8875365eac98ec69f476dcb42d 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||||
@@ -402,7 +402,7 @@ public class PistonBaseBlock extends DirectionalBlock {
|
@@ -415,7 +415,7 @@ public class PistonBaseBlock extends DirectionalBlock {
|
||||||
iblockdata1 = world.getBlockState(blockposition3);
|
iblockdata1 = world.getBlockState(blockposition3);
|
||||||
BlockEntity tileentity = iblockdata1.hasBlockEntity() ? world.getBlockEntity(blockposition3) : null;
|
BlockEntity tileentity = iblockdata1.hasBlockEntity() ? world.getBlockEntity(blockposition3) : null;
|
||||||
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Option to prevent NBT copy in smithing recipes
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||||
index 3036abbcf12753a43f520fc2528928cb9849c311..473b3f7aa7ca4d1c4b9e911984bc7b2647c9bdec 100644
|
index 566b588006da2b46ec1727be85560ccd59c42c6f..8f71a60c1d83dfad67ac77ec4464a55c7439d4b3 100644
|
||||||
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||||
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||||
@@ -23,8 +23,15 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
@@ -23,8 +23,15 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
@ -52,7 +52,7 @@ index 73c5ffff70605b32188a9bb5fb6c0ee04cb66efe..711d227f5ee6d63356a94a0567968da4
|
|||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
|
||||||
index 12972cf5876da72cc5d097aeedb13c9addd98add..e0c1131687fffd7f215505caafe6ef2292ac8672 100644
|
index 128c9d81814ba1fb24895962e5f08495dbedb176..812819e814cfbdb542051a7dbfe123d3c59e66bd 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
|
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
|
||||||
@@ -239,6 +239,14 @@ public class Commodore
|
@@ -239,6 +239,14 @@ public class Commodore
|
@ -5,10 +5,10 @@ Subject: [PATCH] Add back EntityPortalExitEvent
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
index c65986830ce27a2fac7b3154df8db47a021a064e..44c63a57cc6bb992ae6788e23cc23300d43430f0 100644
|
index 2731b44b3cd5de300ffcf93c690a617091b199ef..5f642ba64877a3ba53f69b8cffd99ed8c56a3d3f 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
|
||||||
@@ -3344,6 +3344,28 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -3373,6 +3373,28 @@ 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 c65986830ce27a2fac7b3154df8db47a021a064e..44c63a57cc6bb992ae6788e23cc23300
|
|||||||
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);
|
||||||
@@ -3363,8 +3385,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -3392,8 +3414,8 @@ 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 c65986830ce27a2fac7b3154df8db47a021a064e..44c63a57cc6bb992ae6788e23cc23300
|
|||||||
- 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