Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Rneame CustomByteType -> FixedByteArrayType
Dieser Commit ist enthalten in:
Ursprung
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);
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren