Compare commits
714
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdc7ed36e0 | ||
|
|
5d63308a22 | ||
|
|
214706dbb6 | ||
|
|
fa3b563c70 | ||
|
|
55e31483e7 | ||
|
|
aa34910468 | ||
|
|
5e44913a5e | ||
|
|
b8dc964112 | ||
|
|
890844fb60 | ||
|
|
fc57c9e077 | ||
|
|
f12ef113aa | ||
|
|
e8144ece97 | ||
|
|
b611ad5522 | ||
|
|
53e1014c8d | ||
|
|
69f992a984 | ||
|
|
fde9db39b7 | ||
|
|
6c6a2535c8 | ||
|
|
23d06075dd | ||
|
|
926fd1ae50 | ||
|
|
756add003f | ||
|
|
800ffafb96 | ||
|
|
ba2d9ae9f0 | ||
|
|
31d07e4a39 | ||
|
|
ec36a5d1d8 | ||
|
|
08ba59e1d9 | ||
|
|
851c74e827 | ||
|
|
b31893e035 | ||
|
|
4718fb985d | ||
|
|
aed9bc14fa | ||
|
|
1daad13da3 | ||
|
|
65a984e805 | ||
|
|
a923b950f6 | ||
|
|
ac5790411f | ||
|
|
cd3449ade2 | ||
|
|
75af221f77 | ||
|
|
6f9b2cf5e9 | ||
|
|
4b4dd492cf | ||
|
|
68471d32c8 | ||
|
|
b7d0ce9518 | ||
|
|
58abfc0c1e | ||
|
|
a3f6adac2f | ||
|
|
f0c9af4464 | ||
|
|
f43fff899f | ||
|
|
9291fd8953 | ||
|
|
feb975010e | ||
|
|
5c34c8e6c3 | ||
|
|
8aaf40fc74 | ||
|
|
c6fcab2923 | ||
|
|
64006b91a4 | ||
|
|
625a66f45a | ||
|
|
0c6208f931 | ||
|
|
be32f464c5 | ||
|
|
3389baf40e | ||
|
|
edc85e68e8 | ||
|
|
3f9f093934 | ||
|
|
31426cc69c | ||
|
|
cec8c9789f | ||
|
|
f771e15ce0 | ||
|
|
68a3702cd6 | ||
|
|
8f4f688fb8 | ||
|
|
0a380344c5 | ||
|
|
ab458ded62 | ||
|
|
3bc78c1aec | ||
|
|
0feebb6819 | ||
|
|
cdb48e0ab6 | ||
|
|
85e819d72f | ||
|
|
10d44fe3cb | ||
|
|
6b5ada3c5d | ||
|
|
2f0861c7b7 | ||
|
|
abc8695a29 | ||
|
|
c6577646ce | ||
|
|
a6c68b2d0e | ||
|
|
23e0861192 | ||
|
|
7539aa345c | ||
|
|
2a076a61a0 | ||
|
|
bf0ec04cec | ||
|
|
fea687bba9 | ||
|
|
25e83d6181 | ||
|
|
95a91bb1f2 | ||
|
|
e1e057eabb | ||
|
|
f81120f8ed | ||
|
|
e44ad5edc2 | ||
|
|
c35d0854bc | ||
|
|
47dbb5e9c0 | ||
|
|
702894dd07 | ||
|
|
4801196942 | ||
|
|
c88a9c412c | ||
|
|
4012472404 | ||
|
|
54f3f3c221 | ||
|
|
873557151b | ||
|
|
32e96f3f51 | ||
|
|
cdffd10999 | ||
|
|
1524a546d8 | ||
|
|
40d7be6236 | ||
|
|
98b2b7b631 | ||
|
|
54704811b3 | ||
|
|
54241497b5 | ||
|
|
99637743f5 | ||
|
|
702452c3a1 | ||
|
|
7e424cd46b | ||
|
|
58401fc18e | ||
|
|
7285eeff5a | ||
|
|
cfb57e7a99 | ||
|
|
93cd6f39f9 | ||
|
|
9975706ba8 | ||
|
|
9b88a9ef98 | ||
|
|
548c6183a4 | ||
|
|
19d271881c | ||
|
|
a64978cb0a | ||
|
|
527beda70f | ||
|
|
127421a1d2 | ||
|
|
4a188bd116 | ||
|
|
cd6db40a0d | ||
|
|
d050c10eab | ||
|
|
82e5b68119 | ||
|
|
3f00e1d817 | ||
|
|
7296072bcb | ||
|
|
132ae43496 | ||
|
|
2465ba9306 | ||
|
|
2e10b151c9 | ||
|
|
9a338cd897 | ||
|
|
7c0bac33df | ||
|
|
db8c4ce08d | ||
|
|
af52640237 | ||
|
|
b6d71a79a1 | ||
|
|
407257c2ce | ||
|
|
19e7bc6190 | ||
|
|
e0beccff4d | ||
|
|
1728e667ea | ||
|
|
c2cce6fac7 | ||
|
|
9cf38bc325 | ||
|
|
c0522d7836 | ||
|
|
dc1ac3beb3 | ||
|
|
d59a11a340 | ||
|
|
a8e95c23ac | ||
|
|
607b8dde56 | ||
|
|
a0ccfb4875 | ||
|
|
afcf98e2c8 | ||
|
|
51d74ae7ea | ||
|
|
7b6308c4e0 | ||
|
|
cdbe0df0f3 | ||
|
|
d799ba7190 | ||
|
|
8c03d2e3a0 | ||
|
|
7c2994e54d | ||
|
|
e1e61feebf | ||
|
|
e6fb117182 | ||
|
|
a7aa3eae68 | ||
|
|
d38089a46a | ||
|
|
e2a980adde | ||
|
|
a4e116d34f | ||
|
|
6b61682fe4 | ||
|
|
0c4709ac57 | ||
|
|
c6a542d206 | ||
|
|
d67028f568 | ||
|
|
af48ee3938 | ||
|
|
945919c1e0 | ||
|
|
38de7a4b94 | ||
|
|
419232a075 | ||
|
|
e705b2725d | ||
|
|
004702f642 | ||
|
|
4c29d39292 | ||
|
|
24e8ff4fb4 | ||
|
|
cf61f74ade | ||
|
|
72ab24b419 | ||
|
|
8c8357bfbc | ||
|
|
59d36b6e55 | ||
|
|
decf5579a3 | ||
|
|
187f5a54c6 | ||
|
|
647c05fe98 | ||
|
|
a089b98f6d | ||
|
|
9d21b834cc | ||
|
|
069e872204 | ||
|
|
e945c9c56f | ||
|
|
b8058b57d8 | ||
|
|
7ce167157a | ||
|
|
0503e99c50 | ||
|
|
413d5e1eb5 | ||
|
|
51ebbb7914 | ||
|
|
2b98d5c90b | ||
|
|
099ea9b7e9 | ||
|
|
ce703febc3 | ||
|
|
dce59f99fd | ||
|
|
5ff498b6f0 | ||
|
|
32b85dce18 | ||
|
|
89b8d823c4 | ||
|
|
fc0f1eec68 | ||
|
|
765fb79321 | ||
|
|
eb42c1b473 | ||
|
|
ce484ecac5 | ||
|
|
cb3e4d33a7 | ||
|
|
12c01eb2fa | ||
|
|
c4b8a17437 | ||
|
|
5dde544e07 | ||
|
|
d16ad2154d | ||
|
|
245da7a870 | ||
|
|
2a0b217718 | ||
|
|
582cfa7b57 | ||
|
|
1b295dc827 | ||
|
|
a83248f70d | ||
|
|
42a1375c00 | ||
|
|
fbe89306f5 | ||
|
|
faeb2f55d3 | ||
|
|
239cc09c9f | ||
|
|
6aac1faac4 | ||
|
|
ea4ab05bff | ||
|
|
d53f39bbc7 | ||
|
|
8f28b71ee2 | ||
|
|
58df1fcc91 | ||
|
|
060b919fa3 | ||
|
|
7d0d4aa672 | ||
|
|
e3cde54ab2 | ||
|
|
d681345e41 | ||
|
|
3939b534ad | ||
|
|
a8afbd2a0b | ||
|
|
7d7cbb4445 | ||
|
|
1c5dceb47d | ||
|
|
876fbf6fbf | ||
|
|
b469ce2a69 | ||
|
|
6f7823e8cb | ||
|
|
2619a4398d | ||
|
|
d411fe44fe | ||
|
|
67af517510 | ||
|
|
cce862bc57 | ||
|
|
319750e3f9 | ||
|
|
78ccd8b2d5 | ||
|
|
50ef62f4fb | ||
|
|
05a5b5284b | ||
|
|
8c6865405d | ||
|
|
a204b5d521 | ||
|
|
da0128b330 | ||
|
|
84b005a3b0 | ||
|
|
38fd7eae6d | ||
|
|
e3d08fa0de | ||
|
|
0da59c3585 | ||
|
|
b4145fda44 | ||
|
|
5df58a116d | ||
|
|
7899d8cb46 | ||
|
|
b47e0f20ef | ||
|
|
63a7121653 | ||
|
|
7927c89ba2 | ||
|
|
db5c97a324 | ||
|
|
d4b919430f | ||
|
|
d52df749fa | ||
|
|
63eac8f0f6 | ||
|
|
0d7a618d87 | ||
|
|
7a8d440475 | ||
|
|
89b63802ac | ||
|
|
17e8b51205 | ||
|
|
8bb12b6913 | ||
|
|
8a194d1ff6 | ||
|
|
45bc1e3d80 | ||
|
|
a812e22312 | ||
|
|
b7c9015b39 | ||
|
|
98c7c0d49c | ||
|
|
dc10e3cca6 | ||
|
|
54ae21fd5d | ||
|
|
5d851e849a | ||
|
|
09ef7c2e80 | ||
|
|
e8d7fc30a5 | ||
|
|
5fbb6d7349 | ||
|
|
28b67601c1 | ||
|
|
ba02780727 | ||
|
|
2c756925a1 | ||
|
|
ac37b708c0 | ||
|
|
6b92403dea | ||
|
|
f63da3d3d2 | ||
|
|
de763c948c | ||
|
|
4469b93ed9 | ||
|
|
873c09d224 | ||
|
|
646b0a1050 | ||
|
|
470975ca77 | ||
|
|
2005daa11f | ||
|
|
e28f4e3993 | ||
|
|
7509ecb971 | ||
|
|
738309506d | ||
|
|
5243d9f17d | ||
|
|
bd91ef1be1 | ||
|
|
8a9338ae46 | ||
|
|
9aa27103a0 | ||
|
|
af105f4add | ||
|
|
d2d3d84cbf | ||
|
|
e9a5c9315c | ||
|
|
3a93098804 | ||
|
|
0b404d04cd | ||
|
|
f7b6fc476f | ||
|
|
0bcf58cf80 | ||
|
|
f9390aa69d | ||
|
|
3f6bb1a03d | ||
|
|
67eaa91252 | ||
|
|
911dffccc2 | ||
|
|
3368b7fcc5 | ||
|
|
1ad7cae303 | ||
|
|
b7d04384fb | ||
|
|
ea32d28d0b | ||
|
|
ad70e4b996 | ||
|
|
c320ebce86 | ||
|
|
01c81f5a0b | ||
|
|
66c722ec00 | ||
|
|
af38857d07 | ||
|
|
5a1a02d212 | ||
|
|
bc96b5cd3e | ||
|
|
c44e834c01 | ||
|
|
4273bf6587 | ||
|
|
3329a544a4 | ||
|
|
075784498c | ||
|
|
03b68a7f6f | ||
|
|
dc614c96c3 | ||
|
|
f77f705942 | ||
|
|
aa9cc58b49 | ||
|
|
9de4dcf4b1 | ||
|
|
eae3d091f8 | ||
|
|
5f499123df | ||
|
|
a6c16ab45a | ||
|
|
c060a55740 | ||
|
|
8447998ce6 | ||
|
|
99bc0ffcb6 | ||
|
|
dea5feaa1e | ||
|
|
ebea88f60f | ||
|
|
5717b6050e | ||
|
|
8eb60e9398 | ||
|
|
4db2dc0592 | ||
|
|
ba1daa4b17 | ||
|
|
69700bce2a | ||
|
|
9dc0db4eae | ||
|
|
8aeef01bd4 | ||
|
|
3fff3925b2 | ||
|
|
72c0ecbc5d | ||
|
|
785c8056f9 | ||
|
|
48ef856d02 | ||
|
|
c052ecf8c0 | ||
|
|
64ae9bfe27 | ||
|
|
7b028f61d6 | ||
|
|
5d3f2105f0 | ||
|
|
a4c57cf41c | ||
|
|
e8fa6d793f | ||
|
|
8fa6c3ad1e | ||
|
|
2044657fb6 | ||
|
|
8c216d0aa6 | ||
|
|
b80f22bf08 | ||
|
|
4b0414c61b | ||
|
|
3c43382148 | ||
|
|
00e081fcad | ||
|
|
8cc8e5f171 | ||
|
|
b449205b6f | ||
|
|
bbe88eba3d | ||
|
|
f271778905 | ||
|
|
fdefa91208 | ||
|
|
909eb7cde3 | ||
|
|
1b3598182b | ||
|
|
031d190da2 | ||
|
|
744cb05253 | ||
|
|
b1b2b10ee5 | ||
|
|
6efb6aebdf | ||
|
|
a633c2558a | ||
|
|
88cd3bea89 | ||
|
|
1ec83d1398 | ||
|
|
adf46aaeca | ||
|
|
43669d3652 | ||
|
|
bc356c6daf | ||
|
|
b090424510 | ||
|
|
3fd2b883de | ||
|
|
e3e29ed79b | ||
|
|
be4e820c0a | ||
|
|
d7e1aa2161 | ||
|
|
f214cc54c6 | ||
|
|
31157da8bb | ||
|
|
d54baa4293 | ||
|
|
e3e4ac027f | ||
|
|
c8023cd828 | ||
|
|
9770948c45 | ||
|
|
6b62e2152f | ||
|
|
88a223e2d9 | ||
|
|
74f28ad610 | ||
|
|
085b37b2ed | ||
|
|
ea273ba4b6 | ||
|
|
f3b14030b1 | ||
|
|
c565d94d41 | ||
|
|
d054164a4b | ||
|
|
cd0679c3b2 | ||
|
|
1be60149f9 | ||
|
|
b48e271ced | ||
|
|
2bcb1dcb90 | ||
|
|
c8d472beb7 | ||
|
|
18689e4f00 | ||
|
|
440c73431e | ||
|
|
de634687fa | ||
|
|
6d0a753d2d | ||
|
|
c43b24c0db | ||
|
|
7df7ffcc69 | ||
|
|
cca73eabe0 | ||
|
|
db7f8d9cbd | ||
|
|
a53ff85a66 | ||
|
|
46a7f39be6 | ||
|
|
89801adc76 | ||
|
|
a405880a89 | ||
|
|
bd5c4207bc | ||
|
|
3564bc56e4 | ||
|
|
6f18f867c0 | ||
|
|
1ae1b5abf1 | ||
|
|
f8a920a2cb | ||
|
|
b497efc0c1 | ||
|
|
dfb36a48f9 | ||
|
|
0e471c665d | ||
|
|
f76b2f7c72 | ||
|
|
4915d7d4a3 | ||
|
|
16e3861b41 | ||
|
|
b57855b6ba | ||
|
|
6edd19e416 | ||
|
|
4ef61c71bf | ||
|
|
6a5f0d3e50 | ||
|
|
9b20221587 | ||
|
|
70b540e67f | ||
|
|
f76b26e5d7 | ||
|
|
19b6d3c999 | ||
|
|
49955e2dc8 | ||
|
|
cd6a4d0cd2 | ||
|
|
4f1cd6c8bc | ||
|
|
29fe12ef57 | ||
|
|
5116d62488 | ||
|
|
6387309f01 | ||
|
|
bb27307e25 | ||
|
|
0ad3baeea4 | ||
|
|
635d0f2a7c | ||
|
|
5f49f63e8f | ||
|
|
45dd54dfb3 | ||
|
|
bcf35813d8 | ||
|
|
327b514216 | ||
|
|
96f67109fe | ||
|
|
50d42f9fc9 | ||
|
|
e248a47a1f | ||
|
|
5d3e4bd0f8 | ||
|
|
3b3f0a84be | ||
|
|
9b55e982b3 | ||
|
|
712f1013f4 | ||
|
|
eb4bab70d1 | ||
|
|
d970c4e020 | ||
|
|
825157f998 | ||
|
|
c41f1797e8 | ||
|
|
f871e71823 | ||
|
|
a270b515d2 | ||
|
|
b90920e63a | ||
|
|
4def9c7ab1 | ||
|
|
79f102ecc5 | ||
|
|
1bdc56d251 | ||
|
|
d1d793f9e7 | ||
|
|
1c661f0a5d | ||
|
|
9db70222c0 | ||
|
|
42b16f1fbd | ||
|
|
34d4fac6e8 | ||
|
|
f63a290d34 | ||
|
|
68867c135d | ||
|
|
7ae55731fb | ||
|
|
cd24067ce7 | ||
|
|
3f1f65e4a3 | ||
|
|
0095487773 | ||
|
|
7d2e67b95d | ||
|
|
b0db7045f4 | ||
|
|
bfdab3a518 | ||
|
|
fc49c374bf | ||
|
|
4b776ca7bf | ||
|
|
0f58efa3cc | ||
|
|
0d3a8e5410 | ||
|
|
c6d3d72ce9 | ||
|
|
fc651c65ad | ||
|
|
9b86427884 | ||
|
|
849713eaea | ||
|
|
52db6d7b6a | ||
|
|
0434cd6bf8 | ||
|
|
dbab8591bf | ||
|
|
065649d1df | ||
|
|
2d2e0cdfeb | ||
|
|
c3e8f307b7 | ||
|
|
e03f1ef713 | ||
|
|
eb4f73b582 | ||
|
|
1609d1c2b0 | ||
|
|
3480620eca | ||
|
|
e694af304e | ||
|
|
581c04e66e | ||
|
|
2e737288ef | ||
|
|
18a1d51c19 | ||
|
|
db7ec7fe95 | ||
|
|
d619546735 | ||
|
|
b78b449895 | ||
|
|
f53198aec5 | ||
|
|
fa1728210a | ||
|
|
90674cefc4 | ||
|
|
24d4a21007 | ||
|
|
b4ad4e831d | ||
|
|
886d872241 | ||
|
|
0ef01b868e | ||
|
|
46f89771a5 | ||
|
|
055f473964 | ||
|
|
f3850dab24 | ||
|
|
86870c40a5 | ||
|
|
dbc33f9fe4 | ||
|
|
1f95fda03c | ||
|
|
1724f54b12 | ||
|
|
4b0132ed90 | ||
|
|
d219faafd0 | ||
|
|
6d19f60049 | ||
|
|
a8f1b23769 | ||
|
|
89cb93be67 | ||
|
|
bfe9aba3a8 | ||
|
|
5265ddd27c | ||
|
|
5e118f5e17 | ||
|
|
a522e8262a | ||
|
|
028bfd8ada | ||
|
|
d1ba1b8831 | ||
|
|
2a7c79235d | ||
|
|
ebaf94a5ec | ||
|
|
5c9b930737 | ||
|
|
9483582479 | ||
|
|
cd7b23a537 | ||
|
|
97609976e4 | ||
|
|
4262f1f9cd | ||
|
|
eb6237d913 | ||
|
|
fcf2edefe8 | ||
|
|
a7a9ef52f0 | ||
|
|
d8ad50fcf8 | ||
|
|
3a974ab51f | ||
|
|
9834830bda | ||
|
|
e673558179 | ||
|
|
bd17353576 | ||
|
|
4f0403d315 | ||
|
|
0232e7b212 | ||
|
|
68655dd92b | ||
|
|
28ffd08fbd | ||
|
|
4b92eb7912 | ||
|
|
6f76822785 | ||
|
|
165bc85dfa | ||
|
|
fdcb42caf2 | ||
|
|
7d5fcb22a8 | ||
|
|
c2beac9bfa | ||
|
|
49344d0f3c | ||
|
|
18b6ddca70 | ||
|
|
e901b5dd64 | ||
|
|
bf11a02d44 | ||
|
|
15f0295142 | ||
|
|
5c665053d2 | ||
|
|
cddf378b51 | ||
|
|
96bfb98c87 | ||
|
|
d0f85d69ab | ||
|
|
3374827e66 | ||
|
|
96d8fc6d21 | ||
|
|
1fd19db0f2 | ||
|
|
2ef717cd72 | ||
|
|
1868cee073 | ||
|
|
351742e88e | ||
|
|
bd67caaeb8 | ||
|
|
0f39521750 | ||
|
|
7fde4a379a | ||
|
|
5cc7e6f2bc | ||
|
|
f2f4a8d62b | ||
|
|
16f9eb32c9 | ||
|
|
3567b7d735 | ||
|
|
23a181c33a | ||
|
|
74b6bfca28 | ||
|
|
ef1074e7ba | ||
|
|
b02d7a3df2 | ||
|
|
6c3d6f25ac | ||
|
|
de4b9887b7 | ||
|
|
b7c9eabf8f | ||
|
|
ed43c51428 | ||
|
|
69bc454cc0 | ||
|
|
83b87cf9cb | ||
|
|
0f061764e6 | ||
|
|
77a6b8152e | ||
|
|
6a5e76512f | ||
|
|
24bad668bd | ||
|
|
a670961b99 | ||
|
|
f3896d3c78 | ||
|
|
04e9e57dad | ||
|
|
2bccff6ae6 | ||
|
|
3afa857965 | ||
|
|
3441da2bd5 | ||
|
|
898972d040 | ||
|
|
b0d0f18da2 | ||
|
|
1d3a828f55 | ||
|
|
310bb1ea10 | ||
|
|
7f8deb280a | ||
|
|
3204527b6f | ||
|
|
0354e2b5fc | ||
|
|
07dac7c20e | ||
|
|
bf09ad27b9 | ||
|
|
af3bbb3db8 | ||
|
|
f520af9250 | ||
|
|
df590b7083 | ||
|
|
9ec7b8d776 | ||
|
|
18580ced5a | ||
|
|
8dc6b1be29 | ||
|
|
649839c539 | ||
|
|
7401b9bbb0 | ||
|
|
068967fd74 | ||
|
|
20c07143aa | ||
|
|
fafa6e5191 | ||
|
|
327a986944 | ||
|
|
666cc8f81b | ||
|
|
7c81ae2fa4 | ||
|
|
8224019e23 | ||
|
|
b334d82e76 | ||
|
|
e28f416746 | ||
|
|
cd821c3d86 | ||
|
|
42fd096ac3 | ||
|
|
bff4a10355 | ||
|
|
bd52a7856d | ||
|
|
01fb89f378 | ||
|
|
4abe76816d | ||
|
|
e19283e387 | ||
|
|
03286746a0 | ||
|
|
e7ce4dddec | ||
|
|
cd9829bcae | ||
|
|
132f8d53a9 | ||
|
|
abb74ab2cf | ||
|
|
3d97cd1aa0 | ||
|
|
809f712e80 | ||
|
|
88877c7874 | ||
|
|
749f17efbe | ||
|
|
3ef1b424b1 | ||
|
|
bd0185f825 | ||
|
|
f86ed401b2 | ||
|
|
b9d01eb9d8 | ||
|
|
08a0d108b0 | ||
|
|
30b3c20c80 | ||
|
|
d56885c3f9 | ||
|
|
822a52b5b8 | ||
|
|
d8eb1d07f2 | ||
|
|
34956af6a2 | ||
|
|
1f15d0ba20 | ||
|
|
c4798df9dc | ||
|
|
a1fdc00a01 | ||
|
|
d85e7a2b0f | ||
|
|
c78727f15f | ||
|
|
dd1d85e3e4 | ||
|
|
e29c907188 | ||
|
|
450aec3191 | ||
|
|
c672086b8f | ||
|
|
ae3a3a795d | ||
|
|
2fa200b347 | ||
|
|
7d750a42ab | ||
|
|
f61f93a85d | ||
|
|
e0c38b59c1 | ||
|
|
198034ae67 | ||
|
|
10107a14fc | ||
|
|
0e18040bee | ||
|
|
ab92d8bdd3 | ||
|
|
6bf70f5b47 | ||
|
|
59dfa9fabb | ||
|
|
f4a48d5326 | ||
|
|
af5f0d9f85 | ||
|
|
ab6fa602cc | ||
|
|
a15b0c7cc8 | ||
|
|
86bffa503c | ||
|
|
511b331735 | ||
|
|
78d101dd80 | ||
|
|
70dc93cd09 | ||
|
|
fed8b95199 | ||
|
|
e8d8fb5af8 | ||
|
|
d98038ecf7 | ||
|
|
5ea3713a22 | ||
|
|
0d4cc8a505 | ||
|
|
9d0dc9f06d | ||
|
|
261b89792b | ||
|
|
089f0b0e18 | ||
|
|
53e7fbed0e | ||
|
|
988d118478 | ||
|
|
df7be9b51f | ||
|
|
dead95adad | ||
|
|
d69ad9ef9a | ||
|
|
b65bbb03a8 | ||
|
|
83d3ca01fe | ||
|
|
e7732b03f8 | ||
|
|
b742335ffb | ||
|
|
262a17659b | ||
|
|
191e24398a | ||
|
|
ae2a23f0aa | ||
|
|
59944eadf4 | ||
|
|
5208b090dd | ||
|
|
c14b18d24e | ||
|
|
01e2e6a19d | ||
|
|
71ca117931 | ||
|
|
bee7fef71a | ||
|
|
24b8105dcb | ||
|
|
a01e066dae | ||
|
|
e93f94f87c | ||
|
|
eb052cca32 | ||
|
|
b4c1b8c954 | ||
|
|
5d1b6a7d2a | ||
|
|
12bd685fe7 | ||
|
|
3616a18286 | ||
|
|
db6b3489de | ||
|
|
049f5f4123 | ||
|
|
b553f29b71 | ||
|
|
ea6e8ee74e | ||
|
|
6559603147 | ||
|
|
ab8839c07f | ||
|
|
2c83f6e5a5 | ||
|
|
fa4a4a0ca0 | ||
|
|
e9f0e1d7af | ||
|
|
c9cf4f8c9b | ||
|
|
89e20ef82a | ||
|
|
bab579f6f9 | ||
|
|
e26b1dac22 | ||
|
|
23d9c77305 | ||
|
|
8e49b4b400 | ||
|
|
e434e5df76 | ||
|
|
f9136dbf42 | ||
|
|
f144f66e88 | ||
|
|
ab37570e9b | ||
|
|
7a61bb6cdc | ||
|
|
5cf920c78e | ||
|
|
f1a5ca14bc | ||
|
|
e08e4645b1 | ||
|
|
1452b65879 | ||
|
|
85cb8a72ca |
No files matched your search
@@ -11,9 +11,10 @@ jobs:
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'adopt'
|
||||
@@ -21,34 +22,34 @@ jobs:
|
||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||
|
||||
- name: Build with Gradle
|
||||
run: gradle shadowJar
|
||||
run: chmod +x gradlew && ./gradlew shadowJar
|
||||
|
||||
- name: Upload build artifacts api
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: api-build
|
||||
path: api/build/libs
|
||||
|
||||
- name: Upload build artifacts spigot
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: spigot-build
|
||||
path: spigot/build/libs
|
||||
|
||||
- name: Upload build artifacts netty-common
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: netty-common-build
|
||||
path: netty-common/build/libs
|
||||
|
||||
- name: Upload build artifacts bungeecord
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bungeecord-build
|
||||
path: bungeecord/build/libs
|
||||
|
||||
- name: Upload build artifacts velocity
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: velocity-build
|
||||
path: velocity/build/libs
|
||||
@@ -102,6 +102,7 @@ $RECYCLE.BIN/
|
||||
|
||||
.gradle
|
||||
build/
|
||||
bin/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
@@ -118,3 +119,7 @@ run/
|
||||
!gradle-wrapper.jar
|
||||
/src/main/resources/plugin.yml
|
||||
/.idea/
|
||||
.vscode/
|
||||
.project
|
||||
.settings/
|
||||
.classpath
|
||||
@@ -1,20 +1,17 @@
|
||||
# packetevents
|
||||
|
||||
[](https://github.com/retrooper/packetevents/blob/dev/LICENSE)
|
||||
[](https://jitpack.io/#retrooper/packetevents)
|
||||
[](https://github.com/retrooper/packetevents/blob/2.0/LICENSE) [](https://github.com/retrooper/packetevents/actions) [](https://discord.gg/prqzNg9tRU)
|
||||
|
||||
PacketEvents is a powerful packet library. Our packet wrappers are efficient and easy to use. With our API, you can write code that runs on many platforms including Spigot, BungeeCord, Velocity, and even client-sided Fabric!
|
||||
PacketEvents is a fast and efficient multi-platform packet processing library. Our packet wrappers are easy to use with multi-version support. With our API you can write code that runs on Spigot, BungeeCord, Velocity, and Fabric! Switch to PacketEvents today by joining \
|
||||
our [Discord Server](https://discord.me/packetevents) for help.
|
||||
|
||||
### Resources
|
||||
* [SpigotMC](https://www.spigotmc.org/resources/packetevents-api.80279/)
|
||||
* [JavaDocs](https://packetevents.github.io/javadocs)
|
||||
* [Discord](https://discord.me/packetevents)
|
||||
### Links
|
||||
* [Find release builds on Modrinth](https://modrinth.com/plugin/packetevents)
|
||||
* [Find development builds on Jenkins](https://ci.codemc.io/job/retrooper/job/packetevents)
|
||||
* [View documentation on our JavaDocs Page](https://packetevents.github.io/javadocs)
|
||||
|
||||
### Setup
|
||||
[Learn more](https://github.com/retrooper/packetevents/wiki/Setup)
|
||||
|
||||
### Contributing
|
||||
[Learn more](https://github.com/retrooper/packetevents/wiki/Contributing)
|
||||
[How to Setup PacketEvents](https://github.com/retrooper/packetevents/wiki/Depending-on-pre%E2%80%90built-PacketEvents)
|
||||
|
||||
### Sponsorships
|
||||
[](https://www.ej-technologies.com/products/jprofiler/overview.html)
|
||||
@@ -23,11 +20,11 @@ PacketEvents is a powerful packet library. Our packet wrappers are efficient and
|
||||
PacketEvents optionally collects statistics using [bStats](https://bstats.org/)\
|
||||
Check out our [bStats page](https://bstats.org/plugin/bukkit/packetevents/11327)
|
||||
|
||||
### Credit to
|
||||
[wiki.vg/Protocol](https://wiki.vg/Protocol)
|
||||
[adventure](https://github.com/KyoriPowered/adventure)
|
||||
[gson](https://github.com/google/gson)
|
||||
[ViaVersion](https://github.com/ViaVersion/ViaVersion)
|
||||
[ProtocolSupport](https://github.com/ProtocolSupport/ProtocolSupport)
|
||||
### Credit to these projects
|
||||
[wiki.vg/Protocol](https://wiki.vg/Protocol)\
|
||||
[netty](https://github.com/netty/netty)\
|
||||
[gson](https://github.com/google/gson)\
|
||||
[adventure](https://github.com/KyoriPowered/adventure)\
|
||||
[ViaVersion](https://github.com/ViaVersion/ViaVersion)\
|
||||
[ProtocolSupport](https://github.com/ProtocolSupport/ProtocolSupport)\
|
||||
[MCProtocolLib](https://github.com/GeyserMC/MCProtocolLib/)
|
||||
[netty](https://github.com/netty/netty)
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -37,7 +37,8 @@ public abstract class PacketEventsAPI<T> {
|
||||
private static final UpdateChecker UPDATE_CHECKER = new UpdateChecker();
|
||||
private final Logger LOGGER = Logger.getLogger(PacketEventsAPI.class.getName());
|
||||
private static final LogManager LOG_MANAGER = new LogManager();
|
||||
private static final PEVersion VERSION = new PEVersion(2, 0, 0);
|
||||
//TODO UPDATE
|
||||
private static final PEVersion VERSION = new PEVersion(2, 0, 2);
|
||||
|
||||
public EventManager getEventManager() {
|
||||
return EVENT_MANAGER;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,15 +19,16 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.exception.InvalidHandshakeException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class EventManager {
|
||||
private final Map<Byte, HashSet<PacketListenerCommon>> listenersMap = new ConcurrentHashMap<>();
|
||||
private final Map<Byte, Set<PacketListenerCommon>> listenersMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Call the PacketEvent.
|
||||
@@ -44,13 +45,16 @@ public class EventManager {
|
||||
|
||||
public void callEvent(PacketEvent event, @Nullable Runnable postCallListenerAction) {
|
||||
for (byte priority = PacketListenerPriority.LOWEST.getId(); priority <= PacketListenerPriority.MONITOR.getId(); priority++) {
|
||||
HashSet<PacketListenerCommon> listeners = listenersMap.get(priority);
|
||||
Set<PacketListenerCommon> listeners = listenersMap.get(priority);
|
||||
if (listeners != null) {
|
||||
for (PacketListenerCommon listener : listeners) {
|
||||
try {
|
||||
event.call(listener);
|
||||
} catch (Throwable t) {
|
||||
PacketEvents.getAPI().getLogger().log(Level.WARNING, "PacketEvents caught an unhandled exception while calling your listener.", t);
|
||||
} catch (Exception t) {
|
||||
// ignore handshake exceptions
|
||||
if (t.getClass() != InvalidHandshakeException.class) {
|
||||
PacketEvents.getAPI().getLogger().log(Level.WARNING, "PacketEvents caught an unhandled exception while calling your listener.", t);
|
||||
}
|
||||
}
|
||||
if (postCallListenerAction != null) {
|
||||
postCallListenerAction.run();
|
||||
@@ -58,7 +62,8 @@ public class EventManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event instanceof ProtocolPacketEvent && PacketEvents.getAPI().getSettings().shouldListenersReadOnly()) {
|
||||
// For performance reasons, we don't want to re-encode the packet if it's not needed.
|
||||
if (event instanceof ProtocolPacketEvent && !((ProtocolPacketEvent<?>) event).needsReEncode()) {
|
||||
((ProtocolPacketEvent<?>) event).setLastUsedWrapper(null);
|
||||
}
|
||||
|
||||
@@ -76,9 +81,9 @@ public class EventManager {
|
||||
*/
|
||||
public PacketListenerCommon registerListener(PacketListenerCommon listener) {
|
||||
byte priority = listener.getPriority().getId();
|
||||
HashSet<PacketListenerCommon> listenerSet = listenersMap.get(priority);
|
||||
Set<PacketListenerCommon> listenerSet = listenersMap.get(priority);
|
||||
if (listenerSet == null) {
|
||||
listenerSet = new HashSet<>();
|
||||
listenerSet = ConcurrentHashMap.newKeySet();
|
||||
}
|
||||
listenerSet.add(listener);
|
||||
listenersMap.put(priority, listenerSet);
|
||||
@@ -98,7 +103,7 @@ public class EventManager {
|
||||
}
|
||||
|
||||
public void unregisterListener(PacketListenerCommon listener) {
|
||||
HashSet<PacketListenerCommon> listenerSet = listenersMap.get(listener.getPriority().getId());
|
||||
Set<PacketListenerCommon> listenerSet = listenersMap.get(listener.getPriority().getId());
|
||||
if (listenerSet == null) return;
|
||||
listenerSet.remove(listener);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,12 +23,15 @@ import com.github.retrooper.packetevents.event.simple.PacketPlaySendEvent;
|
||||
import com.github.retrooper.packetevents.event.simple.PacketStatusSendEvent;
|
||||
import com.github.retrooper.packetevents.exception.PacketProcessException;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.PacketSide;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PacketSendEvent extends ProtocolPacketEvent<Object> {
|
||||
private List<Runnable> tasksAfterSend = null;
|
||||
protected PacketSendEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
super(PacketSide.SERVER, channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
@@ -48,6 +51,18 @@ public class PacketSendEvent extends ProtocolPacketEvent<Object> {
|
||||
listener.onPacketSend(this);
|
||||
}
|
||||
|
||||
|
||||
public List<Runnable> getTasksAfterSend() {
|
||||
if (tasksAfterSend == null) {
|
||||
tasksAfterSend = new ArrayList<>();
|
||||
}
|
||||
return tasksAfterSend;
|
||||
}
|
||||
|
||||
public boolean hasTasksAfterSend() {
|
||||
return tasksAfterSend != null && !tasksAfterSend.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketSendEvent clone() {
|
||||
if (this instanceof PacketStatusSendEvent) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,9 +19,11 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.exception.InvalidDisconnectPacketSend;
|
||||
import com.github.retrooper.packetevents.exception.PacketProcessException;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.netty.buffer.UnpooledByteBufAllocationHelper;
|
||||
import com.github.retrooper.packetevents.netty.channel.ChannelHelper;
|
||||
import com.github.retrooper.packetevents.protocol.ConnectionState;
|
||||
import com.github.retrooper.packetevents.protocol.PacketSide;
|
||||
@@ -50,6 +52,7 @@ public abstract class ProtocolPacketEvent<T> extends PacketEvent implements Play
|
||||
private PacketWrapper<?> lastUsedWrapper;
|
||||
private List<Runnable> postTasks = null;
|
||||
private boolean cloned;
|
||||
private boolean needsReEncode = PacketEvents.getAPI().getSettings().reEncodeByDefault();
|
||||
|
||||
public ProtocolPacketEvent(PacketSide packetSide, Object channel,
|
||||
User user, T player, Object byteBuf,
|
||||
@@ -59,8 +62,7 @@ public abstract class ProtocolPacketEvent<T> extends PacketEvent implements Play
|
||||
this.player = player;
|
||||
if (autoProtocolTranslation || user.getClientVersion() == null) {
|
||||
this.serverVersion = PacketEvents.getAPI().getServerManager().getVersion();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//TODO Optimize
|
||||
this.serverVersion = user.getClientVersion().toServerVersion();
|
||||
}
|
||||
@@ -79,7 +81,11 @@ public abstract class ProtocolPacketEvent<T> extends PacketEvent implements Play
|
||||
this.packetType = PacketType.getById(packetSide, user.getConnectionState(),
|
||||
version, packetID);
|
||||
if (this.packetType == null) {
|
||||
throw new PacketProcessException("Failed to map the Packet ID " + packetID + " to a PacketType constant. Bound: " + packetSide.getOpposite() + ", Connection state: " + user.getConnectionState() + ", Server version: " + serverVersion.getReleaseName());
|
||||
// mojang fucked up and keeps sending disconnect packets in the wrong protocol state
|
||||
if (PacketType.getById(packetSide, ConnectionState.PLAY, version, packetID) == PacketType.Play.Server.DISCONNECT) {
|
||||
throw new InvalidDisconnectPacketSend();
|
||||
}
|
||||
throw new PacketProcessException("Failed to map the Packet ID " + packetID + " to a PacketType constant. Bound: " + packetSide.getOpposite() + ", Connection state: " + user.getConnectionState() + ", Server version: " + serverVersion.getReleaseName());
|
||||
}
|
||||
this.connectionState = user.getConnectionState();
|
||||
}
|
||||
@@ -97,6 +103,15 @@ public abstract class ProtocolPacketEvent<T> extends PacketEvent implements Play
|
||||
cloned = true;
|
||||
}
|
||||
|
||||
public void markForReEncode(boolean needsReEncode) {
|
||||
this.needsReEncode = needsReEncode;
|
||||
}
|
||||
|
||||
public boolean needsReEncode() {
|
||||
return needsReEncode;
|
||||
}
|
||||
|
||||
|
||||
public boolean isClone() {
|
||||
return cloned;
|
||||
}
|
||||
@@ -151,7 +166,6 @@ public abstract class ProtocolPacketEvent<T> extends PacketEvent implements Play
|
||||
this.byteBuf = byteBuf;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getPacketId() {
|
||||
return packetID;
|
||||
}
|
||||
@@ -206,4 +220,12 @@ public abstract class ProtocolPacketEvent<T> extends PacketEvent implements Play
|
||||
ByteBufHelper.release(byteBuf);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getFullBufferClone() {
|
||||
byte[] data = ByteBufHelper.copyBytes(getByteBuf());
|
||||
Object buffer = UnpooledByteBufAllocationHelper.buffer();
|
||||
ByteBufHelper.writeVarInt(buffer, getPacketId());
|
||||
ByteBufHelper.writeBytes(buffer, data);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.github.retrooper.packetevents.event.simple;
|
||||
|
||||
import com.github.retrooper.packetevents.event.PacketSendEvent;
|
||||
import com.github.retrooper.packetevents.exception.PacketProcessException;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
|
||||
public class PacketHandshakeSendEvent extends PacketSendEvent {
|
||||
public PacketHandshakeSendEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketHandshakeSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketHandshakeSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PacketType.Handshaking.Client getPacketType() {
|
||||
return (PacketType.Handshaking.Client) super.getPacketType();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.github.retrooper.packetevents.exception;
|
||||
|
||||
public class CancelPacketException extends RuntimeException {
|
||||
public static final CancelPacketException INSTANCE = new CancelPacketException();
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package com.github.retrooper.packetevents.exception;
|
||||
|
||||
public class InvalidDisconnectPacketSend extends RuntimeException {
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package com.github.retrooper.packetevents.exception;
|
||||
|
||||
public class InvalidHandshakeException extends RuntimeException {
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.exception;
|
||||
|
||||
public class PacketProcessException extends Exception {
|
||||
public class PacketProcessException extends RuntimeException {
|
||||
public PacketProcessException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.injector;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.ConnectionState;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface ChannelInjector {
|
||||
default boolean isServerBound() {
|
||||
@@ -31,13 +29,9 @@ public interface ChannelInjector {
|
||||
|
||||
void uninject();
|
||||
|
||||
User getUser(Object channel);
|
||||
|
||||
void changeConnectionState(Object channel, @Nullable ConnectionState connectionState);
|
||||
|
||||
void updateUser(Object channel, User user);
|
||||
|
||||
void setPlayer(Object channel, Object player);
|
||||
|
||||
boolean hasPlayer(Object player);
|
||||
boolean isProxy();
|
||||
}
|
||||
+36
-36
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -61,49 +61,59 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
//Update user profile
|
||||
user.getProfile().setUUID(profile.getUUID());
|
||||
user.getProfile().setName(profile.getName());
|
||||
//Texture properties are passed in login success on 1.19
|
||||
user.getProfile().setTextureProperties(profile.getTextureProperties());
|
||||
|
||||
//Map username with channel
|
||||
ProtocolManager.CHANNELS.put(profile.getName(), channel);
|
||||
PacketEvents.getAPI().getLogManager().debug("Mapped player username with their channel.");
|
||||
synchronized (channel) {
|
||||
ProtocolManager.CHANNELS.put(profile.getUUID(), channel);
|
||||
}
|
||||
|
||||
//Update connection state(injectors might do some adjustments when we transition into PLAY state)
|
||||
//This also updates it for the user instance
|
||||
event.getPostTasks().add(() -> {
|
||||
PacketEvents.getAPI().getInjector().changeConnectionState(channel, ConnectionState.PLAY);
|
||||
PacketEvents.getAPI().getLogManager().debug("Transitioned " + profile.getName() + " into the PLAY state!");
|
||||
});
|
||||
PacketEvents.getAPI().getLogManager().debug("Mapped player UUID with their channel.");
|
||||
|
||||
//Switch the user's connection state to PLAY, but the variable event.getConnectionState() remains LOGIN
|
||||
//We switch user state immediately to remain in sync with vanilla, allowing you to send PLAY packets immediately
|
||||
user.setConnectionState(ConnectionState.PLAY);
|
||||
PacketEvents.getAPI().getLogManager().debug("Transitioned " + profile.getName() + " into the PLAY state!");
|
||||
}
|
||||
|
||||
// Join game can be used to update world height, and sets dimension data
|
||||
|
||||
if (event.getPacketType() == PacketType.Play.Server.JOIN_GAME) {
|
||||
else if (event.getPacketType() == PacketType.Play.Server.JOIN_GAME) {
|
||||
WrapperPlayServerJoinGame joinGame = new WrapperPlayServerJoinGame(event);
|
||||
user.setEntityId(joinGame.getEntityId());
|
||||
user.setDimension(joinGame.getDimension());
|
||||
if (event.getServerVersion().isOlderThanOrEquals(ServerVersion.V_1_16_5)) {
|
||||
return; // Fixed world height, no tags are sent to the client
|
||||
}
|
||||
|
||||
// Store world height
|
||||
NBTList<NBTCompound> list = joinGame.getDimensionCodec()
|
||||
.getCompoundTagOrNull("minecraft:dimension_type").getCompoundListTagOrNull("value");
|
||||
NBTList<NBTCompound> list = joinGame.getDimensionCodec().getCompoundTagOrNull("minecraft:dimension_type").getCompoundListTagOrNull("value");
|
||||
user.setWorldNBT(list);
|
||||
|
||||
// Update world height
|
||||
NBTCompound worldNBT = user.getWorldNBT(joinGame.getDimension().getType().getName()).getCompoundTagOrNull("element");
|
||||
user.setMinWorldHeight(worldNBT.getNumberTagOrNull("min_y").getAsInt());
|
||||
user.setTotalWorldHeight(worldNBT.getNumberTagOrNull("height").getAsInt());
|
||||
NBTCompound dimension = user.getWorldNBT(joinGame.getDimension().getDimensionName());
|
||||
if (dimension != null) {
|
||||
NBTCompound worldNBT = dimension.getCompoundTagOrNull("element");
|
||||
user.setMinWorldHeight(worldNBT.getNumberTagOrNull("min_y").getAsInt());
|
||||
user.setTotalWorldHeight(worldNBT.getNumberTagOrNull("height").getAsInt());
|
||||
}
|
||||
}
|
||||
|
||||
// Respawn is used to switch dimensions
|
||||
if (event.getPacketType() == PacketType.Play.Server.RESPAWN) {
|
||||
if (event.getServerVersion()
|
||||
.isOlderThanOrEquals(ServerVersion.V_1_16_5)) {
|
||||
else if (event.getPacketType() == PacketType.Play.Server.RESPAWN) {
|
||||
WrapperPlayServerRespawn respawn = new WrapperPlayServerRespawn(event);
|
||||
user.setDimension(respawn.getDimension());
|
||||
if (event.getServerVersion().isOlderThanOrEquals(ServerVersion.V_1_16_5)) {
|
||||
return; // Fixed world height, no tags are sent to the client
|
||||
}
|
||||
WrapperPlayServerRespawn respawn = new WrapperPlayServerRespawn(event);
|
||||
|
||||
NBTCompound worldNBT = user.getWorldNBT(respawn.getDimension().getType().getName()).getCompoundTagOrNull("element"); // This is 1.17+, it always sends the world name
|
||||
user.setMinWorldHeight(worldNBT.getNumberTagOrNull("min_y").getAsInt());
|
||||
user.setTotalWorldHeight(worldNBT.getNumberTagOrNull("height").getAsInt());
|
||||
NBTCompound dimension = user.getWorldNBT(respawn.getDimension().getDimensionName());
|
||||
if (dimension != null) {
|
||||
NBTCompound worldNBT = dimension.getCompoundTagOrNull("element"); // This is 1.17+, it always sends the world name
|
||||
user.setMinWorldHeight(worldNBT.getNumberTagOrNull("min_y").getAsInt());
|
||||
user.setTotalWorldHeight(worldNBT.getNumberTagOrNull("height").getAsInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,25 +123,15 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
if (event.getPacketType() == PacketType.Handshaking.Client.HANDSHAKE) {
|
||||
Object channel = event.getChannel();
|
||||
InetSocketAddress address = event.getSocketAddress();
|
||||
WrapperHandshakingClientHandshake handshake;
|
||||
try {
|
||||
handshake = new WrapperHandshakingClientHandshake(event);
|
||||
} catch (ArrayIndexOutOfBoundsException exception) {
|
||||
user.closeConnection();
|
||||
PacketEvents.getAPI().getLogManager().debug("Disconnected " + address.getHostString() + ":" + address.getPort() + " for sending an invalid handshaking packet. They might be on an outdated client.");
|
||||
return;
|
||||
}
|
||||
WrapperHandshakingClientHandshake handshake = new WrapperHandshakingClientHandshake(event);
|
||||
ConnectionState nextState = handshake.getNextConnectionState();
|
||||
ClientVersion clientVersion = handshake.getClientVersion();
|
||||
|
||||
//Update client version for this event call(and user)
|
||||
user.setClientVersion(clientVersion);
|
||||
PacketEvents.getAPI().getLogManager().debug("Processed " + address.getHostString() + ":" + address.getPort() + "'s client version. Client Version: " + clientVersion.getReleaseName());
|
||||
event.getPostTasks().add(() -> {
|
||||
//Transition into the LOGIN OR STATUS connection state
|
||||
PacketEvents.getAPI().getInjector().changeConnectionState(channel, nextState);
|
||||
PacketEvents.getAPI().getLogManager().debug("Transitioned " + address.getHostString() + ":" + address.getPort() + " into the " + nextState + " state!");
|
||||
});
|
||||
//Transition into LOGIN or STATUS connection state immediately, to remain in sync with vanilla
|
||||
user.setConnectionState(nextState);
|
||||
PacketEvents.getAPI().getLogManager().debug("Transitioned " + address.getHostString() + ":" + address.getPort() + " into the " + nextState + " state!");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-51
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -32,7 +32,7 @@ public interface PlayerManager {
|
||||
|
||||
Object getChannel(@NotNull Object player);
|
||||
|
||||
@NotNull User getUser(@NotNull Object player);
|
||||
User getUser(@NotNull Object player);
|
||||
|
||||
default ConnectionState getConnectionState(@NotNull Object player) {
|
||||
return getUser(player).getConnectionState();
|
||||
@@ -41,96 +41,47 @@ public interface PlayerManager {
|
||||
default void sendPacket(@NotNull Object player, @NotNull Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void sendPacketAsync(@NotNull Object player, @NotNull Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacketAsync(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void sendPacket(@NotNull Object player, @NotNull PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(getChannel(player), wrapper);
|
||||
}
|
||||
|
||||
default void sendPacketAsync(@NotNull Object player, @NotNull PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacketAsync(getChannel(player), wrapper);
|
||||
}
|
||||
|
||||
default void sendPacketSilently(@NotNull Object player, @NotNull Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacketSilently(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void sendPacketSilentlyAsync(@NotNull Object player, @NotNull Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacketSilentlyAsync(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void sendPacketSilently(@NotNull Object player, @NotNull PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacketSilently(getChannel(player), wrapper);
|
||||
}
|
||||
|
||||
default void sendPacketSilentlyAsync(@NotNull Object player, @NotNull PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacketSilentlyAsync(getChannel(player), wrapper);
|
||||
}
|
||||
|
||||
default void writePacket(@NotNull Object player, @NotNull Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().writePacket(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void writePacketAsync(@NotNull Object player, @NotNull Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().writePacketAsync(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void writePacket(@NotNull Object player, @NotNull PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().writePacket(getChannel(player), wrapper);
|
||||
}
|
||||
|
||||
default void writePacketAsync(@NotNull Object player, @NotNull PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().writePacketAsync(getChannel(player), wrapper);
|
||||
}
|
||||
|
||||
default void writePacketSilently(@NotNull Object player, @NotNull Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().writePacketSilently(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void writePacketSilentlyAsync(@NotNull Object player, @NotNull Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().writePacketSilentlyAsync(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void writePacketSilently(@NotNull Object player, @NotNull PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().writePacketSilently(getChannel(player), wrapper);
|
||||
}
|
||||
|
||||
default void writePacketSilentlyAsync(@NotNull Object player, @NotNull PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().writePacketSilentlyAsync(getChannel(player), wrapper);
|
||||
}
|
||||
|
||||
default void receivePacket(Object player, Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().receivePacket(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void receivePacketAsync(Object player, Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().receivePacketAsync(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void receivePacket(Object player, PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().receivePacket(getChannel(player), wrapper);
|
||||
}
|
||||
|
||||
default void receivePacketAsync(Object player, PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().receivePacketAsync(getChannel(player), wrapper);
|
||||
}
|
||||
|
||||
default void receivePacketSilently(Object player, Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().receivePacketSilently(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void receivePacketSilentlyAsync(Object player, Object byteBuf) {
|
||||
PacketEvents.getAPI().getProtocolManager().receivePacketSilentlyAsync(getChannel(player), byteBuf);
|
||||
}
|
||||
|
||||
default void receivePacketSilently(Object player, PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().receivePacketSilently(getChannel(player), wrapper);
|
||||
}
|
||||
|
||||
default void receivePacketSilentlyAsync(Object player, PacketWrapper<?> wrapper) {
|
||||
PacketEvents.getAPI().getProtocolManager().receivePacketSilentlyAsync(getChannel(player), wrapper);
|
||||
}
|
||||
}
|
||||
+73
-116
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,21 +20,21 @@ package com.github.retrooper.packetevents.manager.protocol;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.netty.channel.ChannelHelper;
|
||||
import com.github.retrooper.packetevents.protocol.ConnectionState;
|
||||
import com.github.retrooper.packetevents.protocol.ProtocolVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.util.PacketTransformationUtil;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public interface ProtocolManager {
|
||||
Map<String, Object> CHANNELS = new ConcurrentHashMap<>();
|
||||
Map<UUID, Object> CHANNELS = new ConcurrentHashMap<>();
|
||||
// Use SocketAddress because ProtocolLib wraps Channels with NettyChannelProxy class
|
||||
Map<Object, User> USERS = new ConcurrentHashMap<>();
|
||||
|
||||
default Collection<User> getUsers() {
|
||||
@@ -47,163 +47,120 @@ public interface ProtocolManager {
|
||||
|
||||
//Methods to implement
|
||||
ProtocolVersion getPlatformVersion();
|
||||
|
||||
void sendPacket(Object channel, Object packet);
|
||||
|
||||
void sendPacketSilently(Object channel, Object packet);
|
||||
|
||||
void writePacket(Object channel, Object packet);
|
||||
|
||||
void writePacketSilently(Object channel, Object packet);
|
||||
|
||||
void receivePacket(Object channel, Object packet);
|
||||
|
||||
void receivePacketSilently(Object channel, Object packet);
|
||||
|
||||
void sendPacket(Object channel, Object byteBuf);
|
||||
void sendPacketSilently(Object channel, Object byteBuf);
|
||||
void writePacket(Object channel, Object byteBuf);
|
||||
void writePacketSilently(Object channel, Object byteBuf);
|
||||
void receivePacket(Object channel, Object byteBuf);
|
||||
void receivePacketSilently(Object channel, Object byteBuf);
|
||||
ClientVersion getClientVersion(Object channel);
|
||||
//TODO Define method that accepts an array of channels/set/list of channels.
|
||||
|
||||
default void sendPacketAsync(Object channel, Object byteBuf) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
sendPacket(channel, byteBuf);
|
||||
});
|
||||
default void sendPackets(Object channel, Object... byteBuf) {
|
||||
for (Object buf : byteBuf) {
|
||||
sendPacket(channel, buf);
|
||||
}
|
||||
}
|
||||
|
||||
default void sendPacketSilentlyAsync(Object channel, Object byteBuf) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
sendPacketSilently(channel, byteBuf);
|
||||
});
|
||||
default void sendPacketsSilently(Object channel, Object... byteBuf) {
|
||||
for (Object buf : byteBuf) {
|
||||
sendPacketSilently(channel, buf);
|
||||
}
|
||||
}
|
||||
|
||||
default void writePacketAsync(Object channel, Object byteBuf) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
writePacket(channel, byteBuf);
|
||||
});
|
||||
default void writePackets(Object channel, Object... byteBuf) {
|
||||
for (Object buf : byteBuf) {
|
||||
writePacket(channel, buf);
|
||||
}
|
||||
}
|
||||
|
||||
default void writePacketSilentlyAsync(Object channel, Object byteBuf) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
writePacketSilently(channel, byteBuf);
|
||||
});
|
||||
default void writePacketsSilently(Object channel, Object... byteBuf) {
|
||||
for (Object buf : byteBuf) {
|
||||
writePacketSilently(channel, buf);
|
||||
}
|
||||
}
|
||||
|
||||
default void receivePacketAsync(Object channel, Object byteBuf) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
receivePacket(channel, byteBuf);
|
||||
});
|
||||
default void receivePackets(Object channel, Object... byteBuf) {
|
||||
for (Object buf : byteBuf) {
|
||||
receivePacket(channel, buf);
|
||||
}
|
||||
}
|
||||
|
||||
default void receivePacketSilentlyAsync(Object channel, Object byteBuf) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
receivePacketSilently(channel, byteBuf);
|
||||
});
|
||||
default void receivePacketsSilently(Object channel, Object... byteBuf) {
|
||||
for (Object buf : byteBuf) {
|
||||
receivePacketSilently(channel, buf);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO Make it clear that this only updates the connection state in our user.
|
||||
//Sometimes you should use getInjector().changeConnectionState because that can allow the injector to make adjustments.
|
||||
//This is very important, especially on Spigot.
|
||||
//As soon as we switch to the play state on spigot, our injector makes some adjustments.
|
||||
default void changeConnectionState(Object channel, ConnectionState connectionState) {
|
||||
getUser(channel).setConnectionState(connectionState);
|
||||
}
|
||||
|
||||
default void setClientVersion(Object channel, ClientVersion version) {
|
||||
getUser(channel).setClientVersion(version);
|
||||
}
|
||||
|
||||
default void sendPacket(Object channel, PacketWrapper<?> wrapper) {
|
||||
@ApiStatus.Internal
|
||||
default Object[] transformWrappers(PacketWrapper<?> wrapper, Object channel, boolean outgoing) {
|
||||
//It is possible that our packet transformer util decides to transform one wrapper into multiple packets.
|
||||
//(Correcting some mistakes on your end)
|
||||
PacketWrapper<?>[] wrappers = PacketTransformationUtil.transform(wrapper);
|
||||
for (PacketWrapper<?> packet : wrappers) {
|
||||
packet.prepareForSend();
|
||||
sendPacket(channel, packet.buffer);
|
||||
Object[] buffers = new Object[wrappers.length];
|
||||
for (int i = 0; i < wrappers.length; i++) {
|
||||
wrappers[i].prepareForSend(channel, outgoing);
|
||||
buffers[i] = wrappers[i].buffer;
|
||||
// Fix race condition when sending packets to multiple people (due to when the buffer is freed)
|
||||
wrappers[i].buffer = null;
|
||||
}
|
||||
return buffers;
|
||||
}
|
||||
|
||||
default void sendPacketAsync(Object channel, PacketWrapper<?> wrapper) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
sendPacket(channel, wrapper);
|
||||
});
|
||||
default void sendPacket(Object channel, PacketWrapper<?> wrapper) {
|
||||
Object[] transformed = transformWrappers(wrapper, channel, true);
|
||||
sendPackets(channel, transformed);
|
||||
}
|
||||
|
||||
default void sendPacketSilently(Object channel, PacketWrapper<?> wrapper) {
|
||||
PacketWrapper<?>[] wrappers = PacketTransformationUtil.transform(wrapper);
|
||||
for (PacketWrapper<?> packet : wrappers) {
|
||||
packet.prepareForSend();
|
||||
sendPacketSilently(channel, packet.buffer);
|
||||
}
|
||||
}
|
||||
|
||||
default void sendPacketSilentlyAsync(Object channel, PacketWrapper<?> wrapper) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
sendPacketSilently(channel, wrapper);
|
||||
});
|
||||
Object[] transformed = transformWrappers(wrapper, channel, true);
|
||||
sendPacketsSilently(channel, transformed);
|
||||
}
|
||||
|
||||
default void writePacket(Object channel, PacketWrapper<?> wrapper) {
|
||||
PacketWrapper<?>[] wrappers = PacketTransformationUtil.transform(wrapper);
|
||||
for (PacketWrapper<?> packet : wrappers) {
|
||||
packet.prepareForSend();
|
||||
writePacket(channel, packet.buffer);
|
||||
}
|
||||
}
|
||||
|
||||
default void writePacketAsync(Object channel, PacketWrapper<?> wrapper) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
writePacket(channel, wrapper);
|
||||
});
|
||||
Object[] transformed = transformWrappers(wrapper, channel, true);
|
||||
writePackets(channel, transformed);
|
||||
}
|
||||
|
||||
default void writePacketSilently(Object channel, PacketWrapper<?> wrapper) {
|
||||
PacketWrapper<?>[] wrappers = PacketTransformationUtil.transform(wrapper);
|
||||
for (PacketWrapper<?> packet : wrappers) {
|
||||
packet.prepareForSend();
|
||||
writePacketSilently(channel, packet.buffer);
|
||||
}
|
||||
}
|
||||
|
||||
default void writePacketSilentlyAsync(Object channel, PacketWrapper<?> wrapper) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
writePacketSilently(channel, wrapper);
|
||||
});
|
||||
Object[] transformed = transformWrappers(wrapper, channel, true);
|
||||
writePacketsSilently(channel, transformed);
|
||||
}
|
||||
|
||||
default void receivePacket(Object channel, PacketWrapper<?> wrapper) {
|
||||
PacketWrapper<?>[] wrappers = PacketTransformationUtil.transform(wrapper);
|
||||
for (PacketWrapper<?> packet : wrappers) {
|
||||
packet.prepareForSend();
|
||||
receivePacket(channel, packet.buffer);
|
||||
}
|
||||
}
|
||||
|
||||
default void receivePacketAsync(Object channel, PacketWrapper<?> wrapper) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
receivePacket(channel, wrapper);
|
||||
});
|
||||
Object[] transformed = transformWrappers(wrapper, channel, false);
|
||||
receivePackets(channel, transformed);
|
||||
}
|
||||
|
||||
default void receivePacketSilently(Object channel, PacketWrapper<?> wrapper) {
|
||||
PacketWrapper<?>[] wrappers = PacketTransformationUtil.transform(wrapper);
|
||||
for (PacketWrapper<?> packet : wrappers) {
|
||||
packet.prepareForSend();
|
||||
receivePacketSilently(channel, packet.buffer);
|
||||
}
|
||||
}
|
||||
|
||||
default void receivePacketSilentlyAsync(Object channel, PacketWrapper<?> wrapper) {
|
||||
ChannelHelper.runInEventLoop(channel, () -> {
|
||||
receivePacketSilently(channel, wrapper);
|
||||
});
|
||||
Object[] transformed = transformWrappers(wrapper, channel, false);
|
||||
receivePacketsSilently(channel, transformed);
|
||||
}
|
||||
|
||||
default User getUser(Object channel) {
|
||||
return USERS.get(channel);
|
||||
Object pipeline = ChannelHelper.getPipeline(channel);
|
||||
return USERS.get(pipeline);
|
||||
}
|
||||
|
||||
default User removeUser(Object channel) {
|
||||
Object pipeline = ChannelHelper.getPipeline(channel);
|
||||
return USERS.remove(pipeline);
|
||||
}
|
||||
|
||||
default void setUser(Object channel, User user) {
|
||||
USERS.put(channel, user);
|
||||
synchronized (channel) {
|
||||
Object pipeline = ChannelHelper.getPipeline(channel);
|
||||
USERS.put(pipeline, user);
|
||||
}
|
||||
PacketEvents.getAPI().getInjector().updateUser(channel, user);
|
||||
}
|
||||
|
||||
default Object getChannel(String username) {
|
||||
return CHANNELS.get(username);
|
||||
default Object getChannel(UUID uuid) {
|
||||
return CHANNELS.get(uuid);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+50
-55
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.manager.server;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Server Version.
|
||||
@@ -30,7 +31,7 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
* @since 1.6.9
|
||||
*/
|
||||
public enum ServerVersion {
|
||||
//TODO Rename to PlatformVersion or LocalVersion or Version?
|
||||
//TODO Rename to MinecraftVersion?
|
||||
V_1_7_10(5),
|
||||
V_1_8(47), V_1_8_3(47), V_1_8_8(47),
|
||||
V_1_9(107), V_1_9_2(109), V_1_9_4(110),
|
||||
@@ -44,6 +45,10 @@ public enum ServerVersion {
|
||||
V_1_16(735), V_1_16_1(736), V_1_16_2(751), V_1_16_3(753), V_1_16_4(754), V_1_16_5(754),
|
||||
V_1_17(755), V_1_17_1(756),
|
||||
V_1_18(757), V_1_18_1(757), V_1_18_2(758),
|
||||
//1.19.1 and 1.19.2 have the same protocol version
|
||||
V_1_19(759), V_1_19_1(760), V_1_19_2(760), V_1_19_3(761), V_1_19_4(762),
|
||||
//1.20 and 1.20.1 have the same protocol version
|
||||
V_1_20(763), V_1_20_1(763),
|
||||
//TODO UPDATE Add server version constant
|
||||
ERROR(-1, true);
|
||||
|
||||
@@ -64,6 +69,7 @@ public enum ServerVersion {
|
||||
|
||||
private final int protocolVersion;
|
||||
private final String name;
|
||||
private ClientVersion toClientVersion;
|
||||
|
||||
ServerVersion(int protocolVersion) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
@@ -84,17 +90,17 @@ public enum ServerVersion {
|
||||
}
|
||||
|
||||
public static ServerVersion getLatest() {
|
||||
return reversedValues()[1];
|
||||
return REVERSED_VALUES[1];
|
||||
}
|
||||
|
||||
public static ServerVersion getOldest() {
|
||||
return values()[0];
|
||||
return VALUES[0];
|
||||
}
|
||||
|
||||
//TODO Optimize
|
||||
@Deprecated
|
||||
public static ServerVersion getById(int protocolVersion) {
|
||||
for (ServerVersion version : values()) {
|
||||
for (ServerVersion version : VALUES) {
|
||||
if (version.protocolVersion == protocolVersion) {
|
||||
return version;
|
||||
}
|
||||
@@ -103,12 +109,16 @@ public enum ServerVersion {
|
||||
}
|
||||
|
||||
public ClientVersion toClientVersion() {
|
||||
return ClientVersion.getById(this.protocolVersion);
|
||||
if (toClientVersion == null) {
|
||||
toClientVersion = ClientVersion.getById(protocolVersion);
|
||||
}
|
||||
return toClientVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the release name of this server version.
|
||||
* For example, for the V_1_18 enum constant, it would return "1.18".
|
||||
*
|
||||
* @return Release name
|
||||
*/
|
||||
public String getReleaseName() {
|
||||
@@ -133,31 +143,7 @@ public enum ServerVersion {
|
||||
* @return Is this server version newer than the compared server version.
|
||||
*/
|
||||
public boolean isNewerThan(ServerVersion target) {
|
||||
/*
|
||||
* Some server versions have the same protocol version in the minecraft protocol.
|
||||
* We still need this method to work in such cases.
|
||||
* We first check if this is the case, if the protocol versions aren't the same, we can just use the protocol versions
|
||||
* to compare the server versions.
|
||||
*/
|
||||
if (target.protocolVersion != protocolVersion || this == target) {
|
||||
return protocolVersion > target.protocolVersion;
|
||||
}
|
||||
|
||||
/*
|
||||
* The server versions unfortunately have the same protocol version.
|
||||
* We need to look at this "reversedValues" variable.
|
||||
* The reversed values variable is an array containing all enum constants in this enum but in a reversed order.
|
||||
* I already made this variable a while ago for a different usage, you can check that out.
|
||||
* The first one we find in the array is the newer version.
|
||||
*/
|
||||
for (ServerVersion version : reversedValues()) {
|
||||
if (version == target) {
|
||||
return false;
|
||||
}
|
||||
if (version == this) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return this.ordinal() > target.ordinal();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,28 +155,7 @@ public enum ServerVersion {
|
||||
* @return Is this server version older than the compared server version.
|
||||
*/
|
||||
public boolean isOlderThan(ServerVersion target) {
|
||||
/*
|
||||
* Some server versions have the same protocol version in the minecraft protocol.
|
||||
* We still need this method to work in such cases.
|
||||
* We first check if this is the case, if the protocol versions aren't the same, we can just use the protocol versions
|
||||
* to compare the server versions.
|
||||
*/
|
||||
if (target.protocolVersion != protocolVersion || this == target) {
|
||||
return protocolVersion < target.protocolVersion;
|
||||
}
|
||||
/*
|
||||
* The server versions unfortunately have the same protocol version.
|
||||
* We look at all enum constants in the ServerVersion enum in the order they have been defined in.
|
||||
* The first one we find in the array is the newer version.
|
||||
*/
|
||||
for (ServerVersion version : VALUES) {
|
||||
if (version == this) {
|
||||
return true;
|
||||
} else if (version == target) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return this.ordinal() < target.ordinal();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,7 +167,7 @@ public enum ServerVersion {
|
||||
* @return Is this server version newer than or equal to the compared server version.
|
||||
*/
|
||||
public boolean isNewerThanOrEquals(ServerVersion target) {
|
||||
return this == target || isNewerThan(target);
|
||||
return this.ordinal() >= target.ordinal();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,6 +179,36 @@ public enum ServerVersion {
|
||||
* @return Is this server version older than or equal to the compared server version.
|
||||
*/
|
||||
public boolean isOlderThanOrEquals(ServerVersion target) {
|
||||
return this == target || isOlderThan(target);
|
||||
return this.ordinal() <= target.ordinal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this server version newer than, older than or equal to the compared server version?
|
||||
* This method simply checks if this server version's protocol version is greater than, less than or equal to
|
||||
* the compared server version's protocol version.
|
||||
*
|
||||
* @param comparison Comparison type.
|
||||
* @param targetVersion Compared server version.
|
||||
* @return true or false, based on the comparison type.
|
||||
* @see #isNewerThan(ServerVersion)
|
||||
* @see #isNewerThanOrEquals(ServerVersion)
|
||||
* @see #isOlderThan(ServerVersion)
|
||||
* @see #isOlderThanOrEquals(ServerVersion)
|
||||
*/
|
||||
public boolean is(@NotNull VersionComparison comparison, @NotNull ServerVersion targetVersion) {
|
||||
switch (comparison) {
|
||||
case EQUALS:
|
||||
return protocolVersion == targetVersion.protocolVersion;
|
||||
case NEWER_THAN:
|
||||
return isNewerThan(targetVersion);
|
||||
case NEWER_THAN_OR_EQUALS:
|
||||
return isNewerThanOrEquals(targetVersion);
|
||||
case OLDER_THAN:
|
||||
return isOlderThan(targetVersion);
|
||||
case OLDER_THAN_OR_EQUALS:
|
||||
return isOlderThanOrEquals(targetVersion);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.manager.server;
|
||||
|
||||
/**
|
||||
* This enum contains all possible comparison types for server versions.
|
||||
*/
|
||||
public enum VersionComparison {
|
||||
/*
|
||||
The server version equals the compared server version.
|
||||
*/
|
||||
EQUALS,
|
||||
/*
|
||||
The server version is newer than the compared server version.
|
||||
*/
|
||||
NEWER_THAN,
|
||||
/*
|
||||
The server version is newer than or equal to the compared server version.
|
||||
*/
|
||||
NEWER_THAN_OR_EQUALS,
|
||||
/*
|
||||
The server version is older than the compared server version.
|
||||
*/
|
||||
OLDER_THAN,
|
||||
/*
|
||||
The server version is older than or equal to the compared server version.
|
||||
*/
|
||||
OLDER_THAN_OR_EQUALS;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,6 +23,14 @@ import com.github.retrooper.packetevents.PacketEvents;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class ByteBufHelper {
|
||||
public static int capacity(Object buffer) {
|
||||
return PacketEvents.getAPI().getNettyManager().getByteBufOperator().capacity(buffer);
|
||||
}
|
||||
|
||||
public static Object capacity(Object buffer, int capacity) {
|
||||
return PacketEvents.getAPI().getNettyManager().getByteBufOperator().capacity(buffer, capacity);
|
||||
}
|
||||
|
||||
public static int readerIndex(Object buffer) {
|
||||
return PacketEvents.getAPI().getNettyManager().getByteBufOperator().readerIndex(buffer);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+3
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,6 +21,8 @@ package com.github.retrooper.packetevents.netty.buffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public interface ByteBufOperator {
|
||||
int capacity(Object buffer);
|
||||
Object capacity(Object buffer, int capacity);
|
||||
int readerIndex(Object buffer);
|
||||
Object readerIndex(Object buffer, int readerIndex);
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+9
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -81,6 +81,10 @@ public class ChannelHelper {
|
||||
return Arrays.toString(pipelineHandlerNames(channel).toArray(new String[0]));
|
||||
}
|
||||
|
||||
public static Object getPipeline(Object channel) {
|
||||
return PacketEvents.getAPI().getNettyManager().getChannelOperator().getPipeline(channel);
|
||||
}
|
||||
|
||||
public static Object getPipelineHandler(Object channel, String name) {
|
||||
return PacketEvents.getAPI().getNettyManager().getChannelOperator().getPipelineHandler(channel, name);
|
||||
}
|
||||
@@ -89,6 +93,10 @@ public class ChannelHelper {
|
||||
return PacketEvents.getAPI().getNettyManager().getChannelOperator().getPipelineContext(channel, handlerName);
|
||||
}
|
||||
|
||||
public static Object pooledByteBuf(Object channel) {
|
||||
return PacketEvents.getAPI().getNettyManager().getChannelOperator().pooledByteBuf(channel);
|
||||
}
|
||||
|
||||
public static void runInEventLoop(Object channel, Runnable runnable) {
|
||||
PacketEvents.getAPI().getNettyManager().getChannelOperator().runInEventLoop(channel, runnable);
|
||||
}
|
||||
|
||||
+19
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,26 +20,41 @@ package com.github.retrooper.packetevents.netty.channel;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ChannelOperator {
|
||||
Set<Class<? extends Throwable>> getIgnoredHandlerExceptions();
|
||||
|
||||
SocketAddress remoteAddress(Object channel);
|
||||
|
||||
SocketAddress localAddress(Object channel);
|
||||
|
||||
boolean isOpen(Object channel);
|
||||
|
||||
Object close(Object channel);
|
||||
|
||||
Object write(Object channel, Object buffer);
|
||||
|
||||
Object flush(Object channel);
|
||||
|
||||
Object writeAndFlush(Object channel, Object buffer);
|
||||
|
||||
Object fireChannelRead(Object channel, Object buffer);
|
||||
|
||||
Object writeInContext(Object channel, String ctx, Object buffer);
|
||||
|
||||
Object flushInContext(Object channel, String ctx);
|
||||
|
||||
Object writeAndFlushInContext(Object channel, String ctx, Object buffer);
|
||||
|
||||
Object fireChannelReadInContext(Object channel, String ctx, Object buffer);
|
||||
|
||||
List<String> pipelineHandlerNames(Object channel);
|
||||
|
||||
Object getPipelineHandler(Object channel, String name);
|
||||
|
||||
Object getPipelineContext(Object channel, String name);
|
||||
|
||||
Object getPipeline(Object channel);
|
||||
|
||||
void runInEventLoop(Object channel, Runnable runnable);
|
||||
|
||||
Object pooledByteBuf(Object channel);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,6 +26,9 @@ public enum ConnectionState {
|
||||
HANDSHAKING, STATUS, LOGIN, PLAY;
|
||||
|
||||
public static ConnectionState getById(int id) {
|
||||
if (id >= values().length || id < 0) {
|
||||
return null;
|
||||
}
|
||||
return values()[id];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
public enum ChatCompletionAction {
|
||||
ADD,
|
||||
REMOVE,
|
||||
SET;
|
||||
|
||||
private static final ChatCompletionAction[] VALUES = values();
|
||||
|
||||
public static ChatCompletionAction fromId(int id) {
|
||||
return VALUES[id];
|
||||
}
|
||||
}
|
||||
+4
-12
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,16 +18,8 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
public enum ChatPosition {
|
||||
CHAT,
|
||||
SYSTEM,
|
||||
GAME_INFO;
|
||||
|
||||
public int getId() {
|
||||
return ordinal();
|
||||
}
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
|
||||
public interface ChatType extends MappedEntity {
|
||||
|
||||
public static ChatPosition getById(int id) {
|
||||
return values()[id];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.TypesBuilder;
|
||||
import com.github.retrooper.packetevents.util.TypesBuilderData;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatTypes {
|
||||
private static final Map<String, ChatType> CHAT_TYPE_MAP = new HashMap<>();
|
||||
//Key - mappings version, value - map with chat type ids and chat types
|
||||
private static final Map<Byte, Map<Integer, ChatType>> CHAT_TYPE_ID_MAP = new HashMap<>();
|
||||
private static final TypesBuilder TYPES_BUILDER = new TypesBuilder("chat/chat_type_mappings",
|
||||
ClientVersion.V_1_18_2,
|
||||
ClientVersion.V_1_19,
|
||||
ClientVersion.V_1_19_1);
|
||||
|
||||
static {
|
||||
TYPES_BUILDER.unloadFileMappings();
|
||||
}
|
||||
|
||||
public static ChatType define(String key) {
|
||||
TypesBuilderData data = TYPES_BUILDER.define(key);
|
||||
ChatType chatType = new ChatType() {
|
||||
private final int[] ids = data.getData();
|
||||
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return data.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId(ClientVersion version) {
|
||||
int index = TYPES_BUILDER.getDataIndex(version);
|
||||
return ids[index];
|
||||
}
|
||||
};
|
||||
CHAT_TYPE_MAP.put(chatType.getName().toString(), chatType);
|
||||
for (ClientVersion version : TYPES_BUILDER.getVersions()) {
|
||||
int index = TYPES_BUILDER.getDataIndex(version);
|
||||
Map<Integer, ChatType> typeIdMap = CHAT_TYPE_ID_MAP.computeIfAbsent((byte) index, k -> new HashMap<>());
|
||||
typeIdMap.put(chatType.getId(version), chatType);
|
||||
}
|
||||
return chatType;
|
||||
}
|
||||
|
||||
//with minecraft:key
|
||||
public static ChatType getByName(String name) {
|
||||
return CHAT_TYPE_MAP.get(name);
|
||||
}
|
||||
|
||||
public static ChatType getById(ClientVersion version, int id) {
|
||||
int index = TYPES_BUILDER.getDataIndex(version);
|
||||
return CHAT_TYPE_ID_MAP.get((byte) index).get(id);
|
||||
}
|
||||
|
||||
public static final ChatType CHAT = define("chat");
|
||||
public static final ChatType SAY_COMMAND = define("say_command");
|
||||
public static final ChatType MSG_COMMAND_INCOMING = define("msg_command_incoming");
|
||||
public static final ChatType MSG_COMMAND_OUTGOING = define("msg_command_outgoing");
|
||||
public static final ChatType TEAM_MSG_COMMAND_INCOMING = define("team_msg_command_incoming");
|
||||
public static final ChatType TEAM_MSG_COMMAND_OUTGOING = define("team_msg_command_outgoing");
|
||||
public static final ChatType EMOTE_COMMAND = define("emote_command");
|
||||
public static final ChatType RAW = define("raw");
|
||||
|
||||
@Deprecated
|
||||
public static final ChatType SYSTEM = define("system");
|
||||
@Deprecated
|
||||
public static final ChatType GAME_INFO = define("game_info");
|
||||
@Deprecated
|
||||
public static final ChatType MSG_COMMAND = define("msg_command");
|
||||
@Deprecated
|
||||
public static final ChatType TEAM_MSG_COMMAND = define("team_msg_command");
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LastSeenMessages {
|
||||
public static final LastSeenMessages EMPTY = new LastSeenMessages(new ArrayList<>());
|
||||
|
||||
private final List<Entry> entries;
|
||||
|
||||
public LastSeenMessages(List<Entry> entries) {
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
public void updateHash(DataOutput output) throws IOException {
|
||||
for (Entry entry : this.entries) {
|
||||
UUID uuid = entry.getUUID();
|
||||
byte[] lastVerifier = entry.getLastVerifier();
|
||||
output.writeByte(70);
|
||||
output.writeLong(uuid.getMostSignificantBits());
|
||||
output.writeLong(uuid.getLeastSignificantBits());
|
||||
output.write(lastVerifier);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Entry> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public static class Packed {
|
||||
private List<MessageSignature.Packed> packedMessageSignatures;
|
||||
|
||||
public Packed(List<MessageSignature.Packed> packedMessageSignatures) {
|
||||
this.packedMessageSignatures = packedMessageSignatures;
|
||||
}
|
||||
|
||||
public List<MessageSignature.Packed> getPackedMessageSignatures() {
|
||||
return packedMessageSignatures;
|
||||
}
|
||||
|
||||
public void setPackedMessageSignatures(List<MessageSignature.Packed> packedMessageSignatures) {
|
||||
this.packedMessageSignatures = packedMessageSignatures;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Entry {
|
||||
private final UUID uuid;
|
||||
private final byte[] signature;
|
||||
|
||||
public Entry(UUID uuid, byte[] lastVerifier) {
|
||||
this.uuid = uuid;
|
||||
this.signature = lastVerifier;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public byte[] getLastVerifier() {
|
||||
return signature;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LegacyUpdate {
|
||||
private final LastSeenMessages lastSeenMessages;
|
||||
private final @Nullable Entry lastReceived;
|
||||
|
||||
public LegacyUpdate(LastSeenMessages lastSeenMessages, @Nullable Entry lastReceived) {
|
||||
this.lastSeenMessages = lastSeenMessages;
|
||||
this.lastReceived = lastReceived;
|
||||
}
|
||||
|
||||
public LastSeenMessages getLastSeenMessages() {
|
||||
return lastSeenMessages;
|
||||
}
|
||||
|
||||
public @Nullable Entry getLastReceived() {
|
||||
return lastReceived;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Update {
|
||||
private final int offset;
|
||||
private final BitSet acknowledged;
|
||||
|
||||
public Update(int offset, BitSet acknowledged) {
|
||||
this.offset = offset;
|
||||
this.acknowledged = acknowledged;
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public BitSet getAcknowledged() {
|
||||
return acknowledged;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class MessageSender {
|
||||
private @NotNull UUID uuid;
|
||||
private @Nullable Component displayName;
|
||||
private @Nullable Component teamName;
|
||||
|
||||
public MessageSender(@NotNull UUID uuid, @Nullable Component displayName, @Nullable Component teamName) {
|
||||
this.uuid = uuid;
|
||||
this.displayName = displayName;
|
||||
this.teamName = teamName;
|
||||
}
|
||||
|
||||
public MessageSender(@Nullable Component displayName, @Nullable Component teamName) {
|
||||
this(new UUID(0L, 0L), displayName, teamName);
|
||||
}
|
||||
|
||||
public MessageSender() {
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUUID(@NotNull UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public @Nullable Component getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(@Nullable Component displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public @Nullable Component getTeamName() {
|
||||
return teamName;
|
||||
}
|
||||
|
||||
public void setTeamName(@Nullable Component teamName) {
|
||||
this.teamName = teamName;
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2023 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MessageSignature {
|
||||
private byte[] bytes;
|
||||
|
||||
public MessageSignature(byte[] bytes) {
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public void setBytes(byte[] bytes) {
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public static class Packed {
|
||||
private int id;
|
||||
private @Nullable MessageSignature fullSignature;
|
||||
|
||||
public Packed(@Nullable MessageSignature fullSignature) {
|
||||
this.id = -1;
|
||||
this.fullSignature = fullSignature;
|
||||
}
|
||||
|
||||
public Packed(int id) {
|
||||
this.id = id;
|
||||
this.fullSignature = null;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Optional<MessageSignature> getFullSignature() {
|
||||
return Optional.ofNullable(fullSignature);
|
||||
}
|
||||
|
||||
public void setFullSignature(@Nullable MessageSignature fullSignature) {
|
||||
this.fullSignature = fullSignature;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Node {
|
||||
private byte flags;
|
||||
private List<Integer> children;
|
||||
private Optional<Integer> redirectNodeIndex;
|
||||
private Optional<String> name;
|
||||
private Optional<Integer> parserID;
|
||||
private Optional<List<Object>> properties;
|
||||
private Optional<ResourceLocation> suggestionsType;
|
||||
|
||||
public Node(byte flags, List<Integer> children, @Nullable Integer redirectNodeIndex, @Nullable String name, @Nullable Integer parserID, @Nullable List<Object> properties, @Nullable ResourceLocation suggestionsType) {
|
||||
this.flags = flags;
|
||||
this.children = children;
|
||||
this.redirectNodeIndex = Optional.ofNullable(redirectNodeIndex);
|
||||
this.name = Optional.ofNullable(name);
|
||||
this.parserID = Optional.ofNullable(parserID);
|
||||
this.properties = Optional.ofNullable(properties);
|
||||
this.suggestionsType = Optional.ofNullable(suggestionsType);
|
||||
}
|
||||
|
||||
public byte getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void setFlags(byte flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
public List<Integer> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<Integer> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public Optional<Integer> getRedirectNodeIndex() {
|
||||
return redirectNodeIndex;
|
||||
}
|
||||
|
||||
public void setRedirectNodeIndex(Optional<Integer> redirectNodeIndex) {
|
||||
this.redirectNodeIndex = redirectNodeIndex;
|
||||
}
|
||||
|
||||
public Optional<String> getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(Optional<String> name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Optional<Integer> getParserID() {
|
||||
return parserID;
|
||||
}
|
||||
|
||||
public void setParserID(Optional<Integer> parserID) {
|
||||
this.parserID = parserID;
|
||||
}
|
||||
|
||||
public Optional<List<Object>> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Optional<List<Object>> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Optional<ResourceLocation> getSuggestionsType() {
|
||||
return suggestionsType;
|
||||
}
|
||||
|
||||
public void setSuggestionsType(Optional<ResourceLocation> suggestionsType) {
|
||||
this.suggestionsType = suggestionsType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Parsers {
|
||||
private static final List<Parser> parsers = Arrays.asList(
|
||||
new Parser("brigadier:bool", null, null),
|
||||
new Parser("brigadier:float",
|
||||
packetWrapper -> {
|
||||
byte flags = packetWrapper.readByte();
|
||||
float min = (flags & 0x01) != 0 ? packetWrapper.readFloat() : -Float.MAX_VALUE;
|
||||
float max = (flags & 0x02) != 0 ? packetWrapper.readFloat() : Float.MAX_VALUE;
|
||||
return Arrays.asList(flags, min, max);
|
||||
},
|
||||
(packetWrapper, properties) -> {
|
||||
byte flags = (byte) properties.get(0);
|
||||
packetWrapper.writeByte(flags);
|
||||
if ((flags & 0x01) != 0) packetWrapper.writeFloat((float) properties.get(1));
|
||||
if ((flags & 0x02) != 0) packetWrapper.writeFloat((float) properties.get(2));
|
||||
}
|
||||
),
|
||||
new Parser("brigadier:double",
|
||||
packetWrapper -> {
|
||||
byte flags = packetWrapper.readByte();
|
||||
double min = (flags & 0x01) != 0 ? packetWrapper.readDouble() : -Double.MAX_VALUE;
|
||||
double max = (flags & 0x02) != 0 ? packetWrapper.readDouble() : Double.MAX_VALUE;
|
||||
return Arrays.asList(flags, min, max);
|
||||
},
|
||||
(packetWrapper, properties) -> {
|
||||
byte flags = (byte) properties.get(0);
|
||||
packetWrapper.writeByte(flags);
|
||||
if ((flags & 0x01) != 0) packetWrapper.writeDouble((double) properties.get(1));
|
||||
if ((flags & 0x02) != 0) packetWrapper.writeDouble((double) properties.get(2));
|
||||
}
|
||||
),
|
||||
new Parser("brigadier:integer",
|
||||
packetWrapper -> {
|
||||
byte flags = packetWrapper.readByte();
|
||||
int min = (flags & 0x01) != 0 ? packetWrapper.readInt() : Integer.MIN_VALUE;
|
||||
int max = (flags & 0x02) != 0 ? packetWrapper.readInt() : Integer.MAX_VALUE;
|
||||
return Arrays.asList(flags, min, max);
|
||||
},
|
||||
(packetWrapper, properties) -> {
|
||||
byte flags = (byte) properties.get(0);
|
||||
packetWrapper.writeByte(flags);
|
||||
if ((flags & 0x01) != 0) packetWrapper.writeInt((int) properties.get(1));
|
||||
if ((flags & 0x02) != 0) packetWrapper.writeInt((int) properties.get(2));
|
||||
}
|
||||
),
|
||||
new Parser("brigadier:long",
|
||||
packetWrapper -> {
|
||||
byte flags = packetWrapper.readByte();
|
||||
long min = (flags & 0x01) != 0 ? packetWrapper.readLong() : Long.MIN_VALUE;
|
||||
long max = (flags & 0x02) != 0 ? packetWrapper.readLong() : Long.MAX_VALUE;
|
||||
return Arrays.asList(flags, min, max);
|
||||
},
|
||||
(packetWrapper, properties) -> {
|
||||
byte flags = (byte) properties.get(0);
|
||||
packetWrapper.writeByte(flags);
|
||||
if ((flags & 0x01) != 0) packetWrapper.writeLong((long) properties.get(1));
|
||||
if ((flags & 0x02) != 0) packetWrapper.writeLong((long) properties.get(2));
|
||||
}
|
||||
),
|
||||
new Parser("brigadier:string",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readVarInt()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeVarInt((Integer) properties.get(0))
|
||||
),
|
||||
new Parser("brigadier:entity",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readByte()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeByte(((Byte) properties.get(0)).intValue())
|
||||
),
|
||||
new Parser("brigadier:game_profile", null, null),
|
||||
new Parser("brigadier:block_pos", null, null),
|
||||
new Parser("brigadier:column_pos", null, null),
|
||||
new Parser("brigadier:vec3", null, null),
|
||||
new Parser("brigadier:vec2", null, null),
|
||||
new Parser("brigadier:block_state", null, null),
|
||||
new Parser("brigadier:block_predicate", null, null),
|
||||
new Parser("brigadier:item_stack", null, null),
|
||||
new Parser("brigadier:item_predicate", null, null),
|
||||
new Parser("brigadier:color", null, null),
|
||||
new Parser("brigadier:component", null, null),
|
||||
new Parser("brigadier:message", null, null),
|
||||
new Parser("brigadier:nbt", null, null),
|
||||
new Parser("brigadier:nbt_tag", null, null),
|
||||
new Parser("brigadier:nbt_path", null, null),
|
||||
new Parser("brigadier:objective", null, null),
|
||||
new Parser("brigadier:objective_criteria", null, null),
|
||||
new Parser("brigadier:operation", null, null),
|
||||
new Parser("brigadier:particle", null, null),
|
||||
new Parser("brigadier:angle", null, null),
|
||||
new Parser("brigadier:rotation", null, null),
|
||||
new Parser("brigadier:scoreboard_slot", null, null),
|
||||
new Parser("brigadier:score_holder",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readByte()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeByte(((Byte) properties.get(0)).intValue())
|
||||
),
|
||||
new Parser("brigadier:swizzle", null, null),
|
||||
new Parser("brigadier:team", null, null),
|
||||
new Parser("brigadier:item_slot", null, null),
|
||||
new Parser("brigadier:resource_location", null, null),
|
||||
new Parser("brigadier:function", null, null),
|
||||
new Parser("brigadier:entity_anchor", null, null),
|
||||
new Parser("brigadier:int_range", null, null),
|
||||
new Parser("brigadier:float_range", null, null),
|
||||
new Parser("brigadier:dimension", null, null),
|
||||
new Parser("brigadier:gamemode", null, null),
|
||||
new Parser("brigadier:time",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readInt()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeInt((int) properties.get(0))
|
||||
),
|
||||
new Parser("brigadier:resource_or_tag",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readIdentifier()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeIdentifier((ResourceLocation) properties.get(0))
|
||||
),
|
||||
new Parser("brigadier:resource_or_tag_key",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readIdentifier()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeIdentifier((ResourceLocation) properties.get(0))
|
||||
),
|
||||
new Parser("brigadier:resource",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readIdentifier()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeIdentifier((ResourceLocation) properties.get(0))
|
||||
),
|
||||
new Parser("brigadier:resource_key",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readIdentifier()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeIdentifier((ResourceLocation) properties.get(0))
|
||||
),
|
||||
new Parser("brigadier:template_mirror", null, null),
|
||||
new Parser("brigadier:template_rotation", null, null),
|
||||
new Parser("brigadier:heightmap", null, null),
|
||||
new Parser("brigadier:uuid", null, null)
|
||||
);
|
||||
|
||||
public static List<Parser> getParsers() {
|
||||
return parsers;
|
||||
}
|
||||
|
||||
public static final class Parser {
|
||||
private final String name; //not really needed, just for toString or something
|
||||
private final Optional<Function<PacketWrapper<?>, List<Object>>> read;
|
||||
private final Optional<BiConsumer<PacketWrapper<?>, List<Object>>> write;
|
||||
|
||||
public Parser(String name, @Nullable Function<PacketWrapper<?>, List<Object>> read, @Nullable BiConsumer<PacketWrapper<?>, List<Object>> write) {
|
||||
this.name = name;
|
||||
this.read = Optional.ofNullable(read);
|
||||
this.write = Optional.ofNullable(write);
|
||||
}
|
||||
|
||||
public Optional<List<Object>> readProperties(PacketWrapper<?> packetWrapper) {
|
||||
return read.map(fn -> fn.apply(packetWrapper));
|
||||
}
|
||||
|
||||
public void writeProperties(PacketWrapper<?> packetWrapper, List<Object> properties) {
|
||||
write.ifPresent(fn -> fn.accept(packetWrapper, properties));
|
||||
}
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.PublicProfileKey;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class RemoteChatSession {
|
||||
private final UUID sessionId;
|
||||
private final PublicProfileKey publicProfileKey;
|
||||
|
||||
public RemoteChatSession(UUID sessionId, PublicProfileKey publicProfileKey) {
|
||||
this.sessionId = sessionId;
|
||||
this.publicProfileKey = publicProfileKey;
|
||||
}
|
||||
|
||||
public UUID getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public PublicProfileKey getPublicProfileKey() {
|
||||
return publicProfileKey;
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
public class SignedCommandArgument {
|
||||
private String argument;
|
||||
private byte[] signature;
|
||||
|
||||
public SignedCommandArgument(String argument, byte[] signature) {
|
||||
this.argument = argument;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public String getArgument() {
|
||||
return argument;
|
||||
}
|
||||
|
||||
public void setArgument(String argument) {
|
||||
this.argument = argument;
|
||||
}
|
||||
|
||||
public byte[] getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(byte[] signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.filter;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
public class FilterMask {
|
||||
public static final FilterMask FULLY_FILTERED;
|
||||
public static final FilterMask PASS_THROUGH;
|
||||
|
||||
static {
|
||||
FULLY_FILTERED = new FilterMask(new BitSet(0), FilterMaskType.FULLY_FILTERED);
|
||||
PASS_THROUGH = new FilterMask(new BitSet(0), FilterMaskType.PASS_THROUGH);
|
||||
}
|
||||
|
||||
private final BitSet mask;
|
||||
private final FilterMaskType type;
|
||||
|
||||
private FilterMask(BitSet mask, FilterMaskType type) {
|
||||
this.type = type;
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
public FilterMask(BitSet mask) {
|
||||
this.type = FilterMaskType.PARTIALLY_FILTERED;
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
public BitSet getMask() {
|
||||
return mask;
|
||||
}
|
||||
|
||||
public FilterMaskType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.filter;
|
||||
|
||||
public enum FilterMaskType {
|
||||
PASS_THROUGH,
|
||||
FULLY_FILTERED,
|
||||
PARTIALLY_FILTERED;
|
||||
|
||||
public static final FilterMaskType[] VALUES = values();
|
||||
|
||||
public int getId() {
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
public static FilterMaskType getById(int id) {
|
||||
return VALUES[id];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.message;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class ChatMessage {
|
||||
private Component chatContent;
|
||||
private ChatType type;
|
||||
|
||||
protected ChatMessage(Component chatContent, ChatType type) {
|
||||
this.chatContent = chatContent;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Component getChatContent() {
|
||||
return chatContent;
|
||||
}
|
||||
|
||||
public ChatType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setChatContent(Component chatContent) {
|
||||
this.chatContent = chatContent;
|
||||
}
|
||||
|
||||
public void setType(ChatType type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.message;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class ChatMessageLegacy extends ChatMessage {
|
||||
public ChatMessageLegacy(Component chatContent, ChatType type) {
|
||||
super(chatContent, type);
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.message;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatMessage_v1_16 extends ChatMessage {
|
||||
private UUID senderUUID;
|
||||
|
||||
public ChatMessage_v1_16(Component chatContent, ChatType type, UUID senderUUID) {
|
||||
super(chatContent, type);
|
||||
this.senderUUID = senderUUID;
|
||||
}
|
||||
|
||||
public UUID getSenderUUID() {
|
||||
return senderUUID;
|
||||
}
|
||||
|
||||
public void setSenderUUID(UUID senderUUID) {
|
||||
this.senderUUID = senderUUID;
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.message;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
//We'll extend ChatMessage_v1_16 for now, hopefully no breaking changes in the future
|
||||
public class ChatMessage_v1_19 extends ChatMessage_v1_16 {
|
||||
private @Nullable Component unsignedChatContent;
|
||||
private Component senderDisplayName;
|
||||
private @Nullable Component teamName;
|
||||
private Instant timestamp;
|
||||
private long salt;
|
||||
private byte[] signature;
|
||||
|
||||
public ChatMessage_v1_19(Component chatContent, @Nullable Component unsignedChatContent, ChatType type,
|
||||
UUID senderUUID, Component senderDisplayName, @Nullable Component teamName, Instant timestamp,
|
||||
long salt, byte[] signature) {
|
||||
super(chatContent, type, senderUUID);
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
this.senderDisplayName = senderDisplayName;
|
||||
this.teamName = teamName;
|
||||
this.timestamp = timestamp;
|
||||
this.salt = salt;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public @Nullable Component getUnsignedChatContent() {
|
||||
return unsignedChatContent;
|
||||
}
|
||||
|
||||
public Component getSenderDisplayName() {
|
||||
return senderDisplayName;
|
||||
}
|
||||
|
||||
public @Nullable Component getTeamName() {
|
||||
return teamName;
|
||||
}
|
||||
|
||||
public Instant getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public long getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
public byte[] getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setUnsignedChatContent(@Nullable Component unsignedChatContent) {
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
}
|
||||
|
||||
public void setSenderDisplayName(Component senderDisplayName) {
|
||||
this.senderDisplayName = senderDisplayName;
|
||||
}
|
||||
|
||||
public void setTeamName(@Nullable Component teamName) {
|
||||
this.teamName = teamName;
|
||||
}
|
||||
|
||||
public void setTimestamp(Instant timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public void setSalt(long salt) {
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
public void setSignature(byte[] signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
}
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.message;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatType;
|
||||
import com.github.retrooper.packetevents.protocol.chat.LastSeenMessages;
|
||||
import com.github.retrooper.packetevents.protocol.chat.filter.FilterMask;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
//We'll extend ChatMessage_v1_16 for now, hopefully no breaking changes in the future
|
||||
public class ChatMessage_v1_19_1 extends ChatMessage_v1_16 {
|
||||
private String plainContent;
|
||||
private @Nullable Component unsignedChatContent;
|
||||
private ChatTypeBoundNetwork chatType;
|
||||
private byte @Nullable [] previousSignature;
|
||||
private byte[] signature;
|
||||
private Instant timestamp;
|
||||
private long salt;
|
||||
private LastSeenMessages lastSeenMessages;
|
||||
private FilterMask filterMask;
|
||||
|
||||
public ChatMessage_v1_19_1(String plainContent, Component decoratedChatContent,
|
||||
@Nullable Component unsignedChatContent,
|
||||
UUID senderUUID, ChatTypeBoundNetwork chatType,
|
||||
byte @Nullable [] previousSignature, byte[] signature,
|
||||
Instant timestamp, long salt,
|
||||
LastSeenMessages lastSeenMessages,
|
||||
FilterMask filterMask) {
|
||||
super(decoratedChatContent, chatType.getType(), senderUUID);
|
||||
this.plainContent = plainContent;
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
this.chatType = chatType;
|
||||
this.previousSignature = previousSignature;
|
||||
this.signature = signature;
|
||||
this.timestamp = timestamp;
|
||||
this.salt = salt;
|
||||
this.lastSeenMessages = lastSeenMessages;
|
||||
this.filterMask = filterMask;
|
||||
}
|
||||
|
||||
public String getPlainContent() {
|
||||
return plainContent;
|
||||
}
|
||||
|
||||
public void setPlainContent(String plainContent) {
|
||||
this.plainContent = plainContent;
|
||||
}
|
||||
|
||||
public boolean isChatContentDecorated() {
|
||||
return !getChatContent().equals(Component.text(plainContent));
|
||||
}
|
||||
|
||||
public @Nullable Component getUnsignedChatContent() {
|
||||
return unsignedChatContent;
|
||||
}
|
||||
|
||||
public void setUnsignedChatContent(@Nullable Component unsignedChatContent) {
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatType getType() {
|
||||
return chatType.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(ChatType type) {
|
||||
chatType.setType(type);
|
||||
}
|
||||
|
||||
public ChatTypeBoundNetwork getChatType() {
|
||||
return chatType;
|
||||
}
|
||||
|
||||
public void setChatType(ChatTypeBoundNetwork type) {
|
||||
this.chatType = type;
|
||||
}
|
||||
|
||||
public byte @Nullable [] getPreviousSignature() {
|
||||
return previousSignature;
|
||||
}
|
||||
|
||||
public void setPreviousSignature(byte @Nullable [] previousSignature) {
|
||||
this.previousSignature = previousSignature;
|
||||
}
|
||||
|
||||
public byte[] getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(byte[] signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public Instant getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Instant timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public long getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
public void setSalt(long salt) {
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
public LastSeenMessages getLastSeenMessages() {
|
||||
return lastSeenMessages;
|
||||
}
|
||||
|
||||
public void setLastSeenMessages(LastSeenMessages lastSeenMessages) {
|
||||
this.lastSeenMessages = lastSeenMessages;
|
||||
}
|
||||
|
||||
public FilterMask getFilterMask() {
|
||||
return filterMask;
|
||||
}
|
||||
|
||||
public void setFilterMask(FilterMask filterMask) {
|
||||
this.filterMask = filterMask;
|
||||
}
|
||||
|
||||
public static class ChatTypeBoundNetwork {
|
||||
private ChatType type;
|
||||
private Component name;
|
||||
private @Nullable Component targetName;
|
||||
|
||||
public ChatTypeBoundNetwork(ChatType type, Component name, @Nullable Component targetName) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.targetName = targetName;
|
||||
}
|
||||
|
||||
public ChatType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ChatType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Component getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(Component name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public @Nullable Component getTargetName() {
|
||||
return targetName;
|
||||
}
|
||||
|
||||
public void setTargetName(@Nullable Component targetName) {
|
||||
this.targetName = targetName;
|
||||
}
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
package com.github.retrooper.packetevents.protocol.chat.message;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.LastSeenMessages;
|
||||
import com.github.retrooper.packetevents.protocol.chat.filter.FilterMask;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
//We'll extend ChatMessage_v1_16 for now, hopefully no breaking changes in the future
|
||||
public class ChatMessage_v1_19_3 extends ChatMessage_v1_16 {
|
||||
int index;
|
||||
byte[] signature;
|
||||
String plainContent;
|
||||
Instant timestamp;
|
||||
long salt;
|
||||
LastSeenMessages.Packed lastSeenMessagesPacked;
|
||||
@Nullable Component unsignedChatContent;
|
||||
FilterMask filterMask;
|
||||
ChatMessage_v1_19_1.ChatTypeBoundNetwork chatType;
|
||||
|
||||
public ChatMessage_v1_19_3(UUID senderUUID, int index, byte[] signature, String plainContent, Instant timestamp, long salt, LastSeenMessages.Packed lastSeenMessagesPacked, @Nullable Component unsignedChatContent, FilterMask filterMask, ChatMessage_v1_19_1.ChatTypeBoundNetwork chatType) {
|
||||
super(Component.text(plainContent), chatType.getType(), senderUUID);
|
||||
this.index = index;
|
||||
this.signature = signature;
|
||||
this.plainContent = plainContent;
|
||||
this.timestamp = timestamp;
|
||||
this.salt = salt;
|
||||
this.lastSeenMessagesPacked = lastSeenMessagesPacked;
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
this.filterMask = filterMask;
|
||||
this.chatType = chatType;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public byte[] getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(byte[] signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getChatContent() {
|
||||
return Component.text(plainContent);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setChatContent(Component chatContent) {
|
||||
throw new UnsupportedOperationException("PacketEvents is not able to serialize components to plain-text. Please use the #setPlainContent instead to update the content.");
|
||||
}
|
||||
|
||||
public String getPlainContent() {
|
||||
return plainContent;
|
||||
}
|
||||
|
||||
public void setPlainContent(String plainContent) {
|
||||
this.plainContent = plainContent;
|
||||
}
|
||||
|
||||
public Instant getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Instant timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public long getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
public void setSalt(long salt) {
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
public LastSeenMessages.Packed getLastSeenMessagesPacked() {
|
||||
return lastSeenMessagesPacked;
|
||||
}
|
||||
|
||||
public void setLastSeenMessagesPacked(LastSeenMessages.Packed lastSeenMessagesPacked) {
|
||||
this.lastSeenMessagesPacked = lastSeenMessagesPacked;
|
||||
}
|
||||
|
||||
public Optional<Component> getUnsignedChatContent() {
|
||||
return Optional.ofNullable(unsignedChatContent);
|
||||
}
|
||||
|
||||
public void setUnsignedChatContent(@Nullable Component unsignedChatContent) {
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
}
|
||||
|
||||
public FilterMask getFilterMask() {
|
||||
return filterMask;
|
||||
}
|
||||
|
||||
public void setFilterMask(FilterMask filterMask) {
|
||||
this.filterMask = filterMask;
|
||||
}
|
||||
|
||||
public ChatMessage_v1_19_1.ChatTypeBoundNetwork getChatType() {
|
||||
return chatType;
|
||||
}
|
||||
|
||||
public void setChatType(ChatMessage_v1_19_1.ChatTypeBoundNetwork chatType) {
|
||||
this.chatType = chatType;
|
||||
}
|
||||
}
|
||||
+8
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,15 +16,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.util.reflection;
|
||||
package com.github.retrooper.packetevents.protocol.chat.message.reader;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassUtil {
|
||||
private static final Map<Class<?>, String> CLASS_SIMPLE_NAME_CACHE = new ConcurrentHashMap<>();
|
||||
public interface ChatMessageProcessor {
|
||||
ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper);
|
||||
|
||||
public static String getClassSimpleName(Class<?> cls) {
|
||||
return CLASS_SIMPLE_NAME_CACHE.computeIfAbsent(cls, k -> cls.getSimpleName());
|
||||
}
|
||||
void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data);
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.message.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatType;
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatTypes;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessageLegacy;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.reader.ChatMessageProcessor;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChatMessageProcessorLegacy implements ChatMessageProcessor {
|
||||
@Override
|
||||
public ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper) {
|
||||
Component chatContent = wrapper.readComponent();
|
||||
int id = wrapper.readByte();
|
||||
ChatType type = ChatTypes.getById(wrapper.getServerVersion().toClientVersion(), id);
|
||||
return new ChatMessageLegacy(chatContent, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data) {
|
||||
wrapper.writeComponent(data.getChatContent());
|
||||
wrapper.writeByte(data.getType().getId(wrapper.getServerVersion().toClientVersion()));
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.message.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatType;
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatTypes;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage_v1_16;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.reader.ChatMessageProcessor;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatMessageProcessor_v1_16 implements ChatMessageProcessor {
|
||||
@Override
|
||||
public ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper) {
|
||||
Component chatContent = wrapper.readComponent();
|
||||
int id = wrapper.readByte();
|
||||
ChatType type = ChatTypes.getById(wrapper.getServerVersion().toClientVersion(), id);
|
||||
UUID senderUUID = wrapper.readUUID();
|
||||
return new ChatMessage_v1_16(chatContent, type, senderUUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data) {
|
||||
wrapper.writeComponent(data.getChatContent());
|
||||
wrapper.writeByte(data.getType().getId(wrapper.getServerVersion().toClientVersion()));
|
||||
wrapper.writeUUID(((ChatMessage_v1_16) data).getSenderUUID());
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.message.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatType;
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatTypes;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage_v1_19;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.reader.ChatMessageProcessor;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatMessageProcessor_v1_19 implements ChatMessageProcessor {
|
||||
@Override
|
||||
public ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper) {
|
||||
Component chatContent = wrapper.readComponent();
|
||||
Component unsignedChatContent = wrapper.readOptional(PacketWrapper::readComponent);
|
||||
int id = wrapper.readVarInt();
|
||||
ChatType type = ChatTypes.getById(wrapper.getServerVersion().toClientVersion(), id);
|
||||
UUID senderUUID = wrapper.readUUID();
|
||||
Component senderDisplayName = wrapper.readComponent();
|
||||
@Nullable Component teamName = wrapper.readOptional(PacketWrapper::readComponent);
|
||||
Instant timestamp = wrapper.readTimestamp();
|
||||
long salt = wrapper.readLong();
|
||||
byte[] signature = wrapper.readByteArray();
|
||||
return new ChatMessage_v1_19(chatContent, unsignedChatContent, type, senderUUID, senderDisplayName, teamName,
|
||||
timestamp, salt, signature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data) {
|
||||
ChatMessage_v1_19 newData = (ChatMessage_v1_19) data;
|
||||
wrapper.writeComponent(newData.getChatContent());
|
||||
wrapper.writeOptional(newData.getUnsignedChatContent(), PacketWrapper::writeComponent);
|
||||
wrapper.writeVarInt(newData.getType().getId(wrapper.getServerVersion().toClientVersion()));
|
||||
wrapper.writeUUID(newData.getSenderUUID());
|
||||
wrapper.writeComponent(newData.getSenderDisplayName());
|
||||
wrapper.writeOptional(newData.getTeamName(), PacketWrapper::writeComponent);
|
||||
wrapper.writeTimestamp(newData.getTimestamp());
|
||||
wrapper.writeLong(newData.getSalt());
|
||||
wrapper.writeByteArray(newData.getSignature());
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.message.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatType;
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatTypes;
|
||||
import com.github.retrooper.packetevents.protocol.chat.LastSeenMessages;
|
||||
import com.github.retrooper.packetevents.protocol.chat.filter.FilterMask;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage_v1_19_1;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.reader.ChatMessageProcessor;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatMessageProcessor_v1_19_1 implements ChatMessageProcessor {
|
||||
@Override
|
||||
public ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper) {
|
||||
byte[] previousSignature = wrapper.readOptional(PacketWrapper::readByteArray);
|
||||
UUID senderUUID = wrapper.readUUID();
|
||||
byte[] signature = wrapper.readByteArray();
|
||||
String plainContent = wrapper.readString(256);
|
||||
Component chatContent = wrapper.readOptional(PacketWrapper::readComponent);
|
||||
if (chatContent == null && plainContent.isEmpty()) {
|
||||
chatContent = Component.empty();
|
||||
} else if (chatContent == null) {
|
||||
chatContent = Component.text(plainContent);
|
||||
}
|
||||
Instant timestamp = wrapper.readTimestamp();
|
||||
long salt = wrapper.readLong();
|
||||
LastSeenMessages lastSeenMessages = wrapper.readLastSeenMessages();
|
||||
Component unsignedChatContent = wrapper.readOptional(PacketWrapper::readComponent);
|
||||
FilterMask filterMask = wrapper.readFilterMask();
|
||||
ChatMessage_v1_19_1.ChatTypeBoundNetwork chatType = wrapper.readChatTypeBoundNetwork();
|
||||
return new ChatMessage_v1_19_1(plainContent, chatContent, unsignedChatContent, senderUUID, chatType,
|
||||
previousSignature, signature, timestamp, salt, lastSeenMessages, filterMask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data) {
|
||||
ChatMessage_v1_19_1 newData = (ChatMessage_v1_19_1) data;
|
||||
wrapper.writeOptional(newData.getPreviousSignature(), PacketWrapper::writeByteArray);
|
||||
wrapper.writeUUID(newData.getSenderUUID());
|
||||
wrapper.writeByteArray(newData.getSignature());
|
||||
wrapper.writeString(newData.getPlainContent(), 256);
|
||||
wrapper.writeOptional(newData.getChatContent(), PacketWrapper::writeComponent);
|
||||
wrapper.writeTimestamp(newData.getTimestamp());
|
||||
wrapper.writeLong(newData.getSalt());
|
||||
wrapper.writeLastSeenMessages(newData.getLastSeenMessages());
|
||||
wrapper.writeOptional(newData.getUnsignedChatContent(), PacketWrapper::writeComponent);
|
||||
wrapper.writeFilterMask(newData.getFilterMask());
|
||||
wrapper.writeChatTypeBoundNetwork(newData.getChatType());
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.github.retrooper.packetevents.protocol.chat.message.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.LastSeenMessages;
|
||||
import com.github.retrooper.packetevents.protocol.chat.filter.FilterMask;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage_v1_19_1;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage_v1_19_3;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.reader.ChatMessageProcessor;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatMessageProcessor_v1_19_3 implements ChatMessageProcessor {
|
||||
@Override
|
||||
public ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper) {
|
||||
UUID senderUUID = wrapper.readUUID();
|
||||
int index = wrapper.readVarInt();
|
||||
byte[] signature = wrapper.readOptional((w) -> w.readBytes(256));
|
||||
String plainContent = wrapper.readString(256);
|
||||
Instant timestamp = wrapper.readTimestamp();
|
||||
long salt = wrapper.readLong();
|
||||
LastSeenMessages.Packed lastSeenMessagesPacked = wrapper.readLastSeenMessagesPacked();
|
||||
Component unsignedChatContent = wrapper.readOptional(PacketWrapper::readComponent);
|
||||
FilterMask filterMask = wrapper.readFilterMask();
|
||||
ChatMessage_v1_19_1.ChatTypeBoundNetwork chatType = wrapper.readChatTypeBoundNetwork();
|
||||
|
||||
return new ChatMessage_v1_19_3(senderUUID, index, signature, plainContent, timestamp, salt, lastSeenMessagesPacked, unsignedChatContent, filterMask, chatType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data) {
|
||||
ChatMessage_v1_19_3 newData = (ChatMessage_v1_19_3) data;
|
||||
wrapper.writeUUID(newData.getSenderUUID());
|
||||
wrapper.writeVarInt(newData.getIndex());
|
||||
wrapper.writeOptional(newData.getSignature(), PacketWrapper::writeBytes);
|
||||
wrapper.writeString(newData.getPlainContent());
|
||||
wrapper.writeTimestamp(newData.getTimestamp());
|
||||
wrapper.writeLong(newData.getSalt());
|
||||
wrapper.writeLastSeenMessagesPacked(newData.getLastSeenMessagesPacked());
|
||||
wrapper.writeOptional(newData.getUnsignedChatContent().orElse(null), PacketWrapper::writeComponent);
|
||||
wrapper.writeFilterMask(newData.getFilterMask());
|
||||
wrapper.writeChatTypeBoundNetwork(newData.getChatType());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+130
-63
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,18 +21,24 @@ package com.github.retrooper.packetevents.protocol.entity.data;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||
import com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState;
|
||||
import com.github.retrooper.packetevents.protocol.entity.villager.VillagerData;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.enchantment.type.EnchantmentType;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.particle.Particle;
|
||||
import com.github.retrooper.packetevents.protocol.particle.type.ParticleType;
|
||||
import com.github.retrooper.packetevents.protocol.particle.type.ParticleTypes;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.world.BlockFace;
|
||||
import com.github.retrooper.packetevents.protocol.world.WorldBlockPosition;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.*;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -48,19 +54,48 @@ public class EntityDataTypes {
|
||||
ClientVersion.V_1_8,
|
||||
ClientVersion.V_1_9,
|
||||
ClientVersion.V_1_11,
|
||||
ClientVersion.V_1_13, //Fix? Why did we not acknoledge 1.13
|
||||
ClientVersion.V_1_16);
|
||||
ClientVersion.V_1_13,
|
||||
ClientVersion.V_1_14,
|
||||
ClientVersion.V_1_19,
|
||||
ClientVersion.V_1_19_3,
|
||||
ClientVersion.V_1_19_4);
|
||||
|
||||
public static final EntityDataType<Byte> BYTE = define("byte", PacketWrapper::readByte, PacketWrapper::writeByte);
|
||||
public static final EntityDataType<Integer> INT = define("int", readIntDeserializer(), writeIntSerializer());
|
||||
|
||||
public static final EntityDataType<Short> SHORT = define("short", PacketWrapper::readShort, PacketWrapper::writeShort);
|
||||
|
||||
public static final EntityDataType<Integer> INT = define("int", wrapper -> {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_9)) {
|
||||
return wrapper.readVarInt();
|
||||
} else {
|
||||
return wrapper.readInt();
|
||||
}
|
||||
}, (wrapper, value) -> {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_9)) {
|
||||
wrapper.writeVarInt(value);
|
||||
} else {
|
||||
wrapper.writeInt(value);
|
||||
}
|
||||
});
|
||||
|
||||
public static final EntityDataType<Long> LONG = define("long", PacketWrapper::readVarLong, PacketWrapper::writeVarLong);
|
||||
|
||||
public static final EntityDataType<Float> FLOAT = define("float", PacketWrapper::readFloat, PacketWrapper::writeFloat);
|
||||
|
||||
public static final EntityDataType<String> STRING = define("string", PacketWrapper::readString, PacketWrapper::writeString);
|
||||
public static final EntityDataType<Component> COMPONENT = define("component", PacketWrapper::readComponent, PacketWrapper::writeComponent);
|
||||
public static final EntityDataType<Optional<Component>> OPTIONAL_COMPONENT = define("optional_component", readOptionalComponentDeserializer(), writeOptionalComponentSerializer());
|
||||
|
||||
public static final EntityDataType<String> COMPONENT = define("component", PacketWrapper::readComponentJSON, PacketWrapper::writeComponentJSON);
|
||||
|
||||
public static final EntityDataType<Optional<String>> OPTIONAL_COMPONENT = define("optional_component", readOptionalComponentDeserializer(), writeOptionalComponentSerializer());
|
||||
|
||||
public static final EntityDataType<ItemStack> ITEMSTACK = define("itemstack", PacketWrapper::readItemStack, PacketWrapper::writeItemStack);
|
||||
public static final EntityDataType<Optional<Object>> OPTIONAL_BLOCK_STATE = define("optional_block_state", readIntDeserializer(), writeIntSerializer());
|
||||
|
||||
public static final EntityDataType<Optional<ItemStack>> OPTIONAL_ITEMSTACK = define("optional_itemstack",
|
||||
(PacketWrapper<?> wrapper) -> Optional.of(wrapper.readItemStack()),
|
||||
(PacketWrapper<?> wrapper, Optional<ItemStack> value) -> wrapper.writeItemStack(value.orElse(null)));
|
||||
|
||||
public static final EntityDataType<Boolean> BOOLEAN = define("boolean", PacketWrapper::readBoolean, PacketWrapper::writeBoolean);
|
||||
public static final EntityDataType<Integer> PARTICLE = define("particle", PacketWrapper::readVarInt, PacketWrapper::writeVarInt);
|
||||
|
||||
public static final EntityDataType<Vector3f> ROTATION = define("rotation",
|
||||
(PacketWrapper<?> wrapper) -> new Vector3f(wrapper.readFloat(), wrapper.readFloat(), wrapper.readFloat()),
|
||||
(PacketWrapper<?> wrapper, Vector3f value) -> {
|
||||
@@ -68,32 +103,58 @@ public class EntityDataTypes {
|
||||
wrapper.writeFloat(value.y);
|
||||
wrapper.writeFloat(value.z);
|
||||
});
|
||||
public static final EntityDataType<Vector3i> BLOCK_POSITION = define("block_position", readBlockPositionDeserializer(), writeBlockPositionSerializer());
|
||||
public static final EntityDataType<Optional<Vector3i>> OPTIONAL_BLOCK_POSITION = define("optional_block_position", readOptionalBlockPositionDeserializer(), writeOptionalBlockPositionSerializer());
|
||||
|
||||
public static final EntityDataType<Vector3i> BLOCK_POSITION = define("block_position", (PacketWrapper<?> wrapper) -> {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_9)) {
|
||||
return wrapper.readBlockPosition();
|
||||
} else {
|
||||
int x = wrapper.readInt();
|
||||
int y = wrapper.readInt();
|
||||
int z = wrapper.readInt();
|
||||
return new Vector3i(x, y, z);
|
||||
}
|
||||
}, (wrapper, blockPosition) -> {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_9)) {
|
||||
wrapper.writeBlockPosition(blockPosition);
|
||||
} else {
|
||||
wrapper.writeInt(blockPosition.getX());
|
||||
wrapper.writeInt(blockPosition.getY());
|
||||
wrapper.writeInt(blockPosition.getZ());
|
||||
}
|
||||
});
|
||||
|
||||
public static final EntityDataType<Optional<Vector3i>> OPTIONAL_BLOCK_POSITION = define("optional_block_position",
|
||||
readOptionalBlockPositionDeserializer(), writeOptionalBlockPositionSerializer());
|
||||
|
||||
public static final EntityDataType<BlockFace> BLOCK_FACE = define("block_face", (PacketWrapper<?> wrapper) -> {
|
||||
int id = wrapper.readVarInt();
|
||||
return BlockFace.getBlockFaceByValue(id);
|
||||
},
|
||||
(PacketWrapper<?> wrapper, BlockFace value) -> wrapper.writeVarInt(value.getFaceValue()));
|
||||
|
||||
public static final EntityDataType<Optional<UUID>> OPTIONAL_UUID = define("optional_uuid", (PacketWrapper<?> wrapper) -> {
|
||||
if (wrapper.readBoolean()) {
|
||||
return Optional.of(wrapper.readUUID());
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
},
|
||||
(PacketWrapper<?> wrapper, Optional<UUID> value) -> {
|
||||
if (value.isPresent()) {
|
||||
wrapper.writeBoolean(true);
|
||||
wrapper.writeUUID(value.get());
|
||||
} else {
|
||||
wrapper.writeBoolean(false);
|
||||
}
|
||||
});
|
||||
public static final EntityDataType<Optional<UUID>> OPTIONAL_UUID = define("optional_uuid",
|
||||
(PacketWrapper<?> wrapper) -> Optional.ofNullable(wrapper.readOptional(PacketWrapper::readUUID)),
|
||||
(PacketWrapper<?> wrapper, Optional<UUID> value) ->
|
||||
wrapper.writeOptional(value.orElse(null), PacketWrapper::writeUUID));
|
||||
|
||||
public static final EntityDataType<Integer> BLOCK_STATE = define("block_state",
|
||||
readIntDeserializer(), writeIntSerializer());
|
||||
|
||||
public static final EntityDataType<Integer> OPTIONAL_BLOCK_STATE = define("optional_block_state", readIntDeserializer(), writeIntSerializer());
|
||||
|
||||
public static final EntityDataType<NBTCompound> NBT = define("nbt", PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
|
||||
public static final EntityDataType<Particle> PARTICLE = define("particle", wrapper -> {
|
||||
int id = wrapper.readVarInt();
|
||||
ParticleType type = ParticleTypes.getById(PacketEvents.getAPI().getServerManager().getVersion().toClientVersion(), id);
|
||||
return new Particle(type, type.readDataFunction().apply(wrapper));
|
||||
}, (wrapper, particle) -> {
|
||||
wrapper.writeVarInt(particle.getType().getId(PacketEvents.getAPI().getServerManager().getVersion().toClientVersion()));
|
||||
particle.getType().writeDataFunction().accept(wrapper, particle.getData());
|
||||
});
|
||||
|
||||
public static final EntityDataType<VillagerData> VILLAGER_DATA = define("villager_data", PacketWrapper::readVillagerData, PacketWrapper::writeVillagerData);
|
||||
|
||||
public static final EntityDataType<Optional<Integer>> OPTIONAL_INT = define("optional_int", (PacketWrapper<?> wrapper) -> {
|
||||
int i = wrapper.readVarInt();
|
||||
return i == 0 ? Optional.empty() : Optional.of(i - 1);
|
||||
@@ -106,12 +167,45 @@ public class EntityDataTypes {
|
||||
return EntityPose.getById(wrapper.getServerVersion().toClientVersion(), id);
|
||||
}, (PacketWrapper<?> wrapper, EntityPose value) -> wrapper.writeVarInt(value.getId(wrapper.getServerVersion().toClientVersion())));
|
||||
|
||||
@Deprecated
|
||||
public static final EntityDataType<Short> SHORT = define("short", PacketWrapper::readShort, PacketWrapper::writeShort);
|
||||
public static final EntityDataType<Integer> CAT_VARIANT = define("cat_variant_type", readIntDeserializer(), writeIntSerializer());
|
||||
|
||||
public static final EntityDataType<Integer> FROG_VARIANT = define("frog_variant_type", readIntDeserializer(), writeIntSerializer());
|
||||
|
||||
public static final EntityDataType<Optional<WorldBlockPosition>> OPTIONAL_GLOBAL_POSITION = define("optional_global_position",
|
||||
(PacketWrapper<?> wrapper) -> Optional.ofNullable(wrapper.readOptional(w -> new WorldBlockPosition(new ResourceLocation(w.readString(32767)), w.readBlockPosition()))),
|
||||
(PacketWrapper<?> wrapper, Optional<WorldBlockPosition> value) -> wrapper.writeOptional(value.orElse(null), (w, globalPos) -> {
|
||||
w.writeString(globalPos.getWorld().toString());
|
||||
w.writeBlockPosition(globalPos.getBlockPosition());
|
||||
}));
|
||||
|
||||
public static final EntityDataType<Integer> PAINTING_VARIANT_TYPE = define("painting_variant_type", readIntDeserializer(), writeIntSerializer());
|
||||
|
||||
public static final EntityDataType<SnifferState> SNIFFER_STATE = define("sniffer_state", (PacketWrapper<?> wrapper) -> {
|
||||
int id = wrapper.readVarInt();
|
||||
return SnifferState.values()[id];
|
||||
}, (PacketWrapper<?> wrapper, SnifferState value) -> wrapper.writeVarInt(value.ordinal()));
|
||||
|
||||
|
||||
public static final EntityDataType<Vector3f> VECTOR3F = define("vector3f",
|
||||
(PacketWrapper<?> wrapper) -> new Vector3f(wrapper.readFloat(), wrapper.readFloat(), wrapper.readFloat()),
|
||||
(PacketWrapper<?> wrapper, Vector3f value) -> {
|
||||
wrapper.writeFloat(value.x);
|
||||
wrapper.writeFloat(value.y);
|
||||
wrapper.writeFloat(value.z);
|
||||
});
|
||||
|
||||
public static final EntityDataType<Quaternion4f> QUATERNION = define("quaternion",
|
||||
(PacketWrapper<?> wrapper) -> new Quaternion4f(wrapper.readFloat(), wrapper.readFloat(), wrapper.readFloat(), wrapper.readFloat()),
|
||||
(PacketWrapper<?> wrapper, Quaternion4f value) -> {
|
||||
wrapper.writeFloat(value.getX());
|
||||
wrapper.writeFloat(value.getY());
|
||||
wrapper.writeFloat(value.getZ());
|
||||
wrapper.writeFloat(value.getW());
|
||||
});
|
||||
|
||||
public static EntityDataType<?> getById(ClientVersion version, int id) {
|
||||
int index = TYPES_BUILDER.getDataIndex(version);
|
||||
Map<Integer, EntityDataType<?>> typeIdMap = ENTITY_DATA_TYPE_ID_MAP.get((byte)index);
|
||||
Map<Integer, EntityDataType<?>> typeIdMap = ENTITY_DATA_TYPE_ID_MAP.get((byte) index);
|
||||
return typeIdMap.get(id);
|
||||
}
|
||||
|
||||
@@ -165,7 +259,7 @@ public class EntityDataTypes {
|
||||
private static <T> Function<PacketWrapper<?>, T> readOptionalComponentDeserializer() {
|
||||
return (PacketWrapper<?> wrapper) -> {
|
||||
if (wrapper.readBoolean()) {
|
||||
return (T) Optional.of(wrapper.readComponent());
|
||||
return (T) Optional.of(wrapper.readString());
|
||||
} else {
|
||||
return (T) Optional.empty();
|
||||
}
|
||||
@@ -175,10 +269,10 @@ public class EntityDataTypes {
|
||||
private static <T> BiConsumer<PacketWrapper<?>, T> writeOptionalComponentSerializer() {
|
||||
return (PacketWrapper<?> wrapper, T value) -> {
|
||||
if (value instanceof Optional) {
|
||||
Optional<Component> optional = (Optional<Component>) value;
|
||||
Optional<String> optional = (Optional<String>) value;
|
||||
if (optional.isPresent()) {
|
||||
wrapper.writeBoolean(true);
|
||||
wrapper.writeComponent(optional.get());
|
||||
wrapper.writeString(optional.get());
|
||||
} else {
|
||||
wrapper.writeBoolean(false);
|
||||
}
|
||||
@@ -188,34 +282,6 @@ public class EntityDataTypes {
|
||||
};
|
||||
}
|
||||
|
||||
private static <T> Function<PacketWrapper<?>, T> readBlockPositionDeserializer() {
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9)) {
|
||||
return (PacketWrapper<?> wrapper) -> (T) wrapper.readBlockPosition();
|
||||
} else {
|
||||
return (PacketWrapper<?> wrapper) -> {
|
||||
int x = wrapper.readInt();
|
||||
int y = wrapper.readInt();
|
||||
int z = wrapper.readInt();
|
||||
return (T) new Vector3i(x, y, z);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> BiConsumer<PacketWrapper<?>, T> writeBlockPositionSerializer() {
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9)) {
|
||||
return (PacketWrapper<?> wrapper, T value) -> {
|
||||
wrapper.writeBlockPosition((Vector3i) value);
|
||||
};
|
||||
} else {
|
||||
return (PacketWrapper<?> wrapper, T value) -> {
|
||||
Vector3i position = (Vector3i) value;
|
||||
wrapper.writeInt(position.getX());
|
||||
wrapper.writeInt(position.getY());
|
||||
wrapper.writeInt(position.getZ());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> Function<PacketWrapper<?>, T> readOptionalBlockPositionDeserializer() {
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9)) {
|
||||
return (PacketWrapper<?> wrapper) -> {
|
||||
@@ -273,4 +339,5 @@ public class EntityDataTypes {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-343
@@ -1,343 +0,0 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.data.provider;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class EntityDataProvider implements DataProvider {
|
||||
@Nullable
|
||||
private Component customName;
|
||||
|
||||
private boolean customNameVisible;
|
||||
private EntityPose pose = EntityPose.STANDING;
|
||||
private int airTicks;
|
||||
private int ticksFrozenInPowderedSnow = 0;
|
||||
private boolean onFire;
|
||||
private boolean crouching;
|
||||
//Now unused
|
||||
private boolean riding;
|
||||
|
||||
private boolean sprinting;
|
||||
private boolean swimming;
|
||||
private boolean invisible;
|
||||
private boolean glowing;
|
||||
private boolean flyingWithElytra;
|
||||
private boolean silent;
|
||||
private boolean hasGravity = true;
|
||||
|
||||
@Nullable
|
||||
public Component getCustomName() {
|
||||
return customName;
|
||||
}
|
||||
|
||||
public void setCustomName(@Nullable Component customName) {
|
||||
this.customName = customName;
|
||||
}
|
||||
|
||||
public boolean isCustomNameVisible() {
|
||||
return customNameVisible;
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean customNameVisible) {
|
||||
this.customNameVisible = customNameVisible;
|
||||
}
|
||||
|
||||
public EntityPose getPose() {
|
||||
return pose;
|
||||
}
|
||||
|
||||
public void setPose(EntityPose pose) {
|
||||
this.pose = pose;
|
||||
}
|
||||
|
||||
public int getAirTicks() {
|
||||
return airTicks;
|
||||
}
|
||||
|
||||
public void setAirTicks(int airTicks) {
|
||||
this.airTicks = airTicks;
|
||||
}
|
||||
|
||||
public int getTicksFrozenInPowderedSnow() {
|
||||
return ticksFrozenInPowderedSnow;
|
||||
}
|
||||
|
||||
public void setTicksFrozenInPowderedSnow(int ticksFrozenInPowderedSnow) {
|
||||
this.ticksFrozenInPowderedSnow = ticksFrozenInPowderedSnow;
|
||||
}
|
||||
|
||||
public boolean isOnFire() {
|
||||
return onFire;
|
||||
}
|
||||
|
||||
public void setOnFire(boolean onFire) {
|
||||
this.onFire = onFire;
|
||||
}
|
||||
|
||||
public boolean isCrouching() {
|
||||
return crouching;
|
||||
}
|
||||
|
||||
public void setCrouching(boolean crouching) {
|
||||
this.crouching = crouching;
|
||||
}
|
||||
|
||||
public boolean isRiding() {
|
||||
return riding;
|
||||
}
|
||||
|
||||
public void setRiding(boolean riding) {
|
||||
this.riding = riding;
|
||||
}
|
||||
|
||||
public boolean isSprinting() {
|
||||
return sprinting;
|
||||
}
|
||||
|
||||
public void setSprinting(boolean sprinting) {
|
||||
this.sprinting = sprinting;
|
||||
}
|
||||
|
||||
public boolean isSwimming() {
|
||||
return swimming;
|
||||
}
|
||||
|
||||
public void setSwimming(boolean swimming) {
|
||||
this.swimming = swimming;
|
||||
}
|
||||
|
||||
public boolean isInvisible() {
|
||||
return invisible;
|
||||
}
|
||||
|
||||
public void setInvisible(boolean invisible) {
|
||||
this.invisible = invisible;
|
||||
}
|
||||
|
||||
public boolean isGlowing() {
|
||||
return glowing;
|
||||
}
|
||||
|
||||
public void setGlowing(boolean glowing) {
|
||||
this.glowing = glowing;
|
||||
}
|
||||
|
||||
public boolean isFlyingWithElytra() {
|
||||
return flyingWithElytra;
|
||||
}
|
||||
|
||||
public void setFlyingWithElytra(boolean flyingWithElytra) {
|
||||
this.flyingWithElytra = flyingWithElytra;
|
||||
}
|
||||
|
||||
public boolean isSilent() {
|
||||
return silent;
|
||||
}
|
||||
|
||||
public void setSilent(boolean silent) {
|
||||
this.silent = silent;
|
||||
}
|
||||
|
||||
public boolean isHasGravity() {
|
||||
return hasGravity;
|
||||
}
|
||||
|
||||
public void setHasGravity(boolean hasGravity) {
|
||||
this.hasGravity = hasGravity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntityData> encode() {
|
||||
byte mask = 0x00;
|
||||
if (onFire) {
|
||||
mask |= 0x01;
|
||||
}
|
||||
if (crouching) {
|
||||
mask |= 0x02;
|
||||
}
|
||||
//TODO Rethink, should we add this?
|
||||
if (riding) {
|
||||
mask |= 0x04;
|
||||
}
|
||||
if (sprinting) {
|
||||
mask |= 0x08;
|
||||
}
|
||||
if (swimming) {
|
||||
mask |= 0x10;
|
||||
}
|
||||
if (invisible) {
|
||||
mask |= 0x20;
|
||||
}
|
||||
if (glowing) {
|
||||
mask |= 0x40;
|
||||
}
|
||||
if (flyingWithElytra) {
|
||||
mask |= 0x80;
|
||||
}
|
||||
List<EntityData> metadata = new ArrayList<>(8);
|
||||
metadata.add(new EntityData(0, EntityDataTypes.BYTE, mask));
|
||||
metadata.add(new EntityData(1, EntityDataTypes.INT, airTicks));
|
||||
metadata.add(new EntityData(2, EntityDataTypes.OPTIONAL_COMPONENT, Optional.ofNullable(customName)));
|
||||
metadata.add(new EntityData(3, EntityDataTypes.BOOLEAN, customNameVisible));
|
||||
metadata.add(new EntityData(4, EntityDataTypes.BOOLEAN, silent));
|
||||
metadata.add(new EntityData(5, EntityDataTypes.BOOLEAN, !hasGravity));
|
||||
metadata.add(new EntityData(6, EntityDataTypes.ENTITY_POSE, pose));
|
||||
metadata.add(new EntityData(7, EntityDataTypes.INT, ticksFrozenInPowderedSnow));
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(List<EntityData> data) {
|
||||
for (EntityData entityData : data) {
|
||||
switch (entityData.getIndex()) {
|
||||
case 0:
|
||||
byte mask = (byte) entityData.getValue();
|
||||
onFire = (mask & 0x01) != 0;
|
||||
crouching = (mask & 0x02) != 0;
|
||||
riding = (mask & 0x04) != 0;
|
||||
sprinting = (mask & 0x08) != 0;
|
||||
swimming = (mask & 0x10) != 0;
|
||||
invisible = (mask & 0x20) != 0;
|
||||
glowing = (mask & 0x40) != 0;
|
||||
flyingWithElytra = (mask & 0x80) != 0;
|
||||
break;
|
||||
case 1:
|
||||
airTicks = (int) entityData.getValue();
|
||||
break;
|
||||
case 2:
|
||||
customName = ((Optional<Component>) entityData.getValue()).orElse(null);
|
||||
break;
|
||||
case 3:
|
||||
customNameVisible = (boolean) entityData.getValue();
|
||||
break;
|
||||
case 4:
|
||||
silent = (boolean) entityData.getValue();
|
||||
break;
|
||||
case 5:
|
||||
hasGravity = !(boolean) entityData.getValue();
|
||||
break;
|
||||
case 6:
|
||||
pose = (EntityPose) entityData.getValue();
|
||||
break;
|
||||
case 7:
|
||||
ticksFrozenInPowderedSnow = (int) entityData.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityBuilder<EntityBuilder> builderEntity() {
|
||||
return new EntityBuilder<>(new EntityDataProvider());
|
||||
}
|
||||
|
||||
public static class EntityBuilder<T extends EntityBuilder> {
|
||||
protected EntityDataProvider provider;
|
||||
|
||||
public EntityBuilder(EntityDataProvider provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public T customName(@Nullable Component customName) {
|
||||
((EntityDataProvider) provider).setCustomName(customName);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T customNameVisible(boolean customNameVisible) {
|
||||
((EntityDataProvider) provider).setCustomNameVisible(customNameVisible);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T pose(EntityPose pose) {
|
||||
((EntityDataProvider) provider).setPose(pose);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T onFire(boolean onFire) {
|
||||
((EntityDataProvider) provider).setOnFire(onFire);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T crouching(boolean crouching) {
|
||||
((EntityDataProvider) provider).setCrouching(crouching);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T riding(boolean riding) {
|
||||
((EntityDataProvider) provider).setRiding(riding);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T sprinting(boolean sprinting) {
|
||||
((EntityDataProvider) provider).setSprinting(sprinting);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T swimming(boolean swimming) {
|
||||
((EntityDataProvider) provider).setSwimming(swimming);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T invisible(boolean invisible) {
|
||||
((EntityDataProvider) provider).setInvisible(invisible);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T glowing(boolean glowing) {
|
||||
((EntityDataProvider) provider).setGlowing(glowing);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T flyingWithElytra(boolean flyingWithElytra) {
|
||||
((EntityDataProvider) provider).setFlyingWithElytra(flyingWithElytra);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T silent(boolean silent) {
|
||||
((EntityDataProvider) provider).setSilent(silent);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T hasGravity(boolean hasGravity) {
|
||||
((EntityDataProvider) provider).setHasGravity(hasGravity);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T airTicks(int airTicks) {
|
||||
((EntityDataProvider) provider).setAirTicks(airTicks);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T ticksFrozenInPowderedSnow(int ticksFrozenInPowderedSnow) {
|
||||
((EntityDataProvider) provider).setTicksFrozenInPowderedSnow(ticksFrozenInPowderedSnow);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public <K extends EntityDataProvider> K build() {
|
||||
return (K) provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
-232
@@ -1,232 +0,0 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.data.provider;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.player.InteractionHand;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class LivingEntityDataProvider extends EntityDataProvider {
|
||||
private boolean handActive;
|
||||
private InteractionHand hand = InteractionHand.MAIN_HAND;
|
||||
private boolean isInRiptideSpinAttack;
|
||||
private float health = 1.0f;
|
||||
private int potionEffectColor;
|
||||
private boolean potionEffectAmbient;
|
||||
private int arrowInBodyCount;
|
||||
private int beeStingsInBodyCount;
|
||||
@Nullable
|
||||
private Vector3i sleepingPosition;
|
||||
|
||||
|
||||
public boolean isHandActive() {
|
||||
return handActive;
|
||||
}
|
||||
|
||||
public void setHandActive(boolean handActive) {
|
||||
this.handActive = handActive;
|
||||
}
|
||||
|
||||
public InteractionHand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public void setHand(InteractionHand hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
public boolean isInRiptideSpinAttack() {
|
||||
return isInRiptideSpinAttack;
|
||||
}
|
||||
|
||||
public void setInRiptideSpinAttack(boolean inRiptideSpinAttack) {
|
||||
isInRiptideSpinAttack = inRiptideSpinAttack;
|
||||
}
|
||||
|
||||
public float getHealth() {
|
||||
return health;
|
||||
}
|
||||
|
||||
public void setHealth(float health) {
|
||||
this.health = health;
|
||||
}
|
||||
|
||||
public int getPotionEffectColor() {
|
||||
return potionEffectColor;
|
||||
}
|
||||
|
||||
public void setPotionEffectColor(int potionEffectColor) {
|
||||
this.potionEffectColor = potionEffectColor;
|
||||
}
|
||||
|
||||
public boolean isPotionEffectAmbient() {
|
||||
return potionEffectAmbient;
|
||||
}
|
||||
|
||||
public void setPotionEffectAmbient(boolean potionEffectAmbient) {
|
||||
this.potionEffectAmbient = potionEffectAmbient;
|
||||
}
|
||||
|
||||
public int getArrowInBodyCount() {
|
||||
return arrowInBodyCount;
|
||||
}
|
||||
|
||||
public void setArrowInBodyCount(int arrowInBodyCount) {
|
||||
this.arrowInBodyCount = arrowInBodyCount;
|
||||
}
|
||||
|
||||
public int getBeeStingsInBodyCount() {
|
||||
return beeStingsInBodyCount;
|
||||
}
|
||||
|
||||
public void setBeeStingsInBodyCount(int beeStingsInBodyCount) {
|
||||
this.beeStingsInBodyCount = beeStingsInBodyCount;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Vector3i getSleepingPosition() {
|
||||
return sleepingPosition;
|
||||
}
|
||||
|
||||
public void setSleepingPosition(@Nullable Vector3i sleepingPosition) {
|
||||
this.sleepingPosition = sleepingPosition;
|
||||
}
|
||||
|
||||
public static LivingEntityBuilder<LivingEntityBuilder> builderLivingEntity() {
|
||||
return new LivingEntityBuilder<>(new LivingEntityDataProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntityData> encode() {
|
||||
List<EntityData> metadata = super.encode();
|
||||
byte mask = 0x00;
|
||||
if (handActive) {
|
||||
mask |= 0x01;
|
||||
}
|
||||
|
||||
//TODO Confirm
|
||||
if (hand == InteractionHand.OFF_HAND) {
|
||||
mask |= 0x02;
|
||||
}
|
||||
|
||||
if (isInRiptideSpinAttack) {
|
||||
mask |= 0x04;
|
||||
}
|
||||
|
||||
|
||||
metadata.add(new EntityData(8, EntityDataTypes.BYTE, mask));
|
||||
metadata.add(new EntityData(9, EntityDataTypes.FLOAT, health));
|
||||
metadata.add(new EntityData(10, EntityDataTypes.INT, potionEffectColor));
|
||||
metadata.add(new EntityData(11, EntityDataTypes.BOOLEAN, potionEffectAmbient));
|
||||
metadata.add(new EntityData(12, EntityDataTypes.INT, arrowInBodyCount));
|
||||
metadata.add(new EntityData(13, EntityDataTypes.INT, beeStingsInBodyCount));
|
||||
metadata.add(new EntityData(14, EntityDataTypes.OPTIONAL_BLOCK_POSITION, Optional.ofNullable(sleepingPosition)));
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(List<EntityData> data) {
|
||||
super.decode(data);
|
||||
for (EntityData entityData : data) {
|
||||
switch (entityData.getIndex()) {
|
||||
case 8:
|
||||
byte mask = (byte) entityData.getValue();
|
||||
handActive = (mask & 0x01) != 0;
|
||||
//TODO Test, look into
|
||||
hand = (mask & 0x02) != 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
|
||||
isInRiptideSpinAttack = (mask & 0x04) != 0;
|
||||
break;
|
||||
case 9:
|
||||
health = (float) entityData.getValue();
|
||||
break;
|
||||
case 10:
|
||||
potionEffectColor = (int) entityData.getValue();
|
||||
break;
|
||||
case 11:
|
||||
potionEffectAmbient = (boolean) entityData.getValue();
|
||||
break;
|
||||
case 12:
|
||||
arrowInBodyCount = (int) entityData.getValue();
|
||||
break;
|
||||
case 13:
|
||||
beeStingsInBodyCount = (int) entityData.getValue();
|
||||
break;
|
||||
case 14:
|
||||
sleepingPosition = ((Optional<Vector3i>) entityData.getValue()).orElse(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LivingEntityBuilder<T extends LivingEntityBuilder> extends EntityDataProvider.EntityBuilder<T> {
|
||||
public LivingEntityBuilder(LivingEntityDataProvider livingEntityDataProvider) {
|
||||
super(livingEntityDataProvider);
|
||||
}
|
||||
|
||||
public T handActive(boolean handActive) {
|
||||
((LivingEntityDataProvider) provider).setHandActive(handActive);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T hand(InteractionHand hand) {
|
||||
((LivingEntityDataProvider) provider).setHand(hand);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T isInRiptideSpinAttack(boolean isInRiptideSpinAttack) {
|
||||
((LivingEntityDataProvider) provider).setInRiptideSpinAttack(isInRiptideSpinAttack);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T health(float health) {
|
||||
((LivingEntityDataProvider) provider).setHealth(health);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T potionEffectColor(int potionEffectColor) {
|
||||
((LivingEntityDataProvider) provider).setPotionEffectColor(potionEffectColor);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T potionEffectAmbient(boolean potionEffectAmbient) {
|
||||
((LivingEntityDataProvider) provider).setPotionEffectAmbient(potionEffectAmbient);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T arrowInBodyCount(int arrowInBodyCount) {
|
||||
((LivingEntityDataProvider) provider).setArrowInBodyCount(arrowInBodyCount);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T beeStingsInBodyCount(int beeStingsInBodyCount) {
|
||||
((LivingEntityDataProvider) provider).setBeeStingsInBodyCount(beeStingsInBodyCount);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T sleepingPosition(@Nullable Vector3i sleepingPosition) {
|
||||
((LivingEntityDataProvider) provider).setSleepingPosition(sleepingPosition);
|
||||
return (T) this;
|
||||
}
|
||||
}
|
||||
}
|
||||
-169
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.data.provider;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.player.HumanoidArm;
|
||||
import com.github.retrooper.packetevents.protocol.player.SkinSection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class PlayerDataProvider extends LivingEntityDataProvider {
|
||||
private float additionalHealth;
|
||||
private int score;
|
||||
private byte skinPartsMask = SkinSection.getMaskBySections(SkinSection.getAllSections());
|
||||
private HumanoidArm mainArm = HumanoidArm.RIGHT;
|
||||
private NBTCompound leftShoulderNBT = new NBTCompound();
|
||||
private NBTCompound rightShoulderNBT = new NBTCompound();
|
||||
|
||||
public float getAdditionalHealth() {
|
||||
return additionalHealth;
|
||||
}
|
||||
|
||||
public void setAdditionalHealth(float additionalHealth) {
|
||||
this.additionalHealth = additionalHealth;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(int score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public byte getSkinPartsMask() {
|
||||
return skinPartsMask;
|
||||
}
|
||||
|
||||
public void setSkinPartsMask(byte skinPartsMask) {
|
||||
this.skinPartsMask = skinPartsMask;
|
||||
}
|
||||
|
||||
public HumanoidArm getMainArm() {
|
||||
return mainArm;
|
||||
}
|
||||
|
||||
public void setMainArm(HumanoidArm mainArm) {
|
||||
this.mainArm = mainArm;
|
||||
}
|
||||
|
||||
public NBTCompound getLeftShoulderNBT() {
|
||||
return leftShoulderNBT;
|
||||
}
|
||||
|
||||
public void setLeftShoulderNBT(NBTCompound leftShoulderNBT) {
|
||||
this.leftShoulderNBT = leftShoulderNBT;
|
||||
}
|
||||
|
||||
public NBTCompound getRightShoulderNBT() {
|
||||
return rightShoulderNBT;
|
||||
}
|
||||
|
||||
public void setRightShoulderNBT(NBTCompound rightShoulderNBT) {
|
||||
this.rightShoulderNBT = rightShoulderNBT;
|
||||
}
|
||||
|
||||
public static PlayerBuilder<PlayerBuilder> builderPlayer() {
|
||||
return new PlayerBuilder<>(new PlayerDataProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntityData> encode() {
|
||||
List<EntityData> metadata = super.encode();
|
||||
metadata.add(new EntityData(15, EntityDataTypes.FLOAT, additionalHealth));
|
||||
metadata.add(new EntityData(16, EntityDataTypes.INT, score));
|
||||
metadata.add(new EntityData(17, EntityDataTypes.BYTE, skinPartsMask));
|
||||
metadata.add(new EntityData(18, EntityDataTypes.BYTE, (byte) mainArm.ordinal()));
|
||||
metadata.add(new EntityData(19, EntityDataTypes.NBT, leftShoulderNBT));
|
||||
metadata.add(new EntityData(20, EntityDataTypes.NBT, rightShoulderNBT));
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(List<EntityData> data) {
|
||||
super.decode(data);
|
||||
for (EntityData entityData : data) {
|
||||
switch (entityData.getIndex()) {
|
||||
case 15:
|
||||
additionalHealth = (float) entityData.getValue();
|
||||
break;
|
||||
case 16:
|
||||
score = (int) entityData.getValue();
|
||||
break;
|
||||
case 17:
|
||||
skinPartsMask = (byte) entityData.getValue();
|
||||
break;
|
||||
case 18:
|
||||
mainArm = HumanoidArm.values()[(byte) entityData.getValue()];
|
||||
break;
|
||||
case 19:
|
||||
leftShoulderNBT = (NBTCompound) entityData.getValue();
|
||||
break;
|
||||
case 20:
|
||||
rightShoulderNBT = (NBTCompound) entityData.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerBuilder<T extends PlayerBuilder> extends LivingEntityDataProvider.LivingEntityBuilder<T> {
|
||||
public PlayerBuilder(PlayerDataProvider entityDataProvider) {
|
||||
super(entityDataProvider);
|
||||
}
|
||||
|
||||
public T additionalHealth(float additionalHealth) {
|
||||
((PlayerDataProvider)provider).setAdditionalHealth(additionalHealth);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T score(int score) {
|
||||
((PlayerDataProvider)provider).setScore(score);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T skinPartsMask(byte skinPartsMask) {
|
||||
((PlayerDataProvider)provider).setSkinPartsMask(skinPartsMask);
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
public T skinParts(Set<SkinSection> skinSections) {
|
||||
((PlayerDataProvider)provider).setSkinPartsMask(SkinSection.getMaskBySections(skinSections));
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
public T mainArm(HumanoidArm mainArm) {
|
||||
((PlayerDataProvider)provider).setMainArm(mainArm);
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
public T leftShoulderNBT(NBTCompound leftShoulderNBT) {
|
||||
((PlayerDataProvider)provider).setLeftShoulderNBT(leftShoulderNBT);
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
public T rightShoulderNBT(NBTCompound rightShoulderNBT) {
|
||||
((PlayerDataProvider)provider).setRightShoulderNBT(rightShoulderNBT);
|
||||
return (T)this;
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -28,12 +28,22 @@ public enum EntityPose {
|
||||
SPIN_ATTACK,
|
||||
CROUCHING,
|
||||
LONG_JUMPING,
|
||||
DYING;
|
||||
DYING,
|
||||
CROAKING,
|
||||
USING_TONGUE,
|
||||
SITTING,
|
||||
ROARING,
|
||||
SNIFFING,
|
||||
EMERGING,
|
||||
DIGGING;
|
||||
|
||||
public int getId(ClientVersion version) {
|
||||
if (this == DYING && version.isOlderThan(ClientVersion.V_1_17)) {
|
||||
return 6;
|
||||
}
|
||||
if (this.ordinal() >= 11 && version.isOlderThan(ClientVersion.V_1_19_3)) {
|
||||
return this.ordinal() - 1;
|
||||
}
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@@ -42,6 +52,10 @@ public enum EntityPose {
|
||||
if (id == 6 && version.isOlderThan(ClientVersion.V_1_17)) {
|
||||
return DYING;
|
||||
}
|
||||
// The SITTING pose was added in 1.19.3, shifting Warden's poses by 1
|
||||
if (id >= 10 && version.isOlderThan(ClientVersion.V_1_19_3)) {
|
||||
id++;
|
||||
}
|
||||
return values()[id];
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,14 +16,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.github.retrooper.packetevents.util.google;
|
||||
package com.github.retrooper.packetevents.protocol.entity.sniffer;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class GuavaUtils_8 {
|
||||
public static <T, K> ConcurrentMap<T, K> makeMap() {
|
||||
return new MapMaker().weakValues().makeMap();
|
||||
}
|
||||
public enum SnifferState {
|
||||
IDLING,
|
||||
FEELING_HAPPY,
|
||||
SCENTING,
|
||||
SNIFFING,
|
||||
SEARCHING,
|
||||
DIGGING,
|
||||
RISING
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.transform;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class EntityTransformType {
|
||||
public static final EntityTransformType IDENTITY = new EntityTransformType(null, 1.0F, null);
|
||||
|
||||
private @Nullable TypeModifier typeModifier;
|
||||
private float scale;
|
||||
private @Nullable UserProfile playerSkin;
|
||||
|
||||
//Scale must be between 0.1F and 16.0F
|
||||
public EntityTransformType(@Nullable TypeModifier typeModifier, float scale, @Nullable UserProfile playerSkin) {
|
||||
this.typeModifier = typeModifier;
|
||||
this.scale = scale;
|
||||
this.playerSkin = playerSkin;
|
||||
}
|
||||
|
||||
public Optional<TypeModifier> getTypeModifier() {
|
||||
return Optional.ofNullable(typeModifier);
|
||||
}
|
||||
|
||||
public void setTypeModifier(@Nullable TypeModifier typeModifier) {
|
||||
this.typeModifier = typeModifier;
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public void setScale(float scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public Optional<UserProfile> getPlayerSkin() {
|
||||
return Optional.ofNullable(playerSkin);
|
||||
}
|
||||
|
||||
public void setPlayerSkin(@Nullable UserProfile playerSkin) {
|
||||
this.playerSkin = playerSkin;
|
||||
}
|
||||
|
||||
public static class TypeModifier {
|
||||
private EntityType entityType;
|
||||
private @Nullable NBTCompound tag;
|
||||
|
||||
public TypeModifier(EntityType entityType, @Nullable NBTCompound tag) {
|
||||
this.entityType = entityType;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public EntityType getEntityType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
public void setEntityType(EntityType entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
public Optional<NBTCompound> getTag() {
|
||||
return Optional.ofNullable(tag);
|
||||
}
|
||||
|
||||
public void setTag(@Nullable NBTCompound tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+24
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -42,7 +42,10 @@ public class EntityTypes {
|
||||
ClientVersion.V_1_15,
|
||||
ClientVersion.V_1_16,
|
||||
ClientVersion.V_1_16_2,
|
||||
ClientVersion.V_1_17);
|
||||
ClientVersion.V_1_17,
|
||||
ClientVersion.V_1_19,
|
||||
ClientVersion.V_1_19_3,
|
||||
ClientVersion.V_1_19_4);
|
||||
private static final TypesBuilder LEGACY_TYPES_BUILDER = new TypesBuilder("entity/legacy_entity_type_mappings",
|
||||
ClientVersion.V_1_8,
|
||||
ClientVersion.V_1_9,
|
||||
@@ -51,6 +54,12 @@ public class EntityTypes {
|
||||
ClientVersion.V_1_12,
|
||||
ClientVersion.V_1_13);
|
||||
|
||||
|
||||
static {
|
||||
TYPES_BUILDER.unloadFileMappings();
|
||||
LEGACY_TYPES_BUILDER.unloadFileMappings();
|
||||
}
|
||||
|
||||
public static EntityType define(String key, @Nullable EntityType parent) {
|
||||
TypesBuilderData data = TYPES_BUILDER.define(key);
|
||||
TypesBuilderData legacyData = LEGACY_TYPES_BUILDER.define(key);
|
||||
@@ -162,13 +171,16 @@ public class EntityTypes {
|
||||
public static final EntityType CHESTED_MINECART_ABSTRACT = define("chested_minecart_abstract", MINECART_ABSTRACT);
|
||||
public static final EntityType AREA_EFFECT_CLOUD = define("area_effect_cloud", ENTITY);
|
||||
public static final EntityType ARMOR_STAND = define("armor_stand", LIVINGENTITY);
|
||||
public static final EntityType ALLAY = define("allay", ABSTRACT_CREATURE);
|
||||
public static final EntityType ARROW = define("arrow", ABSTRACT_ARROW);
|
||||
public static final EntityType AXOLOTL = define("axolotl", ABSTRACT_ANIMAL);
|
||||
public static final EntityType BAT = define("bat", ABSTRACT_AMBIENT);
|
||||
public static final EntityType BEE = define("bee", ABSTRACT_INSENTIENT);
|
||||
public static final EntityType BLAZE = define("blaze", ABSTRACT_MONSTER);
|
||||
public static final EntityType BOAT = define("boat", ENTITY);
|
||||
public static final EntityType CHEST_BOAT = define("chest_boat", BOAT);
|
||||
public static final EntityType CAT = define("cat", ABSTRACT_TAMEABLE_ANIMAL);
|
||||
public static final EntityType CAMEL = define("camel", ABSTRACT_HORSE);
|
||||
public static final EntityType SPIDER = define("spider", ABSTRACT_MONSTER);
|
||||
public static final EntityType CAVE_SPIDER = define("cave_spider", SPIDER);
|
||||
public static final EntityType CHICKEN = define("chicken", ABSTRACT_ANIMAL);
|
||||
@@ -193,6 +205,7 @@ public class EntityTypes {
|
||||
public static final EntityType FALLING_BLOCK = define("falling_block", ENTITY);
|
||||
public static final EntityType FIREWORK_ROCKET = define("firework_rocket", ENTITY);
|
||||
public static final EntityType FOX = define("fox", ABSTRACT_ANIMAL);
|
||||
public static final EntityType FROG = define("frog", ABSTRACT_ANIMAL);
|
||||
public static final EntityType GHAST = define("ghast", ABSTRACT_FLYING);
|
||||
public static final EntityType GIANT = define("giant", ABSTRACT_MONSTER);
|
||||
public static final EntityType ITEM_FRAME = define("item_frame", ABSTRACT_HANGING);
|
||||
@@ -254,6 +267,7 @@ public class EntityTypes {
|
||||
public static final EntityType ENDER_PEARL = define("ender_pearl", PROJECTILE_ABSTRACT);
|
||||
public static final EntityType EXPERIENCE_BOTTLE = define("experience_bottle", PROJECTILE_ABSTRACT);
|
||||
public static final EntityType POTION = define("potion", PROJECTILE_ABSTRACT);
|
||||
public static final EntityType TADPOLE = define("tadpole", ABSTRACT_FISHES);
|
||||
@Deprecated // Exists only in 1.9 and 1.10
|
||||
public static final EntityType TIPPED_ARROW = define("tipped_arrow", ARROW);
|
||||
public static final EntityType TRIDENT = define("trident", ABSTRACT_ARROW);
|
||||
@@ -264,6 +278,7 @@ public class EntityTypes {
|
||||
public static final EntityType VILLAGER = define("villager", ABSTRACT_AGEABLE);
|
||||
public static final EntityType VINDICATOR = define("vindicator", ABSTRACT_ILLAGER_BASE);
|
||||
public static final EntityType WANDERING_TRADER = define("wandering_trader", ABSTRACT_AGEABLE);
|
||||
public static final EntityType WARDEN = define("warden", ABSTRACT_MONSTER);
|
||||
public static final EntityType WITCH = define("witch", ABSTRACT_MONSTER);
|
||||
public static final EntityType WITHER = define("wither", ABSTRACT_MONSTER);
|
||||
public static final EntityType WITHER_SKELETON = define("wither_skeleton", ABSTRACT_SKELETON);
|
||||
@@ -286,4 +301,11 @@ public class EntityTypes {
|
||||
public static final EntityType MINECART_TNT = define("minecart_tnt", MINECART_ABSTRACT);
|
||||
public static final EntityType MINECART_HOPPER = define("minecart_hopper", MINECART_ABSTRACT);
|
||||
public static final EntityType MINECART_MOB_SPAWNER = define("minecart_mob_spawner", MINECART_ABSTRACT);
|
||||
// Display type entities added in 1.19.4
|
||||
public static final EntityType DISPLAY = define("display", ENTITY);
|
||||
public static final EntityType BLOCK_DISPLAY = define("block_display", DISPLAY);
|
||||
public static final EntityType ITEM_DISPLAY = define("item_display", DISPLAY);
|
||||
public static final EntityType TEXT_DISPLAY = define("text_display", DISPLAY);
|
||||
public static final EntityType INTERACTION = define("interaction", DISPLAY);
|
||||
public static final EntityType SNIFFER = define("sniffer", ABSTRACT_ANIMAL);
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,6 +24,7 @@ import com.github.retrooper.packetevents.protocol.item.enchantment.type.Enchantm
|
||||
import com.github.retrooper.packetevents.protocol.item.type.ItemType;
|
||||
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.*;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -60,9 +61,8 @@ public class ItemStack {
|
||||
if (!this.cachedIsEmpty && this.getType().getMaxDurability() > 0) {
|
||||
NBTCompound tag = this.getNBT();
|
||||
return tag == null || !tag.getBoolean("Unbreakable");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDamaged() {
|
||||
@@ -125,7 +125,7 @@ public class ItemStack {
|
||||
}
|
||||
|
||||
public ItemStack copy() {
|
||||
return cachedIsEmpty ? EMPTY : new ItemStack(type, amount, nbt == null ? new NBTCompound() : nbt.copy(), legacyData);
|
||||
return cachedIsEmpty ? EMPTY : new ItemStack(type, amount, nbt == null ? null : nbt.copy(), legacyData);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -145,29 +145,30 @@ public class ItemStack {
|
||||
this.legacyData = legacyData;
|
||||
}
|
||||
|
||||
public boolean isEnchantable() {
|
||||
public boolean isEnchantable(ClientVersion version) {
|
||||
if (getType() == ItemTypes.BOOK) return getAmount() == 1;
|
||||
if (getType() == ItemTypes.ENCHANTED_BOOK) return false;
|
||||
return getMaxStackSize() == 1 && canBeDepleted() && !isEnchanted();
|
||||
return getMaxStackSize() == 1 && canBeDepleted() && !isEnchanted(version);
|
||||
}
|
||||
|
||||
public boolean isEnchanted() {
|
||||
if (!isEmpty() && this.nbt != null && this.nbt.getCompoundListTagOrNull("Enchantments") != null) {
|
||||
return !this.nbt.getCompoundListTagOrNull("Enchantments").isEmpty();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public boolean isEnchanted(ClientVersion version) {
|
||||
String tagName = getEnchantmentsTagName(version);
|
||||
return !isEmpty() && this.nbt != null && this.nbt.getCompoundListTagOrNull(tagName) != null && !this.nbt.getCompoundListTagOrNull(tagName).getTags().isEmpty();
|
||||
}
|
||||
|
||||
private static List<Enchantment> getEnchantments(@Nullable NBTCompound nbt) {
|
||||
if (nbt == null || nbt.getCompoundListTagOrNull("Enchantments") == null)
|
||||
private List<Enchantment> getEnchantments(@Nullable NBTCompound nbt, ClientVersion version) {
|
||||
String tagName = getEnchantmentsTagName(version);
|
||||
|
||||
if (nbt == null || nbt.getCompoundListTagOrNull(tagName) == null)
|
||||
return new ArrayList<>(0);
|
||||
NBTList<NBTCompound> nbtList = nbt.getCompoundListTagOrNull("Enchantments");
|
||||
|
||||
NBTList<NBTCompound> nbtList = nbt.getCompoundListTagOrNull(tagName);
|
||||
List<NBTCompound> compounds = nbtList.getTags();
|
||||
List<Enchantment> enchantments = new ArrayList<>(compounds.size());
|
||||
|
||||
for (NBTCompound compound : compounds) {
|
||||
String id = compound.getStringTagValueOrNull("id");
|
||||
EnchantmentType type = EnchantmentTypes.getByName(id);
|
||||
EnchantmentType type = getEnchantmentTypeFromTag(compound, version);
|
||||
|
||||
if (type != null) {
|
||||
NBTShort levelTag = compound.getTagOfTypeOrNull("lvl", NBTShort.class);
|
||||
int level = levelTag.getAsInt();
|
||||
@@ -175,21 +176,22 @@ public class ItemStack {
|
||||
enchantments.add(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
public List<Enchantment> getEnchantments() {
|
||||
return getEnchantments(this.nbt);
|
||||
public List<Enchantment> getEnchantments(ClientVersion version) {
|
||||
return getEnchantments(this.nbt, version);
|
||||
}
|
||||
|
||||
// TODO: Test on outdated versions
|
||||
public int getEnchantmentLevel(EnchantmentType enchantment) {
|
||||
if (isEnchanted()) {
|
||||
public int getEnchantmentLevel(EnchantmentType enchantment, ClientVersion version) {
|
||||
if (isEnchanted(version)) {
|
||||
// isEnchanted() is true, so we can assume that nbt is not null
|
||||
assert nbt != null;
|
||||
for (NBTCompound base : nbt.getCompoundListTagOrNull("Enchantments").getTags()) {
|
||||
NBTString string = base.getTagOfTypeOrNull("id", NBTString.class);
|
||||
if (string != null && enchantment == EnchantmentTypes.getByName(string.getValue())) {
|
||||
String tagName = getEnchantmentsTagName(version);
|
||||
for (NBTCompound base : nbt.getCompoundListTagOrNull(tagName).getTags()) {
|
||||
EnchantmentType type = getEnchantmentTypeFromTag(base, version);
|
||||
if (enchantment == type) {
|
||||
return base.getTagOfTypeOrNull("lvl", NBTShort.class).getAsInt();
|
||||
}
|
||||
}
|
||||
@@ -198,27 +200,51 @@ public class ItemStack {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setEnchantments(List<Enchantment> enchantments) {
|
||||
@Nullable
|
||||
private static EnchantmentType getEnchantmentTypeFromTag(NBTCompound tag, ClientVersion version) {
|
||||
if (version.isNewerThanOrEquals(ClientVersion.V_1_13)) {
|
||||
String id = tag.getStringTagValueOrNull("id");
|
||||
return EnchantmentTypes.getByName(id);
|
||||
} else {
|
||||
NBTShort idTag = tag.getTagOfTypeOrNull("id", NBTShort.class);
|
||||
return EnchantmentTypes.getById(version, idTag.getAsInt());
|
||||
}
|
||||
}
|
||||
|
||||
public void setEnchantments(List<Enchantment> enchantments, ClientVersion version) {
|
||||
nbt = getOrCreateTag(); // Create tag if null
|
||||
String tagName = getEnchantmentsTagName(version);
|
||||
if (enchantments.isEmpty()) {
|
||||
//Let us clear the enchantments
|
||||
if (nbt.getTagOrNull("Enchantments") != null) {
|
||||
nbt.removeTag("Enchantments");
|
||||
if (nbt.getTagOrNull(tagName) != null) {
|
||||
nbt.removeTag(tagName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
List<NBTCompound> list = new ArrayList<>();
|
||||
for (Enchantment enchantment : enchantments) {
|
||||
NBTCompound compound = new NBTCompound();
|
||||
compound.setTag("id", new NBTString(enchantment.getType().getName().toString()));
|
||||
if (version.isNewerThanOrEquals(ClientVersion.V_1_13)) {
|
||||
compound.setTag("id", new NBTString(enchantment.getType().getName().toString()));
|
||||
} else {
|
||||
compound.setTag("id", new NBTShort((short) enchantment.getType().getId(version)));
|
||||
}
|
||||
|
||||
compound.setTag("lvl", new NBTShort((short) enchantment.getLevel()));
|
||||
list.add(compound);
|
||||
}
|
||||
assert nbt != null; // NBT was created in getOrCreateTag()
|
||||
nbt.setTag("Enchantments", new NBTList<>(NBTType.COMPOUND, list));
|
||||
nbt.setTag(tagName, new NBTList<>(NBTType.COMPOUND, list));
|
||||
}
|
||||
}
|
||||
|
||||
public String getEnchantmentsTagName(ClientVersion version) {
|
||||
String tagName = version.isNewerThanOrEquals(ClientVersion.V_1_13) ? "Enchantments" : "ench";
|
||||
if (type == ItemTypes.ENCHANTED_BOOK) {
|
||||
tagName = "StoredEnchantments";
|
||||
}
|
||||
return tagName;
|
||||
}
|
||||
|
||||
public boolean canBeDepleted() {
|
||||
return this.getType().getMaxDurability() > 0;
|
||||
}
|
||||
@@ -232,7 +258,16 @@ public class ItemStack {
|
||||
}
|
||||
|
||||
public static boolean tagMatches(ItemStack left, ItemStack right) {
|
||||
return left.isEmpty() && right.isEmpty() || (!left.isEmpty() && !right.isEmpty() && ((left.nbt != null || right.nbt == null) && (left.nbt == null || left.nbt.equals(right.nbt))));
|
||||
if (left == right) {
|
||||
return true;
|
||||
}
|
||||
if (left == null) {
|
||||
return right.isEmpty();
|
||||
}
|
||||
if (right == null) {
|
||||
return left.isEmpty();
|
||||
}
|
||||
return Objects.equals(left.nbt, right.nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -274,7 +309,6 @@ public class ItemStack {
|
||||
private int amount = 1;
|
||||
private NBTCompound nbt = null;
|
||||
private int legacyData = -1;
|
||||
private List<Enchantment> enchantments = null;
|
||||
|
||||
public Builder type(ItemType type) {
|
||||
this.type = type;
|
||||
@@ -288,13 +322,6 @@ public class ItemStack {
|
||||
|
||||
public Builder nbt(NBTCompound nbt) {
|
||||
this.nbt = nbt;
|
||||
|
||||
List<Enchantment> nbtEnchantments = getEnchantments(nbt);
|
||||
// This assumes logically, if already set enchants before NBT, then they would still want the enchants
|
||||
if (!nbtEnchantments.isEmpty()) {
|
||||
this.enchantments = nbtEnchantments;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -303,32 +330,8 @@ public class ItemStack {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Side effect: This will cause NBT to be created if it is null
|
||||
* This may affect some client sided inventory operations and may cause a desync
|
||||
*
|
||||
* @param enchantments The enchantments to set
|
||||
* @return This builder
|
||||
*/
|
||||
public Builder enchantments(List<Enchantment> enchantments) {
|
||||
this.enchantments = enchantments;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addEnchantment(Enchantment enchantment) {
|
||||
if (enchantments == null) {
|
||||
enchantments = new ArrayList<>();
|
||||
}
|
||||
this.enchantments.add(enchantment);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack build() {
|
||||
ItemStack stack = new ItemStack(type, amount, nbt, legacyData);
|
||||
if (enchantments != null) {
|
||||
stack.setEnchantments(enchantments);
|
||||
}
|
||||
return stack;
|
||||
return new ItemStack(type, amount, nbt, legacyData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.github.retrooper.packetevents.protocol.item.book;
|
||||
|
||||
public enum BookType {
|
||||
CRAFTING,
|
||||
FURNACE,
|
||||
BLAST_FURNACE,
|
||||
SMOKER;
|
||||
|
||||
public int getId() {
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
public static BookType getById(int id) {
|
||||
return VALUES[id];
|
||||
}
|
||||
|
||||
private static final BookType[] VALUES = values();
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+8
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2021 retrooper and contributors
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -34,7 +34,8 @@ public class EnchantmentTypes {
|
||||
ClientVersion.V_1_12,
|
||||
ClientVersion.V_1_13,
|
||||
ClientVersion.V_1_14,
|
||||
ClientVersion.V_1_16);
|
||||
ClientVersion.V_1_16,
|
||||
ClientVersion.V_1_19);
|
||||
|
||||
public static EnchantmentType define(String key) {
|
||||
TypesBuilderData data = TYPES_BUILDER.define(key);
|
||||
@@ -94,6 +95,7 @@ public class EnchantmentTypes {
|
||||
public static final EnchantmentType FROST_WALKER = define("frost_walker");
|
||||
public static final EnchantmentType BINDING_CURSE = define("binding_curse");
|
||||
public static final EnchantmentType SOUL_SPEED = define("soul_speed");
|
||||
public static final EnchantmentType SWIFT_SNEAK = define("swift_sneak");
|
||||
public static final EnchantmentType SHARPNESS = define("sharpness");
|
||||
public static final EnchantmentType SMITE = define("smite");
|
||||
public static final EnchantmentType BANE_OF_ARTHROPODS = define("bane_of_arthropods");
|
||||
@@ -120,4 +122,8 @@ public class EnchantmentTypes {
|
||||
public static final EnchantmentType PIERCING = define("piercing");
|
||||
public static final EnchantmentType MENDING = define("mending");
|
||||
public static final EnchantmentType VANISHING_CURSE = define("vanishing_curse");
|
||||
|
||||
static {
|
||||
TYPES_BUILDER.unloadFileMappings();
|
||||
}
|
||||
}
|
||||
Loaded 100 of 582 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user