package NET.worlds.network; import java.io.DataInputStream; import java.io.IOException; import java.io.UTFDataFormatException; class netData { private byte[] _data; private int _packetSize; private int _offset; public netData(DataInputStream in) { try { this._packetSize = in.readUnsignedByte(); this._data = new byte[256]; in.readFully(this._data, 1, this._packetSize - 1); this._data[0] = (byte)this._packetSize; } catch (Exception var3) { this._data = null; this._packetSize = 0; } this._offset = 1; } public final int packetSize() { return this._packetSize; } public final boolean isEmpty() { return this._offset >= this._packetSize; } public final byte getByte() { assert this._offset < this._packetSize; return this._data[this._offset++]; } public final short getShort() { assert this._offset < this._packetSize; assert this._offset + 1 < this._packetSize; short retVal = (short)(this._data[this._offset] << 8 | this._data[this._offset + 1] & 255); this._offset += 2; return retVal; } public String getUTFString(int utflen) { char[] str = new char[utflen]; int count = 0; int strlen = 0; try { while (count < utflen) { int c = this.getByte() & 255; switch (c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: count++; str[strlen++] = (char)c; break; case 12: case 13: count += 2; if (count > utflen) { throw new UTFDataFormatException(); } int char2 = this.getByte() & 255; if ((char2 & 192) != 128) { throw new UTFDataFormatException(); } str[strlen++] = (char)((c & 31) << 6 | char2 & 63); break; case 14: count += 3; if (count > utflen) { throw new UTFDataFormatException(); } char2 = this.getByte() & 255; int char3 = this.getByte() & 255; if ((char2 & 192) != 128 || (char3 & 192) != 128) { throw new UTFDataFormatException(); } str[strlen++] = (char)((c & 15) << 12 | (char2 & 63) << 6 | (char3 & 63) << 0); case 8: case 9: case 10: case 11: default: throw new UTFDataFormatException(); } } } catch (IOException var8) { System.err.println("Exception: " + var8.getMessage()); var8.printStackTrace(); assert false; } return new String(str, 0, strlen); } }