Fix possible error with sending plugin message without a player name
This commit is contained in:
@@ -3,6 +3,7 @@ package us.ajg0702.queue.api.players;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
import us.ajg0702.queue.api.util.Handle;
|
||||
|
||||
@@ -76,7 +77,7 @@ public interface AdaptedPlayer extends Handle, Audience {
|
||||
* Gets the player's username
|
||||
* @return the player's username
|
||||
*/
|
||||
String getName();
|
||||
@Nullable String getName();
|
||||
|
||||
/**
|
||||
* Kick a player from the proxy
|
||||
|
||||
+3
-1
@@ -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);
|
||||
|
||||
+3
-1
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user