модернизания NetStream (extends Input/Output stream)
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
/*
|
||||
* DmitriyMX <dimon550@gmail.com>
|
||||
* 2018-07-25
|
||||
*/
|
||||
package mc.core.network;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class NetInputStream {
|
||||
public abstract class NetInputStream extends InputStream {
|
||||
@Getter
|
||||
@Setter
|
||||
private int dataSize;
|
||||
|
||||
public abstract boolean readBoolean();
|
||||
public abstract byte readByte();
|
||||
public abstract void readBytes(byte[] buffer);
|
||||
public int readBytes(byte[] buffer) {
|
||||
return readBytes(buffer, 0, buffer.length);
|
||||
}
|
||||
public abstract int readBytes(byte[] buffer, int offset, int length);
|
||||
public abstract int readUnsignedByte();
|
||||
public abstract int readUnsignedShort();
|
||||
public abstract short readShort();
|
||||
@@ -30,4 +31,25 @@ public abstract class NetInputStream {
|
||||
public abstract UUID readUUID();
|
||||
|
||||
public abstract void skipBytes(int count);
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b) throws IOException {
|
||||
return readBytes(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
return readBytes(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long skip(long n) throws IOException {
|
||||
skipBytes((int) n);
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
/*
|
||||
* DmitriyMX <dimon550@gmail.com>
|
||||
* 2018-07-25
|
||||
*/
|
||||
package mc.core.network;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class NetOutputStream {
|
||||
public abstract class NetOutputStream extends OutputStream {
|
||||
public abstract void writeBoolean(boolean value);
|
||||
public abstract void writeByte(int value);
|
||||
public abstract void writeUnsignedByte(int value);
|
||||
public abstract void writeBytes(byte[] buffer);
|
||||
public void writeBytes(byte[] buffer) {
|
||||
writeBytes(buffer, 0, buffer.length);
|
||||
}
|
||||
public abstract void writeBytes(byte[] buffer, int offset, int lengtn);
|
||||
public abstract void writeShort(int value);
|
||||
public abstract void writeInt(int value);
|
||||
public abstract void writeVarInt(int value);
|
||||
@@ -19,4 +20,19 @@ public abstract class NetOutputStream {
|
||||
public abstract void writeDouble(double value);
|
||||
public abstract void writeString(String value);
|
||||
public abstract void writeUUID(UUID uuid);
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
writeByte(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
writeBytes(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
writeBytes(b, off, len);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user