Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
113bf1e275 | ||
|
|
2aec3ce6d1 | ||
|
|
f60e31ac78 | ||
|
|
8c4ff7ebfc | ||
|
|
4c7729e602 | ||
|
|
3dfc3bb15b | ||
|
|
69b33dc2d2 | ||
|
|
c24169c410 | ||
|
|
31211c2214 | ||
|
|
cb5fc9fb08 | ||
|
|
a8d7ab62e3 | ||
|
|
71313b4753 | ||
|
|
994bc8eefc | ||
|
|
7d35826637 | ||
|
|
4f40372392 | ||
|
|
e993be751c | ||
|
|
f1b92fea8d | ||
|
|
fc9d5b6d9d | ||
|
|
9549a18cec | ||
|
|
d691096ce1 | ||
|
|
73ed425bf7 | ||
|
|
cdc9c3ae95 | ||
|
|
c113e19d41 | ||
|
|
d3af70d76c | ||
|
|
c00bc6b667 | ||
|
|
fa3c933b2f | ||
|
|
07bb0269c3 | ||
|
|
57c0d83608 | ||
|
|
4854b131b8 | ||
|
|
1864b66e42 | ||
|
|
8aa6769193 | ||
|
|
5f90bcbbaf | ||
|
|
d068822143 | ||
|
|
a77e328dfe | ||
|
|
9c84e0dbe9 | ||
|
|
66e0453398 | ||
|
|
7ec6888a30 | ||
|
|
c9733948b3 | ||
|
|
798b70cbe6 | ||
|
|
1f43ff571d | ||
|
|
d28e7cd652 | ||
|
|
f20d99fcef | ||
|
|
a1c182f291 | ||
|
|
8e63fd635b | ||
|
|
676e62c71f | ||
|
|
f422e03348 | ||
|
|
fdf735420f | ||
|
|
b13fbbe175 | ||
|
|
9dd3348510 | ||
|
|
0e97af29b4 | ||
|
|
3dfcd6b9b9 | ||
|
|
8df0c0ae2e | ||
|
|
d2ca6a82be | ||
|
|
9654a613cd | ||
|
|
c5e6fa7d0c | ||
|
|
b78f9d350b | ||
|
|
ebbe1b6da2 | ||
|
|
3aed7cb949 | ||
|
|
e2f3dc7572 | ||
|
|
f2b9c42590 | ||
|
|
9894671274 | ||
|
|
71ab15b331 | ||
|
|
34bc5b9d36 | ||
|
|
d80fd46c2f | ||
|
|
b47446d9f7 | ||
|
|
dcf741a2ba | ||
|
|
a4adef3cec | ||
|
|
f525ad98e7 | ||
|
|
bc0b4470f6 | ||
|
|
d3d6d4f1cd | ||
|
|
5069b26c2f | ||
|
|
079671060c | ||
|
|
89cd8aec1d | ||
|
|
7ac7ea485f | ||
|
|
5e4f25efeb | ||
|
|
a152993ffd | ||
|
|
73daac471c | ||
|
|
f4e9225f85 | ||
|
|
1ed22327f6 | ||
|
|
ce2ad7d5eb | ||
|
|
d7e66260de | ||
|
|
dc6d581123 | ||
|
|
bd3f1206e6 | ||
|
|
b9e92e5c1f | ||
|
|
0acaed7c7a | ||
|
|
3055a4277d | ||
|
|
bcbe69d24c | ||
|
|
33cc21d6e6 | ||
|
|
949b3d712e | ||
|
|
216dcb2931 | ||
|
|
bff1536529 | ||
|
|
b221e47eb7 | ||
|
|
fb434a79bd | ||
|
|
1be0605f51 | ||
|
|
c75b4d8ef5 | ||
|
|
e08c263ced | ||
|
|
1bb85b11e9 | ||
|
|
128e191132 | ||
|
|
3520f99d5a | ||
|
|
7825a1e460 | ||
|
|
bfde4b953c | ||
|
|
57b37457d6 | ||
|
|
f7aa1a516e | ||
|
|
b1468ac6d0 | ||
|
|
27b5fdb4ff | ||
|
|
a99273db2e | ||
|
|
64f911ed4a | ||
|
|
4302dd61aa | ||
|
|
98c5d38d0c | ||
|
|
033d5ae49a | ||
|
|
8cf9114403 | ||
|
|
bd8e469216 | ||
|
|
57d7fd59cc | ||
|
|
8fe0681778 | ||
|
|
ea5cf3e594 | ||
|
|
13eec3c2ea | ||
|
|
31ccd2ab9b | ||
|
|
2be190d152 | ||
|
|
4e25549682 | ||
|
|
287678c12a | ||
|
|
4343aa17fc | ||
|
|
970986bc59 | ||
|
|
2586788bf6 | ||
|
|
0c2c8400ae | ||
|
|
ba4404fad6 | ||
|
|
6f53c069ea | ||
|
|
99f29e2597 | ||
|
|
7932b79080 | ||
|
|
4b780b92ee | ||
|
|
d04aaeb926 | ||
|
|
9f1ee27afc | ||
|
|
5f685884ff | ||
|
|
ba2e50cc88 | ||
|
|
7b28683b6a | ||
|
|
510747a7cd | ||
|
|
8c5752bb4c | ||
|
|
33e2a1fc13 | ||
|
|
dbe8a389ce | ||
|
|
83223c1520 | ||
|
|
935077222e | ||
|
|
8961660846 | ||
|
|
1fe23e4aeb | ||
|
|
06394c1f74 | ||
|
|
68c2af2795 | ||
|
|
35a00d0b95 | ||
|
|
c2489c7a4c | ||
|
|
c743c20334 | ||
|
|
228689f181 | ||
|
|
67e6e1a2e3 | ||
|
|
a2c1c52f51 | ||
|
|
fd4db24d44 | ||
|
|
0b7fdd4c69 | ||
|
|
4849ca0745 | ||
|
|
60b782455d | ||
|
|
3fef71db2e | ||
|
|
9ca02680c8 | ||
|
|
5899886b42 | ||
|
|
c2567115d8 | ||
|
|
4255876c22 | ||
|
|
57a589924d | ||
|
|
936dcafc11 | ||
|
|
b6489b8343 | ||
|
|
bf11a0a7de | ||
|
|
7d41706026 | ||
|
|
93f081dd84 | ||
|
|
3f82b150d2 | ||
|
|
7a96498f6d | ||
|
|
817febe605 | ||
|
|
bb4a8b73e0 | ||
|
|
8d3492ba30 | ||
|
|
658364b643 | ||
|
|
666b204ebb | ||
|
|
bfab9b0c11 | ||
|
|
121f107ff3 | ||
|
|
426bd9aa99 | ||
|
|
7a66bb8e1c | ||
|
|
329abcac7d | ||
|
|
0961de898d | ||
|
|
b4ee564aa2 | ||
|
|
73178b504e | ||
|
|
d0cc531386 | ||
|
|
617ef10667 | ||
|
|
5569caf610 | ||
|
|
868a5bd24e | ||
|
|
b113a82710 | ||
|
|
3ee4c8ed63 | ||
|
|
cd65925d6b | ||
|
|
307414eb51 | ||
|
|
51745cb2ef | ||
|
|
f44782d21d | ||
|
|
7556f7b8fa | ||
|
|
abd58399cd | ||
|
|
0a2fd8f296 | ||
|
|
f2c816df72 | ||
|
|
098f7ff3c2 | ||
|
|
18f04bf8ea | ||
|
|
feefe6f278 | ||
|
|
4074231a57 | ||
|
|
13efe47a5c | ||
|
|
b07cf03dc1 | ||
|
|
0a921d9bdc | ||
|
|
7b0c2fb51a | ||
|
|
b426302e76 | ||
|
|
3442cda8ce | ||
|
|
55a0a70264 | ||
|
|
a9bfda4568 | ||
|
|
93990c8baa | ||
|
|
f868dfa125 | ||
|
|
386495e168 | ||
|
|
cad78ea68f | ||
|
|
908823c612 | ||
|
|
f6d48e258f | ||
|
|
1f5ee6d763 | ||
|
|
8edad67394 | ||
|
|
2d03110f08 | ||
|
|
92878a39ef | ||
|
|
aa0423c6e2 | ||
|
|
04e572fa30 | ||
|
|
39180e22b8 | ||
|
|
f68aed464d | ||
|
|
6ffa24b50b | ||
|
|
e51d7b3fdb | ||
|
|
01bb8dedda | ||
|
|
6cdca97d35 | ||
|
|
dafce79374 | ||
|
|
4cf271af81 | ||
|
|
aa262bb0a5 | ||
|
|
2480eb6a7f | ||
|
|
56b82b049a | ||
|
|
3c0930c62f | ||
|
|
26a8e5fef1 | ||
|
|
caa6519780 | ||
|
|
1e35c2713f | ||
|
|
cd5d88c34f | ||
|
|
7640342165 | ||
|
|
fe0d30df78 | ||
|
|
4e1d4a75b2 | ||
|
|
343b403cf1 | ||
|
|
78aecbddf8 | ||
|
|
48241ba841 | ||
|
|
a8fbb000eb | ||
|
|
ff25cbd6eb | ||
|
|
e2a7e10312 | ||
|
|
c7baa27fd0 | ||
|
|
35578372a1 | ||
|
|
293427c172 | ||
|
|
08d8ccf6ca | ||
|
|
35ceee1a47 | ||
|
|
dccda57fc0 | ||
|
|
5c21f60ef7 | ||
|
|
c124c1c809 | ||
|
|
302716054d | ||
|
|
46a5bb16d7 | ||
|
|
f3f7ea7987 | ||
|
|
e62c4a3f9e | ||
|
|
d58c80cd2f | ||
|
|
7a6c51331b | ||
|
|
564286d742 | ||
|
|
dcc0642af9 | ||
|
|
e449599ae7 | ||
|
|
621c02f974 | ||
|
|
22bd350e35 | ||
|
|
a8dc5f0f07 | ||
|
|
d76edced04 | ||
|
|
cfc048ba53 | ||
|
|
c7265abfe9 | ||
|
|
8a485db580 | ||
|
|
e0f32d9f2f | ||
|
|
ad62d8552c | ||
|
|
4a8bd2cca2 | ||
|
|
0fcb764652 | ||
|
|
46e322b2f3 | ||
|
|
87d444a017 | ||
|
|
e020c616c9 | ||
|
|
da87241549 | ||
|
|
0d788b0d7a | ||
|
|
1c6f8426f1 | ||
|
|
01f28a052c | ||
|
|
cfc9011cee | ||
|
|
6473b608f6 | ||
|
|
a5bd8abe93 | ||
|
|
f3d95b1e5e | ||
|
|
c8d339ab30 | ||
|
|
8000561ae9 | ||
|
|
1dafa7d273 | ||
|
|
ce8fab7c44 | ||
|
|
37561705ed | ||
|
|
00176c4a0c | ||
|
|
cef6fb35b1 | ||
|
|
7b8a33cc78 | ||
|
|
ceae2c2094 | ||
|
|
52b9db5029 | ||
|
|
27af372f79 | ||
|
|
c4e50efa90 | ||
|
|
fa1ae5b9c9 | ||
|
|
8f6784e0e2 | ||
|
|
5d5c98acc6 | ||
|
|
5b29ac0d8a | ||
|
|
3b9d399afd | ||
|
|
0946c72bdc | ||
|
|
05470c5f1b | ||
|
|
0392992173 | ||
|
|
34bd15dec7 | ||
|
|
ef78fcd478 | ||
|
|
9d646543b6 | ||
|
|
aecef3c3f8 | ||
|
|
5991ac5633 | ||
|
|
930454a723 | ||
|
|
b6ba7dcc44 | ||
|
|
abb05ce902 | ||
|
|
a561bad004 | ||
|
|
bd2c4c8a16 | ||
|
|
f6c49555bf | ||
|
|
bd99b892db | ||
|
|
7b4d544e85 | ||
|
|
fe0fbc7081 | ||
|
|
bae3d8ec8a | ||
|
|
00b8d22cf6 | ||
|
|
d62284e9cd | ||
|
|
3904ed4fd7 | ||
|
|
28a0813676 | ||
|
|
ca4b6fc765 | ||
|
|
f2f357b2ae | ||
|
|
dc2986600c | ||
|
|
984c625776 | ||
|
|
c62a8274ed | ||
|
|
64c436c2e1 | ||
|
|
0e31664bfe | ||
|
|
18f2cf25cd | ||
|
|
84b093a997 | ||
|
|
794f401bd0 | ||
|
|
dc732fac6f | ||
|
|
2f8114abb1 | ||
|
|
90781c9d27 | ||
|
|
9b1716b662 | ||
|
|
dcd4502f5a | ||
|
|
5d4b104b33 | ||
|
|
8e38e25cba | ||
|
|
82e05afacf | ||
|
|
5c8c589a40 | ||
|
|
70645ec5ee | ||
|
|
4aefc23bb8 | ||
|
|
2c9affa0e3 | ||
|
|
1656ad45a0 | ||
|
|
ec2397472d | ||
|
|
cf5f5ed4bb | ||
|
|
9387b86e4a | ||
|
|
e3224281a9 | ||
|
|
f762da2725 | ||
|
|
9a7def62b9 | ||
|
|
ec27cc7a7b | ||
|
|
3b9ac89d73 | ||
|
|
23ba848a69 | ||
|
|
d98c458a4c | ||
|
|
1ad65d1bb0 | ||
|
|
d44d89099b | ||
|
|
d5326fad95 | ||
|
|
7de9bc604a | ||
|
|
dfee03ddbf | ||
|
|
3babc7a13a | ||
|
|
0b1423d8b4 | ||
|
|
6efeb16822 | ||
|
|
9b09b1f5f8 | ||
|
|
851295d48c | ||
|
|
1f453dc0d9 | ||
|
|
916c08ce7e | ||
|
|
0ac29fb2c2 | ||
|
|
45d08e9066 | ||
|
|
bc0bef2e07 | ||
|
|
6d82839e6d | ||
|
|
c039f4e24c | ||
|
|
4add75cda7 | ||
|
|
28f661f270 | ||
|
|
42f38c3209 | ||
|
|
151ecdcd72 | ||
|
|
a0f8ab7bbb | ||
|
|
1af2103f6c | ||
|
|
8769742917 | ||
|
|
20f4907a23 | ||
|
|
6fb27e5c17 | ||
|
|
07b173bb74 | ||
|
|
dbf4271c9d | ||
|
|
a2d287ff9f | ||
|
|
58ca2024e1 | ||
|
|
2881fb18e0 | ||
|
|
ffdddeeb0a | ||
|
|
e356a35aa7 | ||
|
|
0474810b8d | ||
|
|
ea818b272e | ||
|
|
9342b19aad | ||
|
|
2968047571 | ||
|
|
dccac81286 | ||
|
|
bc67e8d952 | ||
|
|
f9ab1bd811 | ||
|
|
8776e8bdc0 | ||
|
|
ba882f8f98 | ||
|
|
a022620712 | ||
|
|
f618cdec99 | ||
|
|
ec2093cf5d | ||
|
|
eb9bc2fdce | ||
|
|
f35b4f1fac | ||
|
|
abe880dae6 | ||
|
|
0f030c86a7 | ||
|
|
2c6e18e4fe | ||
|
|
78c7f03923 | ||
|
|
68a32ed2f0 | ||
|
|
7cf008bb62 | ||
|
|
a60342359b | ||
|
|
0e269fa493 | ||
|
|
815e0820da | ||
|
|
faedf26b5b | ||
|
|
c7c38e70c0 | ||
|
|
21d293dd7f | ||
|
|
6481cec270 | ||
|
|
54c04a62e0 | ||
|
|
7edde72416 | ||
|
|
84a054aac1 | ||
|
|
8ebc8c34f3 | ||
|
|
50e55529d9 | ||
|
|
553dd2cb45 | ||
|
|
a30d62a995 | ||
|
|
08f6b3ce36 | ||
|
|
7d1b0d83ce | ||
|
|
e7d0b01eee | ||
|
|
fdfc528a9a | ||
|
|
dccb6f234b | ||
|
|
6e7f936e83 | ||
|
|
ec26bafd53 | ||
|
|
d7d7940d0b | ||
|
|
667278f9e6 | ||
|
|
fa7096c5c1 | ||
|
|
958064b44c | ||
|
|
26dad99265 | ||
|
|
d8007dc73c | ||
|
|
5850a9852d | ||
|
|
095fe16447 | ||
|
|
cbf8b8f401 | ||
|
|
d600b0cbe1 | ||
|
|
0d70cdbe15 | ||
|
|
b1b0874c0f | ||
|
|
67ba0e9566 | ||
|
|
bebdc34b4b | ||
|
|
3e0eb90662 | ||
|
|
d8f98945e2 | ||
|
|
0c3d709456 | ||
|
|
868c5ba203 | ||
|
|
0953ff77e4 | ||
|
|
c211b10eaa | ||
|
|
def3bf9d4a | ||
|
|
cb1b33b3e7 | ||
|
|
a8acae2d5f | ||
|
|
fdb7f47749 | ||
|
|
cabb95a3a4 | ||
|
|
0b93af88a3 | ||
|
|
11cb113619 | ||
|
|
429e4f0bff | ||
|
|
3b0d1d961a | ||
|
|
b4720c723a | ||
|
|
215cbc6310 | ||
|
|
f07ba9b527 | ||
|
|
5a20030ff3 | ||
|
|
1b350c0c53 | ||
|
|
87db6fc75a | ||
|
|
840770a350 | ||
|
|
3997ea70f7 | ||
|
|
854696abff | ||
|
|
d92b9fdeaa | ||
|
|
270d28f259 | ||
|
|
ed1852ba40 | ||
|
|
f91e6a83f9 | ||
|
|
8a0e187621 | ||
|
|
0e8b5e8e98 | ||
|
|
e30dd63b3c | ||
|
|
489b28e520 | ||
|
|
d23e743550 | ||
|
|
16f89f2638 | ||
|
|
fe5646a68c | ||
|
|
53aca791dd | ||
|
|
1f0a4c26db | ||
|
|
4c34ced240 | ||
|
|
18c4f90cb0 | ||
|
|
9c90445c9c | ||
|
|
494e6ffc05 | ||
|
|
a196dbc16b | ||
|
|
8934bbdfc3 | ||
|
|
8316c59010 | ||
|
|
5ea1c1ec95 | ||
|
|
cc7c571a3c | ||
|
|
06b4678b2d | ||
|
|
a109118a97 | ||
|
|
a135a1414c | ||
|
|
f50751ed48 | ||
|
|
4b7998b4ea | ||
|
|
6db1a2a614 | ||
|
|
625373827c | ||
|
|
a9288ebd3a | ||
|
|
01bbb2c1c2 | ||
|
|
8dbc8e8eba | ||
|
|
0c9f3aa080 | ||
|
|
00625be890 | ||
|
|
e112f81ec8 | ||
|
|
23f776a6ee | ||
|
|
0050872950 | ||
|
|
7e53f55509 | ||
|
|
1bf7962dc3 | ||
|
|
50176dc317 | ||
|
|
9ed074d0d5 | ||
|
|
8bad8a10be | ||
|
|
34509e86c0 | ||
|
|
ef75bd567d | ||
|
|
7ed3e50e93 | ||
|
|
a45eceaf1d | ||
|
|
573cdfb3ac | ||
|
|
28787340d1 | ||
|
|
c358245c0b | ||
|
|
cb073405b7 | ||
|
|
f618f6a7d6 | ||
|
|
c5e066e050 | ||
|
|
d954e1745d | ||
|
|
9c92ccea77 | ||
|
|
2b9e0cec5c | ||
|
|
c1cd8bc03e | ||
|
|
39efc5262e | ||
|
|
6e5e115c3b | ||
|
|
fbcbd33c66 | ||
|
|
7bea3142bc | ||
|
|
fb472c3454 | ||
|
|
ac10bb3fd0 | ||
|
|
1bc3d407d1 | ||
|
|
62c0ef360f | ||
|
|
8c6d104faa | ||
|
|
f6b8c4a8c8 | ||
|
|
6586fc1436 | ||
|
|
6dfd4747ee | ||
|
|
6377721ebd | ||
|
|
2ec6185c46 | ||
|
|
b22907748a | ||
|
|
1aee8a7a6c | ||
|
|
7edb43844c | ||
|
|
f28aac5eb3 | ||
|
|
4971eeab6a | ||
|
|
0bb940e42d | ||
|
|
e32933ada9 | ||
|
|
a817746edc | ||
|
|
408392e796 | ||
|
|
20a4ae3e4b | ||
|
|
08b2d78165 | ||
|
|
17eb7b676a | ||
|
|
9a1598b9ed | ||
|
|
9e7cd151bc | ||
|
|
2a14f9a0cd | ||
|
|
bf825d5ef6 | ||
|
|
28ba4afc27 | ||
|
|
7f347231bb | ||
|
|
f1b5f9223a | ||
|
|
e4a1530aa8 | ||
|
|
09b67fad63 | ||
|
|
1b3c5b4032 | ||
|
|
b7d8a3c8d5 | ||
|
|
9a515df0f3 | ||
|
|
c6103f2f51 | ||
|
|
5c0eda76e8 | ||
|
|
544a28b06b | ||
|
|
5c145d0184 | ||
|
|
ed55bccfe4 | ||
|
|
5acc2fefbc | ||
|
|
7f748b5c68 | ||
|
|
0ec03f8b09 | ||
|
|
a70034e0b5 | ||
|
|
98a0fdca94 | ||
|
|
82961cc153 | ||
|
|
6c0d891c9f | ||
|
|
6fa387e6ab | ||
|
|
07bdb57694 | ||
|
|
75dd79347a | ||
|
|
9257890d3c | ||
|
|
891f55192d | ||
|
|
7adadc0d21 | ||
|
|
638378cddf | ||
|
|
56d772df34 | ||
|
|
7bb5cf3ae9 | ||
|
|
b67e3c30fd | ||
|
|
a2e214ae18 | ||
|
|
54d8e29a7e | ||
|
|
a2daa9c989 | ||
|
|
74cc42fecf | ||
|
|
dd59ddbd4f | ||
|
|
bcfc77aa7d | ||
|
|
1a46346789 | ||
|
|
394be165fd | ||
|
|
20d86374b5 | ||
|
|
8864b161f9 | ||
|
|
7b0160d6c3 | ||
|
|
7e5173982d | ||
|
|
ee75f19790 | ||
|
|
e54f6d1999 | ||
|
|
c46bb5bcf5 | ||
|
|
d08f15c095 | ||
|
|
8aa7898755 | ||
|
|
9682b68251 | ||
|
|
364cfad9d8 | ||
|
|
641171a14f | ||
|
|
23f045feee | ||
|
|
f1bde8ba2a | ||
|
|
9ccc3aed30 | ||
|
|
ad56caeb88 | ||
|
|
573201c0b1 | ||
|
|
e298a7efac | ||
|
|
2e59a51734 | ||
|
|
d4894ca4b5 | ||
|
|
7f7c6241de | ||
|
|
51606eb5ef | ||
|
|
c9883c2638 | ||
|
|
74fb55d96b | ||
|
|
4e844a0095 | ||
|
|
da7f8ea3b6 | ||
|
|
81c4e530e9 | ||
|
|
b1524642aa | ||
|
|
a828c43f99 | ||
|
|
fccfadf1b7 | ||
|
|
18b41c82c4 | ||
|
|
27ee6f519e | ||
|
|
7aa0aed5ec | ||
|
|
10c4d9408e | ||
|
|
e8b4496289 | ||
|
|
10737f17e2 | ||
|
|
7c9c602cec | ||
|
|
2ee2819759 | ||
|
|
72197ddca8 | ||
|
|
9781b7962f | ||
|
|
d180c8fe2f | ||
|
|
d8a9480bf1 | ||
|
|
a3efb676cf | ||
|
|
68d1843496 | ||
|
|
3ced95903a | ||
|
|
b3825e637e | ||
|
|
c765f20558 | ||
|
|
b5259beef7 | ||
|
|
712bbcdc02 | ||
|
|
b94c71b699 | ||
|
|
51d4e11b5f | ||
|
|
d94ed4ebd4 | ||
|
|
9ce3d8e567 | ||
|
|
9fd0d3e565 | ||
|
|
7b91c25379 | ||
|
|
7161377794 | ||
|
|
8f97f43f12 | ||
|
|
57f0d58d58 | ||
|
|
b45be1944e | ||
|
|
c4019fadd8 | ||
|
|
5cad29c754 | ||
|
|
a6e1cb6534 | ||
|
|
26615a11d3 | ||
|
|
3e2ee37829 | ||
|
|
35263e36ff | ||
|
|
bf4e4d771f | ||
|
|
1157029f23 | ||
|
|
7b5cb92982 | ||
|
|
d74f91d606 | ||
|
|
1376312449 | ||
|
|
1faf1f3f49 | ||
|
|
fb0381e76a | ||
|
|
45fcc9ef7d | ||
|
|
f5ddc6550d | ||
|
|
cb2165eb93 | ||
|
|
de5b7bf828 | ||
|
|
98c645f7ed | ||
|
|
b03765a828 | ||
|
|
088f654159 | ||
|
|
1a5f83619d | ||
|
|
734bc9e88c | ||
|
|
93654b8eaf | ||
|
|
64b3771899 | ||
|
|
4031429430 | ||
|
|
50b94abcb1 | ||
|
|
50adff90f2 | ||
|
|
7d0b838474 | ||
|
|
4fb95581ce | ||
|
|
0ae64203f5 | ||
|
|
4067107b52 | ||
|
|
8d7270a2ff | ||
|
|
ece8857535 | ||
|
|
9688b3df5d | ||
|
|
58442ec177 | ||
|
|
2a49fc0bf8 | ||
|
|
7fb8675271 | ||
|
|
57a8744a53 | ||
|
|
09222f1024 | ||
|
|
b4870a49e3 | ||
|
|
f7a48d028b | ||
|
|
382ef3953a | ||
|
|
9be32ca18b | ||
|
|
e0cd121a58 | ||
|
|
96631cee0c | ||
|
|
8c0487fc05 | ||
|
|
aec60f8cef | ||
|
|
a3080800b0 | ||
|
|
85f9414b95 | ||
|
|
e7f07d1fdb | ||
|
|
83efd0a267 | ||
|
|
5c05c61fbf | ||
|
|
fad350c811 | ||
|
|
d3d8d1cab3 | ||
|
|
a3437ca6ba | ||
|
|
17bd048d10 | ||
|
|
955b76f599 | ||
|
|
e3dc9e5b66 | ||
|
|
6095128007 | ||
|
|
0355447d53 | ||
|
|
58fd0bdc9e | ||
|
|
cdc35aa5dc | ||
|
|
10efba31cf | ||
|
|
ef204c2ab2 | ||
|
|
555e1a7722 | ||
|
|
7400784e4f | ||
|
|
2154f0a2cf | ||
|
|
14b11bdd10 | ||
|
|
c5738a2203 | ||
|
|
43ad855499 | ||
|
|
2533619339 | ||
|
|
b133dad642 | ||
|
|
464a85c52b | ||
|
|
7698ee7683 | ||
|
|
c7eb2e4b97 | ||
|
|
e71c88f860 | ||
|
|
c96b2bd859 | ||
|
|
ce4f21b7d8 | ||
|
|
2a55025e99 | ||
|
|
c86da22f4e | ||
|
|
adb10f5fe7 | ||
|
|
a268d3d298 | ||
|
|
b60771e96e | ||
|
|
435a986068 | ||
|
|
6c58f0980c | ||
|
|
e3dde71821 | ||
|
|
47b15e5fef | ||
|
|
ed196bdf99 | ||
|
|
9247e87bbf | ||
|
|
08727f959f | ||
|
|
78342da180 | ||
|
|
2b735172bd | ||
|
|
b032a868bb | ||
|
|
c4fa3b0ff8 | ||
|
|
0c3a1803e1 | ||
|
|
04f9971dee | ||
|
|
9c3395b76b | ||
|
|
f9bbb5b1a3 | ||
|
|
087bbdce1f | ||
|
|
494bf62535 | ||
|
|
4f2a5bb7e2 | ||
|
|
1c511a82b2 | ||
|
|
0c39723d1a | ||
|
|
322af00e80 | ||
|
|
a88747d904 | ||
|
|
e194d27bea | ||
|
|
22daa60eb6 | ||
|
|
6eca07966c | ||
|
|
56cc711c01 | ||
|
|
c2ee558235 | ||
|
|
c8a010c390 | ||
|
|
53c54485eb | ||
|
|
f42a308f2c | ||
|
|
44250cbb99 | ||
|
|
55ffe72198 | ||
|
|
a47dd2ecdb | ||
|
|
8a5233b6a1 | ||
|
|
c8a1279e75 | ||
|
|
57ef90e851 | ||
|
|
2262681351 | ||
|
|
56e1d0a69d | ||
|
|
63ffb51df5 | ||
|
|
b33bd2ac2b | ||
|
|
1afff77a0f | ||
|
|
26af09f2a4 | ||
|
|
a8e475dbf0 | ||
|
|
6388021c6d | ||
|
|
f4aa96a5f8 | ||
|
|
6baae5e4f7 | ||
|
|
189b244a3a | ||
|
|
12d538fe0d | ||
|
|
34f0dbf642 | ||
|
|
548f80bb7c | ||
|
|
9113a77331 | ||
|
|
e3e85db02a | ||
|
|
c4d9209c81 | ||
|
|
24d887a53d | ||
|
|
702ced200e | ||
|
|
40f5cb6e71 | ||
|
|
7ab0c41be6 | ||
|
|
66b21431f2 | ||
|
|
c6cd655f7e | ||
|
|
e9bccda259 | ||
|
|
9a34ff2a51 | ||
|
|
f01d9408de | ||
|
|
15ff7b4c9d | ||
|
|
d47765ce45 | ||
|
|
b82b067745 | ||
|
|
b7005f2400 | ||
|
|
312fe3a851 | ||
|
|
69d50fa992 | ||
|
|
1308dcb8dd | ||
|
|
b4ecba8382 | ||
|
|
3529d6a229 | ||
|
|
4213c4cce5 | ||
|
|
3d3e09977c | ||
|
|
90feac8c83 | ||
|
|
80a807e366 | ||
|
|
3eba8ba922 | ||
|
|
71a68bf36e | ||
|
|
e67501cde3 | ||
|
|
9aa7f5e879 | ||
|
|
854ecf0b47 | ||
|
|
f538f25d63 | ||
|
|
48a7fdc1d1 | ||
|
|
1d5ae0e3e0 | ||
|
|
f0462085d3 | ||
|
|
7dc7b62cc9 | ||
|
|
b9f80754e0 | ||
|
|
5b9f775743 | ||
|
|
0e66228a96 | ||
|
|
8df48bc378 | ||
|
|
d36d5d6def | ||
|
|
8b51430555 | ||
|
|
f71288e299 | ||
|
|
c0fc8195ce | ||
|
|
dd189411e6 | ||
|
|
4693b95bea | ||
|
|
596a42e312 | ||
|
|
71944be482 | ||
|
|
d1699fbb8d | ||
|
|
bd880b608f | ||
|
|
3386431749 | ||
|
|
c3fc8b5f18 | ||
|
|
ec740476da | ||
|
|
a536ad1d10 | ||
|
|
a1ae7818a2 | ||
|
|
365b3a8a38 | ||
|
|
823eb1f392 | ||
|
|
a12dfa405f | ||
|
|
9798ec296a | ||
|
|
c1b993c01b | ||
|
|
f55696a605 | ||
|
|
f361bd66ea | ||
|
|
3dfb96dec9 | ||
|
|
82ada0bcd8 | ||
|
|
28bd50a105 | ||
|
|
46bd5814e3 | ||
|
|
4e9cddac8f | ||
|
|
a85c5578c1 | ||
|
|
130ab70550 | ||
|
|
ee27cbdd22 | ||
|
|
bd0d238f23 | ||
|
|
3a5ac6f037 | ||
|
|
8db0f3ac6e | ||
|
|
60eda447b4 | ||
|
|
d5f2388723 | ||
|
|
d5a568b3fc | ||
|
|
2704d70c1f | ||
|
|
2a1e82ac6d | ||
|
|
755a69e912 | ||
|
|
101a4f63de | ||
|
|
84bdaa79e2 | ||
|
|
c3b6f5ce64 | ||
|
|
06a7260173 | ||
|
|
54236f718f | ||
|
|
2143e38d27 | ||
|
|
7d7651bc39 | ||
|
|
64c11b1f8f | ||
|
|
a1a0926c4b | ||
|
|
aade94a48f | ||
|
|
edebe64cf8 | ||
|
|
ae4f837091 | ||
|
|
5e6d87c8fd | ||
|
|
20e9723d21 | ||
|
|
54724ac540 | ||
|
|
a9c848e32e | ||
|
|
02f9e87233 | ||
|
|
22d546edc0 | ||
|
|
f464e8e287 | ||
|
|
bd5217acb4 | ||
|
|
e0cf62825b | ||
|
|
9ce356aff4 | ||
|
|
60fa54dddc | ||
|
|
99b457965b | ||
|
|
1d1a330ef1 | ||
|
|
4e9910c20e | ||
|
|
82f2958ac6 | ||
|
|
1afa441571 | ||
|
|
d159047dc0 | ||
|
|
3a529d00ce | ||
|
|
b14b2b86e8 | ||
|
|
9ab4319771 | ||
|
|
8de7a4c828 | ||
|
|
782d7a2172 | ||
|
|
2e5f3e4d66 | ||
|
|
6a00bf099e | ||
|
|
bc11bd4caf | ||
|
|
c133552d04 | ||
|
|
2065a83fa1 | ||
|
|
30ce0eaa45 | ||
|
|
8be1fc9340 | ||
|
|
6a8aa497b0 | ||
|
|
390155e03b | ||
|
|
3051ddb6c0 | ||
|
|
25d74632c2 | ||
|
|
2b77427d0b | ||
|
|
dfc77b6f84 | ||
|
|
6bc7f911c3 | ||
|
|
718614f81f | ||
|
|
8e1f3bb086 | ||
|
|
3a87eb463a | ||
|
|
a49c395486 | ||
|
|
ad7f782a1a | ||
|
|
3aa84b5a5a | ||
|
|
52457ea749 | ||
|
|
8104b96b8c | ||
|
|
a7835650bf | ||
|
|
d326dadb5d | ||
|
|
d9307dad0c | ||
|
|
752735159c | ||
|
|
7cc6eb2b66 | ||
|
|
0a19057606 | ||
|
|
a49d73c4c6 | ||
|
|
82ded0299c | ||
|
|
ab7cd4955b | ||
|
|
95493f3bbe | ||
|
|
a8c6f6b783 | ||
|
|
516f746061 | ||
|
|
d8d65ea989 | ||
|
|
d80735e248 | ||
|
|
ff5ad2385c | ||
|
|
2f28b25af3 | ||
|
|
02bf9501a9 | ||
|
|
a6292988d5 | ||
|
|
431f773b77 | ||
|
|
bd2bd1cf32 | ||
|
|
f5d92bf74f | ||
|
|
dbe8b6551a | ||
|
|
027e132749 | ||
|
|
7e3a157fcf | ||
|
|
9cd1ebf576 | ||
|
|
03f929163c | ||
|
|
e7e1ee7a2b | ||
|
|
3f229c4cb9 | ||
|
|
b2e0fdeaf8 | ||
|
|
0b541befbc | ||
|
|
fd9346d4da | ||
|
|
e744214ad6 | ||
|
|
3feff8e751 | ||
|
|
a2acd261d8 | ||
|
|
36b8884d92 | ||
|
|
c15d7b8882 | ||
|
|
9f33a09e87 | ||
|
|
cc78180a6c | ||
|
|
e5338688bb | ||
|
|
b19ec959b3 | ||
|
|
8b4a57985b | ||
|
|
7fb4e4a095 | ||
|
|
1bc4fc211d | ||
|
|
0a4d08886d | ||
|
|
0f5fa620d1 | ||
|
|
a0f26f1ca3 | ||
|
|
e64a0fb62e | ||
|
|
69409d71d1 | ||
|
|
68c63d20ed | ||
|
|
2afa3fd9de | ||
|
|
0bcaf3e422 | ||
|
|
6e5992c168 | ||
|
|
02122f8ce6 | ||
|
|
39f7f70a32 | ||
|
|
427b0a68d0 | ||
|
|
50f3a05fa5 | ||
|
|
a306c222d4 | ||
|
|
5bfee3339a | ||
|
|
2b9df69627 | ||
|
|
4f1e92f309 | ||
|
|
88165088a9 | ||
|
|
e38f76b8bc | ||
|
|
1f63fc7de1 | ||
|
|
763a88fe97 | ||
|
|
12e2be40e8 | ||
|
|
22379eda6f | ||
|
|
4485af577d | ||
|
|
0fcfd78b62 | ||
|
|
4940ed66c1 | ||
|
|
73093c0ff2 | ||
|
|
c5e27b89af | ||
|
|
111cd2fd46 | ||
|
|
5a90c8374c | ||
|
|
9ffa737a4d | ||
|
|
c565f2c9c7 | ||
|
|
eaa18f569a | ||
|
|
bfe6389377 | ||
|
|
f72412484a | ||
|
|
b4301adb3b | ||
|
|
d67269c9fe | ||
|
|
c264e639d6 | ||
|
|
32a84f24ef | ||
|
|
68e4146f3b | ||
|
|
f4f7215a6a | ||
|
|
a0b19872f8 | ||
|
|
f2147179c2 | ||
|
|
e7a0b4cf04 | ||
|
|
533572e8cd | ||
|
|
257eea5b04 | ||
|
|
47af0d634f | ||
|
|
5e11d9d51f | ||
|
|
7ffcff7a7b | ||
|
|
9ee548b967 | ||
|
|
c9142223fd | ||
|
|
2094397bca | ||
|
|
b81109f512 | ||
|
|
874dbafe26 | ||
|
|
46ca469a4a | ||
|
|
8fb51bf3b7 | ||
|
|
9874a9053a | ||
|
|
db87774426 | ||
|
|
d14db9396b | ||
|
|
d7966567e7 | ||
|
|
b4f8024eef | ||
|
|
e70f230f39 | ||
|
|
b28f743306 | ||
|
|
9f97a09942 | ||
|
|
4f7e655613 | ||
|
|
a7d94c2f8f | ||
|
|
c2172821fd | ||
|
|
24393d4ef4 | ||
|
|
622ea91648 | ||
|
|
aed1a63a77 | ||
|
|
14cd568e46 | ||
|
|
44d836e2e7 | ||
|
|
f9af6947f7 | ||
|
|
8e1da82793 | ||
|
|
860aca974b | ||
|
|
6a66d7653f | ||
|
|
d32a4541a9 | ||
|
|
26719169ee | ||
|
|
eae145543e | ||
|
|
48f1300908 | ||
|
|
5cdaabeaec | ||
|
|
40f87e9472 | ||
|
|
7f385d4762 | ||
|
|
389c5adaa3 | ||
|
|
7a82ded94b | ||
|
|
86278e837a | ||
|
|
34a0499152 | ||
|
|
68ccc6634d | ||
|
|
317af7ebc5 | ||
|
|
206368b777 | ||
|
|
204a81b0ea | ||
|
|
b940ecab9c | ||
|
|
15cbc96697 | ||
|
|
b5e5b46f77 | ||
|
|
42b6a1378c |
No files matched your search
@@ -0,0 +1,16 @@
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = false
|
||||
tab_width = 4
|
||||
|
||||
[*.java]
|
||||
ij_java_class_count_to_use_import_on_demand = 999999
|
||||
ij_java_names_count_to_use_import_on_demand = 999999
|
||||
ij_java_imports_layout = *,|,$*
|
||||
ij_java_generate_final_locals = true
|
||||
ij_java_generate_final_parameters = true
|
||||
|
||||
[{*.json,*.yml}]
|
||||
indent_size = 2
|
||||
@@ -0,0 +1,2 @@
|
||||
github: kennytv
|
||||
patreon: kennytv
|
||||
@@ -1,12 +1,13 @@
|
||||
name: Bug Report
|
||||
description: Report a bug or console error
|
||||
labels: [Unconfirmed]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
**Before reporting a bug, please see if using master/dev builds from https://ci.viaversion.com/ fixes your issue.**
|
||||
Whenever you see fit, you can upload images or video to any of the textfields.
|
||||
Whenever you see fit, you can upload images or videos to any of the text fields.
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
@@ -22,11 +23,11 @@ body:
|
||||
attributes:
|
||||
label: Console Error
|
||||
description: |
|
||||
If you encounter warnings/errors in your console, **paste them with https://paste.gg/ and put the paste link here**.
|
||||
If you encounter warnings/errors in your console, **paste them with https://mclo.gs/ and put the paste link here**.
|
||||
If the error is small/less than 10 lines, you may put it directly into this field.
|
||||
value: |
|
||||
```
|
||||
Put the paste.gg link or text here.
|
||||
Put the mclo.gs link or text here.
|
||||
```
|
||||
placeholder: Please do not remove the grave accents; simply replace the line of text in the middle.
|
||||
validations:
|
||||
@@ -70,7 +71,7 @@ body:
|
||||
attributes:
|
||||
label: Additional Server Info
|
||||
description: |
|
||||
Do you use a proxy (eg. BungeeCord)? What software do you use and what plugins?
|
||||
Do you use a proxy (e.g. BungeeCord)? What software do you use and what plugins?
|
||||
placeholder: |
|
||||
Example: "I also use BungeeCord with the following plugins: x, y, z"
|
||||
validations:
|
||||
@@ -87,5 +88,5 @@ body:
|
||||
required: true
|
||||
- label: If applicable, I have included a paste (**not a screenshot**) of the error.
|
||||
required: true
|
||||
- label: I have tried a build from https://ci.viaversion.com/ and the issue still persists.
|
||||
- label: I have tried the latest build(s) from https://ci.viaversion.com/ and the issue still persists.
|
||||
required: true
|
||||
@@ -1,5 +1,6 @@
|
||||
name: Feature Request
|
||||
description: Suggest a feature to be added
|
||||
labels: [Feature Request]
|
||||
|
||||
body:
|
||||
- type: textarea
|
||||
@@ -34,4 +35,4 @@ body:
|
||||
description: |
|
||||
Does the feature apply to any specific version or environment?
|
||||
validations:
|
||||
required: false
|
||||
required: false
|
||||
@@ -1,28 +1,24 @@
|
||||
# This workflow will build a Java project with Gradle
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||
|
||||
name: Java CI with Gradle
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Only run on PRs if the source branch is on a different repo. We do not need run everything twice.
|
||||
# Only run on PRs if the source branch is on a different repo. We do not need to run everything twice.
|
||||
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v2
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: 11
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
check-latest: true
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: artifact
|
||||
path: build/libs
|
||||
@@ -0,0 +1,27 @@
|
||||
name: Publish to Hangar and Modrinth
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
if: github.repository_owner == 'ViaVersion'
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v2
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
check-latest: true
|
||||
- name: Publish
|
||||
env:
|
||||
HANGAR_TOKEN: ${{ secrets.HANGAR_TOKEN }}
|
||||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
||||
run: ./gradlew build modrinth publishAllPublicationsToHangar --stacktrace
|
||||
+4
-5
@@ -18,6 +18,8 @@ hs_err_pid*
|
||||
|
||||
# Ignore IDEA directory
|
||||
.idea/*
|
||||
!.idea/copyright/*
|
||||
!.idea/scopes/*
|
||||
|
||||
# Include the project's dictionary
|
||||
!.idea/dictionaries/
|
||||
@@ -106,8 +108,5 @@ nbactions.xml
|
||||
nb-configuration.xml
|
||||
.nb-gradle/
|
||||
|
||||
|
||||
|
||||
### Git ###
|
||||
# Don't exclude the .gitignore itself
|
||||
!.gitignore
|
||||
### MacOS ###
|
||||
.DS_Store
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings>
|
||||
<module2copyright>
|
||||
<element module="ViaVersion-API" copyright="viaversion-mit" />
|
||||
<element module="ViaVersion" copyright="viaversion-gpl" />
|
||||
</module2copyright>
|
||||
<LanguageOptions name="__TEMPLATE__">
|
||||
<option name="addBlankAfter" value="false" />
|
||||
</LanguageOptions>
|
||||
</settings>
|
||||
</component>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion Copyright (C) 2016-&#36;today.year ViaVersion 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/>." />
|
||||
<option name="myName" value="viaversion-gpl" />
|
||||
</copyright>
|
||||
</component>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion Copyright (C) 2016-&#36;today.year ViaVersion and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." />
|
||||
<option name="myName" value="viaversion-mit" />
|
||||
</copyright>
|
||||
</component>
|
||||
Generated
+3
@@ -0,0 +1,3 @@
|
||||
<component name="DependencyValidationManager">
|
||||
<scope name="ViaVersion" pattern="com.viaversion.viaversion..*&&!src[viaversion-parent.viaversion-api*]:*..*" />
|
||||
</component>
|
||||
Generated
+3
@@ -0,0 +1,3 @@
|
||||
<component name="DependencyValidationManager">
|
||||
<scope name="ViaVersion-API" pattern="src[viaversion-parent.viaversion-api*]:*..*" />
|
||||
</component>
|
||||
@@ -1,44 +1,41 @@
|
||||
# ViaVersion - Spigot, Sponge, BungeeCord, Velocity
|
||||
# ViaVersion
|
||||
|
||||
[](https://viaversion.com)
|
||||
[](https://github.com/ViaVersion/ViaVersion/actions)
|
||||
[](https://viaversion.com/discord)
|
||||
|
||||
**Allows the connection of higher client versions to lower server versions**
|
||||
**Allows the connection of higher client versions to lower server versions -
|
||||
it works on any platform you can think of.**
|
||||
|
||||
The base ViaVersion jar runs on Paper, Velocity, Bungee, and Sponge. We also have projects integrating ViaVersion to run
|
||||
on Fabric, Forge, or as a standalone proxy to join from basically any client version on any server version from the
|
||||
past decade. **See [HERE](https://github.com/ViaVersion) for an overview of the different Via\* projects.**
|
||||
|
||||
Supported Versions:
|
||||
|
||||

|
||||
|
||||
On Paper you may also use ProtocolSupport, but ensure you have the right build for your server version.
|
||||

|
||||
|
||||
**User Docs:** https://docs.viaversion.com/display/VIAVERSION/
|
||||
|
||||
|
||||
Sources:
|
||||
Releases/Dev Builds
|
||||
--------
|
||||
**[wiki.vg](https://wiki.vg)** (Used for information regarding packet structure, we also contribute back)
|
||||
You can find official releases in the following places:
|
||||
|
||||
**[Burger](https://github.com/Pokechu22/Burger)** (See [PAaaS](https://github.com/Matsv/Paaas))
|
||||
- **Hangar (for our plugins)**: https://hangar.papermc.io/ViaVersion/ViaVersion
|
||||
- **Modrinth (for our mods)**: https://modrinth.com/mod/viaversion
|
||||
- **GitHub**: https://github.com/ViaVersion/ViaVersion/releases
|
||||
|
||||
**[OpenNBT](https://github.com/ViaVersion/OpenNBT)**
|
||||
Dev builds for **all** of our projects are on our Jenkins server:
|
||||
|
||||
- **Jenkins**: https://ci.viaversion.com
|
||||
|
||||
Releases / Dev Builds:
|
||||
--------
|
||||
You can find official releases here:
|
||||
|
||||
https://www.spigotmc.org/resources/viaversion.19254/history
|
||||
|
||||
ViaVersion as a Dependency
|
||||
----------
|
||||
|
||||
You can find official dev builds here:
|
||||
|
||||
**Jenkins:** https://ci.viaversion.com
|
||||
|
||||
**JavaDocs:** https://jd.viaversion.com
|
||||
|
||||
**Maven Repository:**
|
||||
**Maven:**
|
||||
|
||||
```xml
|
||||
<repository>
|
||||
<id>viaversion-repo</id>
|
||||
@@ -46,34 +43,57 @@ You can find official dev builds here:
|
||||
</repository>
|
||||
```
|
||||
|
||||
**API-artifact:**
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>viaversion-api</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>[4.0.0,5.0.0)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
Replace the version depending on your needs.
|
||||
**Gradle:**
|
||||
|
||||
```kotlin
|
||||
repositories {
|
||||
maven("https://repo.viaversion.com")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.viaversion:viaversion-api:VERSION") // Replace the version
|
||||
}
|
||||
```
|
||||
|
||||
If you need access to the existing protocol or platform implementations, use the parent artifact `viaversion`.
|
||||
Please note the [differences in licensing](#license).
|
||||
|
||||
|
||||
Building:
|
||||
Building
|
||||
--------
|
||||
After cloning this repository, build the project with Gradle by running `./gradlew build` and take the created jar out of
|
||||
the `build/libs` directory.
|
||||
After cloning this repository, build the project with Gradle by running `./gradlew build` and take the created jar out
|
||||
of the `build/libs` directory.
|
||||
|
||||
|
||||
License:
|
||||
Mapping Files
|
||||
--------------
|
||||
Mapping files are generated and managed in our [Mappings repository](https://github.com/ViaVersion/Mappings).
|
||||
|
||||
|
||||
Resources
|
||||
--------
|
||||
The entirety of the [API directory](api) (including the legacy API directory) is licensed under the MIT License; see [licenses/MIT.md](licenses/MIT.md) for
|
||||
|
||||
- **[Via Mappings Generator](https://github.com/ViaVersion/Mappings)**
|
||||
- **[Mojang mappings](https://minecraft.wiki/w/Obfuscation_map)** (Thank you, Mojang, very cool)
|
||||
- **[wiki.vg](https://wiki.vg)** (Used for historic information regarding packet structure, we also contribute back)
|
||||
- **[Burger](https://github.com/Pokechu22/Burger)** (See [PAaaS](https://github.com/Matsv/Paaas))
|
||||
|
||||
License
|
||||
--------
|
||||
The entirety of the [API directory](api) (including the legacy API directory) is licensed under the MIT License;
|
||||
see [licenses/MIT.md](licenses/MIT.md) for
|
||||
details.
|
||||
|
||||
Everything else, unless explicitly stated otherwise, is licensed under the GNU General Public License, including the end
|
||||
product as a whole; see [licenses/GPL.md](licenses/GPL.md) for details.
|
||||
Everything else, unless explicitly stated otherwise, is licensed under the GNU General Public License v3, including the
|
||||
end-product as a whole; see [licenses/GPL.md](licenses/GPL.md) for details.
|
||||
|
||||
Special thanks to all our [Contributors](https://github.com/ViaVersion/ViaVersion/graphs/contributors).
|
||||
@@ -1,25 +0,0 @@
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
// Shade and relocate adventure in an extra module, so that common/the rest can directly depend on a
|
||||
// relocated adventure without breaking native platform's adventure usage with project wide relocation
|
||||
tasks {
|
||||
shadowJar {
|
||||
relocate("net.kyori", "com.viaversion.viaversion.libs.kyori")
|
||||
}
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(libs.bundles.adventure) {
|
||||
exclude("org.checkerframework")
|
||||
exclude("net.kyori", "adventure-api")
|
||||
exclude("net.kyori", "adventure-bom")
|
||||
exclude("com.google.code.gson", "gson")
|
||||
}
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,13 +23,12 @@
|
||||
package us.myles.ViaVersion.api;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
import us.myles.ViaVersion.api.boss.BossBar;
|
||||
import us.myles.ViaVersion.api.boss.BossColor;
|
||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @deprecated may be removed at some point, use {@link com.viaversion.viaversion.api.Via}
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,13 +24,12 @@ package us.myles.ViaVersion.api;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
import us.myles.ViaVersion.api.boss.BossBar;
|
||||
import us.myles.ViaVersion.api.boss.BossColor;
|
||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @deprecated may be removed at some point, use {@link Via#getAPI()}
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,17 +23,16 @@
|
||||
package us.myles.ViaVersion.api.protocol;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionRange;
|
||||
import com.viaversion.viaversion.api.protocol.version.SubVersionRange;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* @deprecated will no longer be updated and may be removed at some point, use {@link com.viaversion.viaversion.api.protocol.version.ProtocolVersion}
|
||||
@@ -43,23 +42,23 @@ public class ProtocolVersion {
|
||||
private static final Int2ObjectMap<ProtocolVersion> versions = new Int2ObjectOpenHashMap<>();
|
||||
private static final List<ProtocolVersion> versionList = new ArrayList<>();
|
||||
|
||||
public static final ProtocolVersion v1_4_6 = register(51, "1.4.6/7", new VersionRange("1.4", 6, 7));
|
||||
public static final ProtocolVersion v1_4_6 = register(51, "1.4.6/7", new SubVersionRange("1.4", 6, 7));
|
||||
public static final ProtocolVersion v1_5_1 = register(60, "1.5.1");
|
||||
public static final ProtocolVersion v1_5_2 = register(61, "1.5.2");
|
||||
public static final ProtocolVersion v_1_6_1 = register(73, "1.6.1");
|
||||
public static final ProtocolVersion v_1_6_2 = register(74, "1.6.2");
|
||||
public static final ProtocolVersion v_1_6_3 = register(77, "1.6.3");
|
||||
public static final ProtocolVersion v_1_6_4 = register(78, "1.6.4");
|
||||
public static final ProtocolVersion v1_7_1 = register(4, "1.7-1.7.5", new VersionRange("1.7", 0, 5));
|
||||
public static final ProtocolVersion v1_7_6 = register(5, "1.7.6-1.7.10", new VersionRange("1.7", 6, 10));
|
||||
public static final ProtocolVersion v1_7_1 = register(4, "1.7-1.7.5", new SubVersionRange("1.7", 0, 5));
|
||||
public static final ProtocolVersion v1_7_6 = register(5, "1.7.6-1.7.10", new SubVersionRange("1.7", 6, 10));
|
||||
public static final ProtocolVersion v1_8 = register(47, "1.8.x");
|
||||
public static final ProtocolVersion v1_9 = register(107, "1.9");
|
||||
public static final ProtocolVersion v1_9_1 = register(108, "1.9.1");
|
||||
public static final ProtocolVersion v1_9_2 = register(109, "1.9.2");
|
||||
public static final ProtocolVersion v1_9_3 = register(110, "1.9.3/4", new VersionRange("1.9", 3, 4));
|
||||
public static final ProtocolVersion v1_9_3 = register(110, "1.9.3/1.9.4", new SubVersionRange("1.9", 3, 4));
|
||||
public static final ProtocolVersion v1_10 = register(210, "1.10.x");
|
||||
public static final ProtocolVersion v1_11 = register(315, "1.11");
|
||||
public static final ProtocolVersion v1_11_1 = register(316, "1.11.1/2", new VersionRange("1.11", 1, 2));
|
||||
public static final ProtocolVersion v1_11_1 = register(316, "1.11.1/1.11.2", new SubVersionRange("1.11", 1, 2));
|
||||
public static final ProtocolVersion v1_12 = register(335, "1.12");
|
||||
public static final ProtocolVersion v1_12_1 = register(338, "1.12.1");
|
||||
public static final ProtocolVersion v1_12_2 = register(340, "1.12.2");
|
||||
@@ -78,7 +77,19 @@ public class ProtocolVersion {
|
||||
public static final ProtocolVersion v1_16_1 = register(736, "1.16.1");
|
||||
public static final ProtocolVersion v1_16_2 = register(751, "1.16.2");
|
||||
public static final ProtocolVersion v1_16_3 = register(753, "1.16.3");
|
||||
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/5", new VersionRange("1.16", 4, 5));
|
||||
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/1.16.5", new SubVersionRange("1.16", 4, 5));
|
||||
public static final ProtocolVersion v1_17 = register(755, "1.17");
|
||||
public static final ProtocolVersion v1_17_1 = register(756, "1.17.1");
|
||||
public static final ProtocolVersion v1_18 = register(757, "1.18/1.18.1", new SubVersionRange("1.18", 0, 1));
|
||||
public static final ProtocolVersion v1_18_2 = register(758, "1.18.2");
|
||||
public static final ProtocolVersion v1_19 = register(759, "1.19");
|
||||
public static final ProtocolVersion v1_19_1 = register(760, "1.19.1/1.19.2", new SubVersionRange("1.19", 1, 2));
|
||||
public static final ProtocolVersion v1_19_3 = register(761, "1.19.3");
|
||||
public static final ProtocolVersion v1_19_4 = register(762, "1.19.4");
|
||||
public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new SubVersionRange("1.20", 0, 1));
|
||||
public static final ProtocolVersion v1_20_2 = register(764, "1.20.2");
|
||||
public static final ProtocolVersion v1_20_3 = register(765, "1.20.3/1.20.4", new SubVersionRange("1.20", 3, 4));
|
||||
public static final ProtocolVersion v1_20_5 = register(766, "1.20.5");
|
||||
public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
|
||||
|
||||
public static ProtocolVersion register(int version, String name) {
|
||||
@@ -89,11 +100,11 @@ public class ProtocolVersion {
|
||||
return register(version, snapshotVersion, name, null);
|
||||
}
|
||||
|
||||
public static ProtocolVersion register(int version, String name, @Nullable VersionRange versionRange) {
|
||||
public static ProtocolVersion register(int version, String name, @Nullable SubVersionRange versionRange) {
|
||||
return register(version, -1, name, versionRange);
|
||||
}
|
||||
|
||||
public static ProtocolVersion register(int version, int snapshotVersion, String name, @Nullable VersionRange versionRange) {
|
||||
public static ProtocolVersion register(int version, int snapshotVersion, String name, @Nullable SubVersionRange versionRange) {
|
||||
ProtocolVersion protocol = new ProtocolVersion(version, snapshotVersion, name, versionRange);
|
||||
versionList.add(protocol);
|
||||
versions.put(protocol.getVersion(), protocol);
|
||||
@@ -156,7 +167,7 @@ public class ProtocolVersion {
|
||||
this(version, -1, name, null);
|
||||
}
|
||||
|
||||
public ProtocolVersion(int version, int snapshotVersion, String name, @Nullable VersionRange versionRange) {
|
||||
public ProtocolVersion(int version, int snapshotVersion, String name, @Nullable SubVersionRange versionRange) {
|
||||
this.version = version;
|
||||
this.snapshotVersion = snapshotVersion;
|
||||
this.name = name;
|
||||
@@ -165,12 +176,12 @@ public class ProtocolVersion {
|
||||
Preconditions.checkArgument(!versionWildcard || versionRange == null, "A version cannot be a wildcard and a range at the same time!");
|
||||
if (versionRange != null) {
|
||||
includedVersions = new LinkedHashSet<>();
|
||||
for (int i = versionRange.getRangeFrom(); i <= versionRange.getRangeTo(); i++) {
|
||||
for (int i = versionRange.rangeFrom(); i <= versionRange.rangeTo(); i++) {
|
||||
if (i == 0) {
|
||||
includedVersions.add(versionRange.getBaseVersion()); // Keep both the base version and with ".0" appended
|
||||
includedVersions.add(versionRange.baseVersion()); // Keep both the base version and with ".0" appended
|
||||
}
|
||||
|
||||
includedVersions.add(versionRange.getBaseVersion() + "." + i);
|
||||
includedVersions.add(versionRange.baseVersion() + "." + i);
|
||||
}
|
||||
} else {
|
||||
includedVersions = Collections.singleton(name);
|
||||
|
||||
+17
-8
@@ -1,20 +1,27 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom")
|
||||
id("via.shadow-conventions")
|
||||
id("org.jetbrains.gradle.plugin.idea-ext")
|
||||
}
|
||||
|
||||
blossom {
|
||||
replaceToken("\$VERSION", project.version)
|
||||
replaceToken("\$IMPL_VERSION", "git-ViaVersion-${project.version}:${rootProject.latestCommitHash()}")
|
||||
sourceSets {
|
||||
main {
|
||||
blossom {
|
||||
javaSources {
|
||||
property("version", project.version.toString())
|
||||
property("impl_version", "git-ViaVersion-${project.version}:${rootProject.latestCommitHash()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(projects.adventure) {
|
||||
targetConfiguration = "shadow"
|
||||
}
|
||||
api(libs.fastutil)
|
||||
api(libs.openNBT)
|
||||
api(libs.vianbt)
|
||||
api(libs.gson)
|
||||
implementation(rootProject.libs.text) {
|
||||
exclude("com.google.code.gson", "gson")
|
||||
exclude("com.viaversion", "nbt")
|
||||
}
|
||||
|
||||
compileOnlyApi(libs.snakeYaml)
|
||||
compileOnlyApi(libs.netty)
|
||||
@@ -25,3 +32,5 @@ dependencies {
|
||||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
+11
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -31,5 +31,14 @@ public final class VersionInfo {
|
||||
*
|
||||
* @see ViaPlatform#getPluginVersion()
|
||||
*/
|
||||
public static final String VERSION = "$VERSION";
|
||||
public static final String VERSION = "{{ version }}";
|
||||
private static final String IMPLEMENTATION_VERSION = "{{ impl_version }}";
|
||||
|
||||
public static String getVersion() {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
public static String getImplementationVersion() {
|
||||
return IMPLEMENTATION_VERSION;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,6 +25,7 @@ package com.viaversion.viaversion.api;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||
import com.viaversion.viaversion.api.platform.ViaServerProxyPlatform;
|
||||
|
||||
public final class Via {
|
||||
private static ViaManager manager;
|
||||
@@ -63,6 +64,11 @@ public final class Via {
|
||||
return manager().getPlatform();
|
||||
}
|
||||
|
||||
public static ViaServerProxyPlatform<?> proxyPlatform() {
|
||||
Preconditions.checkArgument(manager().getPlatform() instanceof ViaServerProxyPlatform, "Platform is not proxying Minecraft servers!");
|
||||
return (ViaServerProxyPlatform<?>) manager().getPlatform();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the ViaManager associated with the platform.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -27,12 +27,14 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.legacy.LegacyViaAPI;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* General api point. For more specialized api methods, see {@link Via#getManager()}.
|
||||
@@ -46,13 +48,25 @@ import java.util.UUID;
|
||||
public interface ViaAPI<T> {
|
||||
|
||||
/**
|
||||
* Returns the API version incremented with meaningful API changes.
|
||||
* Returns the <b>major version</b> matching {@link #getVersion()}.
|
||||
* It is highly advised to check against the major version and to disable/not initiate
|
||||
* any hooks into ViaVersion if given and expected versions do not match.
|
||||
*
|
||||
* @return major plugin version
|
||||
* @since 4.0.2
|
||||
*/
|
||||
default int majorVersion() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <b>internally based API version</b> incremented with meaningful API changes.
|
||||
* This includes breaking changes to existing API and larger additions.
|
||||
*
|
||||
* @return API version incremented with meaningful API changes
|
||||
*/
|
||||
default int apiVersion() {
|
||||
return 3;
|
||||
return 26;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +83,18 @@ public interface ViaAPI<T> {
|
||||
* @param player the platform's player object, e.g. Bukkit this is Player
|
||||
* @return protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if no longer connected
|
||||
*/
|
||||
int getPlayerVersion(T player);
|
||||
default int getPlayerVersion(T player) {
|
||||
return getPlayerProtocolVersion(player).getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protocol version of a player.
|
||||
* This will also retrieve the version from ProtocolSupport if it's being used.
|
||||
*
|
||||
* @param player the platform's player object, e.g. Bukkit this is Player
|
||||
* @return the protocol version object (see {@link ProtocolVersion}), or ProtocolVersion.unknown if not connected
|
||||
*/
|
||||
ProtocolVersion getPlayerProtocolVersion(T player);
|
||||
|
||||
/**
|
||||
* Returns the protocol version of a player.
|
||||
@@ -77,7 +102,19 @@ public interface ViaAPI<T> {
|
||||
* @param uuid UUID of a player
|
||||
* @return protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if not connected
|
||||
*/
|
||||
int getPlayerVersion(UUID uuid);
|
||||
default int getPlayerVersion(UUID uuid) {
|
||||
return getPlayerProtocolVersion(uuid).getVersion();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the protocol version of a player.
|
||||
* This will also retrieve the version from ProtocolSupport if it's being used.
|
||||
*
|
||||
* @param uuid UUID of a player
|
||||
* @return the protocol version object (see {@link ProtocolVersion}), or ProtocolVersion.unknown if not connected
|
||||
*/
|
||||
ProtocolVersion getPlayerProtocolVersion(UUID uuid);
|
||||
|
||||
/**
|
||||
* Returns whether Via injected into this player connection.
|
||||
@@ -106,7 +143,7 @@ public interface ViaAPI<T> {
|
||||
* Sends a raw packet to the player.
|
||||
*
|
||||
* @param player the platform's player object, e.g. for Bukkit this is Player
|
||||
* @param packet the packet; you need a VarInt Id, then the packet contents
|
||||
* @param packet the packet; you need a VarInt id, then the packet contents
|
||||
* @throws IllegalArgumentException if the player is not injected by Via
|
||||
*/
|
||||
void sendRawPacket(T player, ByteBuf packet);
|
||||
@@ -115,26 +152,37 @@ public interface ViaAPI<T> {
|
||||
* Sends a raw packet to the player.
|
||||
*
|
||||
* @param uuid the uuid from the player to send packet
|
||||
* @param packet the packet; you need a VarInt Id, then the packet contents
|
||||
* @param packet the packet; you need a VarInt id, then the packet contents
|
||||
* @throws IllegalArgumentException if the player is not injected by Via
|
||||
*/
|
||||
void sendRawPacket(UUID uuid, ByteBuf packet);
|
||||
|
||||
@Deprecated
|
||||
default SortedSet<Integer> getSupportedVersions() {
|
||||
return getSupportedProtocolVersions().stream().map(ProtocolVersion::getVersion).collect(Collectors.toCollection(TreeSet::new));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default SortedSet<Integer> getFullSupportedVersions() {
|
||||
return getFullSupportedProtocolVersions().stream().map(ProtocolVersion::getVersion).collect(Collectors.toCollection(TreeSet::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the supported protocol versions.
|
||||
* This method removes any blocked protocol versions.
|
||||
*
|
||||
* @return a list of protocol versions
|
||||
* @return a sorted set of protocol versions
|
||||
* @see #getFullSupportedVersions() for a full list
|
||||
*/
|
||||
SortedSet<Integer> getSupportedVersions();
|
||||
SortedSet<ProtocolVersion> getSupportedProtocolVersions();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the supported protocol versions, including blocked protocols.
|
||||
*
|
||||
* @return a list of protocol versions
|
||||
* @return a sorted set of protocol versions
|
||||
*/
|
||||
SortedSet<Integer> getFullSupportedVersions();
|
||||
SortedSet<ProtocolVersion> getFullSupportedProtocolVersions();
|
||||
|
||||
/**
|
||||
* Returns legacy api only applicable on/to legacy versions.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,13 +23,15 @@
|
||||
package com.viaversion.viaversion.api;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaVersionCommand;
|
||||
import com.viaversion.viaversion.api.configuration.ConfigurationProvider;
|
||||
import com.viaversion.viaversion.api.connection.ConnectionManager;
|
||||
import com.viaversion.viaversion.api.debug.DebugHandler;
|
||||
import com.viaversion.viaversion.api.platform.ViaInjector;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
|
||||
import com.viaversion.viaversion.api.scheduler.Scheduler;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ViaManager {
|
||||
@@ -83,19 +85,45 @@ public interface ViaManager {
|
||||
*/
|
||||
ViaPlatformLoader getLoader();
|
||||
|
||||
/**
|
||||
* Returns the async task scheduler.
|
||||
*
|
||||
* @return async task scheduler
|
||||
*/
|
||||
Scheduler getScheduler();
|
||||
|
||||
/**
|
||||
* Returns the configuration provider.
|
||||
*
|
||||
* @return the configuration provider
|
||||
*/
|
||||
ConfigurationProvider getConfigurationProvider();
|
||||
|
||||
/**
|
||||
* If debug is enabled, packets and other otherwise suppressed warnings will be logged.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isDebug();
|
||||
default boolean isDebug() {
|
||||
return debugHandler().enabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the debug mode. If enabled, packets and other otherwise suppressed warnings will be logged.
|
||||
*
|
||||
* @param debug whether debug should be enabled
|
||||
*/
|
||||
void setDebug(boolean debug);
|
||||
@Deprecated
|
||||
default void setDebug(boolean debug) {
|
||||
debugHandler().setEnabled(debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the debug handler.
|
||||
*
|
||||
* @return debug handler
|
||||
*/
|
||||
DebugHandler debugHandler();
|
||||
|
||||
/**
|
||||
* Returns a mutable set of self-added subplatform version strings.
|
||||
@@ -111,4 +139,12 @@ public interface ViaManager {
|
||||
* @param runnable runnable to be executed
|
||||
*/
|
||||
void addEnableListener(Runnable runnable);
|
||||
|
||||
/**
|
||||
* Returns whether the manager has been initialized (and protocols have been loaded).
|
||||
*
|
||||
* @return whether the manager has been initialized
|
||||
*/
|
||||
boolean isInitialized();
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,7 +28,7 @@ public interface ViaCommandSender {
|
||||
/**
|
||||
* Check if the sender has a permission.
|
||||
*
|
||||
* @param permission Permission string eg. viaversion.admin
|
||||
* @param permission Permission string e.g. viaversion.admin
|
||||
* @return True if the sender has the permission
|
||||
*/
|
||||
boolean hasPermission(String permission);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,6 @@
|
||||
package com.viaversion.viaversion.api.command;
|
||||
|
||||
import com.viaversion.viaversion.util.ChatColorUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -59,7 +58,7 @@ public abstract class ViaSubCommand {
|
||||
* @return The permission required to use the commands
|
||||
*/
|
||||
public String permission() {
|
||||
return "viaversion.admin";
|
||||
return "viaversion.admin." + name();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,9 +22,8 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.command;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ViaVersionCommand {
|
||||
/**
|
||||
@@ -33,7 +32,7 @@ public interface ViaVersionCommand {
|
||||
* @param command Your own SubCommand instance to handle it.
|
||||
* @throws Exception throws an exception when the subcommand already exists or if it's not valid, example: spacee
|
||||
*/
|
||||
void registerSubCommand(ViaSubCommand command) throws Exception;
|
||||
void registerSubCommand(ViaSubCommand command);
|
||||
|
||||
/**
|
||||
* Check if a subcommand is registered.
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.configuration;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface Config {
|
||||
|
||||
/**
|
||||
* Reloads the config
|
||||
*/
|
||||
void reload();
|
||||
|
||||
/**
|
||||
* Saves the config
|
||||
*/
|
||||
void save();
|
||||
|
||||
/**
|
||||
* Sets the specified path to the given value.
|
||||
*
|
||||
* @param path Path of the object to set.
|
||||
* @param value New value to set the path to
|
||||
*/
|
||||
void set(String path, Object value);
|
||||
|
||||
/**
|
||||
* Get all the configuration values
|
||||
*
|
||||
* @return Map with key-values
|
||||
*/
|
||||
Map<String, Object> getValues();
|
||||
}
|
||||
+13
-19
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,32 +22,26 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.configuration;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface ConfigurationProvider {
|
||||
|
||||
/**
|
||||
* Sets the specified path to the given value.
|
||||
* Registers a config to be saved or reloaded when {@link #reloadConfigs()} is called.
|
||||
*
|
||||
* @param path Path of the object to set.
|
||||
* @param value New value to set the path to
|
||||
* @param config the config to register
|
||||
*/
|
||||
void set(String path, Object value);
|
||||
void register(Config config);
|
||||
|
||||
/**
|
||||
* Saves the config
|
||||
*/
|
||||
void saveConfig();
|
||||
|
||||
/**
|
||||
* Reloads the config
|
||||
*/
|
||||
void reloadConfig();
|
||||
|
||||
/**
|
||||
* Get all the configuration values
|
||||
* Returns all registered configs.
|
||||
*
|
||||
* @return Map with key-values
|
||||
* @return unmodifiable collection of all registered configs
|
||||
*/
|
||||
Map<String, Object> getValues();
|
||||
Collection<Config> configs();
|
||||
|
||||
/**
|
||||
* Reloads the configuration files.
|
||||
*/
|
||||
void reloadConfigs();
|
||||
}
|
||||
+62
-19
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,9 +22,13 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.configuration;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
|
||||
import com.viaversion.viaversion.api.protocol.version.BlockedProtocolVersions;
|
||||
|
||||
public interface ViaVersionConfig {
|
||||
public interface ViaVersionConfig extends Config {
|
||||
|
||||
/**
|
||||
* Get if the plugin should check for updates
|
||||
@@ -81,7 +85,7 @@ public interface ViaVersionConfig {
|
||||
* <p>
|
||||
* This option requires {@link #isShowShieldWhenSwordInHand()} to be disabled
|
||||
*
|
||||
* @return {@code true} if non delayed shield blocking is enabled.
|
||||
* @return {@code true} if non-delayed shield blocking is enabled.
|
||||
*/
|
||||
boolean isNoDelayShieldBlocking();
|
||||
|
||||
@@ -120,7 +124,7 @@ public interface ViaVersionConfig {
|
||||
* Get if the boss bars for 1.9 & 1.10 clients are being stopped from flickering
|
||||
* This will keep all boss bars on 100% (not recommended)
|
||||
*
|
||||
* @return true if boss bar anti flickering is enabled
|
||||
* @return true if boss bar anti-flickering is enabled
|
||||
*/
|
||||
boolean isBossbarAntiflicker();
|
||||
|
||||
@@ -180,13 +184,6 @@ public interface ViaVersionConfig {
|
||||
*/
|
||||
String getMaxWarningsKickMessage();
|
||||
|
||||
/**
|
||||
* Is anti-xray enabled?
|
||||
*
|
||||
* @return A boolean
|
||||
*/
|
||||
boolean isAntiXRay();
|
||||
|
||||
/**
|
||||
* Send supported versions in the status response packet
|
||||
*
|
||||
@@ -230,11 +227,11 @@ public interface ViaVersionConfig {
|
||||
int getPistonReplacementId();
|
||||
|
||||
/**
|
||||
* Force json transform
|
||||
* Fix 1.9+ clients not rendering the far away chunks
|
||||
*
|
||||
* @return true if enabled
|
||||
* @return true to fix chunk borders
|
||||
*/
|
||||
boolean isForceJsonTransform();
|
||||
boolean isChunkBorderFix();
|
||||
|
||||
/**
|
||||
* Should we fix nbt array's in json chat messages for 1.12 clients
|
||||
@@ -250,6 +247,8 @@ public interface ViaVersionConfig {
|
||||
*/
|
||||
boolean is1_13TeamColourFix();
|
||||
|
||||
boolean shouldRegisterUserConnectionOnJoin();
|
||||
|
||||
/**
|
||||
* Should we fix shift quick move action for 1.12 clients
|
||||
*
|
||||
@@ -258,11 +257,11 @@ public interface ViaVersionConfig {
|
||||
boolean is1_12QuickMoveActionFix();
|
||||
|
||||
/**
|
||||
* Get the blocked protocols
|
||||
* API to check for blocked protocol versions.
|
||||
*
|
||||
* @return An Integer list
|
||||
* @return blocked protocol versions
|
||||
*/
|
||||
IntSet getBlockedProtocols();
|
||||
BlockedProtocolVersions blockedProtocolVersions();
|
||||
|
||||
/**
|
||||
* Get the custom disconnect message
|
||||
@@ -365,7 +364,7 @@ public interface ViaVersionConfig {
|
||||
boolean isTruncate1_14Books();
|
||||
|
||||
/**
|
||||
* Handles left handed info by using unused bit 7 on Client Settings packet
|
||||
* Handles left-handed info by using unused bit 7 on Client Settings packet
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
@@ -414,4 +413,48 @@ public interface ViaVersionConfig {
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isForcedUse1_17ResourcePack();
|
||||
|
||||
/**
|
||||
* Get the message that is sent when a user displays a resource pack prompt.
|
||||
*
|
||||
* @return cached serialized component
|
||||
*/
|
||||
JsonElement get1_17ResourcePackPrompt();
|
||||
|
||||
/***
|
||||
* Get the world names that should be returned for each Vanilla dimension.
|
||||
* Note that this can be overridden per-user by using {@link UserConnection#put(StorableObject)} with
|
||||
* a custom instance of {@link WorldIdentifiers} for the user's {@link UserConnection}.
|
||||
*
|
||||
* @return the global map from vanilla dimensions to world name
|
||||
*/
|
||||
WorldIdentifiers get1_16WorldNamesMap();
|
||||
|
||||
/**
|
||||
* Caches light until chunks are unloaded to allow subsequent chunk update packets as opposed to instantly uncaching when the first chunk data is sent.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean cache1_17Light();
|
||||
|
||||
/**
|
||||
* Force-update 1.19.4+ player's inventory when they try to swap armor in a pre-occupied slot.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isArmorToggleFix();
|
||||
|
||||
/**
|
||||
* If disabled, tamed cats will be displayed as ocelots to 1.14+ clients on 1.13 servers. Otherwise, ocelots (tamed and untamed) will be displayed as cats.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean translateOcelotToCat();
|
||||
|
||||
/**
|
||||
* Returns the value of the "enforce secure chat" setting sent to 1.19+ clients on join.
|
||||
*
|
||||
* @return the value sent to 1.19+ clients on join
|
||||
*/
|
||||
boolean enforceSecureChat();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,11 +22,10 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.connection;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Handles injected UserConnections
|
||||
@@ -66,7 +65,7 @@ public interface ConnectionManager {
|
||||
|
||||
/**
|
||||
* Returns the UUID from the frontend connection to this proxy server
|
||||
* Returns null when there isn't a server or this connection isn't frontend or it doesn't have an id
|
||||
* Returns null when there isn't a server or this connection isn't frontend, or it doesn't have an id
|
||||
* When ViaVersion is reloaded, this method may not return some players.
|
||||
* May not return ProtocolSupport players.
|
||||
* <p>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,10 +23,11 @@
|
||||
package com.viaversion.viaversion.api.connection;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
|
||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ProtocolInfo {
|
||||
|
||||
@@ -34,30 +35,95 @@ public interface ProtocolInfo {
|
||||
* Returns the protocol state the user is currently in.
|
||||
*
|
||||
* @return protocol state
|
||||
* @deprecated server and client can be in different states, use {@link #getClientState()} or {@link #getServerState()}
|
||||
*/
|
||||
State getState();
|
||||
|
||||
void setState(State state);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default State getState() {
|
||||
return this.getServerState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user's protocol version, or -1 if not set.
|
||||
* This is set during the {@link State#HANDSHAKE} state.
|
||||
* Returns the protocol state the client is currently in.
|
||||
*
|
||||
* @return protocol version, or -1 if not set
|
||||
* @return the client protocol state
|
||||
*/
|
||||
int getProtocolVersion();
|
||||
|
||||
void setProtocolVersion(int protocolVersion);
|
||||
State getClientState();
|
||||
|
||||
/**
|
||||
* Returns the server protocol version the user is connected to, or -1 if not set.
|
||||
* Returns the protocol state the server is currently in.
|
||||
*
|
||||
* @return the server protocol state
|
||||
*/
|
||||
State getServerState();
|
||||
|
||||
/**
|
||||
* Returns the protocol state for the given direction.
|
||||
*
|
||||
* @param direction protocol direction
|
||||
* @return state for the given direction
|
||||
*/
|
||||
default State getState(final Direction direction) {
|
||||
// Return the state the packet is coming from
|
||||
return direction == Direction.CLIENTBOUND ? this.getServerState() : this.getClientState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets both client and server state.
|
||||
*
|
||||
* @param state the new protocol state
|
||||
* @see #setClientState(State)
|
||||
* @see #setServerState(State)
|
||||
*/
|
||||
default void setState(final State state) {
|
||||
this.setClientState(state);
|
||||
this.setServerState(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the client protocol state.
|
||||
*
|
||||
* @param clientState the new client protocol state
|
||||
*/
|
||||
void setClientState(State clientState);
|
||||
|
||||
/**
|
||||
* Sets the server protocol state.
|
||||
*
|
||||
* @param serverState the new server protocol state
|
||||
*/
|
||||
void setServerState(State serverState);
|
||||
|
||||
/**
|
||||
* Returns the user's protocol version, or null if not set.
|
||||
* This is set during the {@link State#HANDSHAKE} state.
|
||||
*
|
||||
* @return server protocol version, or -1 if not set
|
||||
* @return protocol version, may be unknown
|
||||
* @see ProtocolVersion#isKnown()
|
||||
*/
|
||||
int getServerProtocolVersion();
|
||||
ProtocolVersion protocolVersion();
|
||||
|
||||
void setServerProtocolVersion(int serverProtocolVersion);
|
||||
void setProtocolVersion(ProtocolVersion protocolVersion);
|
||||
|
||||
/**
|
||||
* Returns the server protocol version the user is connected to.
|
||||
* This is set during the {@link State#HANDSHAKE} state.
|
||||
*
|
||||
* @return the server protocol version the user is connected to, may be unknown
|
||||
* @see ProtocolVersion#isKnown()
|
||||
*/
|
||||
ProtocolVersion serverProtocolVersion();
|
||||
|
||||
void setServerProtocolVersion(ProtocolVersion protocolVersion);
|
||||
|
||||
@Deprecated
|
||||
default int getProtocolVersion() {
|
||||
return protocolVersion() != null ? protocolVersion().getVersion() : -1;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default int getServerProtocolVersion() {
|
||||
return serverProtocolVersion() != null ? serverProtocolVersion().getVersion() : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the username associated with this connection.
|
||||
@@ -93,5 +159,6 @@ public interface ProtocolInfo {
|
||||
*
|
||||
* @return user connection
|
||||
*/
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
UserConnection getUser();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,4 +29,16 @@ package com.viaversion.viaversion.api.connection;
|
||||
* @see UserConnection#put(StorableObject)
|
||||
*/
|
||||
public interface StorableObject {
|
||||
|
||||
/**
|
||||
* Returns whether the object should be uncached on a server switch.
|
||||
*
|
||||
* @return whether the object should be uncached on a server switch
|
||||
*/
|
||||
default boolean clearOnServerSwitch() {
|
||||
return true;
|
||||
}
|
||||
|
||||
default void onRemove() {
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -32,12 +32,11 @@ import com.viaversion.viaversion.exception.InformativeException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface UserConnection {
|
||||
|
||||
@@ -58,6 +57,15 @@ public interface UserConnection {
|
||||
*/
|
||||
boolean has(Class<? extends StorableObject> objectClass);
|
||||
|
||||
/**
|
||||
* Removes and returns an object from the storage.
|
||||
*
|
||||
* @param objectClass class of the object to get
|
||||
* @param <T> type of the class you want to get
|
||||
* @return removed storable object if present
|
||||
*/
|
||||
@Nullable <T extends StorableObject> T remove(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Put an object into the stored objects based on class.
|
||||
*
|
||||
@@ -83,6 +91,7 @@ public interface UserConnection {
|
||||
|
||||
/**
|
||||
* Adds an entity tracker to the user connection.
|
||||
* Does not override existing entity trackers.
|
||||
*
|
||||
* @param protocolClass protocol class
|
||||
* @param tracker entity tracker
|
||||
@@ -90,10 +99,19 @@ public interface UserConnection {
|
||||
void addEntityTracker(Class<? extends Protocol> protocolClass, EntityTracker tracker);
|
||||
|
||||
/**
|
||||
* Clear all the stored objects.
|
||||
* Used for bungee when switching servers.
|
||||
* Clear stored objects and entity trackers.
|
||||
*/
|
||||
void clearStoredObjects();
|
||||
default void clearStoredObjects() {
|
||||
clearStoredObjects(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear stored objects and entity trackers.
|
||||
* If cleared for a proxy server switch, some stored objects and tracker data will be retained.
|
||||
*
|
||||
* @param isServerSwitch whether the clear is due to a server switch
|
||||
*/
|
||||
void clearStoredObjects(boolean isServerSwitch);
|
||||
|
||||
/**
|
||||
* Sends a raw packet to the connection on the current thread.
|
||||
@@ -291,12 +309,26 @@ public interface UserConnection {
|
||||
boolean isClientSide();
|
||||
|
||||
/**
|
||||
* Returns whether {@link ViaVersionConfig#getBlockedProtocols()} should be checked for this connection.
|
||||
* Returns whether {@link ViaVersionConfig#blockedProtocolVersions()} should be checked for this connection.
|
||||
*
|
||||
* @return whether blocked protocols should be applied
|
||||
*/
|
||||
boolean shouldApplyBlockProtocol();
|
||||
|
||||
/**
|
||||
* Returns whether the packet limiter applies to this user.
|
||||
*
|
||||
* @return whether the packet limiter applies to this user
|
||||
*/
|
||||
boolean isPacketLimiterEnabled();
|
||||
|
||||
/**
|
||||
* Sets the status of the packet limiter.
|
||||
*
|
||||
* @param packetLimiterEnabled whether the packet limiter should be enabled
|
||||
*/
|
||||
void setPacketLimiterEnabled(boolean packetLimiterEnabled);
|
||||
|
||||
/**
|
||||
* Returns a newly generated uuid that will let a packet be passed through without
|
||||
* transformig its contents if used together with {@link PacketWrapper#PASSTHROUGH_ID}.
|
||||
|
||||
+16
-16
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,23 +20,23 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.type.types.minecraft;
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public abstract class BaseItemType extends Type<Item> {
|
||||
|
||||
protected BaseItemType() {
|
||||
super(Item.class);
|
||||
}
|
||||
|
||||
protected BaseItemType(String typeName) {
|
||||
super(typeName, Item.class);
|
||||
}
|
||||
public interface BiMappings extends Mappings {
|
||||
|
||||
/**
|
||||
* Returns the inverse of the bimappings.
|
||||
*
|
||||
* @return inverse of the bimappings
|
||||
*/
|
||||
@Override
|
||||
public Class<? extends Type> getBaseClass() {
|
||||
return BaseItemType.class;
|
||||
BiMappings inverse();
|
||||
|
||||
static BiMappings of(final Mappings mappings) {
|
||||
return of(mappings, mappings.inverse());
|
||||
}
|
||||
|
||||
static BiMappings of(final Mappings mappings, final Mappings inverse) {
|
||||
return new BiMappingsBase(mappings, inverse);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
public class BiMappingsBase implements BiMappings {
|
||||
|
||||
protected final Mappings mappings;
|
||||
private final BiMappingsBase inverse;
|
||||
|
||||
protected BiMappingsBase(final Mappings mappings, final Mappings inverse) {
|
||||
this.mappings = mappings;
|
||||
this.inverse = new BiMappingsBase(inverse, this);
|
||||
}
|
||||
|
||||
private BiMappingsBase(final Mappings mappings, final BiMappingsBase inverse) {
|
||||
this.mappings = mappings;
|
||||
this.inverse = inverse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(final int id) {
|
||||
return mappings.getNewId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(final int id, final int mappedId) {
|
||||
mappings.setNewId(id, mappedId);
|
||||
inverse.mappings.setNewId(mappedId, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mappings.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappings.mappedSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiMappings inverse() {
|
||||
return this.inverse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Mappings containing the full string identifier mappings.
|
||||
*/
|
||||
public interface FullMappings extends BiMappings {
|
||||
|
||||
/**
|
||||
* Returns the unmapped integer id for the given identifier, or -1 if not found.
|
||||
*
|
||||
* @param identifier unmapped string identifier
|
||||
* @return unmapped int id, or -1 if not found
|
||||
*/
|
||||
int id(String identifier);
|
||||
|
||||
/**
|
||||
* Returns the mapped integer id for the given mapped identifier, or -1 if not found.
|
||||
*
|
||||
* @param mappedIdentifier mapped string identifier
|
||||
* @return mapped int id, or -1 if not found
|
||||
*/
|
||||
int mappedId(String mappedIdentifier);
|
||||
|
||||
/**
|
||||
* Returns the unmapped string identifier for the given mapped id.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @return unmapped string identifier, or null if out of bounds
|
||||
*/
|
||||
@Nullable String identifier(int id);
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given mapped id.
|
||||
*
|
||||
* @param mappedId mapped id
|
||||
* @return mapped string identifier, or null if out of bounds
|
||||
*/
|
||||
@Nullable String mappedIdentifier(int mappedId);
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given unmapped identifier.
|
||||
*
|
||||
* @param identifier unmapped identifier
|
||||
* @return mapped string identifier, or null if not found
|
||||
*/
|
||||
@Nullable String mappedIdentifier(String identifier);
|
||||
|
||||
@Override
|
||||
FullMappings inverse();
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class FullMappingsBase implements FullMappings {
|
||||
private static final String[] EMPTY_ARRAY = new String[0];
|
||||
private final Object2IntMap<String> stringToId;
|
||||
private final Object2IntMap<String> mappedStringToId;
|
||||
private final String[] idToString;
|
||||
private final String[] mappedIdToString;
|
||||
private final Mappings mappings;
|
||||
|
||||
public FullMappingsBase(final List<String> unmappedIdentifiers, final List<String> mappedIdentifiers, final Mappings mappings) {
|
||||
Preconditions.checkNotNull(mappings, "Mappings cannot be null");
|
||||
this.mappings = mappings;
|
||||
this.stringToId = toInverseMap(unmappedIdentifiers);
|
||||
this.mappedStringToId = toInverseMap(mappedIdentifiers);
|
||||
this.idToString = unmappedIdentifiers.toArray(EMPTY_ARRAY);
|
||||
this.mappedIdToString = mappedIdentifiers.toArray(EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
private FullMappingsBase(final Object2IntMap<String> stringToId, final Object2IntMap<String> mappedStringToId, final String[] idToString, final String[] mappedIdToString, final Mappings mappings) {
|
||||
this.stringToId = stringToId;
|
||||
this.mappedStringToId = mappedStringToId;
|
||||
this.idToString = idToString;
|
||||
this.mappedIdToString = mappedIdToString;
|
||||
this.mappings = mappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id(final String identifier) {
|
||||
return stringToId.getInt(Key.stripMinecraftNamespace(identifier));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedId(final String mappedIdentifier) {
|
||||
return mappedStringToId.getInt(Key.stripMinecraftNamespace(mappedIdentifier));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifier(final int id) {
|
||||
if (id < 0 || id >= idToString.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String identifier = idToString[id];
|
||||
return Key.namespaced(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mappedIdentifier(final int mappedId) {
|
||||
if (mappedId < 0 || mappedId >= mappedIdToString.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String identifier = mappedIdToString[mappedId];
|
||||
return Key.namespaced(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String mappedIdentifier(final String identifier) {
|
||||
final int id = id(identifier);
|
||||
if (id == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int mappedId = mappings.getNewId(id);
|
||||
return mappedId != -1 ? mappedIdentifier(mappedId) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(int id) {
|
||||
return mappings.getNewId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(int id, int mappedId) {
|
||||
mappings.setNewId(id, mappedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mappings.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappings.mappedSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FullMappings inverse() {
|
||||
return new FullMappingsBase(mappedStringToId, stringToId, mappedIdToString, idToString, mappings.inverse());
|
||||
}
|
||||
|
||||
private static Object2IntMap<String> toInverseMap(final List<String> list) {
|
||||
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(list.size());
|
||||
map.defaultReturnValue(-1);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
map.put(list.get(i), i);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
public class IdentityMappings implements Mappings {
|
||||
|
||||
private final int size;
|
||||
private final int mappedSize;
|
||||
|
||||
public IdentityMappings(final int size, final int mappedSize) {
|
||||
this.size = size;
|
||||
this.mappedSize = mappedSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(final int id) {
|
||||
return id >= 0 && id < size ? id : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(final int id, final int mappedId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappedSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mappings inverse() {
|
||||
return new IdentityMappings(mappedSize, size);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.viaversion.util.Int2IntBiMap;
|
||||
|
||||
public class Int2IntMapBiMappings implements BiMappings {
|
||||
|
||||
private final Int2IntBiMap mappings;
|
||||
private final Int2IntMapBiMappings inverse;
|
||||
|
||||
protected Int2IntMapBiMappings(final Int2IntBiMap mappings) {
|
||||
this.mappings = mappings;
|
||||
this.inverse = new Int2IntMapBiMappings(mappings.inverse(), this);
|
||||
mappings.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
private Int2IntMapBiMappings(final Int2IntBiMap mappings, final Int2IntMapBiMappings inverse) {
|
||||
this.mappings = mappings;
|
||||
this.inverse = inverse;
|
||||
}
|
||||
|
||||
public static Int2IntMapBiMappings of(final Int2IntBiMap mappings) {
|
||||
return new Int2IntMapBiMappings(mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(final int id) {
|
||||
return mappings.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(final int id, final int mappedId) {
|
||||
mappings.put(id, mappedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mappings.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappings.inverse().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiMappings inverse() {
|
||||
return this.inverse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class Int2IntMapMappings implements Mappings {
|
||||
private final Int2IntMap mappings;
|
||||
private final int mappedIds;
|
||||
|
||||
protected Int2IntMapMappings(final Int2IntMap mappings, final int mappedIds) {
|
||||
this.mappings = mappings;
|
||||
this.mappedIds = mappedIds;
|
||||
mappings.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
public static Int2IntMapMappings of(final Int2IntMap mappings, final int mappedIds) {
|
||||
return new Int2IntMapMappings(mappings, mappedIds);
|
||||
}
|
||||
|
||||
public static Int2IntMapMappings of() {
|
||||
return new Int2IntMapMappings(new Int2IntOpenHashMap(), -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(final int id) {
|
||||
return mappings.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(final int id, final int mappedId) {
|
||||
mappings.put(id, mappedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mappings.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappedIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mappings inverse() {
|
||||
final Int2IntMap inverse = new Int2IntOpenHashMap();
|
||||
inverse.defaultReturnValue(-1);
|
||||
for (final Int2IntMap.Entry entry : mappings.int2IntEntrySet()) {
|
||||
if (entry.getIntValue() != -1) {
|
||||
inverse.putIfAbsent(entry.getIntValue(), entry.getIntKey());
|
||||
}
|
||||
}
|
||||
return of(inverse, size());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,101 +22,55 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class IntArrayMappings implements Mappings {
|
||||
protected final int[] oldToNew;
|
||||
private final int[] mappings;
|
||||
private final int mappedIds;
|
||||
|
||||
public IntArrayMappings(int[] oldToNew) {
|
||||
this.oldToNew = oldToNew;
|
||||
protected IntArrayMappings(final int[] mappings, final int mappedIds) {
|
||||
this.mappings = mappings;
|
||||
this.mappedIds = mappedIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps old identifiers to the new ones.
|
||||
* If an old value cannot be found in the new mappings, the diffmapping will be checked for the given entry.
|
||||
*
|
||||
* @param size set size of the underlying short array
|
||||
* @param oldMapping mappings to map from
|
||||
* @param newMapping mappings to map to
|
||||
* @param diffMapping extra mappings that will be used/scanned when an entry cannot be found
|
||||
*/
|
||||
public IntArrayMappings(int size, JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
|
||||
oldToNew = new int[size];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping);
|
||||
}
|
||||
|
||||
public IntArrayMappings(JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
|
||||
this(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps old identifiers to the new ones.
|
||||
*
|
||||
* @param size set size of the underlying short array
|
||||
* @param oldMapping mappings to map from
|
||||
* @param newMapping mappings to map to
|
||||
*/
|
||||
public IntArrayMappings(int size, JsonObject oldMapping, JsonObject newMapping) {
|
||||
oldToNew = new int[size];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping);
|
||||
}
|
||||
|
||||
public IntArrayMappings(JsonObject oldMapping, JsonObject newMapping) {
|
||||
this(oldMapping.entrySet().size(), oldMapping, newMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps old identifiers to the new ones.
|
||||
*
|
||||
* @param size set size of the underlying short array
|
||||
* @param oldMapping mappings to map from
|
||||
* @param newMapping mappings to map to
|
||||
* @param diffMapping extra mappings that will be used/scanned when an entry cannot be found
|
||||
* @param warnOnMissing should "No key for x" be printed if there is no matching identifier
|
||||
*/
|
||||
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
oldToNew = new int[size];
|
||||
Arrays.fill(oldToNew, -1);
|
||||
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing);
|
||||
}
|
||||
|
||||
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
|
||||
this(size, oldMapping, newMapping, null, warnOnMissing);
|
||||
}
|
||||
|
||||
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
|
||||
this(oldMapping.size(), oldMapping, newMapping, warnOnMissing);
|
||||
}
|
||||
|
||||
public IntArrayMappings(int size, JsonArray oldMapping, JsonArray newMapping) {
|
||||
this(size, oldMapping, newMapping, true);
|
||||
}
|
||||
|
||||
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping) {
|
||||
this(oldMapping.size(), oldMapping, newMapping, diffMapping, true);
|
||||
}
|
||||
|
||||
public IntArrayMappings(JsonArray oldMapping, JsonArray newMapping) {
|
||||
this(oldMapping.size(), oldMapping, newMapping, true);
|
||||
public static IntArrayMappings of(final int[] mappings, final int mappedIds) {
|
||||
return new IntArrayMappings(mappings, mappedIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(int id) {
|
||||
return id >= 0 && id < oldToNew.length ? oldToNew[id] : -1;
|
||||
return id >= 0 && id < mappings.length ? mappings[id] : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewId(int id, int newId) {
|
||||
oldToNew[id] = newId;
|
||||
public void setNewId(int id, int mappedId) {
|
||||
mappings[id] = mappedId;
|
||||
}
|
||||
|
||||
public int[] getOldToNew() {
|
||||
return oldToNew;
|
||||
@Override
|
||||
public int size() {
|
||||
return mappings.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mappedSize() {
|
||||
return mappedIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mappings inverse() {
|
||||
final int[] inverse = new int[mappedIds];
|
||||
Arrays.fill(inverse, -1);
|
||||
for (int id = 0; id < mappings.length; id++) {
|
||||
final int mappedId = mappings[id];
|
||||
if (mappedId != -1 && inverse[mappedId] == -1) {
|
||||
inverse[mappedId] = id;
|
||||
}
|
||||
}
|
||||
return of(inverse, mappings.length);
|
||||
}
|
||||
|
||||
public int[] raw() {
|
||||
return mappings;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,10 +24,8 @@ package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.TagData;
|
||||
import com.viaversion.viaversion.util.Int2IntBiMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface MappingData {
|
||||
|
||||
@@ -81,6 +79,8 @@ public interface MappingData {
|
||||
*/
|
||||
int getNewParticleId(int id);
|
||||
|
||||
int getNewAttributeId(int id);
|
||||
|
||||
/**
|
||||
* Returns a list of tags to send if present.
|
||||
*
|
||||
@@ -89,15 +89,46 @@ public interface MappingData {
|
||||
*/
|
||||
@Nullable List<TagData> getTags(RegistryType type);
|
||||
|
||||
@Nullable Int2IntBiMap getItemMappings();
|
||||
/**
|
||||
* Returns item mappings.
|
||||
*
|
||||
* @return item mappings
|
||||
*/
|
||||
@Nullable BiMappings getItemMappings();
|
||||
|
||||
/**
|
||||
* Returns item mappings if they also have identifier data present.
|
||||
*
|
||||
* @return item mappings if they also have identifier data present
|
||||
* @see #getItemMappings()
|
||||
*/
|
||||
@Nullable FullMappings getFullItemMappings();
|
||||
|
||||
@Nullable ParticleMappings getParticleMappings();
|
||||
|
||||
@Nullable Mappings getBlockMappings();
|
||||
|
||||
@Nullable Mappings getBlockEntityMappings();
|
||||
|
||||
@Nullable Mappings getBlockStateMappings();
|
||||
|
||||
@Nullable Mappings getSoundMappings();
|
||||
|
||||
@Nullable Mappings getStatisticsMappings();
|
||||
|
||||
@Nullable Mappings getMenuMappings();
|
||||
|
||||
@Nullable Mappings getEnchantmentMappings();
|
||||
|
||||
@Nullable Mappings getAttributeMappings();
|
||||
|
||||
@Nullable Mappings getPaintingMappings();
|
||||
|
||||
@Nullable FullMappings getEntityMappings();
|
||||
|
||||
@Nullable FullMappings getArgumentTypeMappings();
|
||||
|
||||
@Nullable FullMappings getRecipeSerializerMappings();
|
||||
|
||||
@Nullable FullMappings getDataComponentSerializerMappings();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,143 +22,199 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.TagData;
|
||||
import com.viaversion.viaversion.util.Int2IntBiHashMap;
|
||||
import com.viaversion.viaversion.util.Int2IntBiMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class MappingDataBase implements MappingData {
|
||||
protected final String oldVersion;
|
||||
protected final String newVersion;
|
||||
protected final boolean hasDiffFile;
|
||||
protected Int2IntBiMap itemMappings;
|
||||
|
||||
protected final String unmappedVersion;
|
||||
protected final String mappedVersion;
|
||||
protected BiMappings itemMappings;
|
||||
protected FullMappings argumentTypeMappings;
|
||||
protected FullMappings entityMappings;
|
||||
protected FullMappings recipeSerializerMappings;
|
||||
protected FullMappings itemDataSerializerMappings;
|
||||
protected ParticleMappings particleMappings;
|
||||
protected Mappings blockMappings;
|
||||
protected Mappings blockStateMappings;
|
||||
protected Mappings blockEntityMappings;
|
||||
protected Mappings soundMappings;
|
||||
protected Mappings statisticsMappings;
|
||||
protected Mappings enchantmentMappings;
|
||||
protected Mappings paintingMappings;
|
||||
protected Mappings menuMappings;
|
||||
protected Mappings attributeMappings;
|
||||
protected Map<RegistryType, List<TagData>> tags;
|
||||
protected boolean loadItems = true;
|
||||
|
||||
public MappingDataBase(String oldVersion, String newVersion) {
|
||||
this(oldVersion, newVersion, false);
|
||||
}
|
||||
|
||||
public MappingDataBase(String oldVersion, String newVersion, boolean hasDiffFile) {
|
||||
this.oldVersion = oldVersion;
|
||||
this.newVersion = newVersion;
|
||||
this.hasDiffFile = hasDiffFile;
|
||||
public MappingDataBase(final String unmappedVersion, final String mappedVersion) {
|
||||
this.unmappedVersion = unmappedVersion;
|
||||
this.mappedVersion = mappedVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
getLogger().info("Loading " + oldVersion + " -> " + newVersion + " mappings...");
|
||||
JsonObject diffmapping = hasDiffFile ? loadDiffFile() : null;
|
||||
JsonObject oldMappings = MappingDataLoader.loadData("mapping-" + oldVersion + ".json", true);
|
||||
JsonObject newMappings = MappingDataLoader.loadData("mapping-" + newVersion + ".json", true);
|
||||
|
||||
blockMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blocks");
|
||||
blockStateMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blockstates");
|
||||
soundMappings = loadFromArray(oldMappings, newMappings, diffmapping, "sounds");
|
||||
statisticsMappings = loadFromArray(oldMappings, newMappings, diffmapping, "statistics");
|
||||
|
||||
Mappings particles = loadFromArray(oldMappings, newMappings, diffmapping, "particles");
|
||||
if (particles != null) {
|
||||
particleMappings = new ParticleMappings(oldMappings.getAsJsonArray("particles"), particles);
|
||||
if (Via.getManager().isDebug()) {
|
||||
getLogger().info("Loading " + unmappedVersion + " -> " + mappedVersion + " mappings...");
|
||||
}
|
||||
|
||||
if (loadItems && newMappings.has("items")) {
|
||||
itemMappings = new Int2IntBiHashMap();
|
||||
itemMappings.defaultReturnValue(-1);
|
||||
MappingDataLoader.mapIdentifiers(itemMappings, oldMappings.getAsJsonObject("items"), newMappings.getAsJsonObject("items"),
|
||||
diffmapping != null ? diffmapping.getAsJsonObject("items") : null);
|
||||
final CompoundTag data = readMappingsFile("mappings-" + unmappedVersion + "to" + mappedVersion + ".nbt");
|
||||
blockMappings = loadMappings(data, "blocks");
|
||||
blockStateMappings = loadMappings(data, "blockstates");
|
||||
blockEntityMappings = loadMappings(data, "blockentities");
|
||||
soundMappings = loadMappings(data, "sounds");
|
||||
statisticsMappings = loadMappings(data, "statistics");
|
||||
menuMappings = loadMappings(data, "menus");
|
||||
enchantmentMappings = loadMappings(data, "enchantments");
|
||||
paintingMappings = loadMappings(data, "paintings");
|
||||
attributeMappings = loadMappings(data, "attributes");
|
||||
|
||||
|
||||
final CompoundTag unmappedIdentifierData = readUnmappedIdentifiersFile("identifiers-" + unmappedVersion + ".nbt");
|
||||
final CompoundTag mappedIdentifierData = readMappedIdentifiersFile("identifiers-" + mappedVersion + ".nbt");
|
||||
if (unmappedIdentifierData != null && mappedIdentifierData != null) {
|
||||
itemMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "items");
|
||||
entityMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "entities");
|
||||
argumentTypeMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "argumenttypes");
|
||||
recipeSerializerMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "recipe_serializers");
|
||||
itemDataSerializerMappings = loadFullMappings(data, unmappedIdentifierData, mappedIdentifierData, "data_component_type");
|
||||
|
||||
final List<String> unmappedParticles = identifiersFromGlobalIds(unmappedIdentifierData, "particles");
|
||||
final List<String> mappedParticles = identifiersFromGlobalIds(mappedIdentifierData, "particles");
|
||||
if (unmappedParticles != null && mappedParticles != null) {
|
||||
Mappings particleMappings = loadMappings(data, "particles");
|
||||
if (particleMappings == null) {
|
||||
particleMappings = new IdentityMappings(unmappedParticles.size(), mappedParticles.size());
|
||||
}
|
||||
this.particleMappings = new ParticleMappings(unmappedParticles, mappedParticles, particleMappings);
|
||||
}
|
||||
} else {
|
||||
// Might not have identifiers in older versions
|
||||
itemMappings = loadBiMappings(data, "items");
|
||||
}
|
||||
|
||||
if (diffmapping != null && diffmapping.has("tags")) {
|
||||
final CompoundTag tagsTag = data.getCompoundTag("tags");
|
||||
if (tagsTag != null) {
|
||||
this.tags = new EnumMap<>(RegistryType.class);
|
||||
JsonObject tags = diffmapping.getAsJsonObject("tags");
|
||||
if (tags.has(RegistryType.ITEM.getResourceLocation())) {
|
||||
loadTags(RegistryType.ITEM, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("items")));
|
||||
}
|
||||
if (tags.has(RegistryType.BLOCK.getResourceLocation())) {
|
||||
loadTags(RegistryType.BLOCK, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("blocks")));
|
||||
}
|
||||
loadTags(RegistryType.ITEM, tagsTag);
|
||||
loadTags(RegistryType.BLOCK, tagsTag);
|
||||
}
|
||||
|
||||
loadExtras(oldMappings, newMappings, diffmapping);
|
||||
loadExtras(data);
|
||||
}
|
||||
|
||||
private void loadTags(RegistryType type, JsonObject object, Object2IntMap<String> typeMapping) {
|
||||
JsonObject tags = object.getAsJsonObject(type.getResourceLocation());
|
||||
List<TagData> tagsList = new ArrayList<>(tags.size());
|
||||
for (Map.Entry<String, JsonElement> entry : tags.entrySet()) {
|
||||
JsonArray array = entry.getValue().getAsJsonArray();
|
||||
int[] entries = new int[array.size()];
|
||||
int i = 0;
|
||||
for (JsonElement element : array) {
|
||||
String stringId = element.getAsString();
|
||||
if (!typeMapping.containsKey(stringId) && !typeMapping.containsKey(stringId = stringId.replace("minecraft:", ""))) { // aaa
|
||||
getLogger().warning(type + " Tags contains invalid type identifier " + stringId + " in tag " + entry.getKey());
|
||||
continue;
|
||||
}
|
||||
protected @Nullable List<String> identifiersFromGlobalIds(final CompoundTag mappingsTag, final String key) {
|
||||
return MappingDataLoader.INSTANCE.identifiersFromGlobalIds(mappingsTag, key);
|
||||
}
|
||||
|
||||
entries[i++] = typeMapping.getInt(stringId);
|
||||
}
|
||||
tagsList.add(new TagData(entry.getKey(), entries));
|
||||
protected @Nullable CompoundTag readMappingsFile(final String name) {
|
||||
return MappingDataLoader.INSTANCE.loadNBT(name);
|
||||
}
|
||||
|
||||
protected @Nullable CompoundTag readUnmappedIdentifiersFile(final String name) {
|
||||
return MappingDataLoader.INSTANCE.loadNBT(name, true);
|
||||
}
|
||||
|
||||
protected @Nullable CompoundTag readMappedIdentifiersFile(final String name) {
|
||||
return MappingDataLoader.INSTANCE.loadNBT(name, true);
|
||||
}
|
||||
|
||||
protected @Nullable Mappings loadMappings(final CompoundTag data, final String key) {
|
||||
return MappingDataLoader.INSTANCE.loadMappings(data, key);
|
||||
}
|
||||
|
||||
protected @Nullable FullMappings loadFullMappings(final CompoundTag data, final CompoundTag unmappedIdentifiersTag, final CompoundTag mappedIdentifiersTag, final String key) {
|
||||
if (!unmappedIdentifiersTag.contains(key) || !mappedIdentifiersTag.contains(key)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<String> unmappedIdentifiers = identifiersFromGlobalIds(unmappedIdentifiersTag, key);
|
||||
final List<String> mappedIdentifiers = identifiersFromGlobalIds(mappedIdentifiersTag, key);
|
||||
Mappings mappings = loadBiMappings(data, key); // Load as bi-mappings to keep the inverse cached
|
||||
if (mappings == null) {
|
||||
mappings = new IdentityMappings(unmappedIdentifiers.size(), mappedIdentifiers.size());
|
||||
}
|
||||
|
||||
return new FullMappingsBase(unmappedIdentifiers, mappedIdentifiers, mappings);
|
||||
}
|
||||
|
||||
protected @Nullable BiMappings loadBiMappings(final CompoundTag data, final String key) {
|
||||
final Mappings mappings = loadMappings(data, key);
|
||||
return mappings != null ? BiMappings.of(mappings) : null;
|
||||
}
|
||||
|
||||
private void loadTags(final RegistryType type, final CompoundTag data) {
|
||||
final CompoundTag tag = data.getCompoundTag(type.resourceLocation());
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<TagData> tagsList = new ArrayList<>(tags.size());
|
||||
for (final Map.Entry<String, Tag> entry : tag.entrySet()) {
|
||||
final IntArrayTag entries = (IntArrayTag) entry.getValue();
|
||||
tagsList.add(new TagData(entry.getKey(), entries.getValue()));
|
||||
}
|
||||
|
||||
this.tags.put(type, tagsList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewBlockStateId(int id) {
|
||||
public int getNewBlockStateId(final int id) {
|
||||
return checkValidity(id, blockStateMappings.getNewId(id), "blockstate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewBlockId(int id) {
|
||||
public int getNewBlockId(final int id) {
|
||||
return checkValidity(id, blockMappings.getNewId(id), "block");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewItemId(int id) {
|
||||
return checkValidity(id, itemMappings.get(id), "item");
|
||||
public int getNewItemId(final int id) {
|
||||
return checkValidity(id, itemMappings.getNewId(id), "item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOldItemId(int id) {
|
||||
int oldId = itemMappings.inverse().get(id);
|
||||
// Remap new items to stone
|
||||
return oldId != -1 ? oldId : 1;
|
||||
public int getOldItemId(final int id) {
|
||||
return itemMappings.inverse().getNewIdOrDefault(id, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewParticleId(int id) {
|
||||
return checkValidity(id, particleMappings.getMappings().getNewId(id), "particles");
|
||||
public int getNewParticleId(final int id) {
|
||||
return checkValidity(id, particleMappings.getNewId(id), "particles");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<TagData> getTags(RegistryType type) {
|
||||
public int getNewAttributeId(final int id) {
|
||||
return checkValidity(id, attributeMappings.getNewId(id), "attributes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<TagData> getTags(final RegistryType type) {
|
||||
return tags != null ? tags.get(type) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Int2IntBiMap getItemMappings() {
|
||||
public @Nullable BiMappings getItemMappings() {
|
||||
return itemMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getFullItemMappings() {
|
||||
if (itemMappings instanceof FullMappings) {
|
||||
return (FullMappings) itemMappings;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ParticleMappings getParticleMappings() {
|
||||
return particleMappings;
|
||||
@@ -169,6 +225,11 @@ public class MappingDataBase implements MappingData {
|
||||
return blockMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getBlockEntityMappings() {
|
||||
return blockEntityMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getBlockStateMappings() {
|
||||
return blockStateMappings;
|
||||
@@ -184,22 +245,44 @@ public class MappingDataBase implements MappingData {
|
||||
return statisticsMappings;
|
||||
}
|
||||
|
||||
protected @Nullable Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return new IntArrayMappings(oldMappings.getAsJsonArray(key), newMappings.getAsJsonArray(key), diff);
|
||||
@Override
|
||||
public @Nullable Mappings getMenuMappings() {
|
||||
return menuMappings;
|
||||
}
|
||||
|
||||
protected @Nullable Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return new IntArrayMappings(oldMappings.getAsJsonObject(key), newMappings.getAsJsonObject(key), diff);
|
||||
@Override
|
||||
public @Nullable Mappings getEnchantmentMappings() {
|
||||
return enchantmentMappings;
|
||||
}
|
||||
|
||||
protected @Nullable JsonObject loadDiffFile() {
|
||||
return MappingDataLoader.loadData("mappingdiff-" + oldVersion + "to" + newVersion + ".json");
|
||||
@Override
|
||||
public @Nullable Mappings getAttributeMappings() {
|
||||
return attributeMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getEntityMappings() {
|
||||
return entityMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getArgumentTypeMappings() {
|
||||
return argumentTypeMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getDataComponentSerializerMappings() {
|
||||
return itemDataSerializerMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getPaintingMappings() {
|
||||
return paintingMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getRecipeSerializerMappings() {
|
||||
return recipeSerializerMappings;
|
||||
}
|
||||
|
||||
protected Logger getLogger() {
|
||||
@@ -214,21 +297,16 @@ public class MappingDataBase implements MappingData {
|
||||
* @param type mapping type (e.g. "item")
|
||||
* @return the given mapped id if valid, else 0
|
||||
*/
|
||||
protected int checkValidity(int id, int mappedId, String type) {
|
||||
protected int checkValidity(final int id, final int mappedId, final String type) {
|
||||
if (mappedId == -1) {
|
||||
getLogger().warning(String.format("Missing %s %s for %s %s %d", newVersion, type, oldVersion, type, id));
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
getLogger().warning(String.format("Missing %s %s for %s %s %d", mappedVersion, type, unmappedVersion, type, id));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return mappedId;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be overridden.
|
||||
*
|
||||
* @param oldMappings old mappings
|
||||
* @param newMappings new mappings
|
||||
* @param diffMappings diff mappings if present
|
||||
*/
|
||||
protected void loadExtras(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings) {
|
||||
protected void loadExtras(final CompoundTag data) {
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,6 +22,16 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.github.steveice10.opennbt.tag.io.NBTIO;
|
||||
import com.github.steveice10.opennbt.tag.io.TagReader;
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonIOException;
|
||||
@@ -29,46 +39,79 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
import com.viaversion.viaversion.util.Int2IntBiMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class MappingDataLoader {
|
||||
|
||||
private static final Map<String, JsonObject> MAPPINGS_CACHE = new ConcurrentHashMap<>();
|
||||
private static boolean cacheJsonMappings;
|
||||
public static final MappingDataLoader INSTANCE = new MappingDataLoader(MappingDataLoader.class, "assets/viaversion/data/");
|
||||
public static final TagReader<CompoundTag> MAPPINGS_READER = NBTIO.reader(CompoundTag.class).named();
|
||||
private static final Map<String, String[]> GLOBAL_IDENTIFIER_INDEXES = new HashMap<>();
|
||||
private static final byte DIRECT_ID = 0;
|
||||
private static final byte SHIFTS_ID = 1;
|
||||
private static final byte CHANGES_ID = 2;
|
||||
private static final byte IDENTITY_ID = 3;
|
||||
|
||||
/**
|
||||
* Returns true if a selected number of mappings should be cached.
|
||||
* If enabled, cleanup should be done after the cache is no longer needed.
|
||||
*
|
||||
* @return true if mappings should be cached
|
||||
*/
|
||||
public static boolean isCacheJsonMappings() {
|
||||
return cacheJsonMappings;
|
||||
private final Map<String, CompoundTag> mappingsCache = new HashMap<>();
|
||||
private final Class<?> dataLoaderClass;
|
||||
private final String dataPath;
|
||||
private boolean cacheValid = true;
|
||||
|
||||
public MappingDataLoader(final Class<?> dataLoaderClass, final String dataPath) {
|
||||
this.dataLoaderClass = dataLoaderClass;
|
||||
this.dataPath = dataPath;
|
||||
}
|
||||
|
||||
public static void enableMappingsCache() {
|
||||
cacheJsonMappings = true;
|
||||
public static void loadGlobalIdentifiers() {
|
||||
// Load in a file with all the identifiers we need, so that we don't need to duplicate them
|
||||
// for every single new version with only a couple of changes in them.
|
||||
final CompoundTag globalIdentifiers = INSTANCE.loadNBT("identifier-table.nbt");
|
||||
for (final Map.Entry<String, Tag> entry : globalIdentifiers.entrySet()) {
|
||||
//noinspection unchecked
|
||||
final ListTag<StringTag> value = (ListTag<StringTag>) entry.getValue();
|
||||
final String[] array = new String[value.size()];
|
||||
for (int i = 0, size = value.size(); i < size; i++) {
|
||||
array[i] = value.get(i).getValue();
|
||||
}
|
||||
GLOBAL_IDENTIFIER_INDEXES.put(entry.getKey(), array);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cached mappings. Cleared after ViaVersion has been fully loaded.
|
||||
* Returns the global id of the identifier in the registry.
|
||||
*
|
||||
* @return cached mapping file json objects
|
||||
* @see #isCacheJsonMappings()
|
||||
* @param registry registry key
|
||||
* @param globalId global id
|
||||
* @return identifier
|
||||
* @throws IllegalArgumentException if the registry key is invalid
|
||||
*/
|
||||
public static Map<String, JsonObject> getMappingsCache() {
|
||||
return MAPPINGS_CACHE;
|
||||
public @Nullable String identifierFromGlobalId(final String registry, final int globalId) {
|
||||
final String[] array = GLOBAL_IDENTIFIER_INDEXES.get(registry);
|
||||
if (array == null) {
|
||||
throw new IllegalArgumentException("Unknown global identifier key: " + registry);
|
||||
}
|
||||
if (globalId < 0 || globalId >= array.length) {
|
||||
throw new IllegalArgumentException("Unknown global identifier index: " + globalId);
|
||||
}
|
||||
return array[globalId];
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
mappingsCache.clear();
|
||||
cacheValid = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,138 +119,173 @@ public class MappingDataLoader {
|
||||
*
|
||||
* @return loaded json object, or null if not found or invalid
|
||||
*/
|
||||
public static @Nullable JsonObject loadFromDataDir(String name) {
|
||||
File file = new File(Via.getPlatform().getDataFolder(), name);
|
||||
if (!file.exists()) return loadData(name);
|
||||
public @Nullable JsonObject loadFromDataDir(final String name) {
|
||||
final File file = new File(getDataFolder(), name);
|
||||
if (!file.exists()) {
|
||||
return loadData(name);
|
||||
}
|
||||
|
||||
// Load the file from the platform's directory if present
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
try (final FileReader reader = new FileReader(file)) {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
} catch (final JsonSyntaxException e) {
|
||||
// Users might mess up the format, so let's catch the syntax error
|
||||
Via.getPlatform().getLogger().warning(name + " is badly formatted!");
|
||||
e.printStackTrace();
|
||||
} catch (IOException | JsonIOException e) {
|
||||
e.printStackTrace();
|
||||
getLogger().warning(name + " is badly formatted!");
|
||||
throw new RuntimeException(e);
|
||||
} catch (final IOException | JsonIOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the file from the bundled resources. Uses the cache if enabled.
|
||||
* Loads the file from the bundled resources.
|
||||
*
|
||||
* @return loaded json object from bundled resources if present
|
||||
*/
|
||||
public static @Nullable JsonObject loadData(String name) {
|
||||
return loadData(name, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the file from the bundled resources. Uses the cache if enabled.
|
||||
*
|
||||
* @param cacheIfEnabled whether loaded files should be cached
|
||||
* @return loaded json object from bundled resources if present
|
||||
*/
|
||||
public static @Nullable JsonObject loadData(String name, boolean cacheIfEnabled) {
|
||||
if (cacheJsonMappings) {
|
||||
JsonObject cached = MAPPINGS_CACHE.get(name);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
public @Nullable JsonObject loadData(final String name) {
|
||||
final InputStream stream = getResource(name);
|
||||
if (stream == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
InputStream stream = getResource(name);
|
||||
if (stream == null) return null;
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(stream);
|
||||
try {
|
||||
JsonObject object = GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
if (cacheIfEnabled && cacheJsonMappings) {
|
||||
MAPPINGS_CACHE.put(name, object);
|
||||
}
|
||||
return object;
|
||||
} finally {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException ignored) {
|
||||
// Ignored
|
||||
}
|
||||
try (final InputStreamReader reader = new InputStreamReader(stream)) {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(Int2IntBiMap output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||
int value = mapIdentifierEntry(entry, newIdentifierMap, diffIdentifiers);
|
||||
if (value != -1) {
|
||||
output.put(Integer.parseInt(entry.getKey()), value);
|
||||
}
|
||||
public @Nullable CompoundTag loadNBT(final String name, final boolean cache) {
|
||||
if (!cacheValid) {
|
||||
return loadNBTFromFile(name);
|
||||
}
|
||||
|
||||
CompoundTag data = mappingsCache.get(name);
|
||||
if (data != null) {
|
||||
return data;
|
||||
}
|
||||
|
||||
data = loadNBTFromFile(name);
|
||||
|
||||
if (cache && data != null) {
|
||||
mappingsCache.put(name, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public @Nullable CompoundTag loadNBT(final String name) {
|
||||
return loadNBT(name, false);
|
||||
}
|
||||
|
||||
public @Nullable CompoundTag loadNBTFromFile(final String name) {
|
||||
final InputStream resource = getResource(name);
|
||||
if (resource == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try (final InputStream stream = new BufferedInputStream(resource)) {
|
||||
return MAPPINGS_READER.read(stream);
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
|
||||
MappingDataLoader.mapIdentifiers(output, oldIdentifiers, newIdentifiers, null);
|
||||
public @Nullable Mappings loadMappings(final CompoundTag mappingsTag, final String key) {
|
||||
return loadMappings(mappingsTag, key, size -> {
|
||||
final int[] array = new int[size];
|
||||
Arrays.fill(array, -1);
|
||||
return array;
|
||||
}, (array, id, mappedId) -> array[id] = mappedId, IntArrayMappings::of);
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||
int value = mapIdentifierEntry(entry, newIdentifierMap, diffIdentifiers);
|
||||
if (value != -1) {
|
||||
output[Integer.parseInt(entry.getKey())] = value;
|
||||
}
|
||||
@Beta
|
||||
public <M extends Mappings, V> @Nullable Mappings loadMappings(
|
||||
final CompoundTag mappingsTag,
|
||||
final String key,
|
||||
final MappingHolderSupplier<V> holderSupplier,
|
||||
final AddConsumer<V> addConsumer,
|
||||
final MappingsSupplier<M, V> mappingsSupplier
|
||||
) {
|
||||
final CompoundTag tag = mappingsTag.getCompoundTag(key);
|
||||
if (tag == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static int mapIdentifierEntry(Map.Entry<String, JsonElement> entry, Object2IntMap newIdentifierMap, @Nullable JsonObject diffIdentifiers) {
|
||||
int value = newIdentifierMap.getInt(entry.getValue().getAsString());
|
||||
if (value == -1) {
|
||||
// Search in diff mappings
|
||||
if (diffIdentifiers != null) {
|
||||
JsonElement diffElement = diffIdentifiers.get(entry.getKey());
|
||||
if (diffElement != null) {
|
||||
value = newIdentifierMap.getInt(diffElement.getAsString());
|
||||
final ByteTag serializationStragetyTag = tag.getUnchecked("id");
|
||||
final IntTag mappedSizeTag = tag.getUnchecked("mappedSize");
|
||||
final byte strategy = serializationStragetyTag.asByte();
|
||||
final V mappings;
|
||||
if (strategy == DIRECT_ID) {
|
||||
final IntArrayTag valuesTag = tag.getIntArrayTag("val");
|
||||
return IntArrayMappings.of(valuesTag.getValue(), mappedSizeTag.asInt());
|
||||
} else if (strategy == SHIFTS_ID) {
|
||||
final IntArrayTag shiftsAtTag = tag.getIntArrayTag("at");
|
||||
final IntArrayTag shiftsTag = tag.getIntArrayTag("to");
|
||||
final IntTag sizeTag = tag.getUnchecked("size");
|
||||
final int[] shiftsAt = shiftsAtTag.getValue();
|
||||
final int[] shiftsTo = shiftsTag.getValue();
|
||||
final int size = sizeTag.asInt();
|
||||
mappings = holderSupplier.get(size);
|
||||
|
||||
// Handle values until first shift
|
||||
if (shiftsAt[0] != 0) {
|
||||
final int to = shiftsAt[0];
|
||||
for (int id = 0; id < to; id++) {
|
||||
addConsumer.addTo(mappings, id, id);
|
||||
}
|
||||
}
|
||||
if (value == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
||||
|
||||
// Handle shifts
|
||||
for (int i = 0; i < shiftsAt.length; i++) {
|
||||
final int from = shiftsAt[i];
|
||||
final int to = i == shiftsAt.length - 1 ? size : shiftsAt[i + 1];
|
||||
int mappedId = shiftsTo[i];
|
||||
for (int id = from; id < to; id++) {
|
||||
addConsumer.addTo(mappings, id, mappedId++);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
} else if (strategy == CHANGES_ID) {
|
||||
final IntArrayTag changesAtTag = tag.getIntArrayTag("at");
|
||||
final IntArrayTag valuesTag = tag.getIntArrayTag("val");
|
||||
final IntTag sizeTag = tag.getUnchecked("size");
|
||||
final boolean fillBetween = tag.get("nofill") == null;
|
||||
final int[] changesAt = changesAtTag.getValue();
|
||||
final int[] values = valuesTag.getValue();
|
||||
mappings = holderSupplier.get(sizeTag.asInt());
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, boolean warnOnMissing) {
|
||||
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null, warnOnMissing);
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(int[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
Object2IntMap<String> newIdentifierMap = MappingDataLoader.arrayToMap(newIdentifiers);
|
||||
for (int i = 0; i < oldIdentifiers.size(); i++) {
|
||||
JsonElement oldIdentifier = oldIdentifiers.get(i);
|
||||
int mappedId = newIdentifierMap.getInt(oldIdentifier.getAsString());
|
||||
if (mappedId == -1) {
|
||||
// Search in diff mappings
|
||||
if (diffIdentifiers != null) {
|
||||
JsonElement diffElement = diffIdentifiers.get(oldIdentifier.getAsString());
|
||||
if (diffElement != null) {
|
||||
String mappedName = diffElement.getAsString();
|
||||
if (mappedName.isEmpty()) continue; // "empty" remaps
|
||||
|
||||
mappedId = newIdentifierMap.getInt(mappedName);
|
||||
for (int i = 0; i < changesAt.length; i++) {
|
||||
final int id = changesAt[i];
|
||||
if (fillBetween) {
|
||||
// Fill from after the last change to before this change with unchanged ids
|
||||
final int previousId = i != 0 ? changesAt[i - 1] + 1 : 0;
|
||||
for (int identity = previousId; identity < id; identity++) {
|
||||
addConsumer.addTo(mappings, identity, identity);
|
||||
}
|
||||
}
|
||||
if (mappedId == -1) {
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("No key for " + oldIdentifier + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Assign the changed value
|
||||
addConsumer.addTo(mappings, id, values[i]);
|
||||
}
|
||||
output[i] = mappedId;
|
||||
} else if (strategy == IDENTITY_ID) {
|
||||
final IntTag sizeTag = tag.getUnchecked("size");
|
||||
return new IdentityMappings(sizeTag.asInt(), mappedSizeTag.asInt());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown serialization strategy: " + strategy);
|
||||
}
|
||||
return mappingsSupplier.create(mappings, mappedSizeTag.asInt());
|
||||
}
|
||||
|
||||
public @Nullable List<String> identifiersFromGlobalIds(final CompoundTag mappingsTag, final String key) {
|
||||
final Mappings mappings = loadMappings(mappingsTag, key);
|
||||
if (mappings == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<String> identifiers = new ArrayList<>(mappings.size());
|
||||
for (int i = 0; i < mappings.size(); i++) {
|
||||
identifiers.add(identifierFromGlobalId(key, mappings.getNewId(i)));
|
||||
}
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,10 +294,10 @@ public class MappingDataLoader {
|
||||
* @param object json object
|
||||
* @return map with indexes hashed by their id value
|
||||
*/
|
||||
public static Object2IntMap<String> indexedObjectToMap(JsonObject object) {
|
||||
Object2IntMap<String> map = new Object2IntOpenHashMap<>(object.size(), 1F);
|
||||
public Object2IntMap<String> indexedObjectToMap(final JsonObject object) {
|
||||
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(object.size(), .99F);
|
||||
map.defaultReturnValue(-1);
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
for (final Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
map.put(entry.getValue().getAsString(), Integer.parseInt(entry.getKey()));
|
||||
}
|
||||
return map;
|
||||
@@ -231,8 +309,8 @@ public class MappingDataLoader {
|
||||
* @param array json array
|
||||
* @return map with indexes hashed by their id value
|
||||
*/
|
||||
public static Object2IntMap<String> arrayToMap(JsonArray array) {
|
||||
Object2IntMap<String> map = new Object2IntOpenHashMap<>(array.size(), 1F);
|
||||
public Object2IntMap<String> arrayToMap(final JsonArray array) {
|
||||
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(array.size(), .99F);
|
||||
map.defaultReturnValue(-1);
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
map.put(array.get(i).getAsString(), i);
|
||||
@@ -240,7 +318,33 @@ public class MappingDataLoader {
|
||||
return map;
|
||||
}
|
||||
|
||||
public static @Nullable InputStream getResource(String name) {
|
||||
return MappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
|
||||
public Logger getLogger() {
|
||||
return Via.getPlatform().getLogger();
|
||||
}
|
||||
|
||||
public File getDataFolder() {
|
||||
return Via.getPlatform().getDataFolder();
|
||||
}
|
||||
|
||||
public @Nullable InputStream getResource(final String name) {
|
||||
return dataLoaderClass.getClassLoader().getResourceAsStream(dataPath + name);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface AddConsumer<T> {
|
||||
|
||||
void addTo(T holder, int id, int mappedId);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface MappingHolderSupplier<T> {
|
||||
|
||||
T get(int expectedSize);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface MappingsSupplier<T extends Mappings, V> {
|
||||
|
||||
T create(V mappings, int mappedSize);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -32,12 +32,56 @@ public interface Mappings {
|
||||
*/
|
||||
int getNewId(int id);
|
||||
|
||||
/**
|
||||
* Returns the mapped id from the given id, or the given default if unmapped/invalid.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @param def fallback return value
|
||||
* @return mapped id, or def if invalid/out of bounds
|
||||
*/
|
||||
default int getNewIdOrDefault(int id, int def) {
|
||||
final int mappedId = getNewId(id);
|
||||
return mappedId != -1 ? mappedId : def;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the id has a mapping.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @return whether the id has a mapped id
|
||||
*/
|
||||
default boolean contains(int id) {
|
||||
return getNewId(id) != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually maps a specific id.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @param newId mapped id
|
||||
* @param id unmapped id
|
||||
* @param mappedId mapped id
|
||||
* @throws IndexOutOfBoundsException if the unmapped id is invalid
|
||||
*/
|
||||
void setNewId(int id, int newId);
|
||||
void setNewId(int id, int mappedId);
|
||||
|
||||
/**
|
||||
* Returns amount of unmapped entries, being the size of the mapping.
|
||||
*
|
||||
* @return amount of unmapped entries
|
||||
*/
|
||||
int size();
|
||||
|
||||
/**
|
||||
* Returns the amount of new ids total, even if it does not have a direct mapping.
|
||||
* Returns -1 if unknown.
|
||||
*
|
||||
* @return amount of new ids, or -1 if unknown
|
||||
*/
|
||||
int mappedSize();
|
||||
|
||||
/**
|
||||
* Mappings with keys and values swapped.
|
||||
*
|
||||
* @return mappings with keys and values swapped
|
||||
*/
|
||||
Mappings inverse();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,37 +22,38 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import java.util.List;
|
||||
|
||||
public class ParticleMappings {
|
||||
private final Mappings mappings;
|
||||
private final int blockId;
|
||||
private final int fallingDustId;
|
||||
private final int itemId;
|
||||
public class ParticleMappings extends FullMappingsBase {
|
||||
private final IntList itemParticleIds = new IntArrayList(4);
|
||||
private final IntList blockParticleIds = new IntArrayList(4);
|
||||
|
||||
public ParticleMappings(JsonArray oldMappings, Mappings mappings) {
|
||||
this.mappings = mappings;
|
||||
|
||||
Object2IntMap<String> map = MappingDataLoader.arrayToMap(oldMappings);
|
||||
blockId = map.getInt("block");
|
||||
fallingDustId = map.getInt("falling_dust");
|
||||
itemId = map.getInt("item");
|
||||
public ParticleMappings(final List<String> unmappedIdentifiers, final List<String> mappedIdentifiers, final Mappings mappings) {
|
||||
super(unmappedIdentifiers, mappedIdentifiers, mappings);
|
||||
addBlockParticle("block");
|
||||
addBlockParticle("falling_dust");
|
||||
addBlockParticle("block_marker");
|
||||
addBlockParticle("dust_pillar");
|
||||
addItemParticle("item");
|
||||
}
|
||||
|
||||
public Mappings getMappings() {
|
||||
return mappings;
|
||||
public boolean addItemParticle(final String identifier) {
|
||||
final int id = id(identifier);
|
||||
return id != -1 && itemParticleIds.add(id);
|
||||
}
|
||||
|
||||
public int getBlockId() {
|
||||
return blockId;
|
||||
public boolean addBlockParticle(final String identifier) {
|
||||
final int id = id(identifier);
|
||||
return id != -1 && blockParticleIds.add(id);
|
||||
}
|
||||
|
||||
public int getFallingDustId() {
|
||||
return fallingDustId;
|
||||
public boolean isBlockParticle(final int id) {
|
||||
return blockParticleIds.contains(id);
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
public boolean isItemParticle(final int id) {
|
||||
return itemParticleIds.contains(id);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+7
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,16 +20,13 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.type.types.version;
|
||||
package com.viaversion.viaversion.api.data.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaListType;
|
||||
public interface DimensionData {
|
||||
|
||||
public class MetadataList1_17Type extends ModernMetaListType {
|
||||
int id();
|
||||
|
||||
@Override
|
||||
protected Type<Metadata> getType() {
|
||||
return Types1_17.METADATA;
|
||||
}
|
||||
int minY();
|
||||
|
||||
int height();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.data.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface EntityTracker {
|
||||
@@ -33,6 +34,7 @@ public interface EntityTracker {
|
||||
*
|
||||
* @return user connection
|
||||
*/
|
||||
@Deprecated
|
||||
UserConnection user();
|
||||
|
||||
/**
|
||||
@@ -51,6 +53,14 @@ public interface EntityTracker {
|
||||
*/
|
||||
boolean hasEntity(int id);
|
||||
|
||||
/**
|
||||
* Returns the tracked entity for the given entity id if present.
|
||||
*
|
||||
* @param entityId entity id
|
||||
* @return tracked entity if tracked
|
||||
*/
|
||||
@Nullable TrackedEntity entity(int entityId);
|
||||
|
||||
/**
|
||||
* Entity type of the entity if tracked.
|
||||
* This returning null does not necessarily mean no entity by the id exists.
|
||||
@@ -67,12 +77,18 @@ public interface EntityTracker {
|
||||
*/
|
||||
void removeEntity(int id);
|
||||
|
||||
/**
|
||||
* Clears stored entity types and data.
|
||||
*/
|
||||
void clearEntities();
|
||||
|
||||
/**
|
||||
* Returns the stored entity data if an entity with the id is tracked, else null.
|
||||
* If no data has been initialized yet, it will be done and returned by this method.
|
||||
*
|
||||
* @param id entity id
|
||||
* @return stored entity data if an entity with the id is tracked, else null
|
||||
* @throws IllegalArgumentException if entity data storage has not been enabled via the implementation
|
||||
*/
|
||||
@Nullable StoredEntityData entityData(int id);
|
||||
|
||||
@@ -81,6 +97,7 @@ public interface EntityTracker {
|
||||
*
|
||||
* @param id entity id
|
||||
* @return stored entity data if it has previously been initialized by {@link #entityData(int)}
|
||||
* @throws IllegalArgumentException if entity data storage has not been enabled via the implementation
|
||||
*/
|
||||
@Nullable StoredEntityData entityDataIfPresent(int id);
|
||||
|
||||
@@ -99,8 +116,8 @@ public interface EntityTracker {
|
||||
void setClientEntityId(int clientEntityId);
|
||||
|
||||
/**
|
||||
* Returns the current world section height.
|
||||
* Always 16 for sub 1.17 worlds.
|
||||
* Returns the current world section height (block height / 16).
|
||||
* This is always 16 for sub 1.17 worlds.
|
||||
*
|
||||
* @return current world section height
|
||||
*/
|
||||
@@ -126,4 +143,38 @@ public interface EntityTracker {
|
||||
* @param currentMinY minimum y of the current world
|
||||
*/
|
||||
void setCurrentMinY(int currentMinY);
|
||||
|
||||
/**
|
||||
* Returns the name of the world the player is currently in.
|
||||
*
|
||||
* @return world name of the current world
|
||||
*/
|
||||
@Nullable String currentWorld();
|
||||
|
||||
/**
|
||||
* Sets the name of the world the player is currently in.
|
||||
*
|
||||
* @param currentWorld name of the current world
|
||||
*/
|
||||
void setCurrentWorld(String currentWorld);
|
||||
|
||||
int biomesSent();
|
||||
|
||||
void setBiomesSent(int biomesSent);
|
||||
|
||||
EntityType playerType();
|
||||
|
||||
@Nullable DimensionData dimensionData(String dimension);
|
||||
|
||||
@Nullable DimensionData dimensionData(int dimensionId);
|
||||
|
||||
void setDimensions(Map<String, DimensionData> dimensions);
|
||||
|
||||
/**
|
||||
* Adds the client player entity to the tracker.
|
||||
* If the client entity has not been set yet, this will return false.
|
||||
*
|
||||
* @return whether the client has been tracked
|
||||
*/
|
||||
boolean trackClientEntity();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -51,6 +51,15 @@ public interface StoredEntityData {
|
||||
*/
|
||||
@Nullable <T> T get(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Removes and returns an object from the storage if present.
|
||||
*
|
||||
* @param objectClass class of the object to remove
|
||||
* @param <T> object type
|
||||
* @return removed object if present
|
||||
*/
|
||||
@Nullable <T> T remove(Class<T> objectClass);
|
||||
|
||||
/**
|
||||
* Stores an object based on its class.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data.entity;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
|
||||
public interface TrackedEntity {
|
||||
|
||||
/**
|
||||
* Returns the type of the stored entity.
|
||||
*
|
||||
* @return type of the entity
|
||||
*/
|
||||
EntityType entityType();
|
||||
|
||||
/**
|
||||
* Object to hold arbitrary additional data.
|
||||
*
|
||||
* @return entity data
|
||||
*/
|
||||
StoredEntityData data();
|
||||
|
||||
/**
|
||||
* Returns whether the stored entity currently has any additional data.
|
||||
*
|
||||
* @return whether the stored entity currently has additional data
|
||||
*/
|
||||
boolean hasData();
|
||||
|
||||
/**
|
||||
* Returns whether metadata has already been sent at least once for this entity.
|
||||
*
|
||||
* @return whether metadata has already been sent at least once for this entity
|
||||
*/
|
||||
boolean hasSentMetadata();
|
||||
|
||||
void sentMetadata(boolean sentMetadata);
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.debug;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Beta
|
||||
public interface DebugHandler {
|
||||
|
||||
/**
|
||||
* Returns whether debug mode is enabled.
|
||||
*
|
||||
* @return whether debug mode is enabled
|
||||
*/
|
||||
boolean enabled();
|
||||
|
||||
/**
|
||||
* Sets debug mode.
|
||||
*
|
||||
* @param enabled whether debug should be enabled
|
||||
*/
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Adds a packet type name to the list of packet types to log.
|
||||
*
|
||||
* @param packetTypeName packet type name
|
||||
*/
|
||||
void addPacketTypeNameToLog(String packetTypeName);
|
||||
|
||||
/**
|
||||
* Adds a packet id to the list of packet types to log.
|
||||
* Packets will be checked on each protocol transformer, so this is best used on single protocol pipes.
|
||||
*
|
||||
* @param packetType packet type
|
||||
*/
|
||||
void addPacketTypeToLog(PacketType packetType);
|
||||
|
||||
/**
|
||||
* Removes a packet type name from the list of packet types to log.
|
||||
*
|
||||
* @param packetTypeName packet type name
|
||||
*/
|
||||
boolean removePacketTypeNameToLog(String packetTypeName);
|
||||
|
||||
/**
|
||||
* Resets packet type filters.
|
||||
*/
|
||||
void clearPacketTypesToLog();
|
||||
|
||||
/**
|
||||
* Returns whether packets should be logged after being transformed.
|
||||
* Set to true by default.
|
||||
*
|
||||
* @return whether packets should be logged after being transformed
|
||||
*/
|
||||
boolean logPostPacketTransform();
|
||||
|
||||
/**
|
||||
* Sets whether packets should be logged after being transformed.
|
||||
*
|
||||
* @param logPostPacketTransform whether packets should be logged after being transformed
|
||||
*/
|
||||
void setLogPostPacketTransform(boolean logPostPacketTransform);
|
||||
|
||||
/**
|
||||
* Returns whether the given packet should be logged.
|
||||
* If no specific packet type has been added, all packet types will be logged.
|
||||
*
|
||||
* @param wrapper packet wrapper
|
||||
* @param direction packet direction
|
||||
* @return whether the packet should be logged
|
||||
*/
|
||||
boolean shouldLog(PacketWrapper wrapper, Direction direction);
|
||||
|
||||
default void enableAndLogIds(final PacketType... packetTypes) {
|
||||
setEnabled(true);
|
||||
for (final PacketType packetType : packetTypes) {
|
||||
addPacketTypeToLog(packetType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an error if debug mode is enabled or error suppression is disabled.
|
||||
*
|
||||
* @param error error message
|
||||
* @param t thrown exception
|
||||
*/
|
||||
default void error(final String error, final Throwable t) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || enabled()) {
|
||||
Via.getPlatform().getLogger().log(Level.SEVERE, error, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,6 @@
|
||||
package com.viaversion.viaversion.api.legacy.bossbar;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -67,7 +66,7 @@ public interface BossBar {
|
||||
BossColor getColor();
|
||||
|
||||
/**
|
||||
* Yay colors!
|
||||
* Yay, colors!
|
||||
*
|
||||
* @param color Whatever color you want!
|
||||
* @return The BossBar object
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +25,8 @@ package com.viaversion.viaversion.api.legacy.bossbar;
|
||||
public enum BossFlag {
|
||||
|
||||
DARKEN_SKY(1),
|
||||
PLAY_BOSS_MUSIC(2);
|
||||
PLAY_BOSS_MUSIC(2),
|
||||
CREATE_FOG(4);
|
||||
|
||||
private final int id;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -54,10 +54,10 @@ public interface BlockChangeRecord {
|
||||
short getY(int chunkSectionY);
|
||||
|
||||
/**
|
||||
* Returns the absolute y coordinate - only works for sub 1.16 protocols.
|
||||
*
|
||||
* @return absolute y coordinate
|
||||
* @deprecated 1.16+ stores the relative y coordinate
|
||||
*/
|
||||
@Deprecated
|
||||
default short getY() {
|
||||
return getY(-1);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -58,7 +58,7 @@ public class BlockChangeRecord1_16_2 implements BlockChangeRecord {
|
||||
|
||||
@Override
|
||||
public short getY(int chunkSectionY) {
|
||||
Preconditions.checkArgument(chunkSectionY >= 0 && chunkSectionY < 16, "Invalid chunkSectionY: " + chunkSectionY);
|
||||
Preconditions.checkArgument(chunkSectionY >= 0, "Invalid chunkSectionY: " + chunkSectionY);
|
||||
return (short) ((chunkSectionY << 4) + sectionY);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum BlockFace {
|
||||
@@ -33,7 +33,9 @@ public enum BlockFace {
|
||||
TOP((byte) 0, (byte) 1, (byte) 0, EnumAxis.Y),
|
||||
BOTTOM((byte) 0, (byte) -1, (byte) 0, EnumAxis.Y);
|
||||
|
||||
private static final Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
||||
public static final BlockFace[] HORIZONTAL = {NORTH, SOUTH, EAST, WEST};
|
||||
|
||||
private static final Map<BlockFace, BlockFace> opposites = new EnumMap<>(BlockFace.class);
|
||||
|
||||
static {
|
||||
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
||||
@@ -60,18 +62,38 @@ public enum BlockFace {
|
||||
return opposites.get(this);
|
||||
}
|
||||
|
||||
public byte modX() {
|
||||
return modX;
|
||||
}
|
||||
|
||||
public byte modY() {
|
||||
return modY;
|
||||
}
|
||||
|
||||
public byte modZ() {
|
||||
return modZ;
|
||||
}
|
||||
|
||||
public EnumAxis axis() {
|
||||
return axis;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public byte getModX() {
|
||||
return modX;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public byte getModY() {
|
||||
return modY;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public byte getModZ() {
|
||||
return modZ;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public EnumAxis getAxis() {
|
||||
return axis;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Stored up until 1.14 to be used in chunk sending.
|
||||
*/
|
||||
public class ClientWorld implements StorableObject {
|
||||
private Environment environment;
|
||||
|
||||
public ClientWorld() {
|
||||
}
|
||||
|
||||
public ClientWorld(final Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
public @Nullable Environment getEnvironment() {
|
||||
return environment;
|
||||
}
|
||||
|
||||
public void setEnvironment(final int environmentId) {
|
||||
this.environment = Environment.getEnvironmentById(environmentId);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -34,6 +34,11 @@ public enum Environment {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,14 +33,29 @@ public class EulerAngle {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public float x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public float y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public float z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public float getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public float getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public float getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
+30
-38
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,64 +20,56 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.type.types;
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
public final class GameProfile {
|
||||
|
||||
public class Particle {
|
||||
private int id;
|
||||
private List<ParticleData> arguments = new LinkedList<>();
|
||||
private final String name;
|
||||
private final UUID id;
|
||||
private final Property[] properties;
|
||||
|
||||
public Particle(int id) {
|
||||
public GameProfile(@Nullable final String name, @Nullable final UUID id, final Property[] properties) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public @Nullable String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public @Nullable UUID id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
public Property[] properties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public List<ParticleData> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
public static final class Property {
|
||||
private final String name;
|
||||
private final String value;
|
||||
private final String signature;
|
||||
|
||||
public void setArguments(List<ParticleData> arguments) {
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
public static class ParticleData {
|
||||
private Type type;
|
||||
private Object value;
|
||||
|
||||
public ParticleData(Type type, Object value) {
|
||||
this.type = type;
|
||||
public Property(final String name, final String value, @Nullable final String signature) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public <T> T get() {
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
public @Nullable String signature() {
|
||||
return signature;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public final class GlobalPosition extends Position {
|
||||
private final String dimension;
|
||||
|
||||
public GlobalPosition(final String dimension, final int x, final int y, final int z) {
|
||||
super(x, y, z);
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
public String dimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final GlobalPosition position = (GlobalPosition) o;
|
||||
if (x != position.x) return false;
|
||||
if (y != position.y) return false;
|
||||
if (z != position.z) return false;
|
||||
return dimension.equals(position.dimension);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = dimension.hashCode();
|
||||
result = 31 * result + x;
|
||||
result = 31 * result + y;
|
||||
result = 31 * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalPosition{" +
|
||||
"dimension='" + dimension + '\'' +
|
||||
", x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public interface Holder<T> {
|
||||
|
||||
/**
|
||||
* Returns an indirect id holder.
|
||||
*
|
||||
* @param id the id
|
||||
* @param <T> the type of the value
|
||||
* @return a new holder with the given id
|
||||
* @throws IllegalArgumentException if the id is negative
|
||||
*/
|
||||
static <T> Holder<T> of(final int id) {
|
||||
return new HolderImpl<>(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a direct value holder.
|
||||
*
|
||||
* @param value the value
|
||||
* @param <T> the type of the value
|
||||
* @return a new direct holder
|
||||
*/
|
||||
static <T> Holder<T> of(final T value) {
|
||||
return new HolderImpl<>(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this holder is backed by a direct value.
|
||||
*
|
||||
* @return true if the holder is direct
|
||||
* @see #hasId()
|
||||
*/
|
||||
boolean isDirect();
|
||||
|
||||
/**
|
||||
* Returns true if this holder has an id.
|
||||
*
|
||||
* @return true if this holder has an id
|
||||
* @see #isDirect()
|
||||
*/
|
||||
boolean hasId();
|
||||
|
||||
/**
|
||||
* Returns the value of this holder.
|
||||
*
|
||||
* @return the value of this holder
|
||||
* @throws IllegalArgumentException if this holder is not direct
|
||||
* @see #isDirect()
|
||||
*/
|
||||
T value();
|
||||
|
||||
/**
|
||||
* Returns the id of this holder, or -1 if this holder is direct.
|
||||
*
|
||||
* @return the id of this holder, or -1 if this holder is direct
|
||||
* @see #hasId()
|
||||
*/
|
||||
int id();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
final class HolderImpl<T> implements Holder<T> {
|
||||
|
||||
private final T value;
|
||||
private final int id;
|
||||
|
||||
HolderImpl(final int id) {
|
||||
Preconditions.checkArgument(id >= 0, "id cannot be negative");
|
||||
this.value = null;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
HolderImpl(final T value) {
|
||||
this.value = value;
|
||||
this.id = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirect() {
|
||||
return id == -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasId() {
|
||||
return id != -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T value() {
|
||||
Preconditions.checkArgument(isDirect(), "Holder is not direct");
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
/**
|
||||
* Set of ids that either holds a string tag key or an array of ids.
|
||||
*/
|
||||
public interface HolderSet {
|
||||
|
||||
/**
|
||||
* Creates a new holder set for the given tag.
|
||||
*
|
||||
* @param tagKey the tag key
|
||||
* @return a new holder set
|
||||
*/
|
||||
static HolderSet of(final String tagKey) {
|
||||
return new HolderSetImpl(tagKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new holder set for the given ids.
|
||||
*
|
||||
* @param ids the direct ids
|
||||
* @return a new holder set
|
||||
*/
|
||||
static HolderSet of(final int[] ids) {
|
||||
return new HolderSetImpl(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tag key.
|
||||
*
|
||||
* @return the tag key
|
||||
* @see #hasTagKey()
|
||||
*/
|
||||
String tagKey();
|
||||
|
||||
/**
|
||||
* Returns whether this holder set has a tag key.
|
||||
*
|
||||
* @return true if this holder set has a tag key, false if it has direct ids
|
||||
*/
|
||||
boolean hasTagKey();
|
||||
|
||||
/**
|
||||
* Gets the direct ids.
|
||||
*
|
||||
* @return direct ids
|
||||
* @see #hasIds()
|
||||
*/
|
||||
int[] ids();
|
||||
|
||||
/**
|
||||
* Returns whether this holder set has direct ids.
|
||||
*
|
||||
* @return true if this holder set has direct ids, false if it has a tag key
|
||||
*/
|
||||
boolean hasIds();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.util.EitherImpl;
|
||||
|
||||
final class HolderSetImpl extends EitherImpl<String, int[]> implements HolderSet {
|
||||
|
||||
HolderSetImpl(final String tagKey) {
|
||||
super(tagKey, null);
|
||||
}
|
||||
|
||||
HolderSetImpl(final int[] ids) {
|
||||
super(null, ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tagKey() {
|
||||
return left();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTagKey() {
|
||||
return isLeft();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] ids() {
|
||||
return right();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasIds() {
|
||||
return isRight();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.util.IdHolder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class Particle implements IdHolder {
|
||||
private final List<ParticleData<?>> arguments = new ArrayList<>(4);
|
||||
private int id;
|
||||
|
||||
public Particle(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public <T> ParticleData<T> getArgument(final int index) {
|
||||
//noinspection unchecked
|
||||
return (ParticleData<T>) arguments.get(index);
|
||||
}
|
||||
|
||||
public <T> ParticleData<T> removeArgument(final int index) {
|
||||
//noinspection unchecked
|
||||
return (ParticleData<T>) arguments.remove(index);
|
||||
}
|
||||
|
||||
public List<ParticleData<?>> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public <T> void add(final Type<T> type, final T value) {
|
||||
arguments.add(new ParticleData<>(type, value));
|
||||
}
|
||||
|
||||
public <T> void add(final int index, final Type<T> type, final T value) {
|
||||
arguments.add(index, new ParticleData<>(type, value));
|
||||
}
|
||||
|
||||
public <T> void set(final int index, final Type<T> type, final T value) {
|
||||
arguments.set(index, new ParticleData<>(type, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Particle{" +
|
||||
"arguments=" + arguments +
|
||||
", id=" + id +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static final class ParticleData<T> {
|
||||
private final Type<T> type;
|
||||
private T value;
|
||||
|
||||
public ParticleData(final Type<T> type, final T value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Type<T> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(final T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void write(final ByteBuf buf) throws Exception {
|
||||
type.write(buf, value);
|
||||
}
|
||||
|
||||
public void write(final PacketWrapper wrapper) {
|
||||
wrapper.write(type, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ParticleData{" +
|
||||
"type=" + type +
|
||||
", value=" + value +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-12
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,23 +20,24 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.type.types.minecraft;
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class BaseChunkType extends Type<Chunk> {
|
||||
public final class PlayerMessageSignature {
|
||||
private final UUID uuid;
|
||||
private final byte[] signatureBytes;
|
||||
|
||||
protected BaseChunkType() {
|
||||
super(Chunk.class);
|
||||
public PlayerMessageSignature(final UUID uuid, final byte[] signatureBytes) {
|
||||
this.uuid = uuid;
|
||||
this.signatureBytes = signatureBytes;
|
||||
}
|
||||
|
||||
protected BaseChunkType(String typeName) {
|
||||
super(typeName, Chunk.class);
|
||||
public UUID uuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Type> getBaseClass() {
|
||||
return BaseChunkType.class;
|
||||
public byte[] signatureBytes() {
|
||||
return signatureBytes;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,9 +23,9 @@
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public class Position {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
protected final int x;
|
||||
protected final int y;
|
||||
protected final int z;
|
||||
|
||||
public Position(int x, int y, int z) {
|
||||
this.x = x;
|
||||
@@ -33,28 +33,47 @@ public class Position {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
// @Deprecated/*(forRemoval=true)*/ Just leave this unchecked
|
||||
public Position(int x, short y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this(x, (int) y, z);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public Position(Position toCopy) {
|
||||
this(toCopy.getX(), toCopy.getY(), toCopy.getZ());
|
||||
this(toCopy.x(), toCopy.y(), toCopy.z());
|
||||
}
|
||||
|
||||
public Position getRelative(BlockFace face) {
|
||||
return new Position(x + face.getModX(), (short) (y + face.getModY()), z + face.getModZ());
|
||||
return new Position(x + face.modX(), (short) (y + face.modY()), z + face.modZ());
|
||||
}
|
||||
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public GlobalPosition withDimension(String dimension) {
|
||||
return new GlobalPosition(dimension, x, y, z);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public class Position3d {
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
public Position3d(final double x, final double y, final double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public double x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double z() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public final class ProfileKey {
|
||||
private final long expiresAt;
|
||||
private final byte[] publicKey;
|
||||
private final byte[] keySignature;
|
||||
|
||||
public ProfileKey(final long expiresAt, final byte[] publicKey, final byte[] keySignature) {
|
||||
this.expiresAt = expiresAt;
|
||||
this.publicKey = publicKey;
|
||||
this.keySignature = keySignature;
|
||||
}
|
||||
|
||||
public long expiresAt() {
|
||||
return expiresAt;
|
||||
}
|
||||
|
||||
public byte[] publicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
public byte[] keySignature() {
|
||||
return keySignature;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
public final class Quaternion {
|
||||
private final float x;
|
||||
private final float y;
|
||||
private final float z;
|
||||
private final float w;
|
||||
|
||||
public Quaternion(final float x, final float y, final float z, final float w) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public float x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public float y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public float z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public float w() {
|
||||
return w;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Quaternion{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
", w=" + w +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class RegistryEntry {
|
||||
private final String key;
|
||||
private final Tag tag;
|
||||
|
||||
public RegistryEntry(String key, @Nullable Tag tag) {
|
||||
this.key = key;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String key() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public @Nullable Tag tag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public RegistryEntry withKey(final String key) {
|
||||
return new RegistryEntry(key, tag != null ? tag.copy() : null);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,10 +22,9 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public enum RegistryType {
|
||||
|
||||
@@ -58,7 +57,7 @@ public enum RegistryType {
|
||||
this.resourceLocation = resourceLocation;
|
||||
}
|
||||
|
||||
public String getResourceLocation() {
|
||||
public String resourceLocation() {
|
||||
return resourceLocation;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class SoundEvent {
|
||||
|
||||
private final String identifier;
|
||||
private final Float fixedRange;
|
||||
|
||||
public SoundEvent(final String identifier, @Nullable final Float fixedRange) {
|
||||
this.identifier = identifier;
|
||||
this.fixedRange = fixedRange;
|
||||
}
|
||||
|
||||
public String identifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public @Nullable Float fixedRange() {
|
||||
return fixedRange;
|
||||
}
|
||||
|
||||
public SoundEvent withIdentifier(final String identifier) {
|
||||
return new SoundEvent(identifier, this.fixedRange);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,11 +22,13 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class TagData {
|
||||
private final String identifier;
|
||||
private final int[] entries;
|
||||
|
||||
public TagData(String identifier, int[] entries) {
|
||||
public TagData(final String identifier, final int[] entries) {
|
||||
this.identifier = identifier;
|
||||
this.entries = entries;
|
||||
}
|
||||
@@ -38,4 +40,12 @@ public final class TagData {
|
||||
public int[] entries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TagData{" +
|
||||
"identifier='" + identifier + '\'' +
|
||||
", entries=" + Arrays.toString(entries) +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,26 +33,44 @@ public class Vector {
|
||||
this.blockZ = blockZ;
|
||||
}
|
||||
|
||||
public int blockX() {
|
||||
return blockX;
|
||||
}
|
||||
|
||||
public int blockY() {
|
||||
return blockY;
|
||||
}
|
||||
|
||||
public int blockZ() {
|
||||
return blockZ;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getBlockX() {
|
||||
return blockX;
|
||||
}
|
||||
|
||||
public void setBlockX(int blockX) {
|
||||
this.blockX = blockX;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getBlockY() {
|
||||
return blockY;
|
||||
}
|
||||
|
||||
public void setBlockY(int blockY) {
|
||||
this.blockY = blockY;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getBlockZ() {
|
||||
return blockZ;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public void setBlockX(int blockX) {
|
||||
this.blockX = blockX;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public void setBlockY(int blockY) {
|
||||
this.blockY = blockY;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public void setBlockZ(int blockZ) {
|
||||
this.blockZ = blockZ;
|
||||
}
|
||||
|
||||
+22
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,15 +20,28 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.type.types.version;
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.minecraft.ModernMetaListType;
|
||||
public final class Vector3f {
|
||||
private final float x;
|
||||
private final float y;
|
||||
private final float z;
|
||||
|
||||
public class MetadataList1_13_2Type extends ModernMetaListType {
|
||||
@Override
|
||||
protected Type<Metadata> getType() {
|
||||
return Types1_13_2.METADATA;
|
||||
public Vector3f(final float x, final float y, final float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public float x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public float y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public float z() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,14 +33,29 @@ public class VillagerData {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int profession() {
|
||||
return profession;
|
||||
}
|
||||
|
||||
public int level() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getProfession() {
|
||||
return profession;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class WorldIdentifiers implements StorableObject {
|
||||
public static final String OVERWORLD_DEFAULT = "minecraft:overworld";
|
||||
public static final String NETHER_DEFAULT = "minecraft:the_nether";
|
||||
public static final String END_DEFAULT = "minecraft:the_end";
|
||||
|
||||
private final String overworld;
|
||||
private final String nether;
|
||||
private final String end;
|
||||
|
||||
public WorldIdentifiers(String overworld) {
|
||||
this(overworld, NETHER_DEFAULT, END_DEFAULT);
|
||||
}
|
||||
|
||||
public WorldIdentifiers(String overworld, String nether, String end) {
|
||||
this.overworld = overworld;
|
||||
this.nether = nether;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public String overworld() {
|
||||
return this.overworld;
|
||||
}
|
||||
|
||||
public String nether() {
|
||||
return this.nether;
|
||||
}
|
||||
|
||||
public String end() {
|
||||
return this.end;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.blockentity;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface BlockEntity {
|
||||
|
||||
static byte pack(int sectionX, int sectionZ) {
|
||||
return (byte) (((sectionX) & 15) << 4 | (sectionZ & 15));
|
||||
}
|
||||
|
||||
default byte sectionX() {
|
||||
return (byte) ((packedXZ() >> 4) & 15);
|
||||
}
|
||||
|
||||
default byte sectionZ() {
|
||||
return (byte) (packedXZ() & 15);
|
||||
}
|
||||
|
||||
byte packedXZ();
|
||||
|
||||
short y();
|
||||
|
||||
int typeId();
|
||||
|
||||
@Nullable CompoundTag tag();
|
||||
|
||||
BlockEntity withTypeId(int typeId);
|
||||
}
|
||||
+31
-27
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -20,41 +20,45 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
package com.viaversion.viaversion.api.minecraft.blockentity;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
public final class BlockEntityImpl implements BlockEntity {
|
||||
private final byte packedXZ;
|
||||
private final short y;
|
||||
private final int typeId;
|
||||
private final CompoundTag tag;
|
||||
|
||||
public class Chunk1_8 extends BaseChunk {
|
||||
private boolean unloadPacket;
|
||||
|
||||
public Chunk1_8(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
|
||||
super(x, z, groundUp, false, bitmask, sections, biomeData, blockEntities);
|
||||
public BlockEntityImpl(final byte packedXZ, final short y, final int typeId, final CompoundTag tag) {
|
||||
this.packedXZ = packedXZ;
|
||||
this.y = y;
|
||||
this.typeId = typeId;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chunk unload.
|
||||
*
|
||||
* @param x coord
|
||||
* @param z coord
|
||||
*/
|
||||
public Chunk1_8(int x, int z) {
|
||||
this(x, z, true, 0, new ChunkSection[16], null, new ArrayList<>());
|
||||
this.unloadPacket = true;
|
||||
@Override
|
||||
public byte packedXZ() {
|
||||
return packedXZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this chunks have biome data
|
||||
*
|
||||
* @return True if the chunks has biome data
|
||||
*/
|
||||
public boolean hasBiomeData() {
|
||||
return biomeData != null && fullChunk;
|
||||
@Override
|
||||
public short y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public boolean isUnloadPacket() {
|
||||
return unloadPacket;
|
||||
@Override
|
||||
public int typeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag tag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity withTypeId(int typeId) {
|
||||
return new BlockEntityImpl(packedXZ, y, typeId, tag);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,10 +23,10 @@
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
//TODO Move methods from distinctly different versions to different objects/interfaces
|
||||
public class BaseChunk implements Chunk {
|
||||
@@ -147,4 +147,9 @@ public class BaseChunk implements Chunk {
|
||||
public List<CompoundTag> getBlockEntities() {
|
||||
return blockEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockEntity> blockEntities() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,11 +23,12 @@
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
// TODO specialized sub interfaces
|
||||
public interface Chunk {
|
||||
|
||||
/**
|
||||
@@ -115,4 +116,11 @@ public interface Chunk {
|
||||
* @return list of block entities
|
||||
*/
|
||||
List<CompoundTag> getBlockEntities();
|
||||
|
||||
/**
|
||||
* Returns a list of block entities.
|
||||
*
|
||||
* @return list of block entities
|
||||
*/
|
||||
List<BlockEntity> blockEntities();
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class Chunk1_18 implements Chunk {
|
||||
protected final int x;
|
||||
protected final int z;
|
||||
protected ChunkSection[] sections;
|
||||
protected CompoundTag heightMap;
|
||||
protected final List<BlockEntity> blockEntities;
|
||||
|
||||
public Chunk1_18(int x, int z, ChunkSection[] sections, CompoundTag heightMap, List<BlockEntity> blockEntities) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.sections = sections;
|
||||
this.heightMap = heightMap;
|
||||
this.blockEntities = blockEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBiomeData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullChunk() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoreOldLightData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoreOldLightData(boolean ignoreOldLightData) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBitmask() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmask(int bitmask) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BitSet getChunkMask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChunkMask(BitSet chunkSectionMask) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkSection[] getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSections(ChunkSection[] sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int @Nullable [] getBiomeData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiomeData(int @Nullable [] biomeData) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable CompoundTag getHeightMap() {
|
||||
return heightMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(final CompoundTag heightMap) {
|
||||
this.heightMap = heightMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompoundTag> getBlockEntities() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockEntity> blockEntities() {
|
||||
return blockEntities;
|
||||
}
|
||||
}
|
||||
+74
-100
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -32,143 +32,105 @@ public interface ChunkSection {
|
||||
int SIZE = 16 * 16 * 16; // width * depth * height
|
||||
|
||||
/**
|
||||
* Returns the block index of the given coordinates within a section.
|
||||
*
|
||||
* @param x section x
|
||||
* @param y section y
|
||||
* @param z section z
|
||||
* @return section block index
|
||||
* Size (dimensions) of biomes in a chunks section.
|
||||
*/
|
||||
int BIOME_SIZE = 4 * 4 * 4;
|
||||
|
||||
static int index(int x, int y, int z) {
|
||||
return y << 8 | z << 4 | x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block state of the given index.
|
||||
*
|
||||
* @param idx block index within the section
|
||||
* @return block state of the given index
|
||||
*/
|
||||
int getFlatBlock(int idx);
|
||||
static int xFromIndex(int idx) {
|
||||
return idx & 0xF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block state of the section coordinate.
|
||||
*
|
||||
* @param x section x
|
||||
* @param y section y
|
||||
* @param z section z
|
||||
* @return block state of the given section coordinate
|
||||
*/
|
||||
static int yFromIndex(int idx) {
|
||||
return idx >> 8 & 0xF;
|
||||
}
|
||||
|
||||
static int zFromIndex(int idx) {
|
||||
return idx >> 4 & 0xF;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getFlatBlock(int idx) {
|
||||
return palette(PaletteType.BLOCKS).idAt(idx);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getFlatBlock(int x, int y, int z) {
|
||||
return getFlatBlock(index(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a block state in the chunk section.
|
||||
* This method will not update non-air blocks count.
|
||||
*
|
||||
* @param idx block index within the section
|
||||
* @param id raw or flat id of the block state
|
||||
*/
|
||||
void setFlatBlock(int idx, int id);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setFlatBlock(int idx, int id) {
|
||||
palette(PaletteType.BLOCKS).setIdAt(idx, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a block state in the chunk section.
|
||||
* This method will not update non-air blocks count.
|
||||
*
|
||||
* @param x section x
|
||||
* @param y section y
|
||||
* @param z section z
|
||||
* @param id raw or flat id of the block state
|
||||
*/
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setFlatBlock(int x, int y, int z, int id) {
|
||||
setFlatBlock(index(x, y, z), id);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getBlockWithoutData(int x, int y, int z) {
|
||||
return getFlatBlock(x, y, z) >> 4;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getBlockData(int x, int y, int z) {
|
||||
return getFlatBlock(x, y, z) & 0xF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a block in the chunks.
|
||||
* This method will not update non-air blocks count.
|
||||
*
|
||||
* @param x Block X
|
||||
* @param y Block Y
|
||||
* @param z Block Z
|
||||
* @param type The type of the block
|
||||
* @param data The data value of the block
|
||||
*/
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setBlockWithData(int x, int y, int z, int type, int data) {
|
||||
setFlatBlock(index(x, y, z), type << 4 | (data & 0xF));
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setBlockWithData(int idx, int type, int data) {
|
||||
setFlatBlock(idx, type << 4 | (data & 0xF));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a block to the given palette index.
|
||||
*
|
||||
* @param idx block index
|
||||
* @param index palette index
|
||||
*/
|
||||
void setPaletteIndex(int idx, int index);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setPaletteIndex(int idx, int index) {
|
||||
palette(PaletteType.BLOCKS).setPaletteIndexAt(idx, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the palette index of the given block index.
|
||||
*
|
||||
* @param idx block index
|
||||
* @return palette index of the given block index
|
||||
*/
|
||||
int getPaletteIndex(int idx);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getPaletteIndex(int idx) {
|
||||
return palette(PaletteType.BLOCKS).paletteIndexAt(idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the palette.
|
||||
*
|
||||
* @return palette size
|
||||
*/
|
||||
int getPaletteSize();
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getPaletteSize() {
|
||||
return palette(PaletteType.BLOCKS).size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block state assigned to the given palette index.
|
||||
*
|
||||
* @param index palette index
|
||||
* @return block state assigned to the given palette index
|
||||
*/
|
||||
int getPaletteEntry(int index);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default int getPaletteEntry(int index) {
|
||||
return palette(PaletteType.BLOCKS).idByIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns a block state assigned to the given palette index.
|
||||
*
|
||||
* @param index palette index
|
||||
* @param id block state
|
||||
*/
|
||||
void setPaletteEntry(int index, int id);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void setPaletteEntry(int index, int id) {
|
||||
palette(PaletteType.BLOCKS).setIdByIndex(index, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces a block state in the palette.
|
||||
*
|
||||
* @param oldId old block state
|
||||
* @param newId new block state
|
||||
*/
|
||||
void replacePaletteEntry(int oldId, int newId);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void replacePaletteEntry(int oldId, int newId) {
|
||||
palette(PaletteType.BLOCKS).replaceId(oldId, newId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new block state to the palette.
|
||||
*
|
||||
* @param id block state
|
||||
*/
|
||||
void addPaletteEntry(int id);
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void addPaletteEntry(int id) {
|
||||
palette(PaletteType.BLOCKS).addId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the palette.
|
||||
*/
|
||||
void clearPalette();
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default void clearPalette() {
|
||||
palette(PaletteType.BLOCKS).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of non-air blocks in this section.
|
||||
@@ -198,4 +160,16 @@ public interface ChunkSection {
|
||||
@Nullable ChunkSectionLight getLight();
|
||||
|
||||
void setLight(@Nullable ChunkSectionLight light);
|
||||
|
||||
/**
|
||||
* Returns the palette of the given type if present.
|
||||
*
|
||||
* @param type type of the palette
|
||||
* @return palette
|
||||
*/
|
||||
@Nullable DataPalette palette(PaletteType type);
|
||||
|
||||
void addPalette(PaletteType type, DataPalette blockPalette);
|
||||
|
||||
void removePalette(PaletteType type);
|
||||
}
|
||||
+27
-102
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,120 +22,30 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import java.util.EnumMap;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ChunkSectionImpl implements ChunkSection {
|
||||
|
||||
private final IntList palette;
|
||||
private final Int2IntMap inversePalette;
|
||||
private final int[] blocks;
|
||||
private final EnumMap<PaletteType, DataPalette> palettes = new EnumMap<>(PaletteType.class);
|
||||
private ChunkSectionLight light;
|
||||
private int nonAirBlocksCount;
|
||||
|
||||
public ChunkSectionImpl(boolean holdsLight) {
|
||||
this.blocks = new int[SIZE];
|
||||
palette = new IntArrayList();
|
||||
inversePalette = new Int2IntOpenHashMap();
|
||||
inversePalette.defaultReturnValue(-1);
|
||||
public ChunkSectionImpl() {
|
||||
}
|
||||
|
||||
public ChunkSectionImpl(final boolean holdsLight) {
|
||||
addPalette(PaletteType.BLOCKS, new DataPaletteImpl(ChunkSection.SIZE));
|
||||
if (holdsLight) {
|
||||
this.light = new ChunkSectionLightImpl();
|
||||
}
|
||||
}
|
||||
|
||||
public ChunkSectionImpl(boolean holdsLight, int expectedPaletteLength) {
|
||||
this.blocks = new int[SIZE];
|
||||
public ChunkSectionImpl(final boolean holdsLight, final int expectedPaletteLength) {
|
||||
addPalette(PaletteType.BLOCKS, new DataPaletteImpl(ChunkSection.SIZE, expectedPaletteLength));
|
||||
if (holdsLight) {
|
||||
this.light = new ChunkSectionLightImpl();
|
||||
}
|
||||
|
||||
// Pre-size the palette array/map
|
||||
palette = new IntArrayList(expectedPaletteLength);
|
||||
inversePalette = new Int2IntOpenHashMap(expectedPaletteLength);
|
||||
inversePalette.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlatBlock(int idx) {
|
||||
int index = blocks[idx];
|
||||
return palette.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlatBlock(int idx, int id) {
|
||||
int index = inversePalette.get(id);
|
||||
if (index == -1) {
|
||||
index = palette.size();
|
||||
palette.add(id);
|
||||
inversePalette.put(id, index);
|
||||
}
|
||||
|
||||
blocks[idx] = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPaletteIndex(int idx) {
|
||||
return blocks[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaletteIndex(int idx, int index) {
|
||||
blocks[idx] = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPaletteSize() {
|
||||
return palette.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPaletteEntry(int index) {
|
||||
return palette.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaletteEntry(int index, int id) {
|
||||
int oldId = palette.set(index, id);
|
||||
if (oldId == id) return;
|
||||
|
||||
inversePalette.put(id, index);
|
||||
if (inversePalette.get(oldId) == index) {
|
||||
inversePalette.remove(oldId);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.getInt(i) == oldId) {
|
||||
inversePalette.put(oldId, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replacePaletteEntry(int oldId, int newId) {
|
||||
int index = inversePalette.remove(oldId);
|
||||
if (index == -1) return;
|
||||
|
||||
inversePalette.put(newId, index);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.getInt(i) == oldId) {
|
||||
palette.set(i, newId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPaletteEntry(int id) {
|
||||
inversePalette.put(id, palette.size());
|
||||
palette.add(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPalette() {
|
||||
palette.clear();
|
||||
inversePalette.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,7 +54,7 @@ public class ChunkSectionImpl implements ChunkSection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNonAirBlocksCount(int nonAirBlocksCount) {
|
||||
public void setNonAirBlocksCount(final int nonAirBlocksCount) {
|
||||
this.nonAirBlocksCount = nonAirBlocksCount;
|
||||
}
|
||||
|
||||
@@ -154,7 +64,22 @@ public class ChunkSectionImpl implements ChunkSection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLight(@Nullable ChunkSectionLight light) {
|
||||
public void setLight(@Nullable final ChunkSectionLight light) {
|
||||
this.light = light;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataPalette palette(final PaletteType type) {
|
||||
return palettes.get(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPalette(final PaletteType type, final DataPalette palette) {
|
||||
palettes.put(type, palette);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePalette(final PaletteType type) {
|
||||
palettes.remove(type);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+6
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -47,6 +47,11 @@ public class ChunkSectionLightImpl implements ChunkSectionLight {
|
||||
|
||||
@Override
|
||||
public void setSkyLight(byte[] data) {
|
||||
if (data == null) {
|
||||
this.skyLight = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
|
||||
if (this.skyLight == null) {
|
||||
this.skyLight = new NibbleArray(data);
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
public interface DataPalette {
|
||||
|
||||
/**
|
||||
* Returns the packet section index of the given coordinates.
|
||||
*
|
||||
* @param x x
|
||||
* @param y y
|
||||
* @param z z
|
||||
* @return packed section index of the given coordinates
|
||||
*/
|
||||
int index(final int x, final int y, final int z);
|
||||
|
||||
/**
|
||||
* Returns the value of the given chunk coordinate.
|
||||
*
|
||||
* @param sectionCoordinate section index within the section
|
||||
* @return section state of the given index
|
||||
*/
|
||||
int idAt(int sectionCoordinate);
|
||||
|
||||
/**
|
||||
* Returns the value of the section coordinate.
|
||||
*
|
||||
* @param sectionX section x
|
||||
* @param sectionY section y
|
||||
* @param sectionZ section z
|
||||
* @return id of the given section coordinate
|
||||
*/
|
||||
default int idAt(final int sectionX, final int sectionY, final int sectionZ) {
|
||||
return idAt(index(sectionX, sectionY, sectionZ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value in the chunk section.
|
||||
* This method does not update non-air blocks count.
|
||||
*
|
||||
* @param sectionCoordinate section index within the section
|
||||
* @param id id value
|
||||
*/
|
||||
void setIdAt(int sectionCoordinate, int id);
|
||||
|
||||
/**
|
||||
* Set a value in the chunk section.
|
||||
* This method does not update non-air blocks count.
|
||||
*
|
||||
* @param sectionX section x
|
||||
* @param sectionY section y
|
||||
* @param sectionZ section z
|
||||
* @param id id value
|
||||
*/
|
||||
default void setIdAt(final int sectionX, final int sectionY, final int sectionZ, final int id) {
|
||||
setIdAt(index(sectionX, sectionY, sectionZ), id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id assigned to the given palette index.
|
||||
*
|
||||
* @param index palette index
|
||||
* @return id assigned to the given palette index
|
||||
*/
|
||||
int idByIndex(int index);
|
||||
|
||||
/**
|
||||
* Assigns an id assigned to the given palette index.
|
||||
*
|
||||
* @param index palette index
|
||||
* @param id id value
|
||||
*/
|
||||
void setIdByIndex(int index, int id);
|
||||
|
||||
/**
|
||||
* Returns the palette index of the given section index.
|
||||
*
|
||||
* @param packedCoordinate section index
|
||||
* @return palette index of the given section index
|
||||
*/
|
||||
int paletteIndexAt(int packedCoordinate);
|
||||
|
||||
/**
|
||||
* Sets the index of the given section coordinate.
|
||||
*
|
||||
* @param sectionCoordinate section index
|
||||
* @param index palette index
|
||||
*/
|
||||
void setPaletteIndexAt(int sectionCoordinate, int index);
|
||||
|
||||
/**
|
||||
* Adds a new id to the palette.
|
||||
*
|
||||
* @param id id value
|
||||
*/
|
||||
void addId(int id);
|
||||
|
||||
/**
|
||||
* Replaces an id in the palette.
|
||||
*
|
||||
* @param oldId old id
|
||||
* @param newId new id
|
||||
*/
|
||||
void replaceId(int oldId, int newId);
|
||||
|
||||
/**
|
||||
* Returns the size of the palette.
|
||||
*
|
||||
* @return palette size
|
||||
*/
|
||||
int size();
|
||||
|
||||
/**
|
||||
* Clears the palette.
|
||||
*/
|
||||
void clear();
|
||||
}
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft.chunks;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
|
||||
public final class DataPaletteImpl implements DataPalette {
|
||||
|
||||
private static final int DEFAULT_INITIAL_SIZE = 16;
|
||||
|
||||
private final IntList palette;
|
||||
private final Int2IntMap inversePalette;
|
||||
private final int sizeBits;
|
||||
private ChunkData values;
|
||||
|
||||
public DataPaletteImpl(final int valuesLength) {
|
||||
this(valuesLength, DEFAULT_INITIAL_SIZE);
|
||||
}
|
||||
|
||||
public DataPaletteImpl(final int valuesLength, final int initialSize) {
|
||||
values = new EmptyChunkData(valuesLength);
|
||||
sizeBits = Integer.numberOfTrailingZeros(valuesLength) / 3;
|
||||
// Pre-size the palette array/map
|
||||
palette = new IntArrayList(initialSize);
|
||||
// To get an initial table size of initialSize, need to scale it down by load factor.
|
||||
inversePalette = new Int2IntOpenHashMap((int) (initialSize * Int2IntOpenHashMap.DEFAULT_LOAD_FACTOR));
|
||||
inversePalette.defaultReturnValue(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int index(final int x, final int y, final int z) {
|
||||
return (y << this.sizeBits | z) << this.sizeBits | x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idAt(final int sectionCoordinate) {
|
||||
final int index = values.get(sectionCoordinate);
|
||||
return palette.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdAt(final int sectionCoordinate, final int id) {
|
||||
int index = inversePalette.get(id);
|
||||
if (index == -1) {
|
||||
index = palette.size();
|
||||
palette.add(id);
|
||||
inversePalette.put(id, index);
|
||||
}
|
||||
|
||||
values.set(sectionCoordinate, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int paletteIndexAt(final int packedCoordinate) {
|
||||
return values.get(packedCoordinate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaletteIndexAt(final int sectionCoordinate, final int index) {
|
||||
values.set(sectionCoordinate, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return palette.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idByIndex(final int index) {
|
||||
return palette.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdByIndex(final int index, final int id) {
|
||||
final int oldId = palette.set(index, id);
|
||||
if (oldId == id) return;
|
||||
|
||||
inversePalette.put(id, index);
|
||||
if (inversePalette.get(oldId) == index) {
|
||||
inversePalette.remove(oldId);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.getInt(i) == oldId) {
|
||||
inversePalette.put(oldId, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceId(final int oldId, final int newId) {
|
||||
final int index = inversePalette.remove(oldId);
|
||||
if (index == -1) return;
|
||||
|
||||
inversePalette.put(newId, index);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.getInt(i) == oldId) {
|
||||
palette.set(i, newId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addId(final int id) {
|
||||
inversePalette.put(id, palette.size());
|
||||
palette.add(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
palette.clear();
|
||||
inversePalette.clear();
|
||||
}
|
||||
|
||||
interface ChunkData {
|
||||
int get(int idx);
|
||||
void set(int idx, int val);
|
||||
}
|
||||
|
||||
private class EmptyChunkData implements ChunkData {
|
||||
|
||||
private final int size;
|
||||
|
||||
public EmptyChunkData(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int get(int idx) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int idx, int val) {
|
||||
if (val != 0) {
|
||||
values = new ByteChunkData(size);
|
||||
values.set(idx, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ByteChunkData implements ChunkData {
|
||||
private final byte[] data;
|
||||
|
||||
public ByteChunkData(int size) {
|
||||
this.data = new byte[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int get(int idx) {
|
||||
return data[idx] & 0xFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int idx, int val) {
|
||||
// Overflowed size of byte (over 256 different materials), go up to short
|
||||
if (val > 0xFF) {
|
||||
values = new ShortChunkData(data);
|
||||
values.set(idx, val);
|
||||
return;
|
||||
}
|
||||
data[idx] = (byte) val;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ShortChunkData implements ChunkData {
|
||||
private final short[] data;
|
||||
|
||||
public ShortChunkData(byte[] data) {
|
||||
this.data = new short[data.length];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
this.data[i] = (short) (data[i] & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int get(int idx) {
|
||||
return data[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int idx, int val) {
|
||||
data[idx] = (short) val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 1013 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user