Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f767de3beb
|
||
|
|
78dcd67723
|
||
|
|
f3249e6b9e | ||
|
|
0099e0e3d2 | ||
|
|
f2569fd50e | ||
|
|
e90aeef31b | ||
|
|
3d653a1856 | ||
|
|
b5e0b5ceca | ||
|
|
dcc3cec023 | ||
|
|
989c38f377 | ||
|
|
fea65c7891 | ||
|
|
d49555c5e1 | ||
|
|
dedb96e5cb | ||
|
|
1b0a8bf8de | ||
|
|
8bf18ac3c6 | ||
|
|
61a91ca4a9 | ||
|
|
5e281eb967 | ||
|
|
f0b29d0266 | ||
|
|
4ec6b01e6a | ||
|
|
58a1ada322 | ||
|
|
195ee0446a | ||
|
|
629080cfb3 | ||
|
|
2390e06ad3 | ||
|
|
b6a3e39cae | ||
|
|
548312ea34 | ||
|
|
1c1702b11d | ||
|
|
eb09f196e5 | ||
|
|
d122518bcf | ||
|
|
fd53b95457 | ||
|
|
76af835e2e | ||
|
|
90a196d3bc | ||
|
|
ae928dbee1 | ||
|
|
fa701e81cf | ||
|
|
c44e502dab | ||
|
|
8669b0f183 | ||
|
|
2b9e7b1166 | ||
|
|
5a00e5c79f | ||
|
|
887fa9ff4c | ||
|
|
ac962ce70d | ||
|
|
21866cc94f | ||
|
|
497c8dbd94 | ||
|
|
40cd6b43cb | ||
|
|
84b3392e9a | ||
|
|
b654ab1b54 | ||
|
|
1639b73a0d | ||
|
|
74163d2edf | ||
|
|
a35742fc64 | ||
|
|
2768b3445f | ||
|
|
7763337e37 | ||
|
|
c93fcd2c0f | ||
|
|
ae20589b1a | ||
|
|
6e2005c6c9 | ||
|
|
d7f3ff6e06 | ||
|
|
75b6d14aac | ||
|
|
f250854243 | ||
|
|
bfd1b40482 | ||
|
|
941bf7c30e | ||
|
|
28f14a7b42 | ||
|
|
a3dc1118f8 | ||
|
|
8b9ca0541a | ||
|
|
6680d33abb | ||
|
|
4e6ae10528 | ||
|
|
c728f2fd05 | ||
|
|
aa54f50116 | ||
|
|
f9775eb3ce | ||
|
|
d8adfb132a | ||
|
|
ebd8a66d05 | ||
|
|
024d4b93a3 | ||
|
|
a04e0eddc7 | ||
|
|
0c1e3ee82d | ||
|
|
e65004c12e | ||
|
|
e61a83e5ad | ||
|
|
10d126cbe7 | ||
|
|
39df65b111 | ||
|
|
d8c39f6463 | ||
|
|
b97c13b487 | ||
|
|
71c8f41bd4 | ||
|
|
eeea9d7fdc | ||
|
|
e46deea6c5 | ||
|
|
0e30d2f5ee | ||
|
|
c2634d2dc3 | ||
|
|
d1254391aa | ||
|
|
3dae51062d | ||
|
|
86e454077a | ||
|
|
7d032a3e4a | ||
|
|
b4b6ff015e | ||
|
|
db647ba73a | ||
|
|
5dd5de04a8 | ||
|
|
bfbeb8dafc | ||
|
|
577590b1eb | ||
|
|
c828e8b111 | ||
|
|
9109e247db | ||
|
|
fe29db24cf | ||
|
|
3c8079aee2 | ||
|
|
ee82a47abb | ||
|
|
7251ee1b18 | ||
|
|
1582bca318 | ||
|
|
0615c78075 | ||
|
|
fbb80124db | ||
|
|
3430b25b5e | ||
|
|
def0ce4840 | ||
|
|
ed89d0a5a8 | ||
|
|
7af96fec84 | ||
|
|
d8fd027415 | ||
|
|
4441e04472 | ||
|
|
c5bec028c0 | ||
|
|
bd6008d5a7 | ||
|
|
fc4157127a | ||
|
|
ea3c9d085e | ||
|
|
1b1a104cc4 | ||
|
|
6d43d90367 | ||
|
|
3323449eea | ||
|
|
c72ca2baa0 | ||
|
|
d4e6fff86e | ||
|
|
06c96900ec | ||
|
|
a0dd21bed5 | ||
|
|
b25c0f9850 | ||
|
|
f9ab88c9e4 | ||
|
|
3238a3eca4 | ||
|
|
8685846be3 | ||
|
|
2ebfa4185b | ||
|
|
c4b4c8d9e0 | ||
|
|
60dd509fcb | ||
|
|
b6c67c320e | ||
|
|
e4676a18fe | ||
|
|
a5b0758b67 | ||
|
|
27ba69fa43 | ||
|
|
14b162b098 | ||
|
|
f1e9a6f1e8 | ||
|
|
00c8164201 | ||
|
|
206d1e03bb | ||
|
|
c180263e3f | ||
|
|
8872c65ba2 | ||
|
|
abe79fb351 | ||
|
|
b76a014432 | ||
|
|
c7b9e15cef | ||
|
|
fade6da4e2 | ||
|
|
86c67bfe52 | ||
|
|
6cda366bc2 | ||
|
|
2771c6c5d1 | ||
|
|
7ba541843b | ||
|
|
47ac4d5894 | ||
|
|
6c424946fe | ||
|
|
b4e5b10299 | ||
|
|
efeb9019a6 | ||
|
|
5b994a58da | ||
|
|
0d030d0ca7 | ||
|
|
8b45ddd4ef | ||
|
|
cff73e9e67 | ||
|
|
a7fa150836 | ||
|
|
7225117fea | ||
|
|
3f44016db1 | ||
|
|
c0dc2c5908 | ||
|
|
8a0ebb77eb | ||
|
|
4ebb0acbfe | ||
|
|
b4831c4f09 | ||
|
|
17563f1856 | ||
|
|
486cf4c74d | ||
|
|
0528f0ebc6 | ||
|
|
ce43c2ba84 | ||
|
|
f37bb34cdf | ||
|
|
3fb60fa2c5 | ||
|
|
e59c1a5d3a | ||
|
|
3831a7d1f0 | ||
|
|
f7aee7c797 | ||
|
|
68b0a65288 | ||
|
|
7633319f2a | ||
|
|
ca8ca25a3f | ||
|
|
a96657d600 | ||
|
|
bf664a4314 | ||
|
|
8dd5bec27f | ||
|
|
e11ae8b2cf | ||
|
|
c8f070cf7d | ||
|
|
cc76a19fe3 | ||
|
|
d0b4ca57d1 | ||
|
|
18d103d202 | ||
|
|
56241cee40 | ||
|
|
061874fa46 | ||
|
|
c1d22c98ef | ||
|
|
06c7afd21a | ||
|
|
ecb360eabd | ||
|
|
56941722aa | ||
|
|
2452d753af | ||
|
|
2085a725b0 | ||
|
|
b67f99e8ea | ||
|
|
eee5dd7fa2 | ||
|
|
9c5e2bd4c9 | ||
|
|
87efd2dcf3 | ||
|
|
170e1a9cb5 | ||
|
|
7d4ef278cd | ||
|
|
05c6d3447a | ||
|
|
ef9f8d2000 | ||
|
|
9d192b61ea | ||
|
|
d4d7e96c15 | ||
|
|
918fa83388 | ||
|
|
34f26bb3bd | ||
|
|
ccbfa6cf00 | ||
|
|
bcb429ec7f | ||
|
|
5f38d74cfc | ||
|
|
5111c354c1 | ||
|
|
643b2e9975 | ||
|
|
d9bc12b05e | ||
|
|
f7e6de8594 | ||
|
|
8275088bda | ||
|
|
06dd7a5555 | ||
|
|
4fa6bccaa7 | ||
|
|
7df7e3700b | ||
|
|
adf1b2692a | ||
|
|
b57d3364a3 | ||
|
|
48e67537c1 | ||
|
|
fe7455e379 | ||
|
|
01e4f20c68 | ||
|
|
bf066d6156 | ||
|
|
20bf1fd89d | ||
|
|
f2a470f943 | ||
|
|
845077ff35 | ||
|
|
ff03e29b3f | ||
|
|
fad9a4873f | ||
|
|
ad21d93863 | ||
|
|
4d366d06cd | ||
|
|
197a3c956e | ||
|
|
f8371c461d | ||
|
|
02f0855d3d | ||
|
|
22a4085978 | ||
|
|
acae93e9cf | ||
|
|
803cf8f109 | ||
|
|
4af2de9fee | ||
|
|
d916789acb | ||
|
|
54d120c296 | ||
|
|
a84cbbd209 | ||
|
|
295b6f268e | ||
|
|
a1e674f61d | ||
|
|
bf1f896b39 | ||
|
|
eeb2b40138 | ||
|
|
60ff394785 | ||
|
|
149c017099 | ||
|
|
233d6c150c | ||
|
|
96aa95f9d7 | ||
|
|
7e1a8a704a | ||
|
|
cd769921b9 | ||
|
|
7d33952145 | ||
|
|
58f1134254 | ||
|
|
6d1f2830d1 | ||
|
|
d103dd74f9 | ||
|
|
cd0f238b97 | ||
|
|
d7a475adfd | ||
|
|
ccfb6b422c | ||
|
|
2c8143ddb0 | ||
|
|
f9892c598c | ||
|
|
3eb79fd6d2 | ||
|
|
8ddceada42 | ||
|
|
a1c355d4c9 | ||
|
|
5c23459e1e | ||
|
|
af3dbc928b | ||
|
|
bd1bc7f06a | ||
|
|
7f16b992eb | ||
|
|
460884cbd8 | ||
|
|
0cc99eadde | ||
|
|
24bf010d98 | ||
|
|
e74adedf88 | ||
|
|
a34d03f422 | ||
|
|
c0a9be3c7d | ||
|
|
8f352d9115 | ||
|
|
6ca306405c | ||
|
|
d4190b2fde | ||
|
|
30ed0bdcf3 | ||
|
|
c3e2c3ee9e | ||
|
|
155f8520d4 | ||
|
|
55b548d3ca | ||
|
|
8eff09ff6e | ||
|
|
59596653a2 | ||
|
|
4df76391cb | ||
|
|
822f1d26b8 | ||
|
|
55a42ab0e2 | ||
|
|
cdf3521154 | ||
|
|
820b530240 | ||
|
|
1823f61748 | ||
|
|
d27d8ffd6a | ||
|
|
7a57012822 | ||
|
|
0a10f4d861 | ||
|
|
d1a3145483 | ||
|
|
08096106f8 | ||
|
|
a3fbccc454 | ||
|
|
9ea931d58d | ||
|
|
364be4e34d | ||
|
|
b22394c288 | ||
|
|
208dfbc3f3 | ||
|
|
cfb054b8b2 | ||
|
|
f47e6880fd | ||
|
|
f55f791f8a | ||
|
|
ba389ddb57 | ||
|
|
2ce143d466 | ||
|
|
b7f99503d9 | ||
|
|
52adfbae8a | ||
|
|
a861066cab | ||
|
|
1acec02bfb | ||
|
|
b88857386a | ||
|
|
4c48d4c1df | ||
|
|
68f8fd3d03 | ||
|
|
2d625c6e7a | ||
|
|
83fe2cce0d | ||
|
|
73bfaebab6 | ||
|
|
2ac61fd5cb | ||
|
|
7d31150b35 | ||
|
|
11e4033ec6 | ||
|
|
a6a8866727 | ||
|
|
ce61c3ef52 | ||
|
|
4602ea8107 | ||
|
|
5fb1a6c85e | ||
|
|
7e2ac525ac | ||
|
|
7590d6f7de | ||
|
|
d7c2284ccb | ||
|
|
84a0759288 | ||
|
|
0ca8e27fc8 | ||
|
|
5e30aef0a1 | ||
|
|
9e53791fef | ||
|
|
8346918e86 | ||
|
|
7714c6253a | ||
|
|
0a00e970d7 | ||
|
|
d0dd8dc4cd | ||
|
|
bc01609828 | ||
|
|
c6e7bcb980 | ||
|
|
8987194030 | ||
|
|
4495db796d | ||
|
|
e1a29a20a7 | ||
|
|
bd5ef7cb30 | ||
|
|
36363c885c | ||
|
|
a198f0e8d6 | ||
|
|
69cbe1e405 | ||
|
|
2b0ec87da6 | ||
|
|
08f95b8036 | ||
|
|
a15ad3a8d7 | ||
|
|
fef7f983b0 | ||
|
|
71eae683fb | ||
|
|
f692f41025 | ||
|
|
3b4acde6f8 | ||
|
|
6b14595582 | ||
|
|
50c2a69449 | ||
|
|
b62fc6922c | ||
|
|
cffc7750b9 | ||
|
|
838109ccd5 | ||
|
|
67f413cc59 | ||
|
|
c498332c36 | ||
|
|
1b5479f04f | ||
|
|
ac0041ff52 | ||
|
|
c6f129cdd3 | ||
|
|
21226e6ac9 | ||
|
|
b14f5f5031 | ||
|
|
6ff9f8c401 | ||
|
|
22b28b7b35 | ||
|
|
9e7de426c0 | ||
|
|
77abb65bab | ||
|
|
a5188e5d78 | ||
|
|
cce0ac2d7b | ||
|
|
001f6b9fd7 | ||
|
|
0395378726 | ||
|
|
31fe7a89d9 | ||
|
|
d8b47495e4 | ||
|
|
cba4603ad8 | ||
|
|
f37c74d0d9 | ||
|
|
2085dfb84b | ||
|
|
cdad13d5c5 | ||
|
|
95b50a44e9 | ||
|
|
78f630b5c1 | ||
|
|
08d000ea82 | ||
|
|
28c4fdc7ce | ||
|
|
96c81a69ae | ||
|
|
83720c6a81 | ||
|
|
c95acffab6 | ||
|
|
c2beb331f1 | ||
|
|
2667431ec9 | ||
|
|
21ce0f4d34 | ||
|
|
21c1a7dfa8 | ||
|
|
518a995e8e | ||
|
|
e20e0854ab | ||
|
|
7c3cde51f0 | ||
|
|
cc18a7ad08 | ||
|
|
35fa135e9e | ||
|
|
c68fe76156 | ||
|
|
80846cfea2 | ||
|
|
1a1b03c1f5 | ||
|
|
c411a1925b | ||
|
|
d8b4f5b1b6 | ||
|
|
486c9a493a | ||
|
|
b1ed98f53d | ||
|
|
ca8ca782fc | ||
|
|
c75f039c99 | ||
|
|
c1324fe7fe | ||
|
|
781d4a7c82 | ||
|
|
590479adda | ||
|
|
df2c50ccfc | ||
|
|
f5b60ea3f2 | ||
|
|
c95194f147 | ||
|
|
56a643f8d0 | ||
|
|
7daed688e0 | ||
|
|
f3782dffe1 | ||
|
|
b06063ebf7 | ||
|
|
6cb3d301d8 | ||
|
|
1aab738dd5 | ||
|
|
0aafad8b58 | ||
|
|
910d77252e | ||
|
|
524e6ca16d | ||
|
|
1aa88d05bf | ||
|
|
70271f3694 | ||
|
|
62201ae3fa | ||
|
|
8ce56fc346 | ||
|
|
8029fd1b4e | ||
|
|
de19712dbb | ||
|
|
1d41037bdd | ||
|
|
a98b8c5604 | ||
|
|
7d5d2682b7 | ||
|
|
2b5f8027f0 | ||
|
|
1e37351b48 | ||
|
|
70c8aad74e | ||
|
|
5527546f05 | ||
|
|
56671341ae | ||
|
|
41ea688ff3 | ||
|
|
004195144d | ||
|
|
962aefba17 | ||
|
|
88ec7a583d | ||
|
|
2303d362d7 | ||
|
|
da0e95fa03 | ||
|
|
c98bfad8b8 | ||
|
|
3dfb8389dc | ||
|
|
7c74dd2e05 | ||
|
|
05eabbf667 | ||
|
|
d1cafe2bcc | ||
|
|
26078fcb59 | ||
|
|
3d602b9f96 | ||
|
|
df4f9e425e | ||
|
|
efb9766388 | ||
|
|
ab0ad68d43 | ||
|
|
1be8db5ff4 | ||
|
|
1f68ee1f46 | ||
|
|
e7c6ae4726 | ||
|
|
5db1671895 | ||
|
|
023a0da619 | ||
|
|
51863fa435 | ||
|
|
f46ec64e60 | ||
|
|
f0d7a8e84d | ||
|
|
ac4fac85ed | ||
|
|
8f274e0695 | ||
|
|
cd0892ffe4 | ||
|
|
f9398b58f7 | ||
|
|
9c9f5cf41d | ||
|
|
5983395561 | ||
|
|
686bb4fd3f | ||
|
|
ff4ac7eefc | ||
|
|
20b52fbcd9 | ||
|
|
424fd149e7 | ||
|
|
e372f4f30a | ||
|
|
b520a2ea99 | ||
|
|
4e4174b7d3 | ||
|
|
0931f7c9e7 | ||
|
|
4faf97cdb4 | ||
|
|
71fa7be70d | ||
|
|
a7cb0ce6bf | ||
|
|
8fa1b820d4 | ||
|
|
05f42bc9d5 | ||
|
|
b635dcbe54 | ||
|
|
a1def4170c | ||
|
|
53f1fc495b | ||
|
|
17086d3017 | ||
|
|
d604e9d6af | ||
|
|
76aba6fb8d | ||
|
|
5e8ad3e6e2 | ||
|
|
2f780a22a0 | ||
|
|
7549b22604 | ||
|
|
8083725b96 | ||
|
|
3e624ebde5 | ||
|
|
16f031c585 | ||
|
|
32f7d0b68b | ||
|
|
8a3a418d05 | ||
|
|
3a76049868 | ||
|
|
e7495c2e85 | ||
|
|
a2726516b3 | ||
|
|
bf57fef29c | ||
|
|
a9679cd5b2 | ||
|
|
8e3eba761d | ||
|
|
b4ef9b90b9 | ||
|
|
b2ccbe0bed | ||
|
|
1913c6603e | ||
|
|
9eafaaab7d | ||
|
|
e672aa2b92 | ||
|
|
1ba1ec17fa | ||
|
|
288b0a5bed | ||
|
|
2bc4056c9c | ||
|
|
1c0b85a689 | ||
|
|
51e2538ea4 | ||
|
|
47645e4ea0 | ||
|
|
5aa121db9a | ||
|
|
c32300cd04 | ||
|
|
0d9b183ea1 | ||
|
|
a215fd9b4d | ||
|
|
2ffb9335b3 | ||
|
|
d9ddf4e598 | ||
|
|
eb3b9593be | ||
|
|
e49b989025 | ||
|
|
fdd7947728 | ||
|
|
cc4b69acf5 | ||
|
|
3139282035 | ||
|
|
9a721c79d5 | ||
|
|
5c4ccc544c | ||
|
|
751b93c51f | ||
|
|
1a0c9da630 | ||
|
|
383a680a70 | ||
|
|
83e600c301 | ||
|
|
f69eb78aa4 | ||
|
|
c046bd5a9d | ||
|
|
8740a5ed0f | ||
|
|
9e89b0a5c7 | ||
|
|
5b45f3c634 | ||
|
|
a95250f4f7 | ||
|
|
fb31dab995 | ||
|
|
d3aba54f69 | ||
|
|
e823e17f69 | ||
|
|
98e46dd38a | ||
|
|
405caec719 | ||
|
|
c32b1b90b1 | ||
|
|
2272315d83 | ||
|
|
dfd8eccf87 | ||
|
|
b826fbc197 | ||
|
|
878c7a96d6 | ||
|
|
3a1474c5a6 | ||
|
|
0f94fc8216 | ||
|
|
445893d664 | ||
|
|
e8cc99fa0d | ||
|
|
9948837294 | ||
|
|
3e0191aa17 | ||
|
|
8a3ee34e28 | ||
|
|
ae317c535b | ||
|
|
2949af533f | ||
|
|
e90f377c61 | ||
|
|
088ded2190 | ||
|
|
93a6e3f5ed | ||
|
|
63a6b158eb | ||
|
|
c471b691f7 | ||
|
|
b2c4bb8928 | ||
|
|
253d5f968e | ||
|
|
533274fd45 | ||
|
|
4a35ebf7eb | ||
|
|
9dd45ffc48 | ||
|
|
1e8bee4179 | ||
|
|
b367e1da91 | ||
|
|
2808e35234 | ||
|
|
df7b69249b | ||
|
|
6650ee5d64 | ||
|
|
c75e137bd0 | ||
|
|
57d00aaa4e | ||
|
|
e8a95aeb8e | ||
|
|
2fcdce578d | ||
|
|
ac729a30e3 | ||
|
|
2b626d38b1 | ||
|
|
a5d3633088 | ||
|
|
c79cea2b42 | ||
|
|
9c4e438099 | ||
|
|
7572eeb5ca | ||
|
|
b78f8369f4 | ||
|
|
881898d788 | ||
|
|
c355dbf1fc | ||
|
|
17262757ce | ||
|
|
e890fcd7e5 | ||
|
|
90ff84471f | ||
|
|
963643bdeb | ||
|
|
12c2c307eb | ||
|
|
a4fefad9e6 | ||
|
|
9bb7b6e458 | ||
|
|
18ed3fb529 | ||
|
|
6c70181d77 | ||
|
|
ed848d93d3 | ||
|
|
db30205fa6 | ||
|
|
d33cb38f15 | ||
|
|
1371809b37 | ||
|
|
3a24bed6fb | ||
|
|
ab5f4ee049 | ||
|
|
da8bdd9384 | ||
|
|
7e398fe45a | ||
|
|
1f6314a262 | ||
|
|
2c238c251e | ||
|
|
0018d60f9c | ||
|
|
f9670a71b1 | ||
|
|
bede82c866 | ||
|
|
d5cca6490f | ||
|
|
8f920cd6cc | ||
|
|
06eb3f4b90 | ||
|
|
e57002768b | ||
|
|
a85de1cef2 | ||
|
|
39d45d8d1f | ||
|
|
1bb6268a62 | ||
|
|
4c87f3fce1 | ||
|
|
86358c3fe9 | ||
|
|
34846df85b | ||
|
|
5b214e4187 | ||
|
|
5280f26e00 | ||
|
|
8226aed28e | ||
|
|
ec4496f837 | ||
|
|
91730fdb46 | ||
|
|
c892a15c5a | ||
|
|
2fc6613df0 | ||
|
|
cf0a3115f0 | ||
|
|
513b970c4d | ||
|
|
2b03bbce7c | ||
|
|
319568d92a | ||
|
|
f666047ae5 | ||
|
|
e86beec90f | ||
|
|
3d416fc961 | ||
|
|
2cd2f5d7f9 | ||
|
|
688e32d9a6 | ||
|
|
ef49276809 | ||
|
|
a3116dc2a6 | ||
|
|
3fda55bc39 | ||
|
|
f78294afb4 | ||
|
|
0a30904217 | ||
|
|
8a1506ee53 | ||
|
|
795798de41 | ||
|
|
fed7c147d8 | ||
|
|
5cdb80c002 | ||
|
|
57add57796 | ||
|
|
f7a72713e1 | ||
|
|
2c0a5346f4 | ||
|
|
3627cd4d5a | ||
|
|
6f39702af7 | ||
|
|
fe316a4368 | ||
|
|
e026ef8181 | ||
|
|
d9e78b71a6 | ||
|
|
92fc265333 | ||
|
|
d75137fe5f | ||
|
|
3d90acad8e | ||
|
|
dc3c168d84 | ||
|
|
8a5d4fc3e0 | ||
|
|
8cbfde0c3f | ||
|
|
9dc5908c5e | ||
|
|
3bdab06db4 | ||
|
|
e08b5f69bf | ||
|
|
f6e76b65b6 | ||
|
|
bbf8749f1e | ||
|
|
d4f7f64fc6 | ||
|
|
4a9cd4b8aa | ||
|
|
83ae030352 | ||
|
|
88b3b00c43 | ||
|
|
3b9c3632ad | ||
|
|
e8a8f0d0a3 | ||
|
|
113b4a84c2 | ||
|
|
a9a6c11402 | ||
|
|
2cb427e06d | ||
|
|
22bea4e7b0 | ||
|
|
6703db2528 | ||
|
|
44223018b0 | ||
|
|
d7b677c4db | ||
|
|
e531e434b6 | ||
|
|
97dcbc606e | ||
|
|
4d55df1569 | ||
|
|
a028653207 | ||
|
|
0d92230183 | ||
|
|
5c6c41e62f | ||
|
|
88ff380bbd | ||
|
|
8dd207ccec | ||
|
|
73426fb7bf | ||
|
|
3f13e4374a | ||
|
|
478a3e56c3 | ||
|
|
699594090a | ||
|
|
2a137b0059 | ||
|
|
81c53d3c4c | ||
|
|
c824f9c835 | ||
|
|
e1df40710e | ||
|
|
6507a73042 | ||
|
|
6a99936110 | ||
|
|
93441ece77 | ||
|
|
f5776682ce | ||
|
|
be264f3d81 | ||
|
|
8fcef1d834 | ||
|
|
8210bb32da | ||
|
|
8b3ddb7b47 | ||
|
|
dcb3e5e1cd | ||
|
|
3d2a872de1 | ||
|
|
61f5158279 | ||
|
|
ce481cfdb0 | ||
|
|
3d5c294f64 | ||
|
|
4f0678d782 | ||
|
|
9b1f7a372c | ||
|
|
9a1ee3d888 | ||
|
|
4f20680d5b | ||
|
|
dd5a25eb66 | ||
|
|
3a3f8c498c | ||
|
|
f603b49a3e | ||
|
|
52e182e7f0 | ||
|
|
7cc925120e | ||
|
|
603cb07c27 | ||
|
|
7b5019ba87 | ||
|
|
40f6b2fca4 | ||
|
|
1e50c5d6cb | ||
|
|
d46db268f8 | ||
|
|
8f5b549b84 | ||
|
|
476c61ed47 | ||
|
|
4b6bfbc08b | ||
|
|
0be838c58f | ||
|
|
770a9cd996 | ||
|
|
6afe377b55 | ||
|
|
fad73d2814 | ||
|
|
d6c81f32cd | ||
|
|
5d2104dd91 | ||
|
|
969ce9d6a3 | ||
|
|
55b456cb95 | ||
|
|
062ffc18f9 | ||
|
|
95cbd40655 | ||
|
|
70d94137dd | ||
|
|
bbea70d1db | ||
|
|
b5e5b752a4 | ||
|
|
28b4dd8e08 | ||
|
|
1ae92a8b9d | ||
|
|
00bbea33f6 | ||
|
|
3fd3c397a6 | ||
|
|
f1f95a0aac | ||
|
|
6e90a3e376 | ||
|
|
41d51453a5 | ||
|
|
c74f8b2559 | ||
|
|
be2eb6a8ce | ||
|
|
9819db60cd | ||
|
|
2a86e0d355 | ||
|
|
4a209a342e | ||
|
|
33e5b58e3b | ||
|
|
fd11bd24a9 | ||
|
|
8c1f14de57 | ||
|
|
bc615355c8 | ||
|
|
28730806f9 | ||
|
|
4ec975fcd1 | ||
|
|
b6ce588e10 | ||
|
|
a1510b5f6d | ||
|
|
913d527a64 | ||
|
|
a1e250b521 | ||
|
|
887c107216 | ||
|
|
b6fb699a27 | ||
|
|
575aa4619c | ||
|
|
3f787c0e35 | ||
|
|
a0fc7f6978 | ||
|
|
2cd069ea72 | ||
|
|
d4b4b24e3c | ||
|
|
dca7daec04 | ||
|
|
b686eb467f | ||
|
|
d1f0618c0e | ||
|
|
ce06511b52 | ||
|
|
a2b0c0f28e | ||
|
|
0666097934 | ||
|
|
da71044fc4 | ||
|
|
4167c949fe | ||
|
|
6f490a7e93 | ||
|
|
b14dfc710a | ||
|
|
1877bae091 | ||
|
|
4cf7069254 | ||
|
|
d4c89ebff0 | ||
|
|
f58005a412 | ||
|
|
382931f4f8 | ||
|
|
7be5b84b5d | ||
|
|
0db35d3bd7 | ||
|
|
6e2da40aa5 | ||
|
|
dae7c2e90b | ||
|
|
04db0ba88d | ||
|
|
9680bc77b3 | ||
|
|
85c0d3d9d3 | ||
|
|
b348af9581 | ||
|
|
aedb43b487 | ||
|
|
3b86806d8e | ||
|
|
c4cc09d8e0 | ||
|
|
1a3b2471b3 | ||
|
|
3a004572c1 | ||
|
|
feabf561c5 | ||
|
|
5247ccd129 | ||
|
|
c77390b86c | ||
|
|
8ecad1f93e | ||
|
|
dae82c4d65 | ||
|
|
8f8cc8ac43 | ||
|
|
f66626ae74 | ||
|
|
4ffcbcad91 | ||
|
|
fc31b7de7b | ||
|
|
c24f2d7849 | ||
|
|
b316f54fd8 | ||
|
|
2fda301027 | ||
|
|
9e6f3fbb2a | ||
|
|
980d306100 | ||
|
|
9d4a44b403 | ||
|
|
52d92e6c1a | ||
|
|
0a96edb1bb | ||
|
|
3ced349018 | ||
|
|
9649c99f90 | ||
|
|
0b587d398d | ||
|
|
47eaa1d1ca | ||
|
|
cbd170729d | ||
|
|
6997bb4615 | ||
|
|
dc6db3cfaa | ||
|
|
72c337a68c | ||
|
|
a9d0389adf | ||
|
|
76ea2aa665 | ||
|
|
672700afc5 | ||
|
|
d8a44fe8b6 | ||
|
|
2a777092d2 | ||
|
|
083a060371 | ||
|
|
b1b5dee5f0 | ||
|
|
05dfea6da2 | ||
|
|
208d6911f0 | ||
|
|
07ca508df1 | ||
|
|
40ab1419c5 | ||
|
|
cb48134548 | ||
|
|
ce287ad7db | ||
|
|
be1e743571 | ||
|
|
a57b911fd2 | ||
|
|
a3b7fc8908 | ||
|
|
85717a84b7 | ||
|
|
6a8e96382e | ||
|
|
52b6cb6a71 | ||
|
|
eda7d9273f | ||
|
|
9391b16f50 | ||
|
|
bd499550d8 | ||
|
|
dd6eb173a0 | ||
|
|
78c994987f | ||
|
|
d11a0bade5 | ||
|
|
e54035a683 | ||
|
|
5ef51406eb | ||
|
|
9843e9fd68 | ||
|
|
f3bdcbec83 | ||
|
|
a5d3cf5957 | ||
|
|
aa87cf8032 | ||
|
|
07137ddb26 | ||
|
|
92076e8559 | ||
|
|
5356a011ec | ||
|
|
b72502b8a1 | ||
|
|
20bee30f69 | ||
|
|
4f29b8a2c9 | ||
|
|
ef867acc36 | ||
|
|
da37c4320e | ||
|
|
6b2d3cbc7e | ||
|
|
397310df8b | ||
|
|
04d444cc30 | ||
|
|
eb68151a73 | ||
|
|
a2fcc30fbb | ||
|
|
6cdc535cbc | ||
|
|
095550e041 | ||
|
|
3b4a0609e3 | ||
|
|
54fe6b0dbd | ||
|
|
ff2b73e9b1 | ||
|
|
bb3630840d | ||
|
|
555aed78f3 | ||
|
|
1ed52f3f4e | ||
|
|
72a44648cd | ||
|
|
2db8e75a66 | ||
|
|
e9064c4e87 | ||
|
|
680cbbf932 | ||
|
|
7285af4481 | ||
|
|
bd4f5c2ecf | ||
|
|
dd94a9a677 | ||
|
|
341c70f6dd | ||
|
|
41a8a47060 | ||
|
|
881ad034a6 | ||
|
|
4a1c86cba3 | ||
|
|
56c9b73bcb | ||
|
|
93bac071ac | ||
|
|
f88c9f027d | ||
|
|
1cb2219dbb | ||
|
|
e00d5822f2 | ||
|
|
f64846f339 | ||
|
|
fd2480abbc | ||
|
|
4d820eef6d | ||
|
|
6bddd197db | ||
|
|
8439ca103c | ||
|
|
60e546b075 | ||
|
|
cfc0e5b260 | ||
|
|
3c11278949 | ||
|
|
8bde89d4ee | ||
|
|
a5ebc356ad | ||
|
|
aeb37c0a28 | ||
|
|
85106c8e59 | ||
|
|
06d350bb1e | ||
|
|
a612ffeba1 | ||
|
|
651051f136 | ||
|
|
3000d76272 | ||
|
|
e136327742 | ||
|
|
e1a22373d6 | ||
|
|
b7f4375599 | ||
|
|
bf97a66dd7 | ||
|
|
9077e346f2 | ||
|
|
0031d6aae3 | ||
|
|
cec46d111b | ||
|
|
ef151757db | ||
|
|
fef29a0697 | ||
|
|
b58b71a5b1 | ||
|
|
8a4fc799e4 | ||
|
|
979fc09e13 | ||
|
|
13fa3504bf | ||
|
|
adbaa5cfbc | ||
|
|
1881336a14 | ||
|
|
100d02904e | ||
|
|
be8e15e087 | ||
|
|
487bcc3461 | ||
|
|
1f86c651b8 | ||
|
|
388001447f | ||
|
|
13c59e2b5e | ||
|
|
5c236bb4ed | ||
|
|
fea6e90f12 | ||
|
|
fb098bd169 | ||
|
|
612b2bb6cc | ||
|
|
a145c10e5d | ||
|
|
cb57f4fd6a | ||
|
|
ed28da338a | ||
|
|
0d86b3b297 | ||
|
|
90bd1841f0 | ||
|
|
be24877913 | ||
|
|
7218c365e3 | ||
|
|
33dd09362a | ||
|
|
4aae57075a | ||
|
|
d90240641e | ||
|
|
a5871befe6 | ||
|
|
fa56d226f3 | ||
|
|
a5ff4a9ad8 | ||
|
|
d61c690075 | ||
|
|
873589bd7f | ||
|
|
032f2ff228 | ||
|
|
0c733b31a7 | ||
|
|
2baaf18db6 | ||
|
|
4d7314e2d8 | ||
|
|
f1f4ffe6b2 | ||
|
|
2fac9dc516 | ||
|
|
1260aa1de5 | ||
|
|
bdccde4040 | ||
|
|
7cdb95116a | ||
|
|
c9d42f8e8e | ||
|
|
1e738f038f | ||
|
|
57fb06ca5f | ||
|
|
83d925ead0 | ||
|
|
ce1baaad7a | ||
|
|
a370f6e7b7 |
No files matched your search
@@ -0,0 +1,6 @@
|
||||
[*.java]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
ij_continuation_indent_size = 8
|
||||
ij_java_names_count_to_use_import_on_demand = 9999
|
||||
ij_java_class_count_to_use_import_on_demand = 9999
|
||||
@@ -0,0 +1 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -0,0 +1,3 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
@@ -10,16 +10,16 @@ jobs:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Validate gradle wrapper
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
uses: gradle/actions/wrapper-validation@v5
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'adopt'
|
||||
distribution: 'temurin'
|
||||
cache: 'gradle'
|
||||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||
@@ -31,34 +31,40 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: api-build
|
||||
path: api/build/libs
|
||||
path: build/libs/packetevents-api-*.jar
|
||||
|
||||
- name: Upload build artifacts spigot
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: spigot-build
|
||||
path: spigot/build/libs
|
||||
path: build/libs/packetevents-spigot-*.jar
|
||||
|
||||
- name: Upload build artifacts netty-common
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: netty-common-build
|
||||
path: netty-common/build/libs
|
||||
path: build/libs/packetevents-netty-common-*.jar
|
||||
|
||||
- name: Upload build artifacts bungeecord
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: bungeecord-build
|
||||
path: bungeecord/build/libs
|
||||
path: build/libs/packetevents-bungeecord-*.jar
|
||||
|
||||
- name: Upload build artifacts velocity
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: velocity-build
|
||||
path: velocity/build/libs
|
||||
path: build/libs/packetevents-velocity-*.jar
|
||||
|
||||
- name: Upload build artifacts fabric
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fabric-build
|
||||
path: fabric/build/libs
|
||||
path: build/libs/packetevents-fabric-*.jar
|
||||
|
||||
- name: Upload build artifacts sponge
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: sponge-build
|
||||
path: build/libs/packetevents-sponge-*.jar
|
||||
@@ -0,0 +1,51 @@
|
||||
name: Release
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Publish Release
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Validate gradle wrapper
|
||||
uses: gradle/actions/wrapper-validation@v5
|
||||
|
||||
- name: Setup java 21
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: 21
|
||||
distribution: temurin
|
||||
|
||||
- name: Prepare gradle
|
||||
run: ./gradlew printVersion --no-daemon
|
||||
|
||||
- name: Extract changelog
|
||||
id: changelog
|
||||
run: |
|
||||
OUTPUT_DELIMITER="$(uuidgen)"
|
||||
echo "changelog<<$OUTPUT_DELIMITER" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# extract tag name and use it to get changelog section
|
||||
TAG_NAME="v$(./gradlew -q --no-daemon printVersion)"
|
||||
awk -v tag="${TAG_NAME}" '
|
||||
$1 == "!!!!!" && $2 == tag {found=1; next}
|
||||
$1 == "!!!!!" && found {exit}
|
||||
found
|
||||
' CHANGELOG.md >> "$GITHUB_OUTPUT"
|
||||
|
||||
# end output
|
||||
echo "$OUTPUT_DELIMITER" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Publish plugin
|
||||
env:
|
||||
GITHUB_API_TOKEN: ${{ github.token }}
|
||||
MODRINTH_API_TOKEN: ${{ secrets.MODRINTH_PUBLISH_TOKEN }}
|
||||
CHANGELOG: ${{ steps.changelog.outputs.changelog }}
|
||||
run: ./gradlew publishMods --no-daemon -PnoDryPublish
|
||||
@@ -123,3 +123,8 @@ run/
|
||||
.project
|
||||
.settings/
|
||||
.classpath
|
||||
|
||||
# Build Source Kotlin
|
||||
/buildSrc/.kotlin/
|
||||
|
||||
.env
|
||||
+451
@@ -0,0 +1,451 @@
|
||||
!!!!! v2.11.2
|
||||
|
||||
# PacketEvents 2.11.2 is finally out! 🎉
|
||||
|
||||
This update fixes various bugs. It's encouraged that users update.
|
||||
Again, huge thanks to all users who have donated their hard-earned money to PacketEvents since the previous release. It's been received & it's very much appreciated.
|
||||
|
||||
Recent donors: PebbleHost, SSomar1607, ipavdev, Suleyman Abulkhasan, frap
|
||||
|
||||
Also, thanks to the contributors that made this update possible.
|
||||
|
||||
If you intend on donating and do not wish to be mentioned, please add such a note on your donation.
|
||||
|
||||
# Announcement 📢⚠️
|
||||
|
||||
Visit our website: https://packetevents.com\
|
||||
Documentation: https://docs.packetevents.com\
|
||||
JavaDocs: https://javadocs.packetevents.com\
|
||||
I've released a new YouTube [video](https://youtu.be/G7qYRHpZVIo).
|
||||
|
||||
## What's Changed (Summary)
|
||||
* Fixed SynchronizedRegistriesHandler issues
|
||||
* Fixed various equality/nullability issues with Registry values
|
||||
* Explicitly specify 'Locale#ROOT' for all String#toLowerCaser() calls
|
||||
* Removed 'end skylight' for 1.21.8 and below
|
||||
* Log warning message when failing to uninject from velocity initializer
|
||||
* Recommend release builds (and fallback to development builds) to users who run outdated software.
|
||||
* Add 'CHAIN' to the 'CHAINS' tag
|
||||
* Add new offset(Blockface face, int i) method to Vector3f/d/i classes
|
||||
* Fixed 'infiniburn' tag parsing for 1.18.1 and older
|
||||
* Fixed unexpected NPE if bukkit entity is null during unsafe lookup
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.11.1...v2.11.2
|
||||
|
||||
## If you want to support PacketEvents, consider donating to us on [PayPal](https://paypal.me/retrooperdev) or sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper).
|
||||
|
||||
## Maven/Gradle Dependency Setup Guide
|
||||
|
||||
**Check it out**: https://docs.packetevents.com/introduction/development-setup/
|
||||
|
||||
|
||||
!!!!! v2.11.1
|
||||
|
||||
# PacketEvents 2.11.1 is finally out! 🎉
|
||||
|
||||
This update fixes various bugs. It's encouraged that users update.
|
||||
Thanks to all users who donated after the previous release announcement. It's been received & it's appreciated.
|
||||
|
||||
Recent donors: TrekCraft, 3add, Vadim Soudé
|
||||
|
||||
If you intend on donating and do not wish to be mentioned, please add such a note on your donation.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### Visit our website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
* Fixed 'Can't resolve 'minecraft:day' in 'minecraft:timeline' for V_1_21_11'
|
||||
* Fixed decoding & encoding for WrapperLoginServerPluginRequest & WrapperLoginClientPluginResponse
|
||||
* Improve StateTypes testing
|
||||
* Added system property packetevents.debug.nbt-codec-trace
|
||||
* Fixed Sound Codec
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.11.0...v2.11.1
|
||||
|
||||
## If you want to support PacketEvents, consider donating to us on [PayPal](https://paypal.me/retrooperdev) or sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.11.0
|
||||
|
||||
# PacketEvents 2.11.0 is finally out! 🎉
|
||||
|
||||
This update adds support for Minecraft 1.21.11.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### Visit our website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Added support for Minecraft 1.21.11
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.10.1...v2.11.0
|
||||
|
||||
## If you want to support PacketEvents, consider donating to us on [PayPal](https://paypal.me/retrooperdev) or sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.10.1
|
||||
|
||||
# PacketEvents 2.10.1 is finally out! 🎉
|
||||
|
||||
This update includes some bug fixes.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### Visit our website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Fixed for certain particle types on 1.21.9 & 1.21.10 Minecraft
|
||||
* Fixed the bee's component on 1.21.9 & 1.21.10 Minecraft
|
||||
* Correction of 'mul' calculation in LpVector3d
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.10.0...v2.10.1
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.10.0
|
||||
|
||||
# PacketEvents 2.10.0 is finally out! 🎉
|
||||
|
||||
This update includes critical bug fixes & minor additions to the API.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Added 1.21.9 & 1.21.10 support
|
||||
* Various bug fixes (such as TPS reading, PlayerModelType reading/writing, and more)
|
||||
* Update adventure API
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.9.5...v2.10.0
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.9.5
|
||||
|
||||
# PacketEvents 2.9.5 is out now! 🎉
|
||||
|
||||
This update includes critical bug fixes & minor additions to the API.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Injector bug fix (for Spigot)
|
||||
* WolfVariant issue fixed
|
||||
* Chunk Data error fixed
|
||||
* NBT tag issues fixed
|
||||
* Direction Y/Z axis being swapped fixed
|
||||
* Added WrappedBlockState to constructor of WrapperPlayServerBlockChange
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.9.4...v2.9.5
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.9.4
|
||||
|
||||
# PacketEvents 2.9.4 is out now! 🎉
|
||||
|
||||
This update includes minor bug fixes & minor additions to the API.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Added SpigotConversionUtil#getEntityMetadata to retrieve metadata from a Bukkit entity.
|
||||
* Fixed outdated 1.8 Spigot forks from being unable to load on PacketEvents.
|
||||
* Fixed WrapperPlayServerWorldBorder for versions lower than 1.12.
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.9.3...v2.9.4
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.9.3
|
||||
|
||||
# PacketEvents 2.9.3 is out now! 🎉
|
||||
|
||||
This is an update that adds support for Minecraft 1.21.8 server builds.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Added support for 1.21.8 Minecraft server builds.
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.9.2...v2.9.3
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.9.2
|
||||
|
||||
# PacketEvents 2.9.2 is out now! 🎉
|
||||
|
||||
This is a patch update that fixes issues with UserLoginEvent (which previously contained null user data) and with importing Adventure serializers.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed (Summary)
|
||||
|
||||
* Added support for 1.7.2+ Minecraft protocol (useful for proxies)
|
||||
* Fixed UserLoginEvent. It is now (always) triggered by PlayerJoinEvent to prevent User instances from containing null data.
|
||||
* Fixed importing Adventure serializers.
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.9.1...v2.9.2
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.9.1
|
||||
|
||||
# PacketEvents 2.9.1 is out now! 🎉
|
||||
|
||||
This is a hotfix patch update to fix issues with 2.9.0 release assets. See below for the 2.9.0 changelog.
|
||||
|
||||
### New update now supports Minecraft version 1.21.6 & 1.21.7. We suggest that you update, as numerous bugs have been fixed.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed? (Summary)
|
||||
|
||||
* Added 1.21.6 support
|
||||
* Added 1.21.7 support
|
||||
* Bug fixes
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.8.0...v2.9.1
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.9.0
|
||||
|
||||
# PacketEvents 2.9.0 is out now! 🎉
|
||||
|
||||
### New update now supports Minecraft version 1.21.6 & 1.21.7. We suggest that you update, as numerous bugs have been fixed.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed? (Summary)
|
||||
|
||||
* Added 1.21.6 support
|
||||
* Added 1.21.7 support
|
||||
* Bug fixes
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.8.0...v2.9.0
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.8.0
|
||||
|
||||
# PacketEvents 2.8.0 is out now! 🎉
|
||||
|
||||
### New update now supports Minecraft version 1.21.5. Please update, as numerous bugs have been fixed.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our very own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed? (Summary)
|
||||
|
||||
* Added 1.21.5 support
|
||||
* Various bugs fixed
|
||||
|
||||
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.7.0...v2.8.0
|
||||
|
||||
## Contributors 🏅
|
||||
|
||||
This update wouldn't be possible without these contributors ❤️: @booky10, @Axionize, @Bram1903, @ManInMyVan, @ytnoos,
|
||||
@AoElite, @HaHaWTH, @divinepablo, @scienziatopazzo, @bridgelol, @MachineBreaker, @Luuzzi, @Beaness, @Rubenicos, @Loyisa
|
||||
|
||||
## New Contributors
|
||||
|
||||
* @HaHaWTH made their first contribution in https://github.com/retrooper/packetevents/pull/1097
|
||||
* @divinepablo made their first contribution in https://github.com/retrooper/packetevents/pull/1098
|
||||
* @scienziatopazzo made their first contribution in https://github.com/retrooper/packetevents/pull/1105
|
||||
* @bridgelol made their first contribution in https://github.com/retrooper/packetevents/pull/1199
|
||||
* @Luuzzi made their first contribution in https://github.com/retrooper/packetevents/pull/1197
|
||||
* @Beaness made their first contribution in https://github.com/retrooper/packetevents/pull/1212
|
||||
* @Rubenicos made their first contribution in https://github.com/retrooper/packetevents/pull/1162
|
||||
* @Loyisa made their first contribution in https://github.com/retrooper/packetevents/pull/1220
|
||||
|
||||
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.7.0
|
||||
|
||||
# PacketEvents v2.7.0 is out now! 🎉
|
||||
|
||||
### New update with support of the latest Minecraft version. In addition to that, countless bugs were fixed.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed? (Summary)
|
||||
|
||||
* Added 1.21.4 support
|
||||
* Fix: Potion contents item component for 1.21.2/1.21.3
|
||||
* Fix: NPC objects to have unique server team names
|
||||
* Add missing ServerVersion#V_1_9_1
|
||||
* Validation checks added for window click type
|
||||
|
||||
**Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.6.0...v2.7.0
|
||||
|
||||
## New Contributors
|
||||
|
||||
* @Axionize made their first contribution in https://github.com/retrooper/packetevents/pull/1048
|
||||
* @ShreyasAyyengar made their first contribution in https://github.com/retrooper/packetevents/pull/1044
|
||||
* @mfnalex made their first contribution in https://github.com/retrooper/packetevents/pull/1076
|
||||
|
||||
## Contributors 🏅
|
||||
|
||||
This update wouldn't be possible without these contributors ❤️: @booky10, @rafi67000, @ShreyasAyyengar, @AoElite,
|
||||
@Tecnio, @Axionize, @mfnalex
|
||||
|
||||
### If you want to support PacketEvents, and any upcoming events we plan for the future, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!! v2.6.0
|
||||
|
||||
# PacketEvents v2.6.0 is out now! 🎉
|
||||
|
||||
### New update with support of new platforms & the latest Minecraft version. In addition to that, countless bugs were fixed.
|
||||
|
||||
# Brief Announcement 📢⚠️
|
||||
|
||||
### We have our own website: https://packetevents.com
|
||||
|
||||
### Documentation: https://docs.packetevents.com
|
||||
|
||||
### JavaDocs: https://javadocs.packetevents.com
|
||||
|
||||
## What's Changed? (Summary)
|
||||
|
||||
* 1.21.2 and 1.21.3 Minecraft support
|
||||
* Sponge support added
|
||||
* Fabric support added (also server-side)
|
||||
* Utilizing the proper bStats API
|
||||
* Registry element issues fixed
|
||||
* Mappings issues fixed
|
||||
* AdvancedSlimePaper issues fixed
|
||||
* BungeeCord issues fixed
|
||||
|
||||
### **Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.5.0...v2.6.0
|
||||
|
||||
## Contributors 🏅
|
||||
|
||||
This update wouldn't be possible without these contributors ❤️: @booky10, @ManInMyVan, @SamB440, @rafi67000, @Bram1903,
|
||||
@AbhigyaKrishna
|
||||
|
||||
### If you want to support PacketEvents, and any upcoming events we plan for the future, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
|
||||
|
||||
## Maven/Gradle Dependency
|
||||
|
||||
### **Check out**: https://docs.packetevents.com/getting-started
|
||||
|
||||
!!!!!
|
||||
@@ -1,22 +1,21 @@
|
||||
<!--suppress HtmlDeprecatedAttribute -->
|
||||
<div align="center">
|
||||
<h2><i>packetevents</i></h2>
|
||||
<h2><i>PacketEvents</i></h2>
|
||||
<h3>PacketEvents is a protocol library tailored to Minecraft Java Edition, designed to facilitate the processing and transmission of packets.</h3>
|
||||
<a href="https://github.com/retrooper/packetevents/actions"><img src="https://img.shields.io/github/actions/workflow/status/retrooper/packetevents/gradle-publish.yml?style=for-the-badge&logo=github"></a>
|
||||
<a href="https://discord.gg/DVHxPPxHZc"><img src="https://img.shields.io/discord/721686193061888071?color=5562e9&logo=discord&logoColor=white&style=for-the-badge"></a>
|
||||
<img src="https://img.shields.io/github/license/retrooper/packetevents?style=for-the-badge&logo=github">
|
||||
<a href="https://bstats.org/plugin/bukkit/packetevents/11327"><img src="https://img.shields.io/bstats/servers/11327?style=for-the-badge"></a>
|
||||
<a href="https://github.com/retrooper/packetevents/releases"><img src="https://img.shields.io/github/downloads/retrooper/packetevents/total.svg?style=for-the-badge&logo=github"></a>
|
||||
</div>
|
||||
PacketEvents is emerging as a strong contender in the realm of Minecraft packet processing libraries. Designed to simplify packet manipulation while delivering high performance, this powerful tool aims to demystify the complexities of projects utilizing packets. Imbued with versatility, PacketEvents supports various platforms such as Spigot, BungeeCord, Velocity, and Fabric.
|
||||
|
||||
<h3>Resources</h3>
|
||||
|
||||
- [Read documentation](https://docs.packetevents.com/)
|
||||
- [Getting Started](https://docs.packetevents.com/getting-started)
|
||||
- [JavaDocs](javadocs.packetevents.com)
|
||||
- [Getting Started](https://docs.packetevents.com/development-setup)
|
||||
- [JavaDocs](https://javadocs.packetevents.com)
|
||||
- [Releases](https://github.com/retrooper/packetevents/releases/)
|
||||
- [GitHub](https://github.com/retrooper/packetevents/releases/)
|
||||
- [Modrinth](https://modrinth.com/plugin/packetevents)
|
||||
- [GitHub](https://github.com/retrooper/packetevents/releases/)
|
||||
- [SpigotMC](https://www.spigotmc.org/resources/packetevents-api.80279/)
|
||||
- [Development Builds](https://ci.codemc.io/job/retrooper/job/packetevents)
|
||||
- [Statistics](https://bstats.org/plugin/bukkit/packetevents/11327)
|
||||
@@ -29,14 +28,12 @@ PacketEvents is emerging as a strong contender in the realm of Minecraft packet
|
||||
|
||||
<a href="https://www.ej-technologies.com"><img src="https://www.ej-technologies.com/images/product_banners/jprofiler_small.png"><br>
|
||||
|
||||
<a href="https://github.com/radstevee"><img src="https://github.com/radstevee.png" width="50px" alt="radstevee"/></a><br>
|
||||
|
||||
<h3>Credits</h3>
|
||||
|
||||
<i>Here are some projects that we are heavily inspired by, thus we have integrated</i>\
|
||||
<i>small portions of their code into our work.</i>
|
||||
|
||||
[Protocol Documentation for the Minecraft Java Edition](https://wiki.vg/Protocol)\
|
||||
[Protocol Documentation for the Minecraft Java Edition](https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Protocol)\
|
||||
[ViaVersion](https://github.com/ViaVersion/ViaVersion)\
|
||||
[ProtocolSupport](https://github.com/ProtocolSupport/ProtocolSupport)\
|
||||
[adventure](https://github.com/KyoriPowered/adventure)\
|
||||
|
||||
+16
-75
@@ -1,6 +1,6 @@
|
||||
import com.github.retrooper.compression.strategy.JsonArrayCompressionStrategy
|
||||
import com.github.retrooper.compression.strategy.JsonObjectCompressionStrategy
|
||||
import com.github.retrooper.compression.strategy.JsonToNbtStrategy
|
||||
import com.github.retrooper.compression.strategy.dir.JsonBase64DataDirStrategy
|
||||
import com.github.retrooper.compression.strategy.dir.JsonRegistryCompressionDirStrategy
|
||||
import com.github.retrooper.compression.strategy.dir.JsonToNbtDirStrategy
|
||||
import com.github.retrooper.excludeAdventure
|
||||
|
||||
plugins {
|
||||
@@ -31,86 +31,29 @@ dependencies {
|
||||
}
|
||||
compileOnly(libs.gson)
|
||||
|
||||
testImplementation(libs.bundles.adventure)
|
||||
testImplementation(project(":patch:adventure-text-serializer-gson"))
|
||||
testImplementation(libs.adventure.text.serializer.legacy)
|
||||
testImplementation(project(":netty-common"))
|
||||
testImplementation(testlibs.mockbukkit)
|
||||
testImplementation(testlibs.slf4j)
|
||||
testImplementation(testlibs.bundles.junit)
|
||||
}
|
||||
|
||||
mappingCompression {
|
||||
mappingDirectory = rootDir.resolve("mappings")
|
||||
outDirectory = project.layout.buildDirectory.dir("mappings/generated/assets/mappings")
|
||||
|
||||
with<JsonToNbtStrategy> {
|
||||
compress("block/legacy_block_mappings.json")
|
||||
compress("block/modern_block_mappings.json")
|
||||
|
||||
compress("enchantment/enchantment_type_data.json")
|
||||
|
||||
compress("stats/statistics.json")
|
||||
|
||||
compress("world/biome_data.json")
|
||||
with<JsonToNbtDirStrategy> {
|
||||
compress("data")
|
||||
}
|
||||
|
||||
with<JsonArrayCompressionStrategy> {
|
||||
compress("attribute/attribute_mappings.json")
|
||||
|
||||
compress("block/block_entity_type_mappings.json")
|
||||
compress("block/block_type_mappings.json")
|
||||
|
||||
compress("chat/chat_type_mappings.json")
|
||||
|
||||
compress("command/argument_parser_mappings.json")
|
||||
|
||||
compress("damage/damagetype_mappings.json")
|
||||
|
||||
compress("enchantment/effect_component_type.json")
|
||||
|
||||
compress("entity/entity_data_type_mappings.json")
|
||||
compress("entity/painting_mappings.json")
|
||||
compress("entity/wolf_variant_mappings.json")
|
||||
|
||||
compress("item/item_armor_material_mappings.json")
|
||||
compress("item/item_banner_pattern_mappings.json")
|
||||
compress("item/item_component_mappings.json")
|
||||
compress("item/item_instrument_mappings.json")
|
||||
compress("item/item_jukebox_song_mappings.json")
|
||||
compress("item/item_map_decoration_type_mappings.json")
|
||||
compress("item/item_potion_mappings.json")
|
||||
compress("item/item_trim_material_mappings.json")
|
||||
compress("item/item_trim_pattern_mappings.json")
|
||||
compress("item/recipe_serializer_mappings.json")
|
||||
|
||||
compress("particle/particle_type_mappings.json")
|
||||
|
||||
compress("sound/sound_mappings.json")
|
||||
|
||||
compress("world/biome_mappings.json")
|
||||
compress("world/world_position_source_mappings.json")
|
||||
with<JsonBase64DataDirStrategy> {
|
||||
compress("item_base_components")
|
||||
}
|
||||
|
||||
with<JsonObjectCompressionStrategy> {
|
||||
compress("enchantment/enchantment_type_mappings.json")
|
||||
|
||||
compress("entity/entity_effect_mappings.json")
|
||||
compress("entity/entity_type_mappings.json")
|
||||
compress("entity/legacy_entity_type_mappings.json")
|
||||
|
||||
compress("item/item_type_mappings.json")
|
||||
|
||||
compress("world/dimension_type_mappings.json")
|
||||
with<JsonRegistryCompressionDirStrategy> {
|
||||
compress("registries")
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
assemble {
|
||||
setDependsOn(dependsOn.filterNot { it == "shadowNoAdventure" })
|
||||
}
|
||||
|
||||
javadoc {
|
||||
setDestinationDir(file("${project.layout.buildDirectory.asFile.get()}/docs/javadoc"))
|
||||
options {
|
||||
(this as CoreJavadocOptions).addBooleanOption("Xdoclint:none", true)
|
||||
}
|
||||
mustRunAfter(generateVersionsFile)
|
||||
}
|
||||
|
||||
@@ -131,14 +74,12 @@ tasks {
|
||||
packageName = "com.github.retrooper.packetevents.util"
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude {
|
||||
val path = it.path
|
||||
path.startsWith("net/kyori") && !path.startsWith("net/kyori/adventure/text/serializer") && !path.startsWith("net/kyori/option")
|
||||
path.startsWith("net/kyori") && !path.startsWith("net/kyori/adventure/text/serializer") && !path.startsWith(
|
||||
"net/kyori/option"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.github.retrooper.packetevents.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Documented;
|
||||
|
||||
/**
|
||||
* Marks an API element as obsolete and makes this information available
|
||||
* at runtime via reflection. Use in conjunction with an IDE-recognized
|
||||
* annotation like @ApiStatus.Obsolete if IDE warnings are also desired.
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD}) // Adjust targets as needed
|
||||
public @interface RuntimeObsolete {
|
||||
/**
|
||||
* Specifies in which version the API became obsolete.
|
||||
* Should generally match the value in the corresponding @ApiStatus.Obsolete annotation.
|
||||
*/
|
||||
String since() default "";
|
||||
|
||||
/**
|
||||
* Optional: Add a reason or replacement suggestion.
|
||||
*/
|
||||
String reason() default "";
|
||||
}
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.event.PacketEvent;
|
||||
import com.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* The {@link PacketEvent} implements this interface.
|
||||
@@ -31,7 +30,9 @@ import com.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||
* @author retrooper
|
||||
* @since 1.8
|
||||
*/
|
||||
@NullMarked
|
||||
public interface CallableEvent {
|
||||
|
||||
default void call(PacketListenerCommon listener) {
|
||||
listener.onPacketEventExternal((PacketEvent) this);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class EventManager {
|
||||
* be the final decider whether the event has been cancelled or not.
|
||||
*
|
||||
* @param event {@link PacketEvent}
|
||||
* @param postCallListenerAction The action to be ran after all the listeners have finished processing
|
||||
* @param postCallListenerAction The action to be run after all the listeners have finished processing
|
||||
*/
|
||||
public void callEvent(PacketEvent event, @Nullable Runnable postCallListenerAction) {
|
||||
for (PacketListenerCommon listener : listeners) {
|
||||
@@ -84,7 +84,7 @@ public class EventManager {
|
||||
event.call(listener);
|
||||
} catch (Exception t) {
|
||||
// ignore handshake exceptions
|
||||
if (t.getClass() != InvalidHandshakeException.class) {
|
||||
if (t.getClass() != InvalidHandshakeException.class && (t.getCause() == null || t.getCause().getClass() != InvalidHandshakeException.class)) {
|
||||
PacketEvents.getAPI().getLogger().log(Level.WARNING, "PacketEvents caught an unhandled exception while calling your listener.", t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.util.TimeStampMode;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* An event in both of PacketEvents' event systems.
|
||||
@@ -28,7 +29,9 @@ import com.github.retrooper.packetevents.util.TimeStampMode;
|
||||
* @author retrooper
|
||||
* @since 1.2.6
|
||||
*/
|
||||
@NullMarked
|
||||
public abstract class PacketEvent implements CallableEvent {
|
||||
|
||||
private final long timestamp;
|
||||
|
||||
public PacketEvent() {
|
||||
@@ -60,4 +63,4 @@ public abstract class PacketEvent implements CallableEvent {
|
||||
public void callPacketEventExternal(PacketListenerCommon listener) {
|
||||
listener.onPacketEventExternal(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,17 +24,25 @@ 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 org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketReceiveEvent extends ProtocolPacketEvent {
|
||||
protected PacketReceiveEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
protected PacketReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(PacketSide.CLIENT, channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketReceiveEvent(int packetID, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel, User user, Object player,
|
||||
Object byteBuf) throws PacketProcessException {
|
||||
protected PacketReceiveEvent(
|
||||
int packetID, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetID, packetType, serverVersion,
|
||||
channel, user, player, byteBuf);
|
||||
}
|
||||
@@ -46,13 +54,8 @@ public class PacketReceiveEvent extends ProtocolPacketEvent {
|
||||
|
||||
@Override
|
||||
public PacketReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
}
|
||||
@@ -18,32 +18,38 @@
|
||||
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.event.simple.PacketHandshakeSendEvent;
|
||||
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 org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@NullMarked
|
||||
public class PacketSendEvent extends ProtocolPacketEvent {
|
||||
private List<Runnable> tasksAfterSend = null;
|
||||
|
||||
protected PacketSendEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
private @Nullable List<Runnable> tasksAfterSend = null;
|
||||
|
||||
protected PacketSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(PacketSide.SERVER, channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketSendEvent(int packetID, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
Object player, Object byteBuf) throws PacketProcessException {
|
||||
super(packetID, packetType,
|
||||
serverVersion,
|
||||
channel, user, player, byteBuf);
|
||||
protected PacketSendEvent(
|
||||
int packetID, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetID, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,13 +71,8 @@ public class PacketSendEvent extends ProtocolPacketEvent {
|
||||
|
||||
@Override
|
||||
public PacketSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
}
|
||||
@@ -18,17 +18,22 @@
|
||||
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Every event that has an associated player is recommended to implement this interface.
|
||||
*
|
||||
* @author retrooper
|
||||
* @since 1.6.9
|
||||
*/
|
||||
@NullMarked
|
||||
public interface PlayerEvent {
|
||||
|
||||
/**
|
||||
* Associated player.
|
||||
*
|
||||
* @return Player.
|
||||
*/
|
||||
<T> T getPlayer();
|
||||
<T> @UnknownNullability T getPlayer();
|
||||
}
|
||||
+57
-28
@@ -32,39 +32,50 @@ import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@NullMarked
|
||||
public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerEvent, CancellableEvent, UserEvent {
|
||||
private final Object channel;
|
||||
private final ConnectionState connectionState;
|
||||
private final User user;
|
||||
private final Object player;
|
||||
private Object byteBuf;
|
||||
|
||||
private final int packetID;
|
||||
private final PacketTypeCommon packetType;
|
||||
private ServerVersion serverVersion;
|
||||
|
||||
private final Object channel;
|
||||
private final ConnectionState connectionState;
|
||||
private final User user;
|
||||
|
||||
private @UnknownNullability Object player;
|
||||
private Object byteBuf;
|
||||
|
||||
private boolean cancel;
|
||||
private PacketWrapper<?> lastUsedWrapper;
|
||||
private List<Runnable> postTasks = null;
|
||||
private @Nullable PacketWrapper<?> lastUsedWrapper;
|
||||
private @Nullable List<Runnable> postTasks = null;
|
||||
|
||||
private boolean cloned;
|
||||
private boolean needsReEncode = PacketEvents.getAPI().getSettings().reEncodeByDefault();
|
||||
|
||||
public ProtocolPacketEvent(PacketSide packetSide, Object channel,
|
||||
User user, Object player, Object byteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
public ProtocolPacketEvent(
|
||||
PacketSide packetSide, Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
this.channel = channel;
|
||||
this.user = user;
|
||||
this.player = player;
|
||||
|
||||
if (autoProtocolTranslation || user.getClientVersion() == null) {
|
||||
this.serverVersion = PacketEvents.getAPI().getServerManager().getVersion();
|
||||
} else {
|
||||
//TODO Optimize
|
||||
this.serverVersion = user.getClientVersion().toServerVersion();
|
||||
this.serverVersion = user.getPacketVersion().toServerVersion();
|
||||
}
|
||||
|
||||
this.byteBuf = byteBuf;
|
||||
@@ -77,22 +88,25 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
} catch (Exception e) {
|
||||
throw new PacketProcessException("Failed to read the Packet ID of a packet. (Size: " + size + ")");
|
||||
}
|
||||
|
||||
ClientVersion version = serverVersion.toClientVersion();
|
||||
ConnectionState state = packetSide == PacketSide.CLIENT ? user.getDecoderState() : user.getEncoderState();
|
||||
this.packetType = PacketType.getById(packetSide, state,
|
||||
version, packetID);
|
||||
if (this.packetType == null) {
|
||||
this.connectionState = packetSide == PacketSide.CLIENT ? user.getDecoderState() : user.getEncoderState();
|
||||
PacketTypeCommon packetType = PacketType.getById(packetSide, this.connectionState, version, this.packetID);
|
||||
if (packetType == null) {
|
||||
// mojang messed 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.getDecoderState() + ", Server version: " + serverVersion.getReleaseName());
|
||||
}
|
||||
this.connectionState = state;
|
||||
this.packetType = packetType;
|
||||
}
|
||||
|
||||
public ProtocolPacketEvent(int packetID, PacketTypeCommon packetType, ServerVersion serverVersion, Object channel,
|
||||
User user, Object player, Object byteBuf) {
|
||||
public ProtocolPacketEvent(
|
||||
int packetID, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) {
|
||||
this.channel = channel;
|
||||
this.user = user;
|
||||
this.player = player;
|
||||
@@ -103,7 +117,7 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
|
||||
this.connectionState = (packetType != null && packetType.getSide() == PacketSide.SERVER)
|
||||
? user.getEncoderState() : user.getDecoderState();
|
||||
cloned = true;
|
||||
this.cloned = true;
|
||||
}
|
||||
|
||||
public void markForReEncode(boolean needsReEncode) {
|
||||
@@ -114,7 +128,6 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
return needsReEncode;
|
||||
}
|
||||
|
||||
|
||||
public boolean isClone() {
|
||||
return cloned;
|
||||
}
|
||||
@@ -123,8 +136,15 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
return channel;
|
||||
}
|
||||
|
||||
public SocketAddress getAddress() {
|
||||
return ChannelHelper.remoteAddress(this.channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* <strong>WARNING:</strong> This doesn't support local addresses or unix sockets.
|
||||
*/
|
||||
public InetSocketAddress getSocketAddress() {
|
||||
return (InetSocketAddress) ChannelHelper.remoteAddress(channel);
|
||||
return (InetSocketAddress) this.getAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,22 +153,30 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getPlayer() {
|
||||
public <T> @UnknownNullability T getPlayer() {
|
||||
return (T) player;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.Internal
|
||||
public void setPlayer(Object player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the connection state this packet has been sent/received in.
|
||||
*/
|
||||
public ConnectionState getConnectionState() {
|
||||
return connectionState;
|
||||
}
|
||||
|
||||
//TODO Possibly put clientversion inside User class and remove here
|
||||
@Deprecated
|
||||
public ClientVersion getClientVersion() {
|
||||
return user.getClientVersion();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setClientVersion(@NotNull ClientVersion clientVersion) {
|
||||
public void setClientVersion(ClientVersion clientVersion) {
|
||||
PacketEvents.getAPI().getLogManager().debug("Setting client version with deprecated method " + clientVersion.getReleaseName());
|
||||
user.setClientVersion(clientVersion);
|
||||
}
|
||||
@@ -157,7 +185,8 @@ public abstract class ProtocolPacketEvent extends PacketEvent implements PlayerE
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
public void setServerVersion(@NotNull ServerVersion serverVersion) {
|
||||
@Deprecated
|
||||
public void setServerVersion(ServerVersion serverVersion) {
|
||||
this.serverVersion = serverVersion;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class UserConnectEvent extends PacketEvent implements CancellableEvent, UserEvent {
|
||||
|
||||
public class UserConnectEvent extends PacketEvent implements CancellableEvent, UserEvent{
|
||||
private final User user;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class UserDisconnectEvent extends PacketEvent implements UserEvent {
|
||||
|
||||
private final User user;
|
||||
|
||||
public UserDisconnectEvent(User user) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Event that involves users.
|
||||
@@ -26,6 +27,8 @@ import com.github.retrooper.packetevents.protocol.player.User;
|
||||
* @author retrooper
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@NullMarked
|
||||
public interface UserEvent {
|
||||
|
||||
User getUser();
|
||||
}
|
||||
@@ -19,8 +19,11 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class UserLoginEvent extends PacketEvent implements CallableEvent, UserEvent, PlayerEvent {
|
||||
|
||||
private final User user;
|
||||
private final Object player;
|
||||
|
||||
|
||||
+16
-15
@@ -25,32 +25,33 @@ 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;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketConfigReceiveEvent extends PacketReceiveEvent {
|
||||
|
||||
public PacketConfigReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
public PacketConfigReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketConfigReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketConfigReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketConfigReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Configuration.Client getPacketType() {
|
||||
|
||||
+16
-15
@@ -25,32 +25,33 @@ 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;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketConfigSendEvent extends PacketSendEvent {
|
||||
|
||||
public PacketConfigSendEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
public PacketConfigSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketConfigSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketConfigSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketConfigSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Configuration.Server getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ 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;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketHandshakeReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketHandshakeReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketHandshakeReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketHandshakeReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketHandshakeReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketHandshakeReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Handshaking.Client getPacketType() {
|
||||
|
||||
+17
-15
@@ -7,31 +7,33 @@ 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;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketHandshakeSendEvent extends PacketSendEvent {
|
||||
public PacketHandshakeSendEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketHandshakeSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability 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 {
|
||||
protected PacketHandshakeSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability 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;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketHandshakeSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Handshaking.Client getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ 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;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketLoginReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketLoginReceiveEvent(Object channel, User user, Object player,
|
||||
Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketLoginReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketLoginReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketLoginReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketLoginReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+17
-14
@@ -25,30 +25,33 @@ 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;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketLoginSendEvent extends PacketSendEvent {
|
||||
public PacketLoginSendEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketLoginSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketLoginSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketLoginSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketLoginSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketLoginSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Login.Server getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ 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;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketPlayReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketPlayReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketPlayReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketPlayReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketPlayReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketPlayReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlayReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlayReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Play.Client getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ 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;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketPlaySendEvent extends PacketSendEvent {
|
||||
public PacketPlaySendEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketPlaySendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketPlaySendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketPlaySendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketPlaySendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlaySendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketPlaySendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Play.Server getPacketType() {
|
||||
|
||||
+17
-15
@@ -25,31 +25,33 @@ 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;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketStatusReceiveEvent extends PacketReceiveEvent {
|
||||
public PacketStatusReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketStatusReceiveEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketStatusReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketStatusReceiveEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketStatusReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
public PacketType.Status.Client getPacketType() {
|
||||
|
||||
+17
-14
@@ -25,30 +25,33 @@ 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;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class PacketStatusSendEvent extends PacketSendEvent {
|
||||
public PacketStatusSendEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
|
||||
public PacketStatusSendEvent(
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation
|
||||
) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketStatusSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
protected PacketStatusSendEvent(
|
||||
int packetId, PacketTypeCommon packetType, ServerVersion serverVersion,
|
||||
Object channel, User user,
|
||||
@UnknownNullability Object player, Object byteBuf
|
||||
) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketStatusSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketStatusSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+5
@@ -2,4 +2,9 @@ package com.github.retrooper.packetevents.exception;
|
||||
|
||||
public class CancelPacketException extends RuntimeException {
|
||||
public static final CancelPacketException INSTANCE = new CancelPacketException();
|
||||
|
||||
@Override
|
||||
public synchronized Throwable fillInStackTrace() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,11 @@
|
||||
|
||||
package com.github.retrooper.packetevents.injector;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.PacketSide;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
|
||||
public interface ChannelInjector {
|
||||
|
||||
default boolean isServerBound() {
|
||||
return true;
|
||||
}
|
||||
@@ -33,5 +35,11 @@ public interface ChannelInjector {
|
||||
|
||||
void setPlayer(Object channel, Object player);
|
||||
|
||||
boolean isPlayerSet(Object channel);
|
||||
|
||||
boolean isProxy();
|
||||
|
||||
default PacketSide getPacketSide() {
|
||||
return PacketSide.SERVER;
|
||||
}
|
||||
}
|
||||
+24
-17
@@ -30,15 +30,17 @@ import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||
import com.github.retrooper.packetevents.util.LogManager;
|
||||
import com.github.retrooper.packetevents.util.mappings.SynchronizedRegistriesHandler;
|
||||
import com.github.retrooper.packetevents.wrapper.configuration.server.WrapperConfigServerConfigurationEnd;
|
||||
import com.github.retrooper.packetevents.wrapper.configuration.server.WrapperConfigServerRegistryData;
|
||||
import com.github.retrooper.packetevents.wrapper.handshaking.client.WrapperHandshakingClientHandshake;
|
||||
import com.github.retrooper.packetevents.wrapper.login.server.WrapperLoginServerLoginSuccess;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerJoinGame;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerRespawn;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class InternalPacketListener extends PacketListenerAbstract {
|
||||
|
||||
public InternalPacketListener() {
|
||||
@@ -66,10 +68,12 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
|
||||
//Map username with channel
|
||||
synchronized (channel) {
|
||||
ProtocolManager.CHANNELS.put(profile.getUUID(), channel);
|
||||
PacketEvents.getAPI().getProtocolManager().setChannel(profile.getUUID(), channel);
|
||||
}
|
||||
|
||||
PacketEvents.getAPI().getLogManager().debug("Mapped player UUID with their channel.");
|
||||
if (PacketEvents.getAPI().getLogManager().isDebug()) {
|
||||
PacketEvents.getAPI().getLogManager().debug("Mapped player UUID with their channel " + profile.getUUID() + " " + channel);
|
||||
}
|
||||
|
||||
// Switch the user's connection state to new state, but the variable event.getConnectionState() remains LOGIN
|
||||
// We switch user state immediately to remain in sync with vanilla, allowing you to encode packets immediately
|
||||
@@ -87,12 +91,11 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
WrapperConfigServerRegistryData packet = new WrapperConfigServerRegistryData(event);
|
||||
|
||||
if (packet.getElements() != null) { // 1.20.2 to 1.20.5
|
||||
SynchronizedRegistriesHandler.handleRegistry(user, packet.getServerVersion().toClientVersion(),
|
||||
SynchronizedRegistriesHandler.handleRegistry(user, packet,
|
||||
packet.getRegistryKey(), packet.getElements());
|
||||
}
|
||||
if (packet.getRegistryData() != null) { // since 1.20.5
|
||||
SynchronizedRegistriesHandler.handleLegacyRegistries(user, packet.getServerVersion()
|
||||
.toClientVersion(), packet.getRegistryData());
|
||||
SynchronizedRegistriesHandler.handleLegacyRegistries(user, packet, packet.getRegistryData());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,8 +105,9 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
user.setEntityId(joinGame.getEntityId());
|
||||
|
||||
if (joinGame.getDimensionCodec() != null) { // 1.16 to 1.20.1
|
||||
SynchronizedRegistriesHandler.handleLegacyRegistries(user, joinGame.getServerVersion().toClientVersion(),
|
||||
SynchronizedRegistriesHandler.handleLegacyRegistries(user, joinGame,
|
||||
joinGame.getDimensionCodec());
|
||||
user.finalizeRegistries(joinGame);
|
||||
}
|
||||
|
||||
user.setDimensionType(joinGame.getDimensionType());
|
||||
@@ -117,6 +121,7 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
user.setEncoderState(ConnectionState.CONFIGURATION);
|
||||
} else if (event.getPacketType() == PacketType.Configuration.Server.CONFIGURATION_END) {
|
||||
user.setEncoderState(ConnectionState.PLAY);
|
||||
user.finalizeRegistries(new WrapperConfigServerConfigurationEnd(event));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,16 +129,18 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
User user = event.getUser();
|
||||
if (event.getPacketType() == PacketType.Handshaking.Client.HANDSHAKE) {
|
||||
Object channel = event.getChannel();
|
||||
InetSocketAddress address = event.getSocketAddress();
|
||||
WrapperHandshakingClientHandshake handshake = new WrapperHandshakingClientHandshake(event);
|
||||
ConnectionState nextState = handshake.getNextConnectionState();
|
||||
ClientVersion clientVersion = handshake.getClientVersion();
|
||||
//Update client version for this event call(and user)
|
||||
WrapperHandshakingClientHandshake packet = new WrapperHandshakingClientHandshake(event);
|
||||
ClientVersion clientVersion = packet.getClientVersion();
|
||||
ConnectionState state = packet.getNextConnectionState();
|
||||
|
||||
LogManager logger = PacketEvents.getAPI().getLogManager();
|
||||
if (logger.isDebug()) {
|
||||
logger.debug("Processed handshake for " + event.getAddress() + ": "
|
||||
+ state.name() + " / " + packet.getClientVersion().getReleaseName());
|
||||
}
|
||||
|
||||
user.setClientVersion(clientVersion);
|
||||
PacketEvents.getAPI().getLogManager().debug("Processed " + address.getHostString() + ":" + address.getPort() + "'s client version. Client Version: " + clientVersion.getReleaseName());
|
||||
//Transition into LOGIN or STATUS connection state immediately, to remain in sync with vanilla
|
||||
user.setConnectionState(nextState);
|
||||
user.setConnectionState(state);
|
||||
} else if (event.getPacketType() == PacketType.Login.Client.LOGIN_SUCCESS_ACK) {
|
||||
user.setDecoderState(ConnectionState.CONFIGURATION);
|
||||
} else if (event.getPacketType() == PacketType.Play.Client.CONFIGURATION_ACK) {
|
||||
|
||||
+13
-1
@@ -19,10 +19,12 @@
|
||||
package com.github.retrooper.packetevents.manager.player;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.event.ProtocolPacketEvent;
|
||||
import com.github.retrooper.packetevents.protocol.ConnectionState;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface PlayerManager {
|
||||
@@ -34,7 +36,17 @@ public interface PlayerManager {
|
||||
|
||||
User getUser(@NotNull Object player);
|
||||
|
||||
default ConnectionState getConnectionState(@NotNull Object player) {
|
||||
/**
|
||||
* <strong>WARNING</strong>: Usage of this method should be avoided. Please use either
|
||||
* {@link User#getDecoderState()} or {@link User#getEncoderState()}.<br>
|
||||
* To access the specific state a packet event was sent/received in, use {@link ProtocolPacketEvent#getConnectionState()}.
|
||||
* <p>
|
||||
* Since 1.20.2, the Minecraft protocol allows the decoder/encoder connection states to de-sync.
|
||||
*
|
||||
* @throws IllegalStateException if encoder/decoder connection states do not match
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
default ConnectionState getConnectionState(@NotNull Object player) throws IllegalStateException {
|
||||
return getUser(player).getConnectionState();
|
||||
}
|
||||
|
||||
|
||||
+23
@@ -33,8 +33,10 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public interface ProtocolManager {
|
||||
@ApiStatus.Internal
|
||||
Map<UUID, Object> CHANNELS = new ConcurrentHashMap<>();
|
||||
// Use SocketAddress because ProtocolLib wraps Channels with NettyChannelProxy class
|
||||
@ApiStatus.Internal
|
||||
Map<Object, User> USERS = new ConcurrentHashMap<>();
|
||||
|
||||
default Collection<User> getUsers() {
|
||||
@@ -150,11 +152,13 @@ public interface ProtocolManager {
|
||||
return USERS.get(pipeline);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
default User removeUser(Object channel) {
|
||||
Object pipeline = ChannelHelper.getPipeline(channel);
|
||||
return USERS.remove(pipeline);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
default void setUser(Object channel, User user) {
|
||||
synchronized (channel) {
|
||||
Object pipeline = ChannelHelper.getPipeline(channel);
|
||||
@@ -166,4 +170,23 @@ public interface ProtocolManager {
|
||||
default Object getChannel(UUID uuid) {
|
||||
return CHANNELS.get(uuid);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
default void setChannel(UUID uuid, Object channel) {
|
||||
CHANNELS.put(uuid, channel);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
default void removeChannel(Object channel) {
|
||||
CHANNELS.values().remove(channel);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
default void removeChannelById(UUID uuid) {
|
||||
CHANNELS.remove(uuid);
|
||||
}
|
||||
|
||||
default boolean hasChannel(Object channel) {
|
||||
return CHANNELS.containsValue(channel);
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -32,9 +32,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public enum ServerVersion {
|
||||
//TODO Rename to MinecraftVersion?
|
||||
V_1_7_10(5),
|
||||
V_1_7_2(4), V_1_7_4(4), V_1_7_5(4),
|
||||
V_1_7_6(5), V_1_7_7(5), V_1_7_8(5), V_1_7_9(5), 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),
|
||||
V_1_9(107), V_1_9_1(108), V_1_9_2(109), V_1_9_4(110),
|
||||
//1.10 and 1.10.1 are redundant
|
||||
V_1_10(210), V_1_10_1(210), V_1_10_2(210),
|
||||
V_1_11(315), V_1_11_2(316),
|
||||
@@ -49,8 +50,8 @@ public enum ServerVersion {
|
||||
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. 1.20.3 and 1.20.4 have the same protocol version. 1.20.5 and 1.20.6 have the same protocol version
|
||||
V_1_20(763), V_1_20_1(763), V_1_20_2(764), V_1_20_3(765), V_1_20_4(765), V_1_20_5(766), V_1_20_6(766),
|
||||
//1.21 and 1.21.1 have the same protocol version
|
||||
V_1_21(767), V_1_21_1(767),
|
||||
//1.21 and 1.21.1 have the same protocol version. 1.21.2 and 1.21.3 have the same protocol version. 1.21.7 and 1.21.8 have the same protocol version. 1.21.9 and 1.21.10 have the same protocol version
|
||||
V_1_21(767), V_1_21_1(767), V_1_21_2(768), V_1_21_3(768), V_1_21_4(769), V_1_21_5(770), V_1_21_6(771), V_1_21_7(772), V_1_21_8(772), V_1_21_9(773), V_1_21_10(773), V_1_21_11(774),
|
||||
//TODO UPDATE Add server version constant
|
||||
ERROR(-1, true);
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package com.github.retrooper.packetevents.manager.server;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* System Operating system.
|
||||
*
|
||||
@@ -36,9 +38,9 @@ public enum SystemOS {
|
||||
* @return Operating System.
|
||||
*/
|
||||
public static SystemOS getOSNoCache() {
|
||||
final String os = System.getProperty("os.name").toLowerCase();
|
||||
final String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
|
||||
for (SystemOS sysos : values()) {
|
||||
if (os.contains(sysos.name().toLowerCase())) {
|
||||
if (os.contains(sysos.name().toLowerCase(Locale.ROOT))) {
|
||||
return sysos;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -31,4 +31,6 @@ public interface ByteBufAllocationOperator {
|
||||
|
||||
Object compositeBuffer();
|
||||
Object compositeBuffer(int maxNumComponents);
|
||||
|
||||
Object emptyBuffer();
|
||||
}
|
||||
@@ -103,6 +103,10 @@ public class ByteBufHelper {
|
||||
PacketEvents.getAPI().getNettyManager().getByteBufOperator().writeShort(buffer, value);
|
||||
}
|
||||
|
||||
public static void writeShortLE(Object buffer, int value) {
|
||||
PacketEvents.getAPI().getNettyManager().getByteBufOperator().writeShortLE(buffer, value);
|
||||
}
|
||||
|
||||
public static int readMedium(Object buffer) {
|
||||
return PacketEvents.getAPI().getNettyManager().getByteBufOperator().readMedium(buffer);
|
||||
}
|
||||
@@ -239,6 +243,19 @@ public class ByteBufHelper {
|
||||
return PacketEvents.getAPI().getNettyManager().getByteBufOperator().resetWriterIndex(buffer);
|
||||
}
|
||||
|
||||
public static Object allocateNewBuffer(Object buffer) {
|
||||
return PacketEvents.getAPI().getNettyManager().getByteBufOperator().allocateNewBuffer(buffer);
|
||||
}
|
||||
|
||||
public static int getByteSize(int value) {
|
||||
for (int i = 1; i < 5; ++i) {
|
||||
if ((value & -1 << i * 7) == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
public static int readVarInt(Object buffer) {
|
||||
int value = 0;
|
||||
int length = 0;
|
||||
|
||||
@@ -42,6 +42,7 @@ public interface ByteBufOperator {
|
||||
|
||||
void writeByte(Object buffer, int value);
|
||||
void writeShort(Object buffer, int value);
|
||||
void writeShortLE(Object buffer, int value);
|
||||
void writeMedium(Object buffer, int value);
|
||||
void writeInt(Object buffer, int value);
|
||||
void writeLong(Object buffer, long value);
|
||||
@@ -74,6 +75,8 @@ public interface ByteBufOperator {
|
||||
Object markWriterIndex(Object buffer);
|
||||
Object resetWriterIndex(Object buffer);
|
||||
|
||||
Object allocateNewBuffer(Object buffer);
|
||||
|
||||
default float readFloat(Object buffer) {
|
||||
return Float.intBitsToFloat(readInt(buffer));
|
||||
}
|
||||
|
||||
+4
@@ -52,4 +52,8 @@ public class UnpooledByteBufAllocationHelper {
|
||||
public static Object compositeBuffer(int maxNumComponents) {
|
||||
return PacketEvents.getAPI().getNettyManager().getByteBufAllocationOperator().compositeBuffer(maxNumComponents);
|
||||
}
|
||||
|
||||
public static Object emptyBuffer() {
|
||||
return PacketEvents.getAPI().getNettyManager().getByteBufAllocationOperator().emptyBuffer();
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.advancements;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Advancement {
|
||||
|
||||
private @Nullable ResourceLocation parent;
|
||||
private @Nullable AdvancementDisplay display;
|
||||
/**
|
||||
* Removed with 1.20.2
|
||||
*/
|
||||
private List<String> criteria;
|
||||
private List<List<String>> requirements;
|
||||
/**
|
||||
* Added with 1.20
|
||||
*/
|
||||
private boolean sendsTelemetryData;
|
||||
|
||||
public Advancement(
|
||||
@Nullable ResourceLocation parent,
|
||||
@Nullable AdvancementDisplay display,
|
||||
List<List<String>> requirements,
|
||||
boolean sendsTelemetryData
|
||||
) {
|
||||
this(parent, display, Collections.emptyList(), requirements, sendsTelemetryData);
|
||||
}
|
||||
|
||||
@ApiStatus.Obsolete
|
||||
public Advancement(
|
||||
@Nullable ResourceLocation parent,
|
||||
@Nullable AdvancementDisplay display,
|
||||
List<String> criteria,
|
||||
List<List<String>> requirements,
|
||||
boolean sendsTelemetryData
|
||||
) {
|
||||
this.parent = parent;
|
||||
this.display = display;
|
||||
this.criteria = criteria;
|
||||
this.requirements = requirements;
|
||||
this.sendsTelemetryData = sendsTelemetryData;
|
||||
}
|
||||
|
||||
public static Advancement read(PacketWrapper<?> wrapper) {
|
||||
ResourceLocation parentId = wrapper.readOptional(ResourceLocation::read);
|
||||
AdvancementDisplay display = wrapper.readOptional(AdvancementDisplay::read);
|
||||
List<String> criteria = wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_20_2)
|
||||
? wrapper.readList(PacketWrapper::readString) : null;
|
||||
List<List<String>> requirements = wrapper.readList(
|
||||
ew -> wrapper.readList(PacketWrapper::readString));
|
||||
boolean sendsTelemetryData = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_20)
|
||||
&& wrapper.readBoolean();
|
||||
return new Advancement(parentId, display, criteria, requirements, sendsTelemetryData);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, Advancement advancement) {
|
||||
wrapper.writeOptional(advancement.parent, ResourceLocation::write);
|
||||
wrapper.writeOptional(advancement.display, AdvancementDisplay::write);
|
||||
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_20_2)) {
|
||||
wrapper.writeList(advancement.criteria, PacketWrapper::writeString);
|
||||
}
|
||||
wrapper.writeList(advancement.getRequirements(), (ew, anyList) ->
|
||||
ew.writeList(anyList, PacketWrapper::writeString));
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_20)) {
|
||||
wrapper.writeBoolean(advancement.sendsTelemetryData);
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable ResourceLocation getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public void setParent(@Nullable ResourceLocation parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public @Nullable AdvancementDisplay getDisplay() {
|
||||
return this.display;
|
||||
}
|
||||
|
||||
public void setDisplay(@Nullable AdvancementDisplay display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removed with 1.20.2
|
||||
*/
|
||||
public List<String> getCriteria() {
|
||||
return this.criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removed with 1.20.2
|
||||
*/
|
||||
public void setCriteria(List<String> criteria) {
|
||||
this.criteria = criteria;
|
||||
}
|
||||
|
||||
public List<List<String>> getRequirements() {
|
||||
return this.requirements;
|
||||
}
|
||||
|
||||
public void setRequirements(List<List<String>> requirements) {
|
||||
this.requirements = requirements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Added with 1.20
|
||||
*/
|
||||
public boolean isSendsTelemetryData() {
|
||||
return this.sendsTelemetryData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Added with 1.20
|
||||
*/
|
||||
public void setSendsTelemetryData(boolean sendsTelemetryData) {
|
||||
this.sendsTelemetryData = sendsTelemetryData;
|
||||
}
|
||||
}
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.advancements;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class AdvancementDisplay {
|
||||
|
||||
public static final int FLAG_HAS_BACKGROUND = 0b001;
|
||||
public static final int FLAG_SHOW_TOAST = 0b010;
|
||||
public static final int FLAG_HIDDEN = 0b100;
|
||||
|
||||
private Component title;
|
||||
private Component description;
|
||||
private ItemStack icon;
|
||||
private AdvancementType type;
|
||||
private boolean showToast;
|
||||
private boolean hidden;
|
||||
private @Nullable ResourceLocation background;
|
||||
private float x;
|
||||
private float y;
|
||||
|
||||
public AdvancementDisplay(Component title, Component description, ItemStack icon, AdvancementType type, @Nullable ResourceLocation background, boolean showToast,
|
||||
boolean hidden, float x, float y) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.icon = icon;
|
||||
this.type = type;
|
||||
this.showToast = showToast;
|
||||
this.hidden = hidden;
|
||||
this.background = background;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public static AdvancementDisplay read(PacketWrapper<?> wrapper) {
|
||||
Component title = wrapper.readComponent();
|
||||
Component description = wrapper.readComponent();
|
||||
ItemStack icon = wrapper.readItemStack();
|
||||
AdvancementType type = wrapper.readEnum(AdvancementType.class);
|
||||
int flags = wrapper.readInt();
|
||||
ResourceLocation background = (flags & FLAG_HAS_BACKGROUND) != 0 ? ResourceLocation.read(wrapper) : null;
|
||||
boolean showToast = (flags & FLAG_SHOW_TOAST) != 0;
|
||||
boolean hidden = (flags & FLAG_HIDDEN) != 0;
|
||||
float x = wrapper.readFloat();
|
||||
float y = wrapper.readFloat();
|
||||
return new AdvancementDisplay(title, description, icon, type, background, showToast, hidden, x, y);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, AdvancementDisplay display) {
|
||||
wrapper.writeComponent(display.title);
|
||||
wrapper.writeComponent(display.description);
|
||||
wrapper.writeItemStack(display.icon);
|
||||
wrapper.writeEnum(display.type);
|
||||
wrapper.writeInt(display.packFlags());
|
||||
if (display.background != null) {
|
||||
ResourceLocation.write(wrapper, display.background);
|
||||
}
|
||||
wrapper.writeFloat(display.x);
|
||||
wrapper.writeFloat(display.y);
|
||||
}
|
||||
|
||||
public int packFlags() {
|
||||
int flags = 0;
|
||||
if (this.background != null) {
|
||||
flags |= FLAG_HAS_BACKGROUND;
|
||||
}
|
||||
if (this.showToast) {
|
||||
flags |= FLAG_SHOW_TOAST;
|
||||
}
|
||||
if (this.hidden) {
|
||||
flags |= FLAG_HIDDEN;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public Component getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setTitle(Component title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Component getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(Component description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public ItemStack getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
public void setIcon(ItemStack icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public AdvancementType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(AdvancementType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean isShowToast() {
|
||||
return this.showToast;
|
||||
}
|
||||
|
||||
public void setShowToast(boolean showToast) {
|
||||
this.showToast = showToast;
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return this.hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public @Nullable ResourceLocation getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
public void setBackground(@Nullable ResourceLocation background) {
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public void setX(float x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public float getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public void setY(float y) {
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.advancements;
|
||||
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
public final class AdvancementHolder {
|
||||
|
||||
private ResourceLocation identifier;
|
||||
private Advancement advancement;
|
||||
|
||||
public AdvancementHolder(ResourceLocation identifier, Advancement advancement) {
|
||||
this.identifier = identifier;
|
||||
this.advancement = advancement;
|
||||
}
|
||||
|
||||
public static AdvancementHolder read(PacketWrapper<?> wrapper) {
|
||||
ResourceLocation identifier = wrapper.readIdentifier();
|
||||
Advancement advancement = Advancement.read(wrapper);
|
||||
return new AdvancementHolder(identifier, advancement);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, AdvancementHolder holder) {
|
||||
wrapper.writeIdentifier(holder.identifier);
|
||||
Advancement.write(wrapper, holder.advancement);
|
||||
}
|
||||
|
||||
public ResourceLocation getIdentifier() {
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(ResourceLocation identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public Advancement getAdvancement() {
|
||||
return this.advancement;
|
||||
}
|
||||
|
||||
public void setAdvancement(Advancement advancement) {
|
||||
this.advancement = advancement;
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.advancements;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public final class AdvancementProgress {
|
||||
|
||||
private Map<String, CriterionProgress> criteria;
|
||||
|
||||
public AdvancementProgress(Map<String, CriterionProgress> criteria) {
|
||||
this.criteria = criteria;
|
||||
}
|
||||
|
||||
public static AdvancementProgress read(PacketWrapper<?> wrapper) {
|
||||
Map<String, CriterionProgress> criteria = wrapper.readMap(PacketWrapper::readString, CriterionProgress::read);
|
||||
return new AdvancementProgress(criteria);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, AdvancementProgress progress) {
|
||||
wrapper.writeMap(progress.getCriteria(), PacketWrapper::writeString, CriterionProgress::write);
|
||||
}
|
||||
|
||||
public Map<String, CriterionProgress> getCriteria() {
|
||||
return this.criteria;
|
||||
}
|
||||
|
||||
public void setCriteria(Map<String, CriterionProgress> criteria) {
|
||||
this.criteria = criteria;
|
||||
}
|
||||
|
||||
public static final class CriterionProgress {
|
||||
|
||||
private @Nullable Long obtainedTimestamp;
|
||||
|
||||
public CriterionProgress(@Nullable Long obtainedTimestamp) {
|
||||
this.obtainedTimestamp = obtainedTimestamp;
|
||||
}
|
||||
|
||||
public static CriterionProgress read(PacketWrapper<?> wrapper) {
|
||||
return new CriterionProgress(wrapper.readOptional(PacketWrapper::readLong));
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, CriterionProgress progress) {
|
||||
wrapper.writeOptional(progress.obtainedTimestamp, PacketWrapper::writeLong);
|
||||
}
|
||||
|
||||
public @Nullable Long getObtainedTimestamp() {
|
||||
return this.obtainedTimestamp;
|
||||
}
|
||||
|
||||
public void setObtainedTimestamp(@Nullable Long obtainedTimestamp) {
|
||||
this.obtainedTimestamp = obtainedTimestamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.advancements;
|
||||
|
||||
public enum AdvancementType {
|
||||
|
||||
TASK,
|
||||
CHALLENGE,
|
||||
GOAL,
|
||||
;
|
||||
}
|
||||
@@ -18,7 +18,35 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.MathUtil;
|
||||
|
||||
public interface Attribute extends MappedEntity {
|
||||
|
||||
@Override
|
||||
default ResourceLocation getName() {
|
||||
return this.getName(PacketEvents.getAPI().getServerManager().getVersion().toClientVersion());
|
||||
}
|
||||
|
||||
ResourceLocation getName(ClientVersion version);
|
||||
|
||||
default double sanitizeValue(double value) {
|
||||
return this.sanitizeValue(value, PacketEvents.getAPI().getServerManager().getVersion().toClientVersion());
|
||||
}
|
||||
|
||||
default double sanitizeValue(double value, ClientVersion version) {
|
||||
if (!Double.isNaN(value)) {
|
||||
return MathUtil.clamp(value, this.getMinValue(), this.getMaxValue());
|
||||
}
|
||||
return this.getMinValue();
|
||||
}
|
||||
|
||||
double getDefaultValue();
|
||||
|
||||
double getMinValue();
|
||||
|
||||
double getMaxValue();
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public interface AttributeDisplay {
|
||||
|
||||
static AttributeDisplay read(PacketWrapper<?> wrapper) {
|
||||
AttributeDisplayType<?> type = wrapper.readMappedEntity(AttributeDisplayTypes.getRegistry());
|
||||
return type.read(wrapper);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") // not unchecked
|
||||
static void write(PacketWrapper<?> wrapper, AttributeDisplay display) {
|
||||
wrapper.writeMappedEntity(display.getType());
|
||||
((AttributeDisplayType<? super AttributeDisplay>) display.getType()).write(wrapper, display);
|
||||
}
|
||||
|
||||
AttributeDisplayType<?> getType();
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public interface AttributeDisplayType<T extends AttributeDisplay> extends MappedEntity {
|
||||
|
||||
T read(PacketWrapper<?> wrapper);
|
||||
|
||||
void write(PacketWrapper<?> wrapper, T display);
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public final class AttributeDisplayTypes {
|
||||
|
||||
private static final VersionedRegistry<AttributeDisplayType<?>> REGISTRY = new VersionedRegistry<>("attribute_display_type");
|
||||
|
||||
private AttributeDisplayTypes() {
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static <T extends AttributeDisplay> AttributeDisplayType<T> define(
|
||||
String name, PacketWrapper.Reader<T> reader, PacketWrapper.Writer<T> writer
|
||||
) {
|
||||
return REGISTRY.define(name, data ->
|
||||
new StaticAttributeDisplayType<>(data, reader, writer));
|
||||
}
|
||||
|
||||
public static VersionedRegistry<AttributeDisplayType<?>> getRegistry() {
|
||||
return REGISTRY;
|
||||
}
|
||||
|
||||
public static final AttributeDisplayType<DefaultAttributeDisplay> DEFAULT = define("default",
|
||||
DefaultAttributeDisplay::read, DefaultAttributeDisplay::write);
|
||||
public static final AttributeDisplayType<HiddenAttributeDisplay> HIDDEN = define("hidden",
|
||||
HiddenAttributeDisplay::read, HiddenAttributeDisplay::write);
|
||||
public static final AttributeDisplayType<OverrideAttributeDisplay> OVERRIDE = define("override",
|
||||
OverrideAttributeDisplay::read, OverrideAttributeDisplay::write);
|
||||
|
||||
static {
|
||||
REGISTRY.unloadMappings();
|
||||
}
|
||||
}
|
||||
+331
-76
@@ -20,98 +20,353 @@ package com.github.retrooper.packetevents.protocol.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.mappings.MappingHelper;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilder;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
public final class Attributes {
|
||||
|
||||
public class Attributes {
|
||||
private static final VersionedRegistry<Attribute> REGISTRY = new VersionedRegistry<>("attribute");
|
||||
|
||||
private static final Map<String, Attribute> ATTRIBUTE_MAP = new HashMap<>();
|
||||
private static final Map<Byte, Map<Integer, Attribute>> ATTRIBUTE_ID_MAP = new HashMap<>();
|
||||
private static final TypesBuilder TYPES_BUILDER = new TypesBuilder("attribute/attribute_mappings");
|
||||
|
||||
public static Attribute define(String key) {
|
||||
TypesBuilderData data = TYPES_BUILDER.define(key);
|
||||
Attribute attribute = new Attribute() {
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return data.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId(ClientVersion version) {
|
||||
return MappingHelper.getId(version, TYPES_BUILDER, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Attribute) {
|
||||
return this.getName().equals(((Attribute) obj).getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
MappingHelper.registerMapping(TYPES_BUILDER, ATTRIBUTE_MAP, ATTRIBUTE_ID_MAP, attribute);
|
||||
return attribute;
|
||||
private Attributes() {
|
||||
}
|
||||
|
||||
private static Attribute define(
|
||||
String key, @Nullable String legacyPrefix,
|
||||
double def, double min, double max
|
||||
) {
|
||||
return REGISTRY.define(key, data ->
|
||||
new StaticAttribute(data, legacyPrefix, def, min, max));
|
||||
}
|
||||
|
||||
public static VersionedRegistry<Attribute> getRegistry() {
|
||||
return REGISTRY;
|
||||
}
|
||||
|
||||
// with minecraft:key
|
||||
public static Attribute getByName(String name) {
|
||||
return ATTRIBUTE_MAP.get(name);
|
||||
// "remapping" to support < 1.21.2
|
||||
String normedName = ResourceLocation.normString(name);
|
||||
if (normedName.startsWith(ResourceLocation.VANILLA_NAMESPACE + ":generic.")
|
||||
|| normedName.startsWith(ResourceLocation.VANILLA_NAMESPACE + ":player.")
|
||||
|| normedName.startsWith(ResourceLocation.VANILLA_NAMESPACE + ":zombie.")) {
|
||||
normedName = normedName.substring(normedName.indexOf('.') + 1);
|
||||
}
|
||||
return REGISTRY.getByName(normedName);
|
||||
}
|
||||
|
||||
public static Attribute getById(ClientVersion version, int id) {
|
||||
int index = TYPES_BUILDER.getDataIndex(version);
|
||||
Map<Integer, Attribute> idMap = ATTRIBUTE_ID_MAP.get((byte) index);
|
||||
return idMap.get(id);
|
||||
return REGISTRY.getById(version, id);
|
||||
}
|
||||
|
||||
public static final Attribute GENERIC_ARMOR = define("generic.armor");
|
||||
public static final Attribute GENERIC_ARMOR_TOUGHNESS = define("generic.armor_toughness");
|
||||
public static final Attribute GENERIC_ATTACK_DAMAGE = define("generic.attack_damage");
|
||||
public static final Attribute GENERIC_ATTACK_KNOCKBACK = define("generic.attack_knockback");
|
||||
public static final Attribute GENERIC_ATTACK_SPEED = define("generic.attack_speed");
|
||||
public static final Attribute GENERIC_FLYING_SPEED = define("generic.flying_speed");
|
||||
public static final Attribute GENERIC_FOLLOW_RANGE = define("generic.follow_range");
|
||||
@ApiStatus.Obsolete // renamed in 1.20.5
|
||||
public static final Attribute HORSE_JUMP_STRENGTH = define("horse.jump_strength");
|
||||
public static final Attribute GENERIC_KNOCKBACK_RESISTANCE = define("generic.knockback_resistance");
|
||||
public static final Attribute GENERIC_LUCK = define("generic.luck");
|
||||
public static final Attribute GENERIC_MAX_HEALTH = define("generic.max_health");
|
||||
public static final Attribute GENERIC_MOVEMENT_SPEED = define("generic.movement_speed");
|
||||
public static final Attribute ZOMBIE_SPAWN_REINFORCEMENTS = define("zombie.spawn_reinforcements");
|
||||
public static final Attribute ARMOR = define("armor",
|
||||
"generic", 0d, 0d, 30d);
|
||||
public static final Attribute ARMOR_TOUGHNESS = define("armor_toughness",
|
||||
"generic", 0d, 0d, 20d);
|
||||
public static final Attribute ATTACK_DAMAGE = define("attack_damage",
|
||||
"generic", 2d, 0d, 2048d);
|
||||
public static final Attribute ATTACK_KNOCKBACK = define("attack_knockback",
|
||||
"generic", 0d, 0d, 5d);
|
||||
public static final Attribute ATTACK_SPEED = define("attack_speed",
|
||||
"generic", 4d, 0d, 1024d);
|
||||
public static final Attribute FLYING_SPEED = define("flying_speed",
|
||||
"generic", 0.4d, 0d, 1024d);
|
||||
public static final Attribute FOLLOW_RANGE = define("follow_range",
|
||||
"generic", 32d, 0d, 2048d);
|
||||
public static final Attribute KNOCKBACK_RESISTANCE = define("knockback_resistance",
|
||||
"generic", 0d, 0d, 1d);
|
||||
public static final Attribute LUCK = define("luck",
|
||||
"generic", 0d, -1024d, 1024d);
|
||||
public static final Attribute MAX_HEALTH = define("max_health",
|
||||
"generic", 20d, 1d, 1024d);
|
||||
public static final Attribute MOVEMENT_SPEED = define("movement_speed",
|
||||
"generic", 0.7d, 0d, 1024d);
|
||||
public static final Attribute SPAWN_REINFORCEMENTS = define("spawn_reinforcements",
|
||||
"zombie", 0d, 0d, 1d);
|
||||
|
||||
// Added in 1.20.2
|
||||
public static final Attribute GENERIC_MAX_ABSORPTION = define("generic.max_absorption");
|
||||
/**
|
||||
* Added with 1.20.2
|
||||
*/
|
||||
public static final Attribute MAX_ABSORPTION = define("max_absorption",
|
||||
"generic", 0d, 0d, 2048d);
|
||||
|
||||
// Added in 1.20.5
|
||||
public static final Attribute PLAYER_BLOCK_BREAK_SPEED = define("player.block_break_speed");
|
||||
public static final Attribute PLAYER_BLOCK_INTERACTION_RANGE = define("player.block_interaction_range");
|
||||
public static final Attribute PLAYER_ENTITY_INTERACTION_RANGE = define("player.entity_interaction_range");
|
||||
public static final Attribute GENERIC_FALL_DAMAGE_MULTIPLIER = define("generic.fall_damage_multiplier");
|
||||
public static final Attribute GENERIC_GRAVITY = define("generic.gravity");
|
||||
public static final Attribute GENERIC_JUMP_STRENGTH = define("generic.jump_strength");
|
||||
public static final Attribute GENERIC_SAFE_FALL_DISTANCE = define("generic.safe_fall_distance");
|
||||
public static final Attribute GENERIC_SCALE = define("generic.scale");
|
||||
public static final Attribute GENERIC_STEP_HEIGHT = define("generic.step_height");
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
*/
|
||||
public static final Attribute BLOCK_BREAK_SPEED = define("block_break_speed",
|
||||
"player", 1d, 0d, 1024d);
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
*/
|
||||
public static final Attribute BLOCK_INTERACTION_RANGE = define("block_interaction_range",
|
||||
"player", 4.5d, 0d, 64d);
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
*/
|
||||
public static final Attribute ENTITY_INTERACTION_RANGE = define("entity_interaction_range",
|
||||
"player", 3d, 0d, 64d);
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
*/
|
||||
public static final Attribute FALL_DAMAGE_MULTIPLIER = define("fall_damage_multiplier",
|
||||
"generic", 1d, 0d, 100d);
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
*/
|
||||
public static final Attribute GRAVITY = define("gravity",
|
||||
"generic", 0.08d, -1d, 1d);
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
*/
|
||||
public static final Attribute JUMP_STRENGTH = define("jump_strength",
|
||||
"generic", 0.42d, 0d, 32d);
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
*/
|
||||
public static final Attribute SAFE_FALL_DISTANCE = define("safe_fall_distance",
|
||||
"generic", 3d, 0d, 1024d);
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
*/
|
||||
public static final Attribute SCALE = define("scale",
|
||||
"generic", 1d, 1d / 16d, 16d);
|
||||
/**
|
||||
* Added with 1.20.5
|
||||
*/
|
||||
public static final Attribute STEP_HEIGHT = define("step_height",
|
||||
"generic", 0.6d, 0d, 10d);
|
||||
|
||||
// Added in 1.21
|
||||
public static final Attribute GENERIC_BURNING_TIME = define("generic.burning_time");
|
||||
public static final Attribute GENERIC_EXPLOSION_KNOCKBACK_RESISTANCE = define("generic.explosion_knockback_resistance");
|
||||
public static final Attribute PLAYER_MINING_EFFICIENCY = define("player.mining_efficiency");
|
||||
public static final Attribute GENERIC_MOVEMENT_EFFICIENCY = define("generic.movement_efficiency");
|
||||
public static final Attribute GENERIC_OXYGEN_BONUS = define("generic.oxygen_bonus");
|
||||
public static final Attribute PLAYER_SNEAKING_SPEED = define("player.sneaking_speed");
|
||||
public static final Attribute PLAYER_SUBMERGED_MINING_SPEED = define("player.submerged_mining_speed");
|
||||
public static final Attribute PLAYER_SWEEPING_DAMAGE_RATIO = define("player.sweeping_damage_ratio");
|
||||
public static final Attribute GENERIC_WATER_MOVEMENT_EFFICIENCY = define("generic.water_movement_efficiency");
|
||||
/**
|
||||
* Added with 1.21
|
||||
*/
|
||||
public static final Attribute BURNING_TIME = define("burning_time",
|
||||
"generic", 0d, 1d, 1024d);
|
||||
/**
|
||||
* Added with 1.21
|
||||
*/
|
||||
public static final Attribute EXPLOSION_KNOCKBACK_RESISTANCE = define("explosion_knockback_resistance",
|
||||
"generic", 0d, 0d, 1d);
|
||||
/**
|
||||
* Added with 1.21
|
||||
*/
|
||||
public static final Attribute MINING_EFFICIENCY = define("mining_efficiency",
|
||||
"player", 0d, 0d, 1024d);
|
||||
/**
|
||||
* Added with 1.21
|
||||
*/
|
||||
public static final Attribute MOVEMENT_EFFICIENCY = define("movement_efficiency",
|
||||
"generic", 0d, 0d, 1d);
|
||||
/**
|
||||
* Added with 1.21
|
||||
*/
|
||||
public static final Attribute OXYGEN_BONUS = define("oxygen_bonus",
|
||||
"generic", 0d, 0d, 1024d);
|
||||
/**
|
||||
* Added with 1.21
|
||||
*/
|
||||
public static final Attribute SNEAKING_SPEED = define("sneaking_speed",
|
||||
"player", 0.3d, 0d, 1d);
|
||||
/**
|
||||
* Added with 1.21
|
||||
*/
|
||||
public static final Attribute SUBMERGED_MINING_SPEED = define("submerged_mining_speed",
|
||||
"player", 0.2d, 0d, 20d);
|
||||
/**
|
||||
* Added with 1.21
|
||||
*/
|
||||
public static final Attribute SWEEPING_DAMAGE_RATIO = define("sweeping_damage_ratio",
|
||||
"player", 0d, 0d, 1d);
|
||||
/**
|
||||
* Added with 1.21
|
||||
*/
|
||||
public static final Attribute WATER_MOVEMENT_EFFICIENCY = define("water_movement_efficiency",
|
||||
"generic", 0d, 0d, 1d);
|
||||
|
||||
/**
|
||||
* Added with 1.21.2
|
||||
*/
|
||||
public static final Attribute TEMPT_RANGE = define("tempt_range",
|
||||
null, 10d, 0d, 2048d);
|
||||
|
||||
/**
|
||||
* Added with 1.21.6
|
||||
*/
|
||||
public static final Attribute CAMERA_DISTANCE = define("camera_distance",
|
||||
null, 4d, 0d, 32d);
|
||||
/**
|
||||
* Added with 1.21.6
|
||||
*/
|
||||
public static final Attribute WAYPOINT_TRANSMIT_RANGE = define("waypoint_transmit_range",
|
||||
null, 0d, 0d, 60_000_000d);
|
||||
/**
|
||||
* Added with 1.21.6
|
||||
*/
|
||||
public static final Attribute WAYPOINT_RECEIVE_RANGE = define("waypoint_receive_range",
|
||||
null, 0d, 0d, 60_000_000d);
|
||||
|
||||
/**
|
||||
* This attribute has been renamed in 1.20.5 to {@link #JUMP_STRENGTH}
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public static final Attribute HORSE_JUMP_STRENGTH = define("horse.jump_strength",
|
||||
null, 0.7d, 0d, 2d);
|
||||
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_ARMOR = ARMOR;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_ARMOR_TOUGHNESS = ARMOR_TOUGHNESS;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_ATTACK_DAMAGE = ATTACK_DAMAGE;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_ATTACK_KNOCKBACK = ATTACK_KNOCKBACK;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_ATTACK_SPEED = ATTACK_SPEED;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_FLYING_SPEED = FLYING_SPEED;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_FOLLOW_RANGE = FOLLOW_RANGE;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_KNOCKBACK_RESISTANCE = KNOCKBACK_RESISTANCE;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_LUCK = LUCK;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_MAX_HEALTH = MAX_HEALTH;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_MOVEMENT_SPEED = MOVEMENT_SPEED;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute ZOMBIE_SPAWN_REINFORCEMENTS = SPAWN_REINFORCEMENTS;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_MAX_ABSORPTION = MAX_ABSORPTION;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute PLAYER_BLOCK_BREAK_SPEED = BLOCK_BREAK_SPEED;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute PLAYER_BLOCK_INTERACTION_RANGE = BLOCK_INTERACTION_RANGE;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute PLAYER_ENTITY_INTERACTION_RANGE = ENTITY_INTERACTION_RANGE;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_FALL_DAMAGE_MULTIPLIER = FALL_DAMAGE_MULTIPLIER;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_GRAVITY = GRAVITY;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_JUMP_STRENGTH = JUMP_STRENGTH;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_SAFE_FALL_DISTANCE = SAFE_FALL_DISTANCE;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_SCALE = SCALE;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_STEP_HEIGHT = STEP_HEIGHT;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_BURNING_TIME = BURNING_TIME;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_EXPLOSION_KNOCKBACK_RESISTANCE = EXPLOSION_KNOCKBACK_RESISTANCE;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute PLAYER_MINING_EFFICIENCY = MINING_EFFICIENCY;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_MOVEMENT_EFFICIENCY = MOVEMENT_EFFICIENCY;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_OXYGEN_BONUS = OXYGEN_BONUS;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute PLAYER_SNEAKING_SPEED = SNEAKING_SPEED;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute PLAYER_SUBMERGED_MINING_SPEED = SUBMERGED_MINING_SPEED;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute PLAYER_SWEEPING_DAMAGE_RATIO = SWEEPING_DAMAGE_RATIO;
|
||||
/**
|
||||
* All attribute "type" prefixes were removed with 1.21.2
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Attribute GENERIC_WATER_MOVEMENT_EFFICIENCY = WATER_MOVEMENT_EFFICIENCY;
|
||||
|
||||
static {
|
||||
TYPES_BUILDER.unloadFileMappings();
|
||||
REGISTRY.unloadMappings();
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class DefaultAttributeDisplay implements AttributeDisplay {
|
||||
|
||||
public static final DefaultAttributeDisplay INSTANCE = new DefaultAttributeDisplay();
|
||||
|
||||
private DefaultAttributeDisplay() {
|
||||
}
|
||||
|
||||
public static DefaultAttributeDisplay read(PacketWrapper<?> wrapper) {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DefaultAttributeDisplay display) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeDisplayType<?> getType() {
|
||||
return AttributeDisplayTypes.DEFAULT;
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class HiddenAttributeDisplay implements AttributeDisplay {
|
||||
|
||||
public static final HiddenAttributeDisplay INSTANCE = new HiddenAttributeDisplay();
|
||||
|
||||
private HiddenAttributeDisplay() {
|
||||
}
|
||||
|
||||
public static HiddenAttributeDisplay read(PacketWrapper<?> wrapper) {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, HiddenAttributeDisplay display) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeDisplayType<?> getType() {
|
||||
return AttributeDisplayTypes.HIDDEN;
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class OverrideAttributeDisplay implements AttributeDisplay {
|
||||
|
||||
private final Component component;
|
||||
|
||||
public OverrideAttributeDisplay(Component component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public static OverrideAttributeDisplay read(PacketWrapper<?> wrapper) {
|
||||
return new OverrideAttributeDisplay(wrapper.readComponent());
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, OverrideAttributeDisplay display) {
|
||||
wrapper.writeComponent(display.component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeDisplayType<?> getType() {
|
||||
return AttributeDisplayTypes.OVERRIDE;
|
||||
}
|
||||
|
||||
public Component getComponent() {
|
||||
return this.component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof OverrideAttributeDisplay)) return false;
|
||||
OverrideAttributeDisplay that = (OverrideAttributeDisplay) obj;
|
||||
return this.component.equals(that.component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.component);
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 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.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class StaticAttribute extends AbstractMappedEntity implements Attribute {
|
||||
|
||||
private final @Nullable ResourceLocation legacyName;
|
||||
private final double defaultValue;
|
||||
private final double minValue;
|
||||
private final double maxValue;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public StaticAttribute(
|
||||
@Nullable TypesBuilderData data, String legacyPrefix,
|
||||
double defaultValue, double minValue, double maxValue
|
||||
) {
|
||||
super(data);
|
||||
this.defaultValue = defaultValue;
|
||||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
this.legacyName = legacyPrefix == null || data == null ? null : new ResourceLocation(
|
||||
data.getName().getNamespace(), legacyPrefix + "." + data.getName().getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getName(ClientVersion version) {
|
||||
if (this.data == null) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return version.isNewerThanOrEquals(ClientVersion.V_1_21_2) || this.legacyName == null
|
||||
? this.data.getName() : this.legacyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDefaultValue() {
|
||||
return this.defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMinValue() {
|
||||
return this.minValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxValue() {
|
||||
return this.maxValue;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper.Reader;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper.Writer;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class StaticAttributeDisplayType<T extends AttributeDisplay> extends AbstractMappedEntity implements AttributeDisplayType<T> {
|
||||
|
||||
private final Reader<T> reader;
|
||||
private final Writer<T> writer;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public StaticAttributeDisplayType(@Nullable TypesBuilderData data, Reader<T> reader, Writer<T> writer) {
|
||||
super(data);
|
||||
this.reader = reader;
|
||||
this.writer = writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T read(PacketWrapper<?> wrapper) {
|
||||
return this.reader.apply(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketWrapper<?> wrapper, T display) {
|
||||
this.writer.accept(wrapper, display);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage_v1_19_1;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.CopyableEntity;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.DeepComparableEntity;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
@@ -30,14 +31,16 @@ import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.util.Index;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil.indexValueOrThrow;
|
||||
|
||||
public interface ChatType extends MappedEntity, CopyableEntity<ChatType> {
|
||||
@NullMarked
|
||||
public interface ChatType extends MappedEntity, CopyableEntity<ChatType>, DeepComparableEntity {
|
||||
|
||||
@UnknownNullability("only nullable for 1.19")
|
||||
ChatTypeDecoration getChatDecoration();
|
||||
|
||||
+13
-3
@@ -72,7 +72,12 @@ public class ChatTypeDecoration {
|
||||
wrapper.writeStyle(decoration.style);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static ChatTypeDecoration decode(NBT nbt, ClientVersion version) {
|
||||
return decode(nbt, PacketWrapper.createDummyWrapper(version));
|
||||
}
|
||||
|
||||
public static ChatTypeDecoration decode(NBT nbt, PacketWrapper<?> wrapper) {
|
||||
NBTCompound compound = (NBTCompound) nbt;
|
||||
String translationKey = compound.getStringTagValueOrThrow("translation_key");
|
||||
NBT paramsTag = compound.getTagOrThrow("parameters");
|
||||
@@ -90,11 +95,16 @@ public class ChatTypeDecoration {
|
||||
}
|
||||
NBTCompound styleTag = compound.getCompoundTagOrNull("style");
|
||||
Style style = styleTag == null ? empty() :
|
||||
AdventureSerializer.getNBTSerializer().deserializeStyle(styleTag);
|
||||
wrapper.getSerializers().nbt().deserializeStyle(styleTag, wrapper);
|
||||
return new ChatTypeDecoration(translationKey, params, style);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static NBT encode(ChatTypeDecoration decoration, ClientVersion version) {
|
||||
return encode(decoration, PacketWrapper.createDummyWrapper(version));
|
||||
}
|
||||
|
||||
public static NBT encode(ChatTypeDecoration decoration, PacketWrapper<?> wrapper) {
|
||||
NBTList<NBTString> paramsTag = NBTList.createStringList();
|
||||
for (Parameter param : decoration.parameters) {
|
||||
paramsTag.addTag(new NBTString(param.getId()));
|
||||
@@ -104,8 +114,8 @@ public class ChatTypeDecoration {
|
||||
compound.setTag("translation_key", new NBTString(decoration.translationKey));
|
||||
compound.setTag("parameters", paramsTag);
|
||||
if (!decoration.style.isEmpty()) {
|
||||
compound.setTag("style", AdventureSerializer.getNBTSerializer()
|
||||
.serializeStyle(decoration.style));
|
||||
compound.setTag("style", wrapper.getSerializers()
|
||||
.nbt().serializeStyle(decoration.style, wrapper));
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@ import static com.github.retrooper.packetevents.protocol.chat.ChatTypeDecoration
|
||||
|
||||
public final class ChatTypes {
|
||||
|
||||
private static final VersionedRegistry<ChatType> REGISTRY = new VersionedRegistry<>(
|
||||
"chat_type", "chat/chat_type_mappings");
|
||||
private static final VersionedRegistry<ChatType> REGISTRY = new VersionedRegistry<>("chat_type");
|
||||
|
||||
private ChatTypes() {
|
||||
}
|
||||
|
||||
+19
@@ -1,5 +1,6 @@
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.DataOutput;
|
||||
@@ -86,12 +87,23 @@ public class LastSeenMessages {
|
||||
}
|
||||
|
||||
public static class Update {
|
||||
|
||||
private final int offset;
|
||||
private final BitSet acknowledged;
|
||||
private final byte checksum;
|
||||
|
||||
/**
|
||||
* Checksum has been added with 1.21.5
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public Update(int offset, BitSet acknowledged) {
|
||||
this(offset, acknowledged, (byte) 0);
|
||||
}
|
||||
|
||||
public Update(int offset, BitSet acknowledged, byte checksum) {
|
||||
this.offset = offset;
|
||||
this.acknowledged = acknowledged;
|
||||
this.checksum = checksum;
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
@@ -101,5 +113,12 @@ public class LastSeenMessages {
|
||||
public BitSet getAcknowledged() {
|
||||
return acknowledged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public byte getChecksum() {
|
||||
return this.checksum;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,20 @@ import java.util.Optional;
|
||||
|
||||
public class Node {
|
||||
|
||||
public static final byte TYPE_MASK = 0b11;
|
||||
public static final byte TYPE_ROOT = 0b00;
|
||||
public static final byte TYPE_LITERAL = 0b01;
|
||||
public static final byte TYPE_ARGUMENT = 0b10;
|
||||
|
||||
public static final byte FLAG_MASK = ~TYPE_MASK;
|
||||
public static final byte FLAG_EXECUTABLE = 0b000100;
|
||||
public static final byte FLAG_REDIRECT = 0b001000;
|
||||
public static final byte FLAG_CUSTOM_SUGGESTIONS = 0b010000;
|
||||
/**
|
||||
* Added with 1.21.6
|
||||
*/
|
||||
public static final byte FLAG_RESTRICTED = 0b100000;
|
||||
|
||||
private byte flags;
|
||||
private List<Integer> children;
|
||||
private int redirectNodeIndex;
|
||||
|
||||
@@ -19,58 +19,56 @@
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.mappings.MappingHelper;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilder;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Parsers {
|
||||
@NullMarked
|
||||
public final class Parsers {
|
||||
|
||||
private static final List<Parser> ALL_PARSERS = new ArrayList<>(); // support for old methods
|
||||
private static final Map<String, Parser> PARSER_MAP = new HashMap<>();
|
||||
private static final Map<Byte, Map<Integer, Parser>> PARSER_ID_MAP = new HashMap<>();
|
||||
private static final TypesBuilder TYPES_BUILDER = new TypesBuilder("command/argument_parser_mappings");
|
||||
private static final VersionedRegistry<Parser> REGISTRY = new VersionedRegistry<>("command_argument_type");
|
||||
|
||||
private Parsers() {
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static Parser define(String key) {
|
||||
return define(key, null, null);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static Parser define(String key, @Nullable Reader reader, @Nullable Writer writer) {
|
||||
TypesBuilderData data = TYPES_BUILDER.define(key);
|
||||
Parser parser = new Parser(data, reader, writer);
|
||||
|
||||
ALL_PARSERS.add(parser);
|
||||
MappingHelper.registerMapping(TYPES_BUILDER, PARSER_MAP, PARSER_ID_MAP, parser);
|
||||
return parser;
|
||||
return REGISTRY.define(key, data -> new Parser(data, reader, writer));
|
||||
}
|
||||
|
||||
// with key
|
||||
public static Parser getByName(String name) {
|
||||
return PARSER_MAP.get(name);
|
||||
return REGISTRY.getByName(name);
|
||||
}
|
||||
|
||||
public static Parser getById(ClientVersion version, int id) {
|
||||
int index = TYPES_BUILDER.getDataIndex(version);
|
||||
Map<Integer, Parser> idMap = PARSER_ID_MAP.get((byte) index);
|
||||
return idMap.get(id);
|
||||
return REGISTRY.getById(version, id);
|
||||
}
|
||||
|
||||
public static List<Parser> getParsers() {
|
||||
return Collections.unmodifiableList(ALL_PARSERS);
|
||||
return new ArrayList<>(REGISTRY.getEntries());
|
||||
}
|
||||
|
||||
public static VersionedRegistry<Parser> getRegistry() {
|
||||
return REGISTRY;
|
||||
}
|
||||
|
||||
public static final Parser BRIGADIER_BOOL = define("brigadier:bool", null, null);
|
||||
@@ -152,8 +150,8 @@ public class Parsers {
|
||||
public static final Parser STYLE = define("style", null, null);
|
||||
public static final Parser MESSAGE = define("message", null, null);
|
||||
public static final Parser NBT_COMPOUND_TAG = define("nbt_compound_tag", null, null);
|
||||
@Deprecated
|
||||
public static final Parser NBT = NBT_COMPOUND_TAG;
|
||||
@ApiStatus.Obsolete
|
||||
public static final Parser NBT = define("nbt", null, null);
|
||||
public static final Parser NBT_TAG = define("nbt_tag", null, null);
|
||||
public static final Parser NBT_PATH = define("nbt_path", null, null);
|
||||
public static final Parser OBJECTIVE = define("objective", null, null);
|
||||
@@ -214,8 +212,25 @@ public class Parsers {
|
||||
public static final Parser LOOT_MODIFIER = define("loot_modifier", null, null);
|
||||
public static final Parser UUID = define("uuid", null, null);
|
||||
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final Parser RESOURCE_SELECTOR = define("resource_selector",
|
||||
wrapper -> Collections.singletonList(wrapper.readIdentifier()),
|
||||
(wrapper, value) -> wrapper.writeIdentifier((ResourceLocation) value.get(0))
|
||||
);
|
||||
|
||||
/**
|
||||
* Added with 1.21.6
|
||||
*/
|
||||
public static final Parser HEX_COLOR = define("hex_color", null, null);
|
||||
/**
|
||||
* Added with 1.21.6
|
||||
*/
|
||||
public static final Parser DIALOG = define("dialog", null, null);
|
||||
|
||||
static {
|
||||
TYPES_BUILDER.unloadFileMappings();
|
||||
REGISTRY.unloadMappings();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
@@ -224,9 +239,8 @@ public class Parsers {
|
||||
@FunctionalInterface
|
||||
public interface Writer extends BiConsumer<PacketWrapper<?>, List<Object>> {}
|
||||
|
||||
public static final class Parser implements MappedEntity {
|
||||
public static final class Parser extends AbstractMappedEntity {
|
||||
|
||||
private final TypesBuilderData data;
|
||||
private final Reader reader;
|
||||
private final Writer writer;
|
||||
|
||||
@@ -239,8 +253,9 @@ public class Parsers {
|
||||
);
|
||||
}
|
||||
|
||||
private Parser(TypesBuilderData data, @Nullable Reader reader, Writer writer) {
|
||||
this.data = data;
|
||||
@ApiStatus.Internal
|
||||
public Parser(@Nullable TypesBuilderData data, @Nullable Reader reader, @Nullable Writer writer) {
|
||||
super(data);
|
||||
this.reader = reader;
|
||||
this.writer = writer;
|
||||
}
|
||||
@@ -257,24 +272,5 @@ public class Parsers {
|
||||
this.writer.accept(wrapper, properties);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return this.data.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId(ClientVersion version) {
|
||||
int index = TYPES_BUILDER.getDataIndex(version);
|
||||
return this.data.getData()[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Parser) {
|
||||
return this.getName().equals(((Parser) obj).getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-6
@@ -20,11 +20,14 @@ package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.UnknownNullability;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
|
||||
private final @UnknownNullability("only nullable for 1.19") ChatTypeDecoration chatDecoration;
|
||||
@@ -39,6 +42,7 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
this(null, chatDecoration, null, narrationDecoration, null);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public StaticChatType(
|
||||
@Nullable TypesBuilderData data,
|
||||
ChatTypeDecoration chatDecoration,
|
||||
@@ -56,11 +60,12 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
this(null, chatDecoration, overlayDecoration, narrationDecoration, narrationPriority);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public StaticChatType(
|
||||
@Nullable TypesBuilderData data,
|
||||
@UnknownNullability("only nullable for 1.19") ChatTypeDecoration chatDecoration,
|
||||
@Nullable ChatTypeDecoration chatDecoration,
|
||||
@Nullable ChatTypeDecoration overlayDecoration,
|
||||
@UnknownNullability("only nullable for 1.19") ChatTypeDecoration narrationDecoration,
|
||||
@Nullable ChatTypeDecoration narrationDecoration,
|
||||
@Nullable NarrationPriority narrationPriority
|
||||
) {
|
||||
super(data);
|
||||
@@ -96,10 +101,10 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
return this.narrationPriority;
|
||||
}
|
||||
|
||||
public boolean deepEquals(Object obj) {
|
||||
@Override
|
||||
public boolean deepEquals(@Nullable Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof StaticChatType)) return false;
|
||||
if (!super.equals(obj)) return false;
|
||||
StaticChatType that = (StaticChatType) obj;
|
||||
if (!Objects.equals(this.chatDecoration, that.chatDecoration)) return false;
|
||||
if (!Objects.equals(this.overlayDecoration, that.overlayDecoration)) return false;
|
||||
@@ -107,8 +112,9 @@ public class StaticChatType extends AbstractMappedEntity implements ChatType {
|
||||
return this.narrationPriority == that.narrationPriority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deepHashCode() {
|
||||
return Objects.hash(super.hashCode(), this.chatDecoration, this.overlayDecoration, this.narrationDecoration, this.narrationPriority);
|
||||
return Objects.hash(this.chatDecoration, this.overlayDecoration, this.narrationDecoration, this.narrationPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class ChangePageClickEvent implements ClickEvent {
|
||||
|
||||
private final int page;
|
||||
|
||||
@ApiStatus.Obsolete
|
||||
public ChangePageClickEvent(String page) {
|
||||
this(Integer.parseInt(page));
|
||||
}
|
||||
|
||||
public ChangePageClickEvent(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public static ChangePageClickEvent decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
int page = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5)
|
||||
? compound.getNumberTagValueOrThrow("page").intValue()
|
||||
: Integer.parseInt(compound.getStringTagValueOrThrow("value"));
|
||||
return new ChangePageClickEvent(page);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, ChangePageClickEvent clickEvent) {
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5)) {
|
||||
compound.setTag("page", new NBTInt(clickEvent.page));
|
||||
} else {
|
||||
compound.setTag("value", new NBTString(Integer.toString(clickEvent.page)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickEventAction<?> getAction() {
|
||||
return ClickEventActions.CHANGE_PAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.kyori.adventure.text.event.ClickEvent asAdventure() {
|
||||
return net.kyori.adventure.text.event.ClickEvent.changePage(this.page);
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return this.page;
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.dialog.Dialog;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTEnd;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.adventure.NbtTagHolder;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.event.ClickEvent.Payload;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public interface ClickEvent {
|
||||
|
||||
static ClickEvent decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
String actionName = compound.getStringTagValueOrThrow("action");
|
||||
ClickEventAction<?> action = ClickEventActions.getRegistry().getByNameOrThrow(actionName);
|
||||
return action.decode(compound, wrapper);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") // not unchecked
|
||||
static void encode(NBTCompound compound, PacketWrapper<?> wrapper, ClickEvent clickEvent) {
|
||||
compound.set("action", clickEvent.getAction().getName(), ResourceLocation::encode, wrapper);
|
||||
((ClickEventAction<? super ClickEvent>) clickEvent.getAction()).encode(compound, wrapper, clickEvent);
|
||||
}
|
||||
|
||||
ClickEventAction<?> getAction();
|
||||
|
||||
static ClickEvent fromAdventure(net.kyori.adventure.text.event.ClickEvent clickEvent) {
|
||||
switch (clickEvent.action()) {
|
||||
case OPEN_URL:
|
||||
return new OpenUrlClickEvent(clickEvent.value());
|
||||
case OPEN_FILE:
|
||||
return new OpenFileClickEvent(clickEvent.value());
|
||||
case RUN_COMMAND:
|
||||
return new RunCommandClickEvent(clickEvent.value());
|
||||
case SUGGEST_COMMAND:
|
||||
return new SuggestCommandClickEvent(clickEvent.value());
|
||||
case CHANGE_PAGE:
|
||||
return new ChangePageClickEvent(clickEvent.value());
|
||||
case COPY_TO_CLIPBOARD:
|
||||
return new CopyToClipboardClickEvent(clickEvent.value());
|
||||
case SHOW_DIALOG:
|
||||
return new ShowDialogClickEvent((Dialog) ((Payload.Dialog) clickEvent.payload()).dialog());
|
||||
case CUSTOM:
|
||||
Payload.Custom payload = (Payload.Custom) clickEvent.payload();
|
||||
NbtTagHolder nbtTag = (NbtTagHolder) payload.nbt();
|
||||
return new CustomClickEvent(
|
||||
new ResourceLocation(payload.key()),
|
||||
nbtTag.getTag() instanceof NBTEnd ? null : nbtTag.getTag()
|
||||
);
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unsupported clickevent: " + clickEvent);
|
||||
}
|
||||
}
|
||||
|
||||
net.kyori.adventure.text.event.ClickEvent asAdventure();
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public interface ClickEventAction<T extends ClickEvent> extends MappedEntity {
|
||||
|
||||
boolean isAllowFromServer();
|
||||
|
||||
T decode(NBTCompound compound, PacketWrapper<?> wrapper);
|
||||
|
||||
void encode(NBTCompound compound, PacketWrapper<?> wrapper, T clickEvent);
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapDecoder;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapEncoder;
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public final class ClickEventActions {
|
||||
|
||||
private static final VersionedRegistry<ClickEventAction<?>> REGISTRY = new VersionedRegistry<>("click_event_action");
|
||||
|
||||
private ClickEventActions() {
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static <T extends ClickEvent> ClickEventAction<T> define(
|
||||
String name, boolean allowFromServer,
|
||||
NbtMapDecoder<T> decoder, NbtMapEncoder<T> encoder
|
||||
) {
|
||||
return REGISTRY.define(name, data -> new StaticClickEventAction<>(
|
||||
data, allowFromServer, decoder, encoder));
|
||||
}
|
||||
|
||||
public static VersionedRegistry<ClickEventAction<?>> getRegistry() {
|
||||
return REGISTRY;
|
||||
}
|
||||
|
||||
public static final ClickEventAction<OpenUrlClickEvent> OPEN_URL = define("open_url", true,
|
||||
OpenUrlClickEvent::decode, OpenUrlClickEvent::encode);
|
||||
public static final ClickEventAction<OpenFileClickEvent> OPEN_FILE = define("open_file", false,
|
||||
OpenFileClickEvent::decode, OpenFileClickEvent::encode);
|
||||
public static final ClickEventAction<RunCommandClickEvent> RUN_COMMAND = define("run_command", true,
|
||||
RunCommandClickEvent::decode, RunCommandClickEvent::encode);
|
||||
/**
|
||||
* Removed in 1.9
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public static final ClickEventAction<TwitchUserInfoClickEvent> TWITCH_USER_INFO = define("twitch_user_info", false,
|
||||
TwitchUserInfoClickEvent::decode, TwitchUserInfoClickEvent::encode);
|
||||
public static final ClickEventAction<SuggestCommandClickEvent> SUGGEST_COMMAND = define("suggest_command", true,
|
||||
SuggestCommandClickEvent::decode, SuggestCommandClickEvent::encode);
|
||||
|
||||
/**
|
||||
* Added with 1.8
|
||||
*/
|
||||
public static final ClickEventAction<ChangePageClickEvent> CHANGE_PAGE = define("change_page", true,
|
||||
ChangePageClickEvent::decode, ChangePageClickEvent::encode);
|
||||
|
||||
/**
|
||||
* Added with 1.15
|
||||
*/
|
||||
public static final ClickEventAction<CopyToClipboardClickEvent> COPY_TO_CLIPBOARD = define("copy_to_clipboard", true,
|
||||
CopyToClipboardClickEvent::decode, CopyToClipboardClickEvent::encode);
|
||||
|
||||
/**
|
||||
* Added with 1.21.6
|
||||
*/
|
||||
public static final ClickEventAction<ShowDialogClickEvent> SHOW_DIALOG = define("show_dialog", true,
|
||||
ShowDialogClickEvent::decode, ShowDialogClickEvent::encode);
|
||||
/**
|
||||
* Added with 1.21.6
|
||||
*/
|
||||
public static final ClickEventAction<CustomClickEvent> CUSTOM = define("custom", true,
|
||||
CustomClickEvent::decode, CustomClickEvent::encode);
|
||||
|
||||
static {
|
||||
REGISTRY.unloadMappings();
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class CopyToClipboardClickEvent implements ClickEvent {
|
||||
|
||||
private final String value;
|
||||
|
||||
public CopyToClipboardClickEvent(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static CopyToClipboardClickEvent decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
String value = compound.getStringTagValueOrThrow("value");
|
||||
return new CopyToClipboardClickEvent(value);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, CopyToClipboardClickEvent clickEvent) {
|
||||
compound.setTag("value", new NBTString(clickEvent.value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickEventAction<?> getAction() {
|
||||
return ClickEventActions.COPY_TO_CLIPBOARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.kyori.adventure.text.event.ClickEvent asAdventure() {
|
||||
return net.kyori.adventure.text.event.ClickEvent.copyToClipboard(this.value);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTEnd;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.adventure.NbtTagHolder;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public class CustomClickEvent implements ClickEvent {
|
||||
|
||||
private final ResourceLocation id;
|
||||
private final @Nullable NBT payload;
|
||||
|
||||
public CustomClickEvent(ResourceLocation id, @Nullable NBT payload) {
|
||||
this.id = id;
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public static CustomClickEvent decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
ResourceLocation id = compound.getOrThrow("id", ResourceLocation::decode, wrapper);
|
||||
NBT payload = compound.getTagOrNull("payload");
|
||||
return new CustomClickEvent(id, payload);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, CustomClickEvent clickEvent) {
|
||||
compound.set("id", clickEvent.id, ResourceLocation::encode, wrapper);
|
||||
if (clickEvent.payload != null) {
|
||||
compound.setTag("payload", clickEvent.payload);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickEventAction<?> getAction() {
|
||||
return ClickEventActions.CUSTOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.kyori.adventure.text.event.ClickEvent asAdventure() {
|
||||
return net.kyori.adventure.text.event.ClickEvent.custom(
|
||||
this.id.key(), new NbtTagHolder(this.payload != null ? this.payload : NBTEnd.INSTANCE));
|
||||
}
|
||||
|
||||
public ResourceLocation getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public @Nullable NBT getPayload() {
|
||||
return this.payload;
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class OpenFileClickEvent implements ClickEvent {
|
||||
|
||||
private final String path;
|
||||
|
||||
public OpenFileClickEvent(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public static OpenFileClickEvent decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
boolean v1215 = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5);
|
||||
String path = compound.getStringTagValueOrThrow(v1215 ? "path" : "value");
|
||||
return new OpenFileClickEvent(path);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, OpenFileClickEvent clickEvent) {
|
||||
boolean v1215 = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5);
|
||||
compound.setTag(v1215 ? "path" : "value", new NBTString(clickEvent.path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickEventAction<?> getAction() {
|
||||
return ClickEventActions.OPEN_FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.kyori.adventure.text.event.ClickEvent asAdventure() {
|
||||
return net.kyori.adventure.text.event.ClickEvent.openFile(this.path);
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class OpenUrlClickEvent implements ClickEvent {
|
||||
|
||||
private final String url;
|
||||
|
||||
public OpenUrlClickEvent(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public static OpenUrlClickEvent decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
boolean v1215 = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5);
|
||||
String url = compound.getStringTagValueOrThrow(v1215 ? "url" : "value");
|
||||
return new OpenUrlClickEvent(url);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, OpenUrlClickEvent clickEvent) {
|
||||
boolean v1215 = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5);
|
||||
compound.setTag(v1215 ? "url" : "value", new NBTString(clickEvent.url));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickEventAction<?> getAction() {
|
||||
return ClickEventActions.OPEN_URL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.kyori.adventure.text.event.ClickEvent asAdventure() {
|
||||
return net.kyori.adventure.text.event.ClickEvent.openUrl(this.url);
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class RunCommandClickEvent implements ClickEvent {
|
||||
|
||||
private final String command;
|
||||
|
||||
public RunCommandClickEvent(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public static RunCommandClickEvent decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
boolean v1215 = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5);
|
||||
String command = compound.getStringTagValueOrThrow(v1215 ? "command" : "value");
|
||||
return new RunCommandClickEvent(command);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, RunCommandClickEvent clickEvent) {
|
||||
boolean v1215 = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5);
|
||||
compound.setTag(v1215 ? "command" : "value", new NBTString(clickEvent.command));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickEventAction<?> getAction() {
|
||||
return ClickEventActions.RUN_COMMAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.kyori.adventure.text.event.ClickEvent asAdventure() {
|
||||
return net.kyori.adventure.text.event.ClickEvent.runCommand(this.command);
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return this.command;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.dialog.Dialog;
|
||||
import com.github.retrooper.packetevents.protocol.dialog.Dialogs;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntityRef;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class ShowDialogClickEvent implements ClickEvent {
|
||||
|
||||
private final MappedEntityRef<Dialog> dialog;
|
||||
|
||||
public ShowDialogClickEvent(Dialog dialog) {
|
||||
this(new MappedEntityRef.Static<>(dialog));
|
||||
}
|
||||
|
||||
public ShowDialogClickEvent(MappedEntityRef<Dialog> dialog) {
|
||||
this.dialog = dialog;
|
||||
}
|
||||
|
||||
public static ShowDialogClickEvent decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
MappedEntityRef<Dialog> dialog = MappedEntityRef.decode(compound.getTagOrThrow("dialog"),
|
||||
Dialogs.getRegistry(), Dialog::decode, wrapper);
|
||||
return new ShowDialogClickEvent(dialog);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, ShowDialogClickEvent clickEvent) {
|
||||
compound.setTag("dialog", MappedEntityRef.encode(wrapper, Dialog::encode, clickEvent.dialog));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickEventAction<?> getAction() {
|
||||
return ClickEventActions.SHOW_DIALOG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.kyori.adventure.text.event.ClickEvent asAdventure() {
|
||||
return net.kyori.adventure.text.event.ClickEvent.showDialog(this.dialog.get());
|
||||
}
|
||||
|
||||
public MappedEntityRef<Dialog> getDialogRef() {
|
||||
return this.dialog;
|
||||
}
|
||||
|
||||
public Dialog getDialog() {
|
||||
return this.dialog.get();
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapDecoder;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapEncoder;
|
||||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class StaticClickEventAction<T extends ClickEvent> extends AbstractMappedEntity implements ClickEventAction<T> {
|
||||
|
||||
private final boolean allowFromServer;
|
||||
private final NbtMapDecoder<T> decoder;
|
||||
private final NbtMapEncoder<T> encoder;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public StaticClickEventAction(
|
||||
@Nullable TypesBuilderData data, boolean allowFromServer,
|
||||
NbtMapDecoder<T> decoder, NbtMapEncoder<T> encoder
|
||||
) {
|
||||
super(data);
|
||||
this.allowFromServer = allowFromServer;
|
||||
this.decoder = decoder;
|
||||
this.encoder = encoder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowFromServer() {
|
||||
return this.allowFromServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
return this.decoder.decode(compound, wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(NBTCompound compound, PacketWrapper<?> wrapper, T clickEvent) {
|
||||
this.encoder.encode(compound, wrapper, clickEvent);
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class SuggestCommandClickEvent implements ClickEvent {
|
||||
|
||||
private final String command;
|
||||
|
||||
public SuggestCommandClickEvent(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public static SuggestCommandClickEvent decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
boolean v1215 = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5);
|
||||
String command = compound.getStringTagValueOrThrow(v1215 ? "command" : "value");
|
||||
return new SuggestCommandClickEvent(command);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, SuggestCommandClickEvent clickEvent) {
|
||||
boolean v1215 = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5);
|
||||
compound.setTag(v1215 ? "command" : "value", new NBTString(clickEvent.command));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickEventAction<?> getAction() {
|
||||
return ClickEventActions.SUGGEST_COMMAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.kyori.adventure.text.event.ClickEvent asAdventure() {
|
||||
return net.kyori.adventure.text.event.ClickEvent.suggestCommand(this.command);
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return this.command;
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Removed in 1.9
|
||||
*/
|
||||
@NullMarked
|
||||
@ApiStatus.Obsolete
|
||||
public class TwitchUserInfoClickEvent implements ClickEvent {
|
||||
|
||||
private final String value;
|
||||
|
||||
public TwitchUserInfoClickEvent(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static TwitchUserInfoClickEvent decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
String value = compound.getStringTagValueOrThrow("value");
|
||||
return new TwitchUserInfoClickEvent(value);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, TwitchUserInfoClickEvent clickEvent) {
|
||||
compound.setTag("value", new NBTString(clickEvent.value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickEventAction<?> getAction() {
|
||||
return ClickEventActions.TWITCH_USER_INFO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.kyori.adventure.text.event.ClickEvent asAdventure() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
+12
-2
@@ -19,6 +19,8 @@
|
||||
package com.github.retrooper.packetevents.protocol.chat.message;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.ChatType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class ChatMessage {
|
||||
@@ -34,14 +36,22 @@ public class ChatMessage {
|
||||
return chatContent;
|
||||
}
|
||||
|
||||
public ChatType getType() {
|
||||
return type;
|
||||
public String getChatContentJson(ClientVersion version) {
|
||||
return AdventureSerializer.serializer(version).asJson(this.getChatContent());
|
||||
}
|
||||
|
||||
public void setChatContent(Component chatContent) {
|
||||
this.chatContent = chatContent;
|
||||
}
|
||||
|
||||
public void setChatContentJson(ClientVersion version, String json) {
|
||||
this.setChatContent(AdventureSerializer.serializer(version).fromJson(json));
|
||||
}
|
||||
|
||||
public ChatType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ChatType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
-1
@@ -10,7 +10,6 @@ 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;
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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_19_3 for now, hopefully no breaking changes in the future
|
||||
public class ChatMessage_v1_21_5 extends ChatMessage_v1_19_3 {
|
||||
|
||||
int globalIndex;
|
||||
|
||||
public ChatMessage_v1_21_5(int globalIndex, UUID senderUUID, int index, byte[] signature, String plainContent,
|
||||
Instant timestamp, long salt, LastSeenMessages.Packed lastSeenMessagesPacked, @Nullable Component unsignedChatContent,
|
||||
FilterMask filterMask, ChatType.Bound chatFormatting) {
|
||||
super(senderUUID, index, signature, plainContent, timestamp, salt, lastSeenMessagesPacked, unsignedChatContent, filterMask, chatFormatting);
|
||||
this.globalIndex = globalIndex;
|
||||
}
|
||||
|
||||
public int getGlobalIndex() {
|
||||
return this.globalIndex;
|
||||
}
|
||||
|
||||
public void setGlobalIndex(int globalIndex) {
|
||||
this.globalIndex = globalIndex;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.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_21_5;
|
||||
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_21_5 implements ChatMessageProcessor {
|
||||
|
||||
@Override
|
||||
public ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper) {
|
||||
int globalIndex = wrapper.readVarInt();
|
||||
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();
|
||||
ChatType.Bound chatType = wrapper.readChatTypeBoundNetwork();
|
||||
|
||||
return new ChatMessage_v1_21_5(globalIndex, senderUUID, index, signature, plainContent, timestamp, salt, lastSeenMessagesPacked, unsignedChatContent, filterMask, chatType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data) {
|
||||
ChatMessage_v1_21_5 newData = (ChatMessage_v1_21_5) data;
|
||||
wrapper.writeVarInt(newData.getGlobalIndex());
|
||||
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.getChatFormatting());
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.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 ChatMessageProcessor_v1_7 implements ChatMessageProcessor {
|
||||
@Override
|
||||
public ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper) {
|
||||
Component chatContent = wrapper.readComponent();
|
||||
return new ChatMessageLegacy(chatContent, ChatTypes.CHAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data) {
|
||||
wrapper.writeComponent(data.getChatContent());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 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.color;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTFloat;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTList;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTNumber;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.util.MathUtil;
|
||||
import org.jetbrains.annotations.Range;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public final class AlphaColor extends Color {
|
||||
|
||||
public static final AlphaColor WHITE = new AlphaColor(0xFFFFFFFF);
|
||||
public static final AlphaColor BLACK = new AlphaColor(0xFF000000);
|
||||
public static final AlphaColor TRANSPARENT = new AlphaColor(0x00000000);
|
||||
|
||||
private final int alpha;
|
||||
|
||||
public AlphaColor(
|
||||
@Range(from = 0L, to = 255L) int red,
|
||||
@Range(from = 0L, to = 255L) int green,
|
||||
@Range(from = 0L, to = 255L) int blue
|
||||
) {
|
||||
this(255, red, green, blue);
|
||||
}
|
||||
|
||||
public AlphaColor(
|
||||
@Range(from = 0L, to = 255L) int alpha,
|
||||
@Range(from = 0L, to = 255L) int red,
|
||||
@Range(from = 0L, to = 255L) int green,
|
||||
@Range(from = 0L, to = 255L) int blue
|
||||
) {
|
||||
super(red, green, blue);
|
||||
this.alpha = MathUtil.clamp(alpha, 0, 255);
|
||||
}
|
||||
|
||||
public AlphaColor(
|
||||
@Range(from = 0L, to = 1L) float red,
|
||||
@Range(from = 0L, to = 1L) float green,
|
||||
@Range(from = 0L, to = 1L) float blue
|
||||
) {
|
||||
this(1f, red, green, blue);
|
||||
}
|
||||
|
||||
public AlphaColor(
|
||||
@Range(from = 0L, to = 1L) float alpha,
|
||||
@Range(from = 0L, to = 1L) float red,
|
||||
@Range(from = 0L, to = 1L) float green,
|
||||
@Range(from = 0L, to = 1L) float blue
|
||||
) {
|
||||
super(red, green, blue);
|
||||
this.alpha = MathUtil.floor(alpha * 255f);
|
||||
}
|
||||
|
||||
public AlphaColor(int rgb) {
|
||||
this((rgb >> 24) & BIT_MASK,
|
||||
(rgb >> 16) & BIT_MASK,
|
||||
(rgb >> 8) & BIT_MASK,
|
||||
rgb & BIT_MASK);
|
||||
}
|
||||
|
||||
public static AlphaColor decode(NBT nbt, ClientVersion version) {
|
||||
if (nbt instanceof NBTNumber) {
|
||||
return new AlphaColor(((NBTNumber) nbt).getAsInt());
|
||||
}
|
||||
NBTList<?> list = (NBTList<?>) nbt;
|
||||
float red = ((NBTNumber) list.getTag(0)).getAsFloat();
|
||||
float green = ((NBTNumber) list.getTag(1)).getAsFloat();
|
||||
float blue = ((NBTNumber) list.getTag(2)).getAsFloat();
|
||||
float alpha = ((NBTNumber) list.getTag(3)).getAsFloat();
|
||||
return new AlphaColor(alpha, red, green, blue);
|
||||
}
|
||||
|
||||
public static NBT encode(AlphaColor color, ClientVersion version) {
|
||||
if (version.isNewerThanOrEquals(ClientVersion.V_1_21_2)) {
|
||||
return new NBTInt(color.asRGB());
|
||||
}
|
||||
NBTList<NBTFloat> list = new NBTList<>(NBTType.FLOAT, 4);
|
||||
list.addTag(new NBTFloat(color.red));
|
||||
list.addTag(new NBTFloat(color.green));
|
||||
list.addTag(new NBTFloat(color.blue));
|
||||
list.addTag(new NBTFloat(color.alpha));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor withAlpha() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor withRed(@Range(from = 0L, to = 255L) int red) {
|
||||
return new AlphaColor(this.alpha, red, this.green, this.blue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor withGreen(@Range(from = 0L, to = 255L) int green) {
|
||||
return new AlphaColor(this.alpha, this.red, green, this.blue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor withBlue(@Range(from = 0L, to = 255L) int blue) {
|
||||
return new AlphaColor(this.alpha, this.red, this.green, blue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int asRGB() {
|
||||
return (this.alpha << 24) | (this.red << 16) | (this.green << 8) | this.blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor plus(Color other) {
|
||||
return new AlphaColor(
|
||||
this.alpha,
|
||||
this.red + other.red,
|
||||
this.green + other.green,
|
||||
this.blue + other.blue
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor minus(Color other) {
|
||||
return new AlphaColor(
|
||||
this.alpha,
|
||||
this.red - other.red,
|
||||
this.green - other.green,
|
||||
this.blue - other.blue
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor times(Color other) {
|
||||
if (other.alpha() == 255 && other.red == 255 && other.green == 255 && other.blue == 255) {
|
||||
return this;
|
||||
}
|
||||
return new AlphaColor(
|
||||
(this.alpha * other.alpha()) / 255,
|
||||
(this.red * other.red) / 255,
|
||||
(this.green * other.green) / 255,
|
||||
(this.blue * other.blue) / 255
|
||||
);
|
||||
}
|
||||
|
||||
public AlphaColor blendWith(AlphaColor source) {
|
||||
int srcAlpha = source.alpha;
|
||||
if (srcAlpha == 255) {
|
||||
return source;
|
||||
} else if (srcAlpha == 0) {
|
||||
return this;
|
||||
}
|
||||
int alpha = srcAlpha + (this.alpha * (255 - srcAlpha)) / 255;
|
||||
return new AlphaColor(
|
||||
alpha,
|
||||
alphaBlendChannel(alpha, srcAlpha, this.red, source.red),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.green, source.green),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.blue, source.blue)
|
||||
);
|
||||
}
|
||||
|
||||
protected static int alphaBlendChannel(int alpha, int srcAlpha, int dest, int src) {
|
||||
return (src * srcAlpha + dest * (alpha - srcAlpha)) / alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor asGrayscale() {
|
||||
int grayscale = (int) ((float) this.red * 0.30f + (float) this.green * 0.59f + (float) this.blue * 0.11f);
|
||||
return new AlphaColor(this.alpha, grayscale, grayscale, grayscale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor scale(float scale) {
|
||||
return this.scale(scale, scale, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor scale(float redScale, float greenScale, float blueScale) {
|
||||
return new AlphaColor(
|
||||
this.alpha,
|
||||
(int) ((float) this.red * redScale),
|
||||
(int) ((float) this.green * greenScale),
|
||||
(int) ((float) this.blue * blueScale)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaColor lerpSrgb(Color dest, float t) {
|
||||
return new AlphaColor(
|
||||
MathUtil.lerp(t, this.alpha, dest.alpha()),
|
||||
MathUtil.lerp(t, this.red, dest.red),
|
||||
MathUtil.lerp(t, this.green, dest.green),
|
||||
MathUtil.lerp(t, this.blue, dest.blue)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int alpha() {
|
||||
return this.alpha;
|
||||
}
|
||||
}
|
||||
@@ -18,42 +18,207 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.color;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTFloat;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTInt;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTList;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTNumber;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.util.MathUtil;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.util.RGBLike;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
public final class Color implements RGBLike {
|
||||
import java.util.Objects;
|
||||
|
||||
private static final int BIT_MASK = 0xFF;
|
||||
@NullMarked
|
||||
public class Color implements RGBLike {
|
||||
|
||||
private final int red, green, blue;
|
||||
public static final Color WHITE = new Color(0xFFFFFFFF);
|
||||
public static final Color BLACK = new Color(0xFF000000);
|
||||
|
||||
public Color(@Range(from = 0L, to = 255L) int red, @Range(from = 0L, to = 255L) int green, @Range(from = 0L, to = 255L) int blue) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
protected static final int BIT_MASK = 0xFF;
|
||||
|
||||
protected final int red, green, blue;
|
||||
|
||||
public Color(
|
||||
@Range(from = 0L, to = 255L) int red,
|
||||
@Range(from = 0L, to = 255L) int green,
|
||||
@Range(from = 0L, to = 255L) int blue
|
||||
) {
|
||||
this.red = MathUtil.clamp(red, 0, 255);
|
||||
this.green = MathUtil.clamp(green, 0, 255);
|
||||
this.blue = MathUtil.clamp(blue, 0, 255);
|
||||
}
|
||||
|
||||
public Color(
|
||||
@Range(from = 0L, to = 1L) float red,
|
||||
@Range(from = 0L, to = 1L) float green,
|
||||
@Range(from = 0L, to = 1L) float blue
|
||||
) {
|
||||
this(MathUtil.floor(red * 255f),
|
||||
MathUtil.floor(green * 255f),
|
||||
MathUtil.floor(blue * 255f));
|
||||
}
|
||||
|
||||
public Color(int rgb) {
|
||||
this((rgb >> 16) & BIT_MASK, (rgb >> 8) & BIT_MASK, rgb & BIT_MASK);
|
||||
}
|
||||
|
||||
public @NotNull Color withRed(@Range(from = 0L, to = 255L) int red) {
|
||||
public static Color read(PacketWrapper<?> wrapper) {
|
||||
return new Color(wrapper.readInt());
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, Color color) {
|
||||
wrapper.writeInt(color.asRGB());
|
||||
}
|
||||
|
||||
public static Color readShort(PacketWrapper<?> wrapper) {
|
||||
return new Color(wrapper.readUnsignedByte(), wrapper.readUnsignedByte(), wrapper.readUnsignedByte());
|
||||
}
|
||||
|
||||
public static void writeShort(PacketWrapper<?> wrapper, Color color) {
|
||||
wrapper.writeByte(color.red);
|
||||
wrapper.writeByte(color.green);
|
||||
wrapper.writeByte(color.blue);
|
||||
}
|
||||
|
||||
public static Color decode(NBT nbt, PacketWrapper<?> wrapper) {
|
||||
return decode(nbt, wrapper.getServerVersion().toClientVersion());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Color decode(NBT nbt, ClientVersion version) {
|
||||
if (nbt instanceof NBTNumber) {
|
||||
return new Color(((NBTNumber) nbt).getAsInt());
|
||||
}
|
||||
NBTList<?> list = (NBTList<?>) nbt;
|
||||
float red = ((NBTNumber) list.getTag(0)).getAsFloat();
|
||||
float green = ((NBTNumber) list.getTag(1)).getAsFloat();
|
||||
float blue = ((NBTNumber) list.getTag(2)).getAsFloat();
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public @NotNull Color withGreen(@Range(from = 0L, to = 255L) int green) {
|
||||
public static NBT encode(PacketWrapper<?> wrapper, Color color) {
|
||||
return encode(color, wrapper.getServerVersion().toClientVersion());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static NBT encode(Color color, ClientVersion version) {
|
||||
if (version.isNewerThanOrEquals(ClientVersion.V_1_21_2)) {
|
||||
return new NBTInt(color.asRGB());
|
||||
}
|
||||
NBTList<NBTFloat> list = new NBTList<>(NBTType.FLOAT, 3);
|
||||
list.addTag(new NBTFloat(color.red));
|
||||
list.addTag(new NBTFloat(color.green));
|
||||
list.addTag(new NBTFloat(color.blue));
|
||||
return list;
|
||||
}
|
||||
|
||||
public AlphaColor withAlpha() {
|
||||
return this.withAlpha(255);
|
||||
}
|
||||
|
||||
public AlphaColor withAlpha(@Range(from = 0L, to = 255L) int alpha) {
|
||||
return new AlphaColor(alpha, this.red, this.green, this.blue);
|
||||
}
|
||||
|
||||
public Color withRed(@Range(from = 0L, to = 255L) int red) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public @NotNull Color withBlue(@Range(from = 0L, to = 255L) int blue) {
|
||||
public Color withGreen(@Range(from = 0L, to = 255L) int green) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public Color withBlue(@Range(from = 0L, to = 255L) int blue) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public int asRGB() {
|
||||
int rgb = red;
|
||||
rgb = (rgb << 8) + green;
|
||||
return (rgb << 8) + blue;
|
||||
return (this.red << 16) | (this.green << 8) | this.blue;
|
||||
}
|
||||
|
||||
public Color plus(Color other) {
|
||||
return new Color(
|
||||
this.red + other.red,
|
||||
this.green + other.green,
|
||||
this.blue + other.blue
|
||||
);
|
||||
}
|
||||
|
||||
public Color minus(Color other) {
|
||||
return new Color(
|
||||
this.red - other.red,
|
||||
this.green - other.green,
|
||||
this.blue - other.blue
|
||||
);
|
||||
}
|
||||
|
||||
public Color times(Color other) {
|
||||
if (other instanceof AlphaColor) {
|
||||
return other.times(this);
|
||||
} else if (this.red == 255 && this.green == 255 && this.blue == 255) {
|
||||
return other;
|
||||
} else if (other.red == 255 && other.green == 255 && other.blue == 255) {
|
||||
return this;
|
||||
}
|
||||
return new Color(
|
||||
(this.red * other.red) / 255,
|
||||
(this.green * other.green) / 255,
|
||||
(this.blue * other.blue) / 255
|
||||
);
|
||||
}
|
||||
|
||||
public AlphaColor blendWith(AlphaColor source) {
|
||||
int srcAlpha = source.alpha();
|
||||
if (srcAlpha == 255) {
|
||||
return source;
|
||||
} else if (srcAlpha == 0) {
|
||||
return this.withAlpha();
|
||||
}
|
||||
int alpha = srcAlpha + (255 - srcAlpha);
|
||||
return new AlphaColor(
|
||||
alpha,
|
||||
alphaBlendChannel(alpha, srcAlpha, this.red, source.red),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.green, source.green),
|
||||
alphaBlendChannel(alpha, srcAlpha, this.blue, source.blue)
|
||||
);
|
||||
}
|
||||
|
||||
protected static int alphaBlendChannel(int alpha, int srcAlpha, int dest, int src) {
|
||||
return (src * srcAlpha + dest * (alpha - srcAlpha)) / alpha;
|
||||
}
|
||||
|
||||
public Color asGrayscale() {
|
||||
int grayscale = (int) ((float) this.red * 0.30f + (float) this.green * 0.59f + (float) this.blue * 0.11f);
|
||||
return new Color(grayscale, grayscale, grayscale);
|
||||
}
|
||||
|
||||
public Color scale(float scale) {
|
||||
return this.scale(scale, scale, scale);
|
||||
}
|
||||
|
||||
public Color scale(float redScale, float greenScale, float blueScale) {
|
||||
return new Color(
|
||||
(int) ((float) this.red * redScale),
|
||||
(int) ((float) this.green * greenScale),
|
||||
(int) ((float) this.blue * blueScale)
|
||||
);
|
||||
}
|
||||
|
||||
public Color lerpSrgb(Color dest, float t) {
|
||||
return new Color(
|
||||
MathUtil.lerp(t, this.red, dest.red),
|
||||
MathUtil.lerp(t, this.green, dest.green),
|
||||
MathUtil.lerp(t, this.blue, dest.blue)
|
||||
);
|
||||
}
|
||||
|
||||
public @Range(from = 0L, to = 255L) int alpha() {
|
||||
return 255;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,4 +235,17 @@ public final class Color implements RGBLike {
|
||||
public @Range(from = 0L, to = 255L) int blue() {
|
||||
return blue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Color) {
|
||||
return this.asRGB() == ((Color) obj).asRGB();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.asRGB());
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.color;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.util.RGBLike;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -54,6 +55,8 @@ public enum DyeColor implements RGBLike {
|
||||
|
||||
BLACK(new Color(0x1d1d21), new Color(0x0), new Color(0x1e1b1b), 29);
|
||||
|
||||
private static final DyeColor[] COLORS = values();
|
||||
|
||||
private final Color textureDiffuseColor;
|
||||
|
||||
private final Color textColor;
|
||||
@@ -70,6 +73,14 @@ public enum DyeColor implements RGBLike {
|
||||
this.mapColorId = mapColorId;
|
||||
}
|
||||
|
||||
public static DyeColor read(PacketWrapper<?> wrapper) {
|
||||
return wrapper.readEnum(COLORS);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, DyeColor color) {
|
||||
wrapper.writeEnum(color);
|
||||
}
|
||||
|
||||
public @NotNull Color color() {
|
||||
return this.textureDiffuseColor;
|
||||
}
|
||||
@@ -100,4 +111,4 @@ public enum DyeColor implements RGBLike {
|
||||
public int mapColorId() {
|
||||
return this.mapColorId;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -31,6 +31,10 @@ public class ComponentPredicate implements Predicate<IComponentMap> {
|
||||
|
||||
private List<ComponentValue<?>> requiredComponents;
|
||||
|
||||
public ComponentPredicate() {
|
||||
this(new ArrayList<>());
|
||||
}
|
||||
|
||||
public ComponentPredicate(List<ComponentValue<?>> requiredComponents) {
|
||||
this.requiredComponents = requiredComponents;
|
||||
}
|
||||
|
||||
+6
@@ -22,6 +22,9 @@ import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface ComponentType<T> extends MappedEntity {
|
||||
|
||||
@@ -33,6 +36,9 @@ public interface ComponentType<T> extends MappedEntity {
|
||||
|
||||
NBT encode(T value, ClientVersion version);
|
||||
|
||||
@ApiStatus.Internal
|
||||
<Z> ComponentType<Z> legacyMap(Function<T, Z> mapper, Function<Z, T> unmapper);
|
||||
|
||||
interface Decoder<T> {
|
||||
|
||||
T decode(NBT nbt, ClientVersion version);
|
||||
|
||||
+321
-12
@@ -19,6 +19,33 @@
|
||||
package com.github.retrooper.packetevents.protocol.component;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.color.DyeColor;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.AxolotlVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.CatCollarComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.CatVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.ChickenVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.CowVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.FoxVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.FrogVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.HorseVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.LlamaVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.MooshroomVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.PaintingVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.ParrotVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.PigVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.RabbitVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.SalmonSizeComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.SheepColorComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.ShulkerColorComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishBaseColorComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishPatternColorComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishPatternComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TypedBlockEntityData;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.TypedEntityData;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.VillagerVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.WolfCollarComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.WolfSoundVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.WolfVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.ZombieNautilusVariantComponent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ArmorTrim;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.BannerLayers;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.BundleContents;
|
||||
@@ -28,30 +55,58 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.DebugSt
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.FireworkExplosion;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.FoodProperties;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAdventurePredicate;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAttackRange;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAttributeModifiers;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBees;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBlockStateProperties;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBlocksAttacks;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBreakSound;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemConsumable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemContainerContents;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemContainerLoot;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemCustomModelData;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDamageResistant;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDamageType;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDeathProtection;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemDyeColor;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEnchantable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEnchantments;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEquippable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemFireworks;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemInstrument;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemJukeboxPlayable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemKineticWeapon;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemLock;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemLore;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMapDecorations;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMapPostProcessingState;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMinimumAttackCharge;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemModel;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPiercingWeapon;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPotionContents;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPotionDurationScale;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemProfile;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemProvidesBannerPatterns;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemProvidesTrimMaterial;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRarity;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRecipes;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRepairable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemSwingAnimation;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTool;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTooltipDisplay;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTooltipStyle;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUnbreakable;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUseCooldown;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUseEffects;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUseRemainder;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemWeapon;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.LodestoneTracker;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.PotDecorations;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.SuspiciousStewEffects;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.WritableBookContent;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.WrittenBookContent;
|
||||
import com.github.retrooper.packetevents.protocol.item.instrument.Instrument;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
@@ -73,8 +128,7 @@ import java.util.Collection;
|
||||
*/
|
||||
public final class ComponentTypes {
|
||||
|
||||
private static final VersionedRegistry<ComponentType<?>> REGISTRY = new VersionedRegistry<>(
|
||||
"data_component_type", "item/item_component_mappings");
|
||||
private static final VersionedRegistry<ComponentType<?>> REGISTRY = new VersionedRegistry<>("data_component_type");
|
||||
|
||||
private ComponentTypes() {
|
||||
}
|
||||
@@ -111,8 +165,14 @@ public final class ComponentTypes {
|
||||
PacketWrapper::readVarInt, PacketWrapper::writeVarInt);
|
||||
public static final ComponentType<Integer> DAMAGE = define("damage",
|
||||
PacketWrapper::readVarInt, PacketWrapper::writeVarInt);
|
||||
public static final ComponentType<Boolean> UNBREAKABLE = define("unbreakable",
|
||||
PacketWrapper::readBoolean, PacketWrapper::writeBoolean);
|
||||
public static final ComponentType<ItemUnbreakable> UNBREAKABLE_MODERN = define("unbreakable",
|
||||
ItemUnbreakable::read, ItemUnbreakable::write);
|
||||
/**
|
||||
* Changed in 1.21.5
|
||||
*/
|
||||
@Deprecated
|
||||
public static final ComponentType<Boolean> UNBREAKABLE = UNBREAKABLE_MODERN.legacyMap(
|
||||
ItemUnbreakable::isShowInTooltip, ItemUnbreakable::new);
|
||||
public static final ComponentType<Component> CUSTOM_NAME = define("custom_name",
|
||||
PacketWrapper::readComponent, PacketWrapper::writeComponent);
|
||||
public static final ComponentType<Component> ITEM_NAME = define("item_name",
|
||||
@@ -129,10 +189,24 @@ public final class ComponentTypes {
|
||||
ItemAdventurePredicate::read, ItemAdventurePredicate::write);
|
||||
public static final ComponentType<ItemAttributeModifiers> ATTRIBUTE_MODIFIERS = define("attribute_modifiers",
|
||||
ItemAttributeModifiers::read, ItemAttributeModifiers::write);
|
||||
public static final ComponentType<Integer> CUSTOM_MODEL_DATA = define("custom_model_data",
|
||||
PacketWrapper::readVarInt, PacketWrapper::writeVarInt);
|
||||
public static final ComponentType<ItemCustomModelData> CUSTOM_MODEL_DATA_LISTS = define("custom_model_data",
|
||||
ItemCustomModelData::read, ItemCustomModelData::write);
|
||||
/**
|
||||
* Rewritten in 1.21.4
|
||||
*/
|
||||
@Deprecated
|
||||
public static final ComponentType<Integer> CUSTOM_MODEL_DATA = CUSTOM_MODEL_DATA_LISTS.legacyMap(
|
||||
ItemCustomModelData::getLegacyId, ItemCustomModelData::new);
|
||||
/**
|
||||
* Removed with 1.21.5
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public static final ComponentType<Dummy> HIDE_ADDITIONAL_TOOLTIP = define("hide_additional_tooltip",
|
||||
Dummy::dummyRead, Dummy::dummyWrite);
|
||||
/**
|
||||
* Removed with 1.21.5
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public static final ComponentType<Dummy> HIDE_TOOLTIP = define("hide_tooltip",
|
||||
Dummy::dummyRead, Dummy::dummyWrite);
|
||||
public static final ComponentType<Integer> REPAIR_COST = define("repair_cost",
|
||||
@@ -145,6 +219,10 @@ public final class ComponentTypes {
|
||||
Dummy::dummyReadNbt, Dummy::dummyWriteNbt);
|
||||
public static final ComponentType<FoodProperties> FOOD = define("food",
|
||||
FoodProperties::read, FoodProperties::write);
|
||||
/**
|
||||
* Has been migrated to #DAMAGE_RESISTANT with 1.21.2.
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public static final ComponentType<Dummy> FIRE_RESISTANT = define("fire_resistant",
|
||||
Dummy::dummyRead, Dummy::dummyWrite);
|
||||
public static final ComponentType<ItemTool> TOOL = define("tool",
|
||||
@@ -177,14 +255,24 @@ public final class ComponentTypes {
|
||||
ArmorTrim::read, ArmorTrim::write);
|
||||
public static final ComponentType<DebugStickState> DEBUG_STICK_STATE = define("debug_stick_state",
|
||||
DebugStickState::read, DebugStickState::write);
|
||||
public static final ComponentType<NBTCompound> ENTITY_DATA = define("entity_data",
|
||||
PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
public static final ComponentType<TypedEntityData> TYPED_ENTITY_DATA = define("entity_data",
|
||||
TypedEntityData::read, TypedEntityData::write);
|
||||
@Deprecated
|
||||
public static final ComponentType<NBTCompound> ENTITY_DATA = TYPED_ENTITY_DATA
|
||||
.legacyMap(TypedEntityData::getCompound, TypedEntityData::new);
|
||||
public static final ComponentType<NBTCompound> BUCKET_ENTITY_DATA = define("bucket_entity_data",
|
||||
PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
public static final ComponentType<NBTCompound> BLOCK_ENTITY_DATA = define("block_entity_data",
|
||||
PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
public static final ComponentType<Instrument> INSTRUMENT = define("instrument",
|
||||
Instrument::read, Instrument::write);
|
||||
public static final ComponentType<TypedBlockEntityData> TYPED_BLOCK_ENTITY_DATA = define("block_entity_data",
|
||||
TypedBlockEntityData::read, TypedBlockEntityData::write);
|
||||
@Deprecated
|
||||
public static final ComponentType<NBTCompound> BLOCK_ENTITY_DATA = TYPED_BLOCK_ENTITY_DATA
|
||||
.legacyMap(TypedBlockEntityData::getCompound, TypedBlockEntityData::new);
|
||||
public static final ComponentType<ItemInstrument> ITEM_INSTRUMENT = define("instrument",
|
||||
ItemInstrument::read, ItemInstrument::write);
|
||||
@Deprecated
|
||||
public static final ComponentType<Instrument> INSTRUMENT = ITEM_INSTRUMENT.legacyMap(
|
||||
inst -> inst.getInstrument().getValue(),
|
||||
inst -> new ItemInstrument(new MaybeMappedEntity<>(inst)));
|
||||
public static final ComponentType<Integer> OMINOUS_BOTTLE_AMPLIFIER = define("ominous_bottle_amplifier",
|
||||
PacketWrapper::readVarInt, PacketWrapper::writeVarInt);
|
||||
public static final ComponentType<ItemRecipes> RECIPES = define("recipes",
|
||||
@@ -220,6 +308,227 @@ public final class ComponentTypes {
|
||||
public static final ComponentType<ItemJukeboxPlayable> JUKEBOX_PLAYABLE = define("jukebox_playable",
|
||||
ItemJukeboxPlayable::read, ItemJukeboxPlayable::write);
|
||||
|
||||
// added in 1.21.2
|
||||
public static final ComponentType<ItemConsumable> CONSUMABLE = define("consumable",
|
||||
ItemConsumable::read, ItemConsumable::write);
|
||||
public static final ComponentType<ItemUseRemainder> USE_REMAINDER = define("use_remainder",
|
||||
ItemUseRemainder::read, ItemUseRemainder::write);
|
||||
public static final ComponentType<ItemUseCooldown> USE_COOLDOWN = define("use_cooldown",
|
||||
ItemUseCooldown::read, ItemUseCooldown::write);
|
||||
public static final ComponentType<ItemEnchantable> ENCHANTABLE = define("enchantable",
|
||||
ItemEnchantable::read, ItemEnchantable::write);
|
||||
public static final ComponentType<ItemRepairable> REPAIRABLE = define("repairable",
|
||||
ItemRepairable::read, ItemRepairable::write);
|
||||
public static final ComponentType<ItemModel> ITEM_MODEL = define("item_model",
|
||||
ItemModel::read, ItemModel::write);
|
||||
public static final ComponentType<ItemDamageResistant> DAMAGE_RESISTANT = define("damage_resistant",
|
||||
ItemDamageResistant::read, ItemDamageResistant::write);
|
||||
public static final ComponentType<ItemEquippable> EQUIPPABLE = define("equippable",
|
||||
ItemEquippable::read, ItemEquippable::write);
|
||||
public static final ComponentType<Dummy> GLIDER = define("glider",
|
||||
Dummy::dummyRead, Dummy::dummyWrite);
|
||||
public static final ComponentType<ItemDeathProtection> DEATH_PROTECTION = define("death_protection",
|
||||
ItemDeathProtection::read, ItemDeathProtection::write);
|
||||
public static final ComponentType<ItemTooltipStyle> TOOLTIP_STYLE = define("tooltip_style",
|
||||
ItemTooltipStyle::read, ItemTooltipStyle::write);
|
||||
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<ItemTooltipDisplay> TOOLTIP_DISPLAY = define("tooltip_display",
|
||||
ItemTooltipDisplay::read, ItemTooltipDisplay::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<ItemWeapon> WEAPON = define("weapon",
|
||||
ItemWeapon::read, ItemWeapon::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<ItemBlocksAttacks> BLOCKS_ATTACKS = define("blocks_attacks",
|
||||
ItemBlocksAttacks::read, ItemBlocksAttacks::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<ItemPotionDurationScale> POTION_DURATION_SCALE = define("potion_duration_scale",
|
||||
ItemPotionDurationScale::read, ItemPotionDurationScale::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<ItemProvidesTrimMaterial> PROVIDES_TRIM_MATERIAL = define("provides_trim_material",
|
||||
ItemProvidesTrimMaterial::read, ItemProvidesTrimMaterial::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<ItemProvidesBannerPatterns> PROVIDES_BANNER_PATTERNS = define("provides_banner_patterns",
|
||||
ItemProvidesBannerPatterns::read, ItemProvidesBannerPatterns::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<ItemBreakSound> BREAK_SOUND = define("break_sound",
|
||||
ItemBreakSound::read, ItemBreakSound::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<VillagerVariantComponent> VILLAGER_VARIANT = define("villager/variant",
|
||||
VillagerVariantComponent::read, VillagerVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<WolfVariantComponent> WOLF_VARIANT = define("wolf/variant",
|
||||
WolfVariantComponent::read, WolfVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<WolfSoundVariantComponent> WOLF_SOUND_VARIANT = define("wolf/sound_variant",
|
||||
WolfSoundVariantComponent::read, WolfSoundVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<WolfCollarComponent> WOLF_COLLAR = define("wolf/collar",
|
||||
WolfCollarComponent::read, WolfCollarComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<FoxVariantComponent> FOX_VARIANT = define("fox/variant",
|
||||
FoxVariantComponent::read, FoxVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<SalmonSizeComponent> SALMON_SIZE = define("salmon/size",
|
||||
SalmonSizeComponent::read, SalmonSizeComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<ParrotVariantComponent> PARROT_VARIANT = define("parrot/variant",
|
||||
ParrotVariantComponent::read, ParrotVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<TropicalFishPatternComponent> TROPICAL_FISH_PATTERN = define("tropical_fish/pattern",
|
||||
TropicalFishPatternComponent::read, TropicalFishPatternComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<TropicalFishBaseColorComponent> TROPICAL_FISH_BASE_COLOR = define("tropical_fish/base_color",
|
||||
TropicalFishBaseColorComponent::read, TropicalFishBaseColorComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<TropicalFishPatternColorComponent> TROPICAL_FISH_PATTERN_COLOR = define("tropical_fish/pattern_color",
|
||||
TropicalFishPatternColorComponent::read, TropicalFishPatternColorComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<MooshroomVariantComponent> MOOSHROOM_VARIANT = define("mooshroom/variant",
|
||||
MooshroomVariantComponent::read, MooshroomVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<RabbitVariantComponent> RABBIT_VARIANT = define("rabbit/variant",
|
||||
RabbitVariantComponent::read, RabbitVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<PigVariantComponent> PIG_VARIANT = define("pig/variant",
|
||||
PigVariantComponent::read, PigVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<CowVariantComponent> COW_VARIANT = define("cow/variant",
|
||||
CowVariantComponent::read, CowVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<ChickenVariantComponent> CHICKEN_VARIANT = define("chicken/variant",
|
||||
ChickenVariantComponent::read, ChickenVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<FrogVariantComponent> FROG_VARIANT = define("frog/variant",
|
||||
FrogVariantComponent::read, FrogVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<HorseVariantComponent> HORSE_VARIANT = define("horse/variant",
|
||||
HorseVariantComponent::read, HorseVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<PaintingVariantComponent> PAINTING_VARIANT = define("painting/variant",
|
||||
PaintingVariantComponent::read, PaintingVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<LlamaVariantComponent> LLAMA_VARIANT = define("llama/variant",
|
||||
LlamaVariantComponent::read, LlamaVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<AxolotlVariantComponent> AXOLOTL_VARIANT = define("axolotl/variant",
|
||||
AxolotlVariantComponent::read, AxolotlVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<CatVariantComponent> CAT_VARIANT = define("cat/variant",
|
||||
CatVariantComponent::read, CatVariantComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<CatCollarComponent> CAT_COLLAR = define("cat/collar",
|
||||
CatCollarComponent::read, CatCollarComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<SheepColorComponent> SHEEP_COLOR = define("sheep/color",
|
||||
SheepColorComponent::read, SheepColorComponent::write);
|
||||
/**
|
||||
* Added with 1.21.5
|
||||
*/
|
||||
public static final ComponentType<ShulkerColorComponent> SHULKER_COLOR = define("shulker/color",
|
||||
ShulkerColorComponent::read, ShulkerColorComponent::write);
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemUseEffects> USE_EFFECTS = define("use_effects",
|
||||
ItemUseEffects::read, ItemUseEffects::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemMinimumAttackCharge> MINIMUM_ATTACK_CHARGE = define("minimum_attack_charge",
|
||||
ItemMinimumAttackCharge::read, ItemMinimumAttackCharge::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemDamageType> DAMAGE_TYPE = define("damage_type",
|
||||
ItemDamageType::read, ItemDamageType::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemAttackRange> ATTACK_RANGE = define("attack_range",
|
||||
ItemAttackRange::read, ItemAttackRange::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemPiercingWeapon> PIERCING_WEAPON = define("piercing_weapon",
|
||||
ItemPiercingWeapon::read, ItemPiercingWeapon::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemKineticWeapon> KINETIC_WEAPON = define("kinetic_weapon",
|
||||
ItemKineticWeapon::read, ItemKineticWeapon::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ItemSwingAnimation> SWING_ANIMATION = define("swing_animation",
|
||||
ItemSwingAnimation::read, ItemSwingAnimation::write);
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static final ComponentType<ZombieNautilusVariantComponent> ZOMBIE_NAUTILUS_VARIANT = define("zombie_nautilus/variant",
|
||||
ZombieNautilusVariantComponent::read, ZombieNautilusVariantComponent::write);
|
||||
|
||||
/**
|
||||
* Returns an immutable view of the component types.
|
||||
*
|
||||
|
||||
+7
-2
@@ -32,8 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public final class EnchantEffectComponentTypes {
|
||||
|
||||
private static final VersionedRegistry<ComponentType<?>> REGISTRY = new VersionedRegistry<>(
|
||||
"enchantment_effect_component_type", "enchantment/effect_component_type");
|
||||
private static final VersionedRegistry<ComponentType<?>> REGISTRY = new VersionedRegistry<>("enchantment_effect_component_type");
|
||||
|
||||
private EnchantEffectComponentTypes() {
|
||||
}
|
||||
@@ -114,6 +113,12 @@ public final class EnchantEffectComponentTypes {
|
||||
public static ComponentType<NBT> TRIDENT_SPIN_ATTACK_STRENGTH = define("trident_spin_attack_strength",
|
||||
(nbt, version) -> nbt, (val, version) -> val);
|
||||
|
||||
/**
|
||||
* @versions 1.21.11+
|
||||
*/
|
||||
public static ComponentType<NBT> POST_PIERCING_ATTACK = define("post_piercing_attack",
|
||||
(nbt, version) -> nbt, (val, version) -> val);
|
||||
|
||||
static {
|
||||
REGISTRY.unloadMappings();
|
||||
}
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.component;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public final class HashedComponentPatchMap {
|
||||
|
||||
private final Map<ComponentType<?>, Integer> addedComponents;
|
||||
private final Set<ComponentType<?>> removedComponents;
|
||||
|
||||
public HashedComponentPatchMap(Map<ComponentType<?>, Integer> addedComponents, Set<ComponentType<?>> removedComponents) {
|
||||
this.addedComponents = addedComponents;
|
||||
this.removedComponents = removedComponents;
|
||||
}
|
||||
|
||||
public static HashedComponentPatchMap read(PacketWrapper<?> wrapper) {
|
||||
Map<ComponentType<?>, Integer> addedComponents = wrapper.readMap(ew ->
|
||||
ew.readMappedEntity(ComponentTypes.getRegistry()), PacketWrapper::readInt);
|
||||
Set<ComponentType<?>> removedComponents = wrapper.readCollection(HashSet::new, ew ->
|
||||
ew.readMappedEntity(ComponentTypes.getRegistry()));
|
||||
return new HashedComponentPatchMap(addedComponents, removedComponents);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, HashedComponentPatchMap map) {
|
||||
wrapper.writeMap(map.addedComponents, PacketWrapper::writeMappedEntity, PacketWrapper::writeInt);
|
||||
wrapper.writeCollection(map.removedComponents, PacketWrapper::writeMappedEntity);
|
||||
}
|
||||
|
||||
public Map<ComponentType<?>, Integer> getAddedComponents() {
|
||||
return this.addedComponents;
|
||||
}
|
||||
|
||||
public Set<ComponentType<?>> getRemovedComponents() {
|
||||
return this.removedComponents;
|
||||
}
|
||||
}
|
||||
+13
@@ -22,14 +22,22 @@ import com.github.retrooper.packetevents.protocol.nbt.NBT;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.util.mappings.IRegistry;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@NullMarked
|
||||
public interface IComponentMap {
|
||||
|
||||
static StaticComponentMap decode(NBT nbt, PacketWrapper<?> wrapper, IRegistry<? extends ComponentType<?>> registry) {
|
||||
return decode(nbt, wrapper.getServerVersion().toClientVersion(), registry);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked") // safe in this case
|
||||
static StaticComponentMap decode(NBT nbt, ClientVersion version, IRegistry<? extends ComponentType<?>> registry) {
|
||||
NBTCompound compound = (NBTCompound) nbt;
|
||||
@@ -45,6 +53,11 @@ public interface IComponentMap {
|
||||
return components.build();
|
||||
}
|
||||
|
||||
static NBT encode(PacketWrapper<?> wrapper, StaticComponentMap components) {
|
||||
return encode(components, wrapper.getServerVersion().toClientVersion());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked") // safe in this case
|
||||
static NBT encode(StaticComponentMap components, ClientVersion version) {
|
||||
NBTCompound compound = new NBTCompound();
|
||||
|
||||
+8
-1
@@ -22,6 +22,7 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAtt
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEnchantments;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemLore;
|
||||
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRarity;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -33,6 +34,8 @@ import java.util.Optional;
|
||||
public class StaticComponentMap implements IComponentMap {
|
||||
|
||||
public static final StaticComponentMap EMPTY = new StaticComponentMap(Collections.emptyMap());
|
||||
|
||||
@ApiStatus.Obsolete
|
||||
public static final StaticComponentMap SHARED_ITEM_COMPONENTS = builder()
|
||||
.set(ComponentTypes.MAX_STACK_SIZE, 64)
|
||||
.set(ComponentTypes.LORE, ItemLore.EMPTY)
|
||||
@@ -98,7 +101,7 @@ public class StaticComponentMap implements IComponentMap {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StaticComponentMap{empty=" + this.empty + ", delegate=" + this.delegate + '}';
|
||||
return "Components" + this.delegate;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@@ -112,6 +115,10 @@ public class StaticComponentMap implements IComponentMap {
|
||||
return new StaticComponentMap(this.map);
|
||||
}
|
||||
|
||||
public Builder setAll(StaticComponentMap.Builder map) {
|
||||
return this.setAll(map.map);
|
||||
}
|
||||
|
||||
public Builder setAll(StaticComponentMap map) {
|
||||
return this.setAll(map.getDelegate());
|
||||
}
|
||||
|
||||
+15
@@ -25,8 +25,11 @@ import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper.Reader;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper.Writer;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class StaticComponentType<T> extends AbstractMappedEntity implements ComponentType<T> {
|
||||
|
||||
private final @Nullable Reader<T> reader;
|
||||
@@ -34,6 +37,7 @@ public class StaticComponentType<T> extends AbstractMappedEntity implements Comp
|
||||
private final @Nullable Decoder<T> decoder;
|
||||
private final @Nullable Encoder<T> encoder;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public StaticComponentType(
|
||||
@Nullable TypesBuilderData data,
|
||||
@Nullable Reader<T> reader,
|
||||
@@ -42,6 +46,7 @@ public class StaticComponentType<T> extends AbstractMappedEntity implements Comp
|
||||
this(data, reader, writer, null, null);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public StaticComponentType(
|
||||
@Nullable TypesBuilderData data,
|
||||
@Nullable Decoder<T> decoder,
|
||||
@@ -50,6 +55,7 @@ public class StaticComponentType<T> extends AbstractMappedEntity implements Comp
|
||||
this(data, null, null, decoder, encoder);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public StaticComponentType(
|
||||
@Nullable TypesBuilderData data,
|
||||
@Nullable Reader<T> reader,
|
||||
@@ -91,4 +97,13 @@ public class StaticComponentType<T> extends AbstractMappedEntity implements Comp
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Z> ComponentType<Z> legacyMap(Function<T, Z> mapper, Function<Z, T> unmapper) {
|
||||
Reader<Z> reader = this.reader != null ? wrapper -> mapper.apply(this.reader.apply(wrapper)) : null;
|
||||
Writer<Z> writer = this.writer != null ? (wrapper, value) -> this.writer.accept(wrapper, unmapper.apply(value)) : null;
|
||||
Decoder<Z> decoder = this.decoder != null ? (nbt, version) -> mapper.apply(this.decoder.decode(nbt, version)) : null;
|
||||
Encoder<Z> encoder = this.encoder != null ? (value, version) -> this.encoder.encode(unmapper.apply(value), version) : null;
|
||||
return new StaticComponentType<>(this.data, reader, writer, decoder, encoder);
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.axolotl.AxolotlVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.axolotl.AxolotlVariants;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class AxolotlVariantComponent {
|
||||
|
||||
private AxolotlVariant variant;
|
||||
|
||||
public AxolotlVariantComponent(AxolotlVariant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
public static AxolotlVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
AxolotlVariant type = wrapper.readMappedEntity(AxolotlVariants.getRegistry());
|
||||
return new AxolotlVariantComponent(type);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, AxolotlVariantComponent component) {
|
||||
wrapper.writeMappedEntity(component.variant);
|
||||
}
|
||||
|
||||
public AxolotlVariant getVariant() {
|
||||
return this.variant;
|
||||
}
|
||||
|
||||
public void setVariant(AxolotlVariant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof AxolotlVariantComponent)) return false;
|
||||
AxolotlVariantComponent that = (AxolotlVariantComponent) obj;
|
||||
return this.variant.equals(that.variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.variant);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.color.DyeColor;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CatCollarComponent {
|
||||
|
||||
private DyeColor color;
|
||||
|
||||
public CatCollarComponent(DyeColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public static CatCollarComponent read(PacketWrapper<?> wrapper) {
|
||||
DyeColor type = DyeColor.read(wrapper);
|
||||
return new CatCollarComponent(type);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, CatCollarComponent component) {
|
||||
DyeColor.write(wrapper, component.color);
|
||||
}
|
||||
|
||||
public DyeColor getDyeColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public void setDyeColor(DyeColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof CatCollarComponent)) return false;
|
||||
CatCollarComponent that = (CatCollarComponent) obj;
|
||||
return this.color.equals(that.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.color);
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.cat.CatVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.cat.CatVariants;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CatVariantComponent {
|
||||
|
||||
private CatVariant variant;
|
||||
|
||||
public CatVariantComponent(CatVariant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
public static CatVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
CatVariant type = wrapper.readMappedEntity(CatVariants.getRegistry());
|
||||
return new CatVariantComponent(type);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, CatVariantComponent component) {
|
||||
wrapper.writeMappedEntity(component.variant);
|
||||
}
|
||||
|
||||
public CatVariant getVariant() {
|
||||
return this.variant;
|
||||
}
|
||||
|
||||
public void setVariant(CatVariant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof CatVariantComponent)) return false;
|
||||
CatVariantComponent that = (CatVariantComponent) obj;
|
||||
return this.variant.equals(that.variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.variant);
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.chicken.ChickenVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.chicken.ChickenVariants;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ChickenVariantComponent {
|
||||
|
||||
private MaybeMappedEntity<ChickenVariant> variant;
|
||||
|
||||
public ChickenVariantComponent(MaybeMappedEntity<ChickenVariant> variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
public static ChickenVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
MaybeMappedEntity<ChickenVariant> variant = MaybeMappedEntity.read(wrapper,
|
||||
ChickenVariants.getRegistry(), ChickenVariant::read);
|
||||
return new ChickenVariantComponent(variant);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ChickenVariantComponent component) {
|
||||
MaybeMappedEntity.write(wrapper, component.variant, ChickenVariant::write);
|
||||
}
|
||||
|
||||
public MaybeMappedEntity<ChickenVariant> getVariant() {
|
||||
return this.variant;
|
||||
}
|
||||
|
||||
public void setVariant(MaybeMappedEntity<ChickenVariant> variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ChickenVariantComponent)) return false;
|
||||
ChickenVariantComponent that = (ChickenVariantComponent) obj;
|
||||
return this.variant.equals(that.variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.variant);
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.cow.CowVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.cow.CowVariants;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CowVariantComponent {
|
||||
|
||||
private CowVariant variant;
|
||||
|
||||
public CowVariantComponent(CowVariant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
public static CowVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
CowVariant type = wrapper.readMappedEntity(CowVariants.getRegistry());
|
||||
return new CowVariantComponent(type);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, CowVariantComponent component) {
|
||||
wrapper.writeMappedEntity(component.variant);
|
||||
}
|
||||
|
||||
public CowVariant getVariant() {
|
||||
return this.variant;
|
||||
}
|
||||
|
||||
public void setVariant(CowVariant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof CowVariantComponent)) return false;
|
||||
CowVariantComponent that = (CowVariantComponent) obj;
|
||||
return this.variant.equals(that.variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.variant);
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.fox.FoxVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.fox.FoxVariants;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class FoxVariantComponent {
|
||||
|
||||
private FoxVariant variant;
|
||||
|
||||
public FoxVariantComponent(FoxVariant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
public static FoxVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
FoxVariant type = wrapper.readMappedEntity(FoxVariants.getRegistry());
|
||||
return new FoxVariantComponent(type);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, FoxVariantComponent component) {
|
||||
wrapper.writeMappedEntity(component.variant);
|
||||
}
|
||||
|
||||
public FoxVariant getVariant() {
|
||||
return this.variant;
|
||||
}
|
||||
|
||||
public void setVariant(FoxVariant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof FoxVariantComponent)) return false;
|
||||
FoxVariantComponent that = (FoxVariantComponent) obj;
|
||||
return this.variant.equals(that.variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.variant);
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 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.component.builtin;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.frog.FrogVariant;
|
||||
import com.github.retrooper.packetevents.protocol.entity.frog.FrogVariants;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class FrogVariantComponent {
|
||||
|
||||
private FrogVariant variant;
|
||||
|
||||
public FrogVariantComponent(FrogVariant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
public static FrogVariantComponent read(PacketWrapper<?> wrapper) {
|
||||
FrogVariant variant = wrapper.readMappedEntity(FrogVariants.getRegistry());
|
||||
return new FrogVariantComponent(variant);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, FrogVariantComponent component) {
|
||||
wrapper.writeMappedEntity(component.variant);
|
||||
}
|
||||
|
||||
public FrogVariant getVariant() {
|
||||
return this.variant;
|
||||
}
|
||||
|
||||
public void setVariant(FrogVariant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof FrogVariantComponent)) return false;
|
||||
FrogVariantComponent that = (FrogVariantComponent) obj;
|
||||
return this.variant.equals(that.variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.variant);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 956 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user