1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
@@ -8,7 +8,6 @@
import io.netty.buffer.ByteBufProcessor;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.EncoderException;
-import io.netty.util.ReferenceCounted;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@@ -21,6 +20,8 @@
import java.nio.charset.Charset;
import java.util.UUID;
+import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
+
public class PacketDataSerializer extends ByteBuf {
private final ByteBuf a;
@@ -142,7 +143,7 @@
} else {
try {
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
- } catch (IOException ioexception) {
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
throw new EncoderException(ioexception);
}
}
@@ -162,7 +163,7 @@
}
public void a(ItemStack itemstack) {
- if (itemstack == null) {
+ if (itemstack == null || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
this.writeShort(-1);
} else {
this.writeShort(Item.getId(itemstack.getItem()));
@@ -189,6 +190,11 @@
itemstack = new ItemStack(Item.getById(short0), b0, short1);
itemstack.setTag(this.h());
+ // CraftBukkit start
+ if (itemstack.getTag() != null) {
+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
+ }
+ // CraftBukkit end
}
return itemstack;
@@ -416,11 +422,11 @@
return this.a.getBytes(i, bytebuffer);
}
- public ByteBuf getBytes(int i, OutputStream outputstream, int j) {
+ public ByteBuf getBytes(int i, OutputStream outputstream, int j) throws IOException { // CraftBukkit - throws IOException
return this.a.getBytes(i, outputstream, j);
}
- public int getBytes(int i, GatheringByteChannel gatheringbytechannel, int j) {
+ public int getBytes(int i, GatheringByteChannel gatheringbytechannel, int j) throws IOException { // CraftBukkit - throws IOException
return this.a.getBytes(i, gatheringbytechannel, j);
}
@@ -484,11 +490,11 @@
return this.a.setBytes(i, bytebuffer);
}
- public int setBytes(int i, InputStream inputstream, int j) {
+ public int setBytes(int i, InputStream inputstream, int j) throws IOException { // CraftBukkit - throws IOException
return this.a.setBytes(i, inputstream, j);
}
- public int setBytes(int i, ScatteringByteChannel scatteringbytechannel, int j) {
+ public int setBytes(int i, ScatteringByteChannel scatteringbytechannel, int j) throws IOException { // CraftBukkit - throws IOException
return this.a.setBytes(i, scatteringbytechannel, j);
}
@@ -580,11 +586,11 @@
return this.a.readBytes(bytebuffer);
}
- public ByteBuf readBytes(OutputStream outputstream, int i) {
+ public ByteBuf readBytes(OutputStream outputstream, int i) throws IOException { // CraftBukkit - throws IOException
return this.a.readBytes(outputstream, i);
}
- public int readBytes(GatheringByteChannel gatheringbytechannel, int i) {
+ public int readBytes(GatheringByteChannel gatheringbytechannel, int i) throws IOException { // CraftBukkit - throws IOException
return this.a.readBytes(gatheringbytechannel, i);
}
@@ -652,11 +658,11 @@
return this.a.writeBytes(bytebuffer);
}
- public int writeBytes(InputStream inputstream, int i) {
+ public int writeBytes(InputStream inputstream, int i) throws IOException { // CraftBukkit - throws IOException
return this.a.writeBytes(inputstream, i);
}
- public int writeBytes(ScatteringByteChannel scatteringbytechannel, int i) {
+ public int writeBytes(ScatteringByteChannel scatteringbytechannel, int i) throws IOException { // CraftBukkit - throws IOException
return this.a.writeBytes(scatteringbytechannel, i);
}
@@ -803,16 +809,4 @@
public boolean release(int i) {
return this.a.release(i);
}
-
- public ReferenceCounted retain(int i) {
- return this.retain(i);
- }
-
- public ReferenceCounted retain() {
- return this.retain();
- }
-
- public int compareTo(Object object) {
- return this.compareTo((ByteBuf) object);
- }
}
|