Workaround for some hacky environments that mess up things

2 people had issues where some plugin is doing some reallly insane NMS hackery
that created invalid worlds, which caused some errors...

Really don't understand what in the world they did, but putting in a dumb guard that
shouldn't even be necessary to just not send the sound effect rather than erroring.
This commit is contained in:
Aikar 2020-05-23 22:27:37 -04:00
parent 18bd266258
commit 41d5f3cc86
3 changed files with 15 additions and 4 deletions

View file

@ -1418,8 +1418,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(worlddata.getName(), this.spigotConfig); // Paper
+ this.chunkPacketBlockController = this.paperConfig.antiXray ? new ChunkPacketBlockControllerAntiXray(this.paperConfig) : ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray
this.generator = gen;
dimensionmanager.world = (WorldServer) this; // Paper
this.world = new CraftWorld((WorldServer) this, gen, env);
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
@@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
// CraftBukkit end

View file

@ -3014,10 +3014,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public WorldServer world; // Paper - store ref to world this manager is for
public WorldProvider getWorldProvider(World world) {
+ if (this.world == null) this.world = (WorldServer) world; // Paper
return (WorldProvider) this.providerFactory.apply(world, this);
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/Entity.java
@ -4372,6 +4370,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.event.block.BlockPhysicsEvent;
// CraftBukkit end
@@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
this.spigotConfig = new org.spigotmc.SpigotWorldConfig( worlddata.getName() ); // Spigot
this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(worlddata.getName(), this.spigotConfig); // Paper
this.generator = gen;
+ dimensionmanager.world = (WorldServer) this; // Paper
this.world = new CraftWorld((WorldServer) this, gen, env);
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
@@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
return (Chunk) this.getChunkAt(i, j, ChunkStatus.FULL);
}

View file

@ -31,7 +31,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ LOGGER.error("Sending packet to invalid world" + entityhuman + " " + dimensionmanager + " - " + packet.getClass().getName(), new Throwable());
+ return; // ??? shouldn't happen...
+ }
+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<EntityPlayer> nearbyPlayers = world.getChunkProvider().playerChunkMap.playerViewDistanceBroadcastMap.getObjectsInRange(MCUtil.fastFloor(d0) >> 4, MCUtil.fastFloor(d2) >> 4);
+ ChunkProviderServer chunkProvider = (ChunkProviderServer) world.chunkProvider;
+ if (chunkProvider == null) {
+ // ??? Shouldn't be possible but seem some hacky plugins apparently do hack things.
+ return;
+ }
+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<EntityPlayer> nearbyPlayers = chunkProvider.playerChunkMap.playerViewDistanceBroadcastMap.getObjectsInRange(MCUtil.fastFloor(d0) >> 4, MCUtil.fastFloor(d2) >> 4);
+ if (nearbyPlayers == null) {
+ return;
+ }