mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 08:20:51 +01:00
de04cbced5
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: f29cb801 Separate checkstyle-suppressions file is not required 86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack 9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode() 994a6163 Attempt upgrade of resolver libraries CraftBukkit Changes: b3b43a6ad Add Checkstyle check for unused imports 13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names 3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API 2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor 1dbdbbed4 PR-1238: Remove unnecessary sign ticking 659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper e37e29ce0 Increase outdated build delay c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack 492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode() e11fbb9d7 Upgrade MySQL driver 9f3a0bd2a Attempt upgrade of resolver libraries 60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion Spigot Changes: 06d602e7 Rebuild patches
97 lines
5.3 KiB
Diff
97 lines
5.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
|
Date: Fri, 29 Jul 2022 12:35:19 -0400
|
|
Subject: [PATCH] Warn on plugins accessing faraway chunks
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 3a5bf6937a98d60be0d0142a15cf12d8de9b687f..436c16feb53b3dbf32e86f1960714d3d3ffeffd8 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -813,7 +813,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
}
|
|
|
|
private static boolean isInWorldBoundsHorizontal(BlockPos pos) {
|
|
- return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000;
|
|
+ return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000; // Dif on change
|
|
}
|
|
|
|
private static boolean isOutsideSpawnableHeight(int y) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index 3f4145bef3ef0d0d54914c1f6ebd216622d9a747..c77fec78636805a496ecea3e56f26290dbcbffff 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -313,9 +313,24 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
public boolean setSpawnLocation(int x, int y, int z) {
|
|
return this.setSpawnLocation(x, y, z, 0.0F);
|
|
}
|
|
+ // Paper start
|
|
+ private static void warnUnsafeChunk(String reason, int x, int z) {
|
|
+ // if any chunk coord is outside of 30 million blocks
|
|
+ if (x > 1875000 || z > 1875000 || x < -1875000 || z < -1875000) {
|
|
+ Plugin plugin = io.papermc.paper.util.StackWalkerUtil.getFirstPluginCaller();
|
|
+ if (plugin != null) {
|
|
+ plugin.getLogger().warning("Plugin is %s at (%s, %s), this might cause issues.".formatted(reason, x, z));
|
|
+ }
|
|
+ if (net.minecraft.server.MinecraftServer.getServer().isDebugging()) {
|
|
+ io.papermc.paper.util.TraceUtil.dumpTraceForThread("Dangerous chunk retrieval");
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
|
|
@Override
|
|
public Chunk getChunkAt(int x, int z) {
|
|
+ warnUnsafeChunk("getting a faraway chunk", x, z); // Paper
|
|
// Paper start - add ticket to hold chunk for a little while longer if plugin accesses it
|
|
net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
|
if (chunk == null) {
|
|
@@ -430,6 +445,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
@Override
|
|
public boolean regenerateChunk(int x, int z) {
|
|
org.spigotmc.AsyncCatcher.catchOp("chunk regenerate"); // Spigot
|
|
+ warnUnsafeChunk("regenerating a faraway chunk", x, z); // Paper
|
|
// Paper start - implement regenerateChunk method
|
|
final ServerLevel serverLevel = this.world;
|
|
final net.minecraft.server.level.ServerChunkCache serverChunkCache = serverLevel.getChunkSource();
|
|
@@ -525,6 +541,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
@Override
|
|
public boolean loadChunk(int x, int z, boolean generate) {
|
|
org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
|
|
+ warnUnsafeChunk("loading a faraway chunk", x, z); // Paper
|
|
// Paper start - Optimize this method
|
|
ChunkPos chunkPos = new ChunkPos(x, z);
|
|
ChunkAccess immediate = world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); // Paper
|
|
@@ -588,6 +605,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public boolean addPluginChunkTicket(int x, int z, Plugin plugin) {
|
|
+ warnUnsafeChunk("adding a faraway chunk ticket", x, z); // Paper
|
|
Preconditions.checkArgument(plugin != null, "null plugin");
|
|
Preconditions.checkArgument(plugin.isEnabled(), "plugin is not enabled");
|
|
|
|
@@ -656,6 +674,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public void setChunkForceLoaded(int x, int z, boolean forced) {
|
|
+ warnUnsafeChunk("forceloading a faraway chunk", x, z); // Paper
|
|
this.getHandle().setChunkForced(x, z, forced);
|
|
}
|
|
|
|
@@ -968,6 +987,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) {
|
|
+ warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper
|
|
// Transient load for this tick
|
|
return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z);
|
|
}
|
|
@@ -2420,6 +2440,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
// Spigot end
|
|
// Paper start
|
|
public java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent) {
|
|
+ warnUnsafeChunk("getting a faraway chunk async", x, z); // Paper
|
|
if (Bukkit.isPrimaryThread()) {
|
|
net.minecraft.world.level.chunk.LevelChunk immediate = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
|
if (immediate != null) {
|