Use ByteStreams from Guava

This commit is contained in:
Xephi 2015-12-10 20:45:46 +01:00
parent 3253b43a63
commit dff4e6d135
2 changed files with 10 additions and 6 deletions

View File

@ -24,6 +24,9 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.potion.PotionEffectType;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
/**
*/
public class ProcessSyncronousPlayerLogin implements Runnable {
@ -118,8 +121,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
}
protected void sendBungeeMessage() {
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
ByteArrayDataOutput out = ByteStreams.newDataOutput();
try {
String str = "AuthMe;login;" + name;
out.writeUTF("Forward");
@ -127,7 +129,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
out.writeUTF("AuthMe");
out.writeShort(str.length());
out.writeUTF(str);
player.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} catch (Exception e)
{}
}

View File

@ -20,6 +20,9 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
/**
*/
public class ProcessSyncronousPlayerLogout implements Runnable {
@ -43,8 +46,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
}
protected void sendBungeeMessage() {
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
ByteArrayDataOutput out = ByteStreams.newDataOutput();
try {
String str = "AuthMe;logout;" + name;
out.writeUTF("Forward");
@ -52,7 +54,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
out.writeUTF("AuthMe");
out.writeShort(str.length());
out.writeUTF(str);
player.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} catch (Exception e)
{}
}