mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 11:35:18 +01:00
Rneame CustomByteType -> FixedByteArrayType
This commit is contained in:
parent
6481cec270
commit
21d293dd7f
@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.type;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
@Deprecated
|
||||
public abstract class PartialType<T, X> extends Type<T> {
|
||||
private final X param;
|
||||
|
||||
|
@ -22,27 +22,31 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.type.types;
|
||||
|
||||
import com.viaversion.viaversion.api.type.PartialType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class CustomByteType extends PartialType<byte[], Integer> {
|
||||
public class FixedByteArrayType extends Type<byte[]> {
|
||||
|
||||
public CustomByteType(Integer param) {
|
||||
super(param, byte[].class);
|
||||
private final int arrayLength;
|
||||
|
||||
public FixedByteArrayType(final int arrayLength) {
|
||||
super(byte[].class);
|
||||
this.arrayLength = arrayLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] read(ByteBuf byteBuf, Integer integer) throws Exception {
|
||||
if (byteBuf.readableBytes() < integer) throw new RuntimeException("Readable bytes does not match expected!");
|
||||
public byte[] read(final ByteBuf byteBuf) throws Exception {
|
||||
if (byteBuf.readableBytes() < this.arrayLength) {
|
||||
throw new RuntimeException("Readable bytes does not match expected!");
|
||||
}
|
||||
|
||||
byte[] byteArray = new byte[integer];
|
||||
final byte[] byteArray = new byte[this.arrayLength];
|
||||
byteBuf.readBytes(byteArray);
|
||||
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf byteBuf, Integer integer, byte[] bytes) throws Exception {
|
||||
public void write(final ByteBuf byteBuf, final byte[] bytes) throws Exception {
|
||||
byteBuf.writeBytes(bytes);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user