Only form data buf once in Bukkit PluginMessage messenger

This commit is contained in:
Luck 2019-01-23 12:12:12 +00:00
parent b744e35ad8
commit 5db999f995
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -69,6 +69,10 @@ public class PluginMessageMessenger implements Messenger, PluginMessageListener
@Override
public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(outgoingMessage.asEncodedString());
byte[] data = out.toByteArray();
new BukkitRunnable() {
@Override
public void run() {
@ -78,11 +82,6 @@ public class PluginMessageMessenger implements Messenger, PluginMessageListener
return;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(outgoingMessage.asEncodedString());
byte[] data = out.toByteArray();
p.sendPluginMessage(PluginMessageMessenger.this.plugin.getBootstrap(), CHANNEL, data);
cancel();
}