Fix possible error with sending plugin message without a player name

This commit is contained in:
ajgeiss0702
2023-03-11 10:25:49 -07:00
parent 5343a31683
commit a0f5903862
3 changed files with 8 additions and 3 deletions
@@ -35,9 +35,11 @@ public class BungeeMethods implements PlatformMethods {
public void sendPluginMessage(AdaptedPlayer player, String channel, String... data) {
Collection<ProxiedPlayer> networkPlayers = ProxyServer.getInstance().getPlayers();
if (networkPlayers != null && !networkPlayers.isEmpty()) {
String playerName = player.getName();
if(playerName == null) return;
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(channel);
out.writeUTF(player.getName());
out.writeUTF(playerName);
for (String s : data) {
out.writeUTF(s);
@@ -41,8 +41,10 @@ public class VelocityMethods implements PlatformMethods {
if(player == null) return;
Player velocityPlayer = ((VelocityPlayer) player).getHandle();
@SuppressWarnings("UnstableApiUsage") ByteArrayDataOutput out = ByteStreams.newDataOutput();
String playerName = player.getName();
if(playerName == null) return;
out.writeUTF( channel );
out.writeUTF(player.getName());
out.writeUTF(playerName);
for(String s : data) {
out.writeUTF( s );
}