File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ public void decode() {
3838 this .type = (int ) this .getUnsignedVarInt ();
3939 this .id = this .getUUID ();
4040
41- this .input = this .getArray (BinaryStream ::getSlot );
42- this .output = this .getArray (BinaryStream ::getSlot );
41+ this .input = this .getArray (Item . class , BinaryStream ::getSlot );
42+ this .output = this .getArray (Item . class , BinaryStream ::getSlot );
4343 }
4444
4545 @ Override
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ public void decode() {
5959 case TYPE_POPUP :
6060 case TYPE_JUKEBOX_POPUP :
6161 this .message = this .getString ();
62- this .parameters = this .getArray (BinaryStream ::getString );
62+ this .parameters = this .getArray (String . class , BinaryStream ::getString );
6363 }
6464 this .xboxUserId = this .getString ();
6565 this .platformChatId = this .getString ();
Original file line number Diff line number Diff line change 1414import cn .nukkit .nbt .tag .ListTag ;
1515import cn .nukkit .nbt .tag .StringTag ;
1616import cn .nukkit .network .protocol .types .EntityLink ;
17+ import com .google .common .collect .Iterables ;
1718import it .unimi .dsi .fastutil .io .FastByteArrayInputStream ;
1819
1920import java .io .IOException ;
21+ import java .lang .reflect .Array ;
2022import java .nio .ByteOrder ;
2123import java .nio .charset .StandardCharsets ;
2224import java .util .*;
@@ -669,13 +671,13 @@ public EntityLink getEntityLink() {
669671 }
670672
671673 @ SuppressWarnings ("unchecked" )
672- public <T > T [] getArray (Function <BinaryStream , T > function ) {
673- ArrayDeque <T > array = new ArrayDeque <>();
674+ public <T > T [] getArray (Class < T > clazz , Function <BinaryStream , T > function ) {
675+ ArrayDeque <T > deque = new ArrayDeque <>();
674676 int count = (int ) getUnsignedVarInt ();
675677 for (int i = 0 ; i < count ; i ++) {
676- array .add (function .apply (this ));
678+ deque .add (function .apply (this ));
677679 }
678- return ( T []) array . toArray ( );
680+ return deque . toArray (( T []) Array . newInstance ( clazz , 0 ) );
679681 }
680682
681683 public boolean feof () {
You can’t perform that action at this time.
0 commit comments