Workaround for really evil plugins breaking sounds
Some plugins are doing really really bad things to worlds breaking the ability to send sounds to some users. So creating another reference to the player chunk map that plugins wont be breaking, and print a stack trace at world creation if we ever get an expected world state to identify who is doing it! If we encounter this illegal state, we fall back to the old method of sending sounds, so sending sounds will still work, just less effecient.
This commit is contained in:
@@ -24,26 +24,50 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
- if (!(entity instanceof EntityPlayer)) continue;
|
- if (!(entity instanceof EntityPlayer)) continue;
|
||||||
- EntityPlayer entityplayer = (EntityPlayer) entity;
|
- EntityPlayer entityplayer = (EntityPlayer) entity;
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ if (world == null && dimensionmanager != null) {
|
+ if ((world == null || world.chunkProvider == null) && dimensionmanager != null) {
|
||||||
+ world = dimensionmanager.world;
|
+ world = dimensionmanager.world;
|
||||||
+ }
|
+ }
|
||||||
+ if (world == null) {
|
+ if (world == null) {
|
||||||
+ LOGGER.error("Sending packet to invalid world" + entityhuman + " " + dimensionmanager + " - " + packet.getClass().getName(), new Throwable());
|
+ LOGGER.error("Sending packet to invalid world" + entityhuman + " " + dimensionmanager + " - " + packet.getClass().getName(), new Throwable());
|
||||||
+ return; // ??? shouldn't happen...
|
+ return; // ??? shouldn't happen...
|
||||||
+ }
|
+ }
|
||||||
+ ChunkProviderServer chunkProvider = (ChunkProviderServer) world.chunkProvider;
|
+ PlayerChunkMap chunkMap = world.chunkMap;
|
||||||
+ if (chunkProvider == null) {
|
+ Object[] backingSet;
|
||||||
+ // ??? Shouldn't be possible but seem some hacky plugins apparently do hack things.
|
+ if (chunkMap == null) {
|
||||||
+ return;
|
+ // Really shouldn't happen...
|
||||||
|
+ backingSet = world.players.toArray();
|
||||||
|
+ } else {
|
||||||
|
+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<EntityPlayer> nearbyPlayers = chunkMap.playerViewDistanceBroadcastMap.getObjectsInRange(MCUtil.fastFloor(d0) >> 4, MCUtil.fastFloor(d2) >> 4);
|
||||||
|
+ if (nearbyPlayers == null) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ backingSet = nearbyPlayers.getBackingSet();
|
||||||
+ }
|
+ }
|
||||||
+ 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;
|
|
||||||
+ }
|
|
||||||
+ Object[] backingSet = nearbyPlayers.getBackingSet();
|
|
||||||
+ for (Object object : backingSet) {
|
+ for (Object object : backingSet) {
|
||||||
+ if (!(object instanceof EntityPlayer)) continue;
|
+ if (!(object instanceof EntityPlayer)) continue;
|
||||||
+ EntityPlayer entityplayer = (EntityPlayer) object;
|
+ EntityPlayer entityplayer = (EntityPlayer) object;
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
||||||
// CraftBukkit start - Test if player receiving packet can see the source of the packet
|
// CraftBukkit start - Test if player receiving packet can see the source of the packet
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||||
|
@@ -0,0 +0,0 @@ public class WorldServer extends World {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
|
+ public final PlayerChunkMap chunkMap; // Paper
|
||||||
|
private final MinecraftServer server;
|
||||||
|
private final WorldNBTStorage dataManager;
|
||||||
|
public boolean savingDisabled;
|
||||||
|
@@ -0,0 +0,0 @@ public class WorldServer extends World {
|
||||||
|
}, gameprofilerfiller, false, gen, env);
|
||||||
|
this.pvpMode = minecraftserver.getPVP();
|
||||||
|
worlddata.world = this;
|
||||||
|
+ if (chunkProvider == null) { chunkMap = null; new Throwable("World created without a ChunkProvider!").printStackTrace(); } // Paper - figure out if something weird happened here
|
||||||
|
+ else chunkMap = ((ChunkProviderServer) chunkProvider).playerChunkMap;
|
||||||
|
// CraftBukkit end
|
||||||
|
if (com.destroystokyo.paper.PaperConfig.useOptimizedTickList) {
|
||||||
|
this.nextTickListBlock = new com.destroystokyo.paper.server.ticklist.PaperTickList<>(this, (block) -> { // Paper - optimise TickListServer
|
||||||
|
|||||||
Reference in New Issue
Block a user