Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 53 lines 1.5 kB view raw
1package net.minecraft.server; 2 3import java.io.DataInputStream; 4import java.io.DataOutputStream; 5import java.io.IOException; 6 7public class Packet2Handshake extends Packet { 8 9 public String a; 10 public boolean pvn11; 11 12 public Packet2Handshake() { 13 } 14 15 public Packet2Handshake(String s, boolean pvn11) { 16 this.a = s; 17 this.pvn11 = pvn11; 18 } 19 20 public void a(DataInputStream datainputstream) throws IOException { 21 // uberbukkit -- read the packet in a custom way to allow joining with vastly different PVNs 22 23 // both readUTF() and the minecraft method read short first 24 int UTFlen = datainputstream.readShort(); 25 // if pvn is 11 or higher (aka client uses the minecraft method for transferring strings), 26 // `available` will be 2x `UTFlen` 27 int available = datainputstream.available(); 28 29 this.pvn11 = available > UTFlen; 30 31 byte[] buf = new byte[available]; 32 datainputstream.readFully(buf, 0, available); 33 34 this.a = new String(buf, "UTF-8").replace(Character.toString((char) 0), ""); 35 } 36 37 public void a(DataOutputStream dataoutputstream) throws IOException { 38 // uberbukkit 39 if (this.pvn11) { 40 a(this.a, dataoutputstream); 41 } else { 42 dataoutputstream.writeUTF(this.a); 43 } 44 } 45 46 public void a(NetHandler nethandler) { 47 nethandler.a(this); 48 } 49 50 public int a() { 51 return 4 + this.a.length() + 4; 52 } 53}