Fix NPE when using broadcast as players are joining

This commit is contained in:
Shane Freeder 2021-06-29 22:21:42 +01:00
parent 2291667661
commit 2103ad2f81
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
5 changed files with 12 additions and 11 deletions

View File

@ -2041,7 +2041,7 @@ index d4ea706d5456e709b95e34be8220a0d39be2c8f4..2db149bf57c561d7f8f49341fbefafb5
player.initMenu(container); player.initMenu(container);
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 969d5071dbf3356b80da38526351d488ab936c08..bc901793055db9481ec32e668386ba33696bc0a5 100644 index 969d5071dbf3356b80da38526351d488ab936c08..9c643472f0c271dcd41721cc121f7af161cafd9b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -244,14 +244,39 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -244,14 +244,39 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@ -2223,7 +2223,7 @@ index 969d5071dbf3356b80da38526351d488ab936c08..bc901793055db9481ec32e668386ba33
@Override @Override
public int getPing() { public int getPing() {
return this.getHandle().latency; return this.getHandle().latency;
@@ -1727,6 +1798,158 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -1727,6 +1798,159 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
getInventory().setItemInMainHand(hand); getInventory().setItemInMainHand(hand);
} }
@ -2241,6 +2241,7 @@ index 969d5071dbf3356b80da38526351d488ab936c08..bc901793055db9481ec32e668386ba33
+ +
+ @Override + @Override
+ public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) { + public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) {
+ if (getHandle().connection == null) return;
+ final ClientboundChatPacket packet = new ClientboundChatPacket(null, type == net.kyori.adventure.audience.MessageType.CHAT ? net.minecraft.network.chat.ChatType.CHAT : net.minecraft.network.chat.ChatType.SYSTEM, identity.uuid()); + final ClientboundChatPacket packet = new ClientboundChatPacket(null, type == net.kyori.adventure.audience.MessageType.CHAT ? net.minecraft.network.chat.ChatType.CHAT : net.minecraft.network.chat.ChatType.SYSTEM, identity.uuid());
+ packet.adventure$message = message; + packet.adventure$message = message;
+ this.getHandle().connection.send(packet); + this.getHandle().connection.send(packet);

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Expose attack cooldown methods for Player
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 1800119160d5711b694c14e9dde175b11c06ce61..6950e36b5e0522ba40874d3c786e5dff2ad12fed 100644 index 295f82fcdc42103e99bb5c0ab472388f83ac5646..96d924299f20f96fbf94b491da0ff3f692344334 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2232,6 +2232,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -2233,6 +2233,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
connection.send(new net.minecraft.network.protocol.game.ClientboundOpenBookPacket(net.minecraft.world.InteractionHand.MAIN_HAND)); connection.send(new net.minecraft.network.protocol.game.ClientboundOpenBookPacket(net.minecraft.world.InteractionHand.MAIN_HAND));
connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(0, slot, inventory.getSelected())); connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(0, slot, inventory.getSelected()));
} }

View File

@ -12,10 +12,10 @@ Player we will look at limiting the scope of this change. It appears to
be unintentional in the few cases we've seen so far. be unintentional in the few cases we've seen so far.
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0e27598d8b05c09e0ae3aae618573fe774b84cca..8c19f5b79fd846bea4eb5c4776eb9a4a282b24c1 100644 index 8563dca3c712ebb579056a3e2a344616018b7274..29d1f363348c67f158b8f4aac923e5f30d54b080 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2279,6 +2279,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -2280,6 +2280,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void resetCooldown() { public void resetCooldown() {
getHandle().resetAttackStrengthTicker(); getHandle().resetAttackStrengthTicker();
} }

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Brand support
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index ea17f9263bef3a2a36dde15d0d75b8a5a695aa93..10126fccdfde8acdb55bbe9c9bfc57435ed13677 100644 index 758e3169b163dccfceffb2537fd37d1a2ee05994..fc16032f5693b0fb39974d027f237f88aabc2e7b 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists; @@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
@ -72,10 +72,10 @@ index ea17f9263bef3a2a36dde15d0d75b8a5a695aa93..10126fccdfde8acdb55bbe9c9bfc5743
return (!this.player.joining && !this.connection.isConnected()) || this.processedDisconnect; // Paper return (!this.player.joining && !this.connection.isConnected()) || this.processedDisconnect; // Paper
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 535fb8f029dc09862e42e239a0fc7326e31508ef..6557ae8a996ddb227a9fadd4ac30d44b1c5e47b2 100644 index 5aba300b2aa99bcf17fdf19f8203a52bc814168e..be7b69f8279bbb95d49c5b6ac24fde356d5caaf2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2420,6 +2420,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -2421,6 +2421,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Paper end // Paper end
}; };

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Expose Tracked Players
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 85187e7b0d965b7930e6b2ab8d321d6d27211a35..4f61acf44b40bf15ae6465d7999e2bc2da837c82 100644 index 5b5c9d1bedb5fb87f390e39942a64f4d87098eeb..313bfab694bb93968db927b5e4bd98a7c7931184 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2339,6 +2339,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -2340,6 +2340,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
// Paper end // Paper end