mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 23:57:43 +01:00
77a5779e24
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2ec53f49 PR-1050: Fix empty result check for Complex Recipes 10671012 PR-1044: Add CrafterCraftEvent 4d87ffe0 Use correct method in JavaDoc ae5e5817 SPIGOT-7850: Add API for Bogged shear state 46b6d445 SPIGOT-7837: Support data pack banner patterns d5d0cefc Fix JavaDoc error b3c2b83d PR-1036: Add API for InventoryView derivatives 1fe2c75a SPIGOT-7809: Add ShieldMeta CraftBukkit Changes: 8ee6fd1b8 SPIGOT-7857: Improve ItemMeta block data deserialization 8f26c30c6 SPIGOT-7857: Fix spurious internal NBT tag when deserializing BlockStateMeta 759061b93 SPIGOT-7855: Fire does not spread or burn blocks 00fc9fb64 SPIGOT-7853: AnvilInventory#getRepairCost() always returns 0 7501e2e04 PR-1450: Add CrafterCraftEvent 8c51673e7 SPIGOT-5731: PortalCreateEvent#getEntity returns null for nether portals ignited by flint and steel d53d0d0b1 PR-1456: Fix inverted logic in CraftCrafterView#setSlotDisabled 682a678c8 SPIGOT-7850: Add API for Bogged shear state fccf5243a SPIGOT-7837: Support data pack banner patterns 9c3bd4390 PR-1431: Add API for InventoryView derivatives 0cc6acbc4 SPIGOT-7849: Fix FoodComponent serialize with "using-converts-to" using null 2c5474952 Don't rely on tags for CraftItemMetas 20d107e46 SPIGOT-7846: Fix ItemMeta for hanging signs 76f59e315 Remove redundant clone in Dropper InventoryMoveItemEvent e61a53d25 SPIGOT-7817: Call InventoryMoveItemEvent for Crafters 894682e2d SPIGOT-7839: Remove redundant Java version checks 2c12b2187 SPIGOT-7809: Add ShieldMeta and fix setting shield base colours Spigot Changes: fb8fb722 Rebuild patches 34bd42b7 SPIGOT-7835: Fix issue with custom hopper settings
227 lines
13 KiB
Diff
227 lines
13 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Wed, 25 Aug 2021 20:17:12 -0700
|
|
Subject: [PATCH] Improve and expand AsyncCatcher
|
|
|
|
Log when the async catcher is tripped
|
|
The chunk system can swallow the exception given it's all
|
|
built with completablefuture, so ensure it is at least printed.
|
|
|
|
Add/move several async catchers
|
|
|
|
Async catch modifications to critical entity state
|
|
These used to be here from Spigot, but were dropped with 1.17.
|
|
Now in 1.17, this state is _even more_ critical than it was before,
|
|
so these must exist to catch stupid plugins.
|
|
|
|
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 93a9ef3fc5620c622ce0dfb010c6dafad8fcdb71..987ad7f7130c45a4b3843e186b6a5662859a06ae 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1578,6 +1578,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
}
|
|
|
|
public void internalTeleport(double d0, double d1, double d2, float f, float f1, Set<RelativeMovement> set) { // Paper
|
|
+ org.spigotmc.AsyncCatcher.catchOp("teleport"); // Paper
|
|
// Paper start - Prevent teleporting dead entities
|
|
if (player.isRemoved()) {
|
|
LOGGER.info("Attempt to teleport removed player {} restricted", player.getScoreboardName());
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index 85f3dcdc8349683cb79ce1d9fe56eff02af2a7a7..4714931fd5218df160e39f013278b7996cc5eca6 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -1122,7 +1122,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
|
|
public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause) {
|
|
- org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot
|
|
+ // org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API
|
|
if (this.isTickingEffects) {
|
|
this.effectsToProcess.add(new ProcessableEffect(mobeffect, cause));
|
|
return true;
|
|
diff --git a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
|
index 1cfc906317f07a44f06a4adf021c44e34a2f1d07..6baa313b8201ed23193d7885c85606b0899ade3c 100644
|
|
--- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
|
+++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
|
@@ -78,6 +78,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
}
|
|
|
|
private boolean addEntityUuid(T entity) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity add by UUID"); // Paper
|
|
if (!this.knownUuids.add(entity.getUUID())) {
|
|
PersistentEntitySectionManager.LOGGER.warn("UUID of added entity already exists: {}", entity);
|
|
return false;
|
|
@@ -91,6 +92,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
}
|
|
|
|
private boolean addEntity(T entity, boolean existing) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity add"); // Paper
|
|
// Paper start - chunk system hooks
|
|
if (existing) {
|
|
// I don't want to know why this is a generic type.
|
|
@@ -146,19 +148,23 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
}
|
|
|
|
void startTicking(T entity) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity start ticking"); // Paper
|
|
this.callbacks.onTickingStart(entity);
|
|
}
|
|
|
|
void stopTicking(T entity) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity stop ticking"); // Paper
|
|
this.callbacks.onTickingEnd(entity);
|
|
}
|
|
|
|
void startTracking(T entity) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity start tracking"); // Paper
|
|
this.visibleEntityStorage.add(entity);
|
|
this.callbacks.onTrackingStart(entity);
|
|
}
|
|
|
|
void stopTracking(T entity) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity stop tracking"); // Paper
|
|
this.callbacks.onTrackingEnd(entity);
|
|
this.visibleEntityStorage.remove(entity);
|
|
}
|
|
@@ -170,6 +176,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
}
|
|
|
|
public void updateChunkStatus(ChunkPos chunkPos, Visibility trackingStatus) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Update chunk status"); // Paper
|
|
long i = chunkPos.toLong();
|
|
|
|
if (trackingStatus == Visibility.HIDDEN) {
|
|
@@ -214,6 +221,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
}
|
|
|
|
public void ensureChunkQueuedForLoad(long chunkPos) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity chunk save"); // Paper
|
|
PersistentEntitySectionManager.ChunkLoadStatus persistententitysectionmanager_b = (PersistentEntitySectionManager.ChunkLoadStatus) this.chunkLoadStatuses.get(chunkPos);
|
|
|
|
if (persistententitysectionmanager_b == PersistentEntitySectionManager.ChunkLoadStatus.FRESH) {
|
|
@@ -258,6 +266,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
}
|
|
|
|
private void requestChunkLoad(long chunkPos) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity chunk load request"); // Paper
|
|
this.chunkLoadStatuses.put(chunkPos, PersistentEntitySectionManager.ChunkLoadStatus.PENDING);
|
|
ChunkPos chunkcoordintpair = new ChunkPos(chunkPos);
|
|
CompletableFuture completablefuture = this.permanentStorage.loadEntities(chunkcoordintpair);
|
|
@@ -271,6 +280,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
}
|
|
|
|
private boolean processChunkUnload(long chunkPos) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity chunk unload process"); // Paper
|
|
boolean flag = this.storeChunkSections(chunkPos, (entityaccess) -> {
|
|
entityaccess.getPassengersAndSelf().forEach(this::unloadEntity);
|
|
}, true); // CraftBukkit - add boolean for event call
|
|
@@ -295,6 +305,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
}
|
|
|
|
private void processPendingLoads() {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity chunk process pending loads"); // Paper
|
|
ChunkEntities<T> chunkentities; // CraftBukkit - decompile error
|
|
|
|
while ((chunkentities = (ChunkEntities) this.loadingInbox.poll()) != null) {
|
|
@@ -311,6 +322,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
}
|
|
|
|
public void tick() {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity manager tick"); // Paper
|
|
this.processPendingLoads();
|
|
this.processUnloads();
|
|
}
|
|
@@ -331,6 +343,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
}
|
|
|
|
public void autoSave() {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity manager autosave"); // Paper
|
|
this.getAllChunksToSave().forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error
|
|
boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN;
|
|
|
|
@@ -345,6 +358,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
}
|
|
|
|
public void saveAll() {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity manager save"); // Paper
|
|
LongSet longset = this.getAllChunksToSave();
|
|
|
|
while (!longset.isEmpty()) {
|
|
@@ -452,6 +466,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
long i = SectionPos.asLong(blockposition);
|
|
|
|
if (i != this.currentSectionKey) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity move"); // Paper
|
|
Visibility visibility = this.currentSection.getStatus();
|
|
|
|
if (!this.currentSection.remove(this.entity)) {
|
|
@@ -506,6 +521,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
|
|
@Override
|
|
public void onRemove(Entity.RemovalReason reason) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Entity remove"); // Paper
|
|
if (!this.currentSection.remove(this.entity)) {
|
|
PersistentEntitySectionManager.LOGGER.warn("Entity {} wasn't found in section {} (destroying due to {})", new Object[]{this.entity, SectionPos.of(this.currentSectionKey), reason});
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index 390cacc7916d1322a7e1e8bff004d415e9fa5622..786a3722f3a50d828e5abe2ff9d415b0e10995ce 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -1758,6 +1758,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper
|
|
if (loc == null || sound == null || category == null) return;
|
|
|
|
double x = loc.getX();
|
|
@@ -1769,6 +1770,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper
|
|
if (loc == null || sound == null || category == null) return;
|
|
|
|
double x = loc.getX();
|
|
@@ -1801,6 +1803,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public void playSound(Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper
|
|
if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return;
|
|
|
|
ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(CraftSound.bukkitToMinecraftHolder(sound), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed);
|
|
@@ -1812,6 +1815,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public void playSound(Entity entity, String sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper
|
|
if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return;
|
|
|
|
ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(Holder.direct(SoundEvent.createVariableRangeEvent(ResourceLocation.parse(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
index e3487e8429b285519a0a12d6d283266225b75a80..464d67075e052f13e86b51f3e71d05a6536ef540 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -524,6 +524,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|
|
|
@Override
|
|
public boolean addPotionEffect(PotionEffect effect, boolean force) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("effect add"); // Paper
|
|
this.getHandle().addEffect(org.bukkit.craftbukkit.potion.CraftPotionUtil.fromBukkit(effect), EntityPotionEffectEvent.Cause.PLUGIN); // Paper - Don't ignore icon
|
|
return true;
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java
|
|
index bbf0d9d9c44fe8d7add2f978994ec129420814c7..ef2598760458833021ef1bee92137f42c9fe591f 100644
|
|
--- a/src/main/java/org/spigotmc/AsyncCatcher.java
|
|
+++ b/src/main/java/org/spigotmc/AsyncCatcher.java
|
|
@@ -11,6 +11,7 @@ public class AsyncCatcher
|
|
{
|
|
if ( AsyncCatcher.enabled && Thread.currentThread() != MinecraftServer.getServer().serverThread )
|
|
{
|
|
+ MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable()); // Paper
|
|
throw new IllegalStateException( "Asynchronous " + reason + "!" );
|
|
}
|
|
}
|