Compare commits
452 Commits
Author | SHA1 | Date |
---|---|---|
Nassim Jahnke | 2d41eb52a6 | |
Nassim Jahnke | 7e268a6f87 | |
Nassim Jahnke | 113bf1e275 | |
EnZaXD | 2aec3ce6d1 | |
EnZaXD | f60e31ac78 | |
EnZaXD | 8c4ff7ebfc | |
Nassim Jahnke | 4c7729e602 | |
Nassim Jahnke | 3dfc3bb15b | |
EnZaXD | 69b33dc2d2 | |
EnZaXD | c24169c410 | |
Nassim Jahnke | 31211c2214 | |
Nassim Jahnke | cb5fc9fb08 | |
EnZaXD | a8d7ab62e3 | |
Nassim Jahnke | 71313b4753 | |
Nassim Jahnke | 994bc8eefc | |
Nassim Jahnke | 7d35826637 | |
Nassim Jahnke | 4f40372392 | |
Nassim Jahnke | e993be751c | |
Nassim Jahnke | f1b92fea8d | |
Nassim Jahnke | fc9d5b6d9d | |
EnZaXD | 9549a18cec | |
Nassim Jahnke | d691096ce1 | |
Nassim Jahnke | 73ed425bf7 | |
EnZaXD | cdc9c3ae95 | |
EnZaXD | c113e19d41 | |
EnZaXD | d3af70d76c | |
Nassim Jahnke | c00bc6b667 | |
Nassim Jahnke | fa3c933b2f | |
Nassim Jahnke | 07bb0269c3 | |
Nassim Jahnke | 57c0d83608 | |
Nassim Jahnke | 4854b131b8 | |
Nassim Jahnke | 1864b66e42 | |
Nassim Jahnke | 8aa6769193 | |
Nassim Jahnke | 5f90bcbbaf | |
Nassim Jahnke | d068822143 | |
Nassim Jahnke | a77e328dfe | |
Gero | 9c84e0dbe9 | |
Nassim Jahnke | 66e0453398 | |
Nassim Jahnke | 7ec6888a30 | |
Nassim Jahnke | c9733948b3 | |
Nassim Jahnke | 798b70cbe6 | |
Nassim Jahnke | 1f43ff571d | |
Nassim Jahnke | d28e7cd652 | |
Nassim Jahnke | f20d99fcef | |
Nassim Jahnke | a1c182f291 | |
Nassim Jahnke | 8e63fd635b | |
FlorianMichael | 676e62c71f | |
FlorianMichael | f422e03348 | |
Nassim Jahnke | fdf735420f | |
Nassim Jahnke | b13fbbe175 | |
Nassim Jahnke | 9dd3348510 | |
Nassim Jahnke | 0e97af29b4 | |
Nassim Jahnke | 3dfcd6b9b9 | |
Nassim Jahnke | 8df0c0ae2e | |
Nassim Jahnke | d2ca6a82be | |
Nassim Jahnke | 9654a613cd | |
Nassim Jahnke | c5e6fa7d0c | |
Nassim Jahnke | b78f9d350b | |
Nassim Jahnke | ebbe1b6da2 | |
Nassim Jahnke | 3aed7cb949 | |
Nassim Jahnke | e2f3dc7572 | |
Nassim Jahnke | f2b9c42590 | |
Nassim Jahnke | 9894671274 | |
Nassim Jahnke | 71ab15b331 | |
Nassim Jahnke | 34bc5b9d36 | |
Nassim Jahnke | d80fd46c2f | |
Nassim Jahnke | b47446d9f7 | |
EnZaXD | dcf741a2ba | |
Nassim Jahnke | a4adef3cec | |
Nassim Jahnke | f525ad98e7 | |
Nassim Jahnke | bc0b4470f6 | |
Nassim Jahnke | d3d6d4f1cd | |
Nassim Jahnke | 5069b26c2f | |
FlorianMichael | 079671060c | |
Nassim Jahnke | 89cd8aec1d | |
Nassim Jahnke | 7ac7ea485f | |
Nassim Jahnke | 5e4f25efeb | |
Nassim Jahnke | a152993ffd | |
Nassim Jahnke | 73daac471c | |
Nassim Jahnke | f4e9225f85 | |
EnZaXD | 1ed22327f6 | |
EnZaXD | ce2ad7d5eb | |
FlorianMichael | d7e66260de | |
FlorianMichael | dc6d581123 | |
FlorianMichael | bd3f1206e6 | |
FlorianMichael | b9e92e5c1f | |
Gero | 0acaed7c7a | |
FlorianMichael | 3055a4277d | |
Gero | bcbe69d24c | |
EnZaXD | 33cc21d6e6 | |
Nassim Jahnke | 949b3d712e | |
Nassim Jahnke | 216dcb2931 | |
Nassim Jahnke | bff1536529 | |
Nassim Jahnke | b221e47eb7 | |
EnZaXD | fb434a79bd | |
Nassim Jahnke | 1be0605f51 | |
Nassim Jahnke | c75b4d8ef5 | |
Gero | e08c263ced | |
Nassim Jahnke | 1bb85b11e9 | |
AJ Ferguson | 128e191132 | |
Nassim Jahnke | 3520f99d5a | |
RaphiMC | 7825a1e460 | |
RK_01 | bfde4b953c | |
Nassim Jahnke | 57b37457d6 | |
Nassim Jahnke | f7aa1a516e | |
Nassim Jahnke | b1468ac6d0 | |
Nassim Jahnke | 27b5fdb4ff | |
Nassim Jahnke | a99273db2e | |
Nassim Jahnke | 64f911ed4a | |
EnZaXD | 4302dd61aa | |
EnZaXD | 98c5d38d0c | |
FlorianMichael | 033d5ae49a | |
Nassim Jahnke | 8cf9114403 | |
EnZaXD | bd8e469216 | |
EnZaXD | 57d7fd59cc | |
EnZaXD | 8fe0681778 | |
EnZaXD | ea5cf3e594 | |
Nassim Jahnke | 13eec3c2ea | |
Nassim Jahnke | 31ccd2ab9b | |
FlorianMichael | 2be190d152 | |
FlorianMichael | 4e25549682 | |
FlorianMichael | 287678c12a | |
FlorianMichael | 4343aa17fc | |
FlorianMichael | 970986bc59 | |
RK_01 | 2586788bf6 | |
EnZaXD | 0c2c8400ae | |
Nassim Jahnke | ba4404fad6 | |
RK_01 | 6f53c069ea | |
Nassim Jahnke | 99f29e2597 | |
EnZaXD | 7932b79080 | |
FlorianMichael | 4b780b92ee | |
Nassim Jahnke | d04aaeb926 | |
FlorianMichael | 9f1ee27afc | |
Nassim Jahnke | 5f685884ff | |
FlorianMichael | ba2e50cc88 | |
FlorianMichael | 7b28683b6a | |
Nassim Jahnke | 510747a7cd | |
Nassim Jahnke | 8c5752bb4c | |
Nassim Jahnke | 33e2a1fc13 | |
Nassim Jahnke | dbe8a389ce | |
Nassim Jahnke | 83223c1520 | |
FlorianMichael | 935077222e | |
FlorianMichael | 8961660846 | |
Nassim Jahnke | 1fe23e4aeb | |
Nassim Jahnke | 06394c1f74 | |
Nassim Jahnke | 68c2af2795 | |
Nassim Jahnke | 35a00d0b95 | |
Nassim Jahnke | c2489c7a4c | |
Nassim Jahnke | c743c20334 | |
FlorianMichael | 228689f181 | |
Nassim Jahnke | 67e6e1a2e3 | |
Nassim Jahnke | a2c1c52f51 | |
Nassim Jahnke | fd4db24d44 | |
Nassim Jahnke | 0b7fdd4c69 | |
Nassim Jahnke | 4849ca0745 | |
Nassim Jahnke | 60b782455d | |
FlorianMichael | 3fef71db2e | |
Nassim Jahnke | 9ca02680c8 | |
FlorianMichael | 5899886b42 | |
Nassim Jahnke | c2567115d8 | |
Nassim Jahnke | 4255876c22 | |
FlorianMichael | 57a589924d | |
Nassim Jahnke | 936dcafc11 | |
Nassim Jahnke | b6489b8343 | |
Nassim Jahnke | bf11a0a7de | |
Nassim Jahnke | 7d41706026 | |
FlorianMichael | 93f081dd84 | |
Nassim Jahnke | 3f82b150d2 | |
Nassim Jahnke | 7a96498f6d | |
FlorianMichael | 817febe605 | |
Nassim Jahnke | bb4a8b73e0 | |
Nassim Jahnke | 8d3492ba30 | |
Nassim Jahnke | 658364b643 | |
Nassim Jahnke | 666b204ebb | |
Nassim Jahnke | bfab9b0c11 | |
Nassim Jahnke | 121f107ff3 | |
Nassim Jahnke | 426bd9aa99 | |
Nassim Jahnke | 7a66bb8e1c | |
Nassim Jahnke | 329abcac7d | |
Nassim Jahnke | 0961de898d | |
Nassim Jahnke | b4ee564aa2 | |
EnZaXD | 73178b504e | |
EnZaXD | d0cc531386 | |
EnZaXD | 617ef10667 | |
EnZaXD | 5569caf610 | |
EnZaXD | 868a5bd24e | |
EnZaXD | b113a82710 | |
EnZaXD | 3ee4c8ed63 | |
EnZaXD | cd65925d6b | |
Nassim Jahnke | 307414eb51 | |
EnZaXD | 51745cb2ef | |
EnZaXD | f44782d21d | |
EnZaXD | 7556f7b8fa | |
EnZaXD | abd58399cd | |
EnZaXD | 0a2fd8f296 | |
EnZaXD | f2c816df72 | |
EnZaXD | 098f7ff3c2 | |
RK_01 | 18f04bf8ea | |
Nassim Jahnke | feefe6f278 | |
Nassim Jahnke | 4074231a57 | |
Kichura | 13efe47a5c | |
Nassim Jahnke | b07cf03dc1 | |
Nassim Jahnke | 0a921d9bdc | |
EnZaXD | 7b0c2fb51a | |
Nassim Jahnke | b426302e76 | |
Nassim Jahnke | 3442cda8ce | |
Nassim Jahnke | 55a0a70264 | |
EnZaXD | a9bfda4568 | |
Nassim Jahnke | 93990c8baa | |
Nassim Jahnke | f868dfa125 | |
Nassim Jahnke | 386495e168 | |
Nassim Jahnke | cad78ea68f | |
EnZaXD | 908823c612 | |
Nassim Jahnke | f6d48e258f | |
Nassim Jahnke | 1f5ee6d763 | |
Nassim Jahnke | 8edad67394 | |
Nassim Jahnke | 2d03110f08 | |
Nassim Jahnke | 92878a39ef | |
Nassim Jahnke | aa0423c6e2 | |
Nassim Jahnke | 04e572fa30 | |
Nassim Jahnke | 39180e22b8 | |
Nassim Jahnke | f68aed464d | |
Nassim Jahnke | 6ffa24b50b | |
Nassim Jahnke | e51d7b3fdb | |
Nassim Jahnke | 01bb8dedda | |
EnZaXD | 6cdca97d35 | |
EnZaXD | dafce79374 | |
RK_01 | 4cf271af81 | |
Nassim Jahnke | aa262bb0a5 | |
Nassim Jahnke | 2480eb6a7f | |
Nassim Jahnke | 56b82b049a | |
EnZaXD | 3c0930c62f | |
EnZaXD | 26a8e5fef1 | |
caramel | caa6519780 | |
caramel | 1e35c2713f | |
caramel | cd5d88c34f | |
EnZaXD | 7640342165 | |
EnZaXD | fe0d30df78 | |
Nassim Jahnke | 4e1d4a75b2 | |
EnZaXD | 343b403cf1 | |
RK_01 | 78aecbddf8 | |
Nassim Jahnke | 48241ba841 | |
Nassim Jahnke | a8fbb000eb | |
EnZaXD | ff25cbd6eb | |
Nassim Jahnke | e2a7e10312 | |
EnZaXD | c7baa27fd0 | |
Nassim Jahnke | 35578372a1 | |
EnZaXD | 293427c172 | |
EnZaXD | 08d8ccf6ca | |
EnZaXD | 35ceee1a47 | |
Nassim Jahnke | dccda57fc0 | |
Nassim Jahnke | 5c21f60ef7 | |
Nassim Jahnke | c124c1c809 | |
EnZaXD | 302716054d | |
Nassim Jahnke | 46a5bb16d7 | |
EnZaXD | f3f7ea7987 | |
EnZaXD | e62c4a3f9e | |
EnZaXD | d58c80cd2f | |
Nassim Jahnke | 7a6c51331b | |
Nassim Jahnke | 564286d742 | |
Nassim Jahnke | dcc0642af9 | |
EnZaXD | e449599ae7 | |
Nassim Jahnke | 621c02f974 | |
Nassim Jahnke | 22bd350e35 | |
Nassim Jahnke | a8dc5f0f07 | |
Nassim Jahnke | d76edced04 | |
Nassim Jahnke | cfc048ba53 | |
Nassim Jahnke | c7265abfe9 | |
Nassim Jahnke | 8a485db580 | |
Nassim Jahnke | e0f32d9f2f | |
EnZaXD | ad62d8552c | |
Nassim Jahnke | 4a8bd2cca2 | |
Nassim Jahnke | 0fcb764652 | |
Nassim Jahnke | 46e322b2f3 | |
Nassim Jahnke | 87d444a017 | |
Nassim Jahnke | e020c616c9 | |
Nassim Jahnke | da87241549 | |
EnZaXD | 0d788b0d7a | |
Nassim Jahnke | 1c6f8426f1 | |
Nassim Jahnke | 01f28a052c | |
Nassim Jahnke | cfc9011cee | |
Nassim Jahnke | 6473b608f6 | |
Nassim Jahnke | a5bd8abe93 | |
EnZaXD | f3d95b1e5e | |
Nassim Jahnke | c8d339ab30 | |
Nassim Jahnke | 8000561ae9 | |
Nassim Jahnke | 1dafa7d273 | |
Nassim Jahnke | ce8fab7c44 | |
Nassim Jahnke | 37561705ed | |
Nassim Jahnke | 00176c4a0c | |
Kichura | cef6fb35b1 | |
Nassim Jahnke | 7b8a33cc78 | |
Nassim Jahnke | ceae2c2094 | |
Nassim Jahnke | 52b9db5029 | |
Nassim Jahnke | 27af372f79 | |
Nassim Jahnke | c4e50efa90 | |
Nassim Jahnke | fa1ae5b9c9 | |
Nassim Jahnke | 8f6784e0e2 | |
Nassim Jahnke | 5d5c98acc6 | |
vadage | 5b29ac0d8a | |
Kichura | 3b9d399afd | |
Nassim Jahnke | 0946c72bdc | |
Nassim Jahnke | 05470c5f1b | |
Nassim Jahnke | 0392992173 | |
Nassim Jahnke | 34bd15dec7 | |
Nassim Jahnke | ef78fcd478 | |
EnZaXD | 9d646543b6 | |
Nassim Jahnke | aecef3c3f8 | |
Nassim Jahnke | 5991ac5633 | |
Nassim Jahnke | 930454a723 | |
Nassim Jahnke | b6ba7dcc44 | |
Nassim Jahnke | abb05ce902 | |
Nassim Jahnke | a561bad004 | |
Nassim Jahnke | bd2c4c8a16 | |
Nassim Jahnke | f6c49555bf | |
Nassim Jahnke | bd99b892db | |
Nassim Jahnke | 7b4d544e85 | |
Nassim Jahnke | fe0fbc7081 | |
Nassim Jahnke | bae3d8ec8a | |
RK_01 | 00b8d22cf6 | |
Nassim Jahnke | d62284e9cd | |
Nassim Jahnke | 3904ed4fd7 | |
RK_01 | 28a0813676 | |
Nassim Jahnke | ca4b6fc765 | |
Nassim Jahnke | f2f357b2ae | |
Nassim Jahnke | dc2986600c | |
Nassim Jahnke | 984c625776 | |
Nassim Jahnke | c62a8274ed | |
RK_01 | 64c436c2e1 | |
Jerry Xiao | 0e31664bfe | |
Valaphee The Meerkat | 18f2cf25cd | |
Kichura | 84b093a997 | |
Nassim Jahnke | 794f401bd0 | |
Nassim Jahnke | dc732fac6f | |
Nassim Jahnke | 2f8114abb1 | |
Nassim Jahnke | 90781c9d27 | |
Myles | 9b1716b662 | |
Jo0001 | dcd4502f5a | |
Aeltumn | 5d4b104b33 | |
Nassim Jahnke | 8e38e25cba | |
Jo0001 | 82e05afacf | |
Nassim Jahnke | 5c8c589a40 | |
Nassim Jahnke | 70645ec5ee | |
Nassim Jahnke | 4aefc23bb8 | |
Nassim Jahnke | 2c9affa0e3 | |
Nassim Jahnke | 1656ad45a0 | |
Nassim Jahnke | ec2397472d | |
Nassim Jahnke | cf5f5ed4bb | |
Nassim Jahnke | 9387b86e4a | |
Nassim Jahnke | e3224281a9 | |
Nassim Jahnke | f762da2725 | |
Nassim Jahnke | 9a7def62b9 | |
Nassim Jahnke | ec27cc7a7b | |
Nassim Jahnke | 3b9ac89d73 | |
Nassim Jahnke | 23ba848a69 | |
Nassim Jahnke | d98c458a4c | |
Nassim Jahnke | 1ad65d1bb0 | |
David Lüdtke | d44d89099b | |
Nassim Jahnke | d5326fad95 | |
Nassim Jahnke | 7de9bc604a | |
Nassim Jahnke | dfee03ddbf | |
Nassim Jahnke | 3babc7a13a | |
Nassim Jahnke | 0b1423d8b4 | |
Nassim Jahnke | 6efeb16822 | |
RK_01 | 9b09b1f5f8 | |
RK_01 | 851295d48c | |
RK_01 | 1f453dc0d9 | |
RK_01 | 916c08ce7e | |
RK_01 | 0ac29fb2c2 | |
Nassim Jahnke | 45d08e9066 | |
Nassim Jahnke | bc0bef2e07 | |
Nassim Jahnke | 6d82839e6d | |
Nassim Jahnke | c039f4e24c | |
Nassim Jahnke | 4add75cda7 | |
Nassim Jahnke | 28f661f270 | |
Nassim Jahnke | 42f38c3209 | |
Nassim Jahnke | 151ecdcd72 | |
Nassim Jahnke | a0f8ab7bbb | |
Nassim Jahnke | 1af2103f6c | |
Nassim Jahnke | 8769742917 | |
Nassim Jahnke | 20f4907a23 | |
Nassim Jahnke | 6fb27e5c17 | |
Nassim Jahnke | 07b173bb74 | |
Nassim Jahnke | dbf4271c9d | |
Nassim Jahnke | a2d287ff9f | |
Nassim Jahnke | 58ca2024e1 | |
Nassim Jahnke | 2881fb18e0 | |
Nassim Jahnke | ffdddeeb0a | |
Nassim Jahnke | e356a35aa7 | |
Nassim Jahnke | 0474810b8d | |
Nassim Jahnke | ea818b272e | |
Nassim Jahnke | 9342b19aad | |
Nassim Jahnke | 2968047571 | |
Nassim Jahnke | dccac81286 | |
Myles | bc67e8d952 | |
Myles | f9ab1bd811 | |
Jo0001 | 8776e8bdc0 | |
Jo0001 | ba882f8f98 | |
fren_gor | a022620712 | |
EnZaXD | f618cdec99 | |
Nassim Jahnke | ec2093cf5d | |
EnZaXD | eb9bc2fdce | |
EnZaXD | f35b4f1fac | |
EnZaXD | abe880dae6 | |
EnZaXD | 0f030c86a7 | |
EnZaXD | 2c6e18e4fe | |
RK_01 | 78c7f03923 | |
RK_01 | 68a32ed2f0 | |
EnZaXD | 7cf008bb62 | |
RK_01 | a60342359b | |
RK_01 | 0e269fa493 | |
Nassim Jahnke | 815e0820da | |
Nassim Jahnke | faedf26b5b | |
RK_01 | c7c38e70c0 | |
Nassim Jahnke | 21d293dd7f | |
Nassim Jahnke | 6481cec270 | |
Nassim Jahnke | 54c04a62e0 | |
Nassim Jahnke | 7edde72416 | |
Nassim Jahnke | 84a054aac1 | |
Nassim Jahnke | 8ebc8c34f3 | |
Nassim Jahnke | 50e55529d9 | |
Nassim Jahnke | 553dd2cb45 | |
Nassim Jahnke | a30d62a995 | |
Nassim Jahnke | 08f6b3ce36 | |
Nassim Jahnke | 7d1b0d83ce | |
Nassim Jahnke | e7d0b01eee | |
Nassim Jahnke | fdfc528a9a | |
Nassim Jahnke | dccb6f234b | |
Nassim Jahnke | 6e7f936e83 | |
Nassim Jahnke | ec26bafd53 | |
Nassim Jahnke | d7d7940d0b | |
Nassim Jahnke | 667278f9e6 | |
Nassim Jahnke | fa7096c5c1 | |
Kichura | 958064b44c | |
Nassim Jahnke | 26dad99265 | |
Pablo Herrera | d8007dc73c | |
Nassim Jahnke | 5850a9852d | |
Nassim Jahnke | 095fe16447 | |
Nassim Jahnke | cbf8b8f401 | |
Nassim Jahnke | d600b0cbe1 | |
Nassim Jahnke | 0d70cdbe15 | |
Nassim Jahnke | b1b0874c0f | |
Nassim Jahnke | 67ba0e9566 | |
Nassim Jahnke | bebdc34b4b | |
Nassim Jahnke | 3e0eb90662 | |
Nassim Jahnke | d8f98945e2 | |
RK_01 | 0c3d709456 | |
EnZaXD | 868c5ba203 | |
Nassim Jahnke | 0953ff77e4 | |
Nassim Jahnke | c211b10eaa | |
Nassim Jahnke | def3bf9d4a | |
Nassim Jahnke | cb1b33b3e7 |
|
@ -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
|
|
@ -23,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:
|
||||
|
@ -71,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:
|
||||
|
|
|
@ -13,12 +13,12 @@ jobs:
|
|||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
uses: gradle/wrapper-validation-action@v2
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 11
|
||||
java-version: 17
|
||||
check-latest: true
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
|
|
|
@ -13,9 +13,9 @@ jobs:
|
|||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
uses: gradle/wrapper-validation-action@v2
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion Copyright (C) &#36;originalComment.match("Copyright \(C\) (\d+)", 1, "-")&#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="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>
|
|
@ -1,6 +1,6 @@
|
|||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion Copyright (C) &#36;originalComment.match("Copyright \(C\) (\d+)", 1, "-")&#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="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>
|
|
@ -1,3 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="ViaVersion-API" pattern="src[viaversion-parent.viaversion-api*]:*..*&&!src[viaversion-parent.viaversion-api.main]:com.viaversion.viaversion.api.minecraft.nbt.*" />
|
||||
<scope name="ViaVersion-API" pattern="src[viaversion-parent.viaversion-api*]:*..*" />
|
||||
</component>
|
|
@ -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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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,7 @@
|
|||
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 java.util.ArrayList;
|
||||
|
@ -42,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");
|
||||
|
@ -77,17 +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 VersionRange("1.18", 0, 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/2", new VersionRange("1.19", 1, 2));
|
||||
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 VersionRange("1.20", 0, 1));
|
||||
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) {
|
||||
|
@ -98,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);
|
||||
|
@ -165,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;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
plugins {
|
||||
id("net.kyori.blossom")
|
||||
id("org.jetbrains.gradle.plugin.idea-ext")
|
||||
id("via.shadow-conventions")
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
@ -16,14 +15,13 @@ sourceSets {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
api(projects.adventure) {
|
||||
targetConfiguration = "shadow"
|
||||
}
|
||||
api(libs.fastutil)
|
||||
api(libs.flare)
|
||||
api(libs.flareFastutil)
|
||||
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)
|
||||
|
@ -34,3 +32,5 @@ dependencies {
|
|||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
publishShadowJar()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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-2023 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-2023 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,10 +27,13 @@ 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 java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -63,7 +66,7 @@ public interface ViaAPI<T> {
|
|||
* @return API version incremented with meaningful API changes
|
||||
*/
|
||||
default int apiVersion() {
|
||||
return 20;
|
||||
return 26;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,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.
|
||||
|
@ -88,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.
|
||||
|
@ -117,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);
|
||||
|
@ -126,11 +152,21 @@ 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.
|
||||
|
@ -138,14 +174,15 @@ public interface ViaAPI<T> {
|
|||
* @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 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-2023 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,6 +23,7 @@
|
|||
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;
|
||||
|
@ -91,6 +92,13 @@ public interface ViaManager {
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
@ -138,4 +146,5 @@ public interface ViaManager {
|
|||
* @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-2023 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-2023 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 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-2023 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,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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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,20 +20,34 @@
|
|||
* 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.configuration;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import java.util.Map;
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public class Particle1_17Type extends AbstractParticleType {
|
||||
public interface Config {
|
||||
|
||||
public Particle1_17Type() {
|
||||
readers.put(4, blockHandler());
|
||||
readers.put(25, blockHandler());
|
||||
readers.put(15, dustHandler());
|
||||
readers.put(16, dustTransitionHandler());
|
||||
readers.put(36, itemHandler(Type.FLAT_VAR_INT_ITEM));
|
||||
readers.put(37, vibrationHandler(Type.POSITION1_14));
|
||||
}
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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,10 +27,8 @@ 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;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ViaVersionConfig {
|
||||
public interface ViaVersionConfig extends Config {
|
||||
|
||||
/**
|
||||
* Get if the plugin should check for updates
|
||||
|
@ -87,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();
|
||||
|
||||
|
@ -126,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();
|
||||
|
||||
|
@ -235,13 +233,6 @@ public interface ViaVersionConfig {
|
|||
*/
|
||||
boolean isChunkBorderFix();
|
||||
|
||||
/**
|
||||
* Force json transform
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isForceJsonTransform();
|
||||
|
||||
/**
|
||||
* Should we fix nbt array's in json chat messages for 1.12 clients
|
||||
*
|
||||
|
@ -272,17 +263,6 @@ public interface ViaVersionConfig {
|
|||
*/
|
||||
BlockedProtocolVersions blockedProtocolVersions();
|
||||
|
||||
/**
|
||||
* Get the blocked protocols
|
||||
*
|
||||
* @return An Integer list
|
||||
* @deprecated use {@link #blockedProtocolVersions()}
|
||||
*/
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
default IntSet getBlockedProtocols() {
|
||||
return blockedProtocolVersions().singleBlockedVersions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom disconnect message
|
||||
*
|
||||
|
@ -384,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
|
||||
*/
|
||||
|
@ -443,16 +423,38 @@ public interface ViaVersionConfig {
|
|||
|
||||
/***
|
||||
* Get the world names that should be returned for each Vanilla dimension.
|
||||
* Note that this can be overriden per-user by using {@link UserConnection#put(StorableObject)} with
|
||||
* 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();
|
||||
|
||||
@Nullable String chatTypeFormat(String translationKey);
|
||||
|
||||
/**
|
||||
* 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-2023 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
|
||||
|
@ -65,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-2023 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.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 com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
@ -93,24 +94,36 @@ public interface ProtocolInfo {
|
|||
void setServerState(State serverState);
|
||||
|
||||
/**
|
||||
* Returns the user's protocol version, or -1 if not set.
|
||||
* Returns the user's protocol version, or null if not set.
|
||||
* This is set during the {@link State#HANDSHAKE} state.
|
||||
*
|
||||
* @return protocol version, or -1 if not set
|
||||
* @return protocol version, may be unknown
|
||||
* @see ProtocolVersion#isKnown()
|
||||
*/
|
||||
int getProtocolVersion();
|
||||
ProtocolVersion protocolVersion();
|
||||
|
||||
void setProtocolVersion(int protocolVersion);
|
||||
void setProtocolVersion(ProtocolVersion protocolVersion);
|
||||
|
||||
/**
|
||||
* Returns the server protocol version the user is connected to, or -1 if not set.
|
||||
* Returns the server protocol version the user is connected to.
|
||||
* This is set during the {@link State#HANDSHAKE} state.
|
||||
*
|
||||
* @return server protocol version, or -1 if not set
|
||||
* @return the server protocol version the user is connected to, may be unknown
|
||||
* @see ProtocolVersion#isKnown()
|
||||
*/
|
||||
int getServerProtocolVersion();
|
||||
ProtocolVersion serverProtocolVersion();
|
||||
|
||||
void setServerProtocolVersion(int 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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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-2023 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-2023 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) 2023 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-2023 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-2023 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,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||
/**
|
||||
* Mappings containing the full string identifier mappings.
|
||||
*/
|
||||
public interface FullMappings extends Mappings {
|
||||
|
||||
@Deprecated
|
||||
default Mappings mappings() {
|
||||
return this;
|
||||
}
|
||||
public interface FullMappings extends BiMappings {
|
||||
|
||||
/**
|
||||
* Returns the unmapped integer id for the given identifier, or -1 if not found.
|
||||
|
@ -54,17 +49,17 @@ public interface FullMappings extends Mappings {
|
|||
* Returns the unmapped string identifier for the given mapped id.
|
||||
*
|
||||
* @param id unmapped id
|
||||
* @return unmapped string identifier
|
||||
* @return unmapped string identifier, or null if out of bounds
|
||||
*/
|
||||
String identifier(int id);
|
||||
@Nullable String identifier(int id);
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given mapped id.
|
||||
*
|
||||
* @param mappedId mapped id
|
||||
* @return mapped string identifier
|
||||
* @return mapped string identifier, or null if out of bounds
|
||||
*/
|
||||
String mappedIdentifier(int mappedId);
|
||||
@Nullable String mappedIdentifier(int mappedId);
|
||||
|
||||
/**
|
||||
* Returns the mapped string identifier for the given unmapped identifier.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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,7 @@
|
|||
*/
|
||||
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;
|
||||
|
@ -37,6 +38,7 @@ public class FullMappingsBase implements FullMappings {
|
|||
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);
|
||||
|
@ -52,11 +54,6 @@ public class FullMappingsBase implements FullMappings {
|
|||
this.mappings = mappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mappings mappings() {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id(final String identifier) {
|
||||
return stringToId.getInt(Key.stripMinecraftNamespace(identifier));
|
||||
|
@ -69,12 +66,20 @@ public class FullMappingsBase implements FullMappings {
|
|||
|
||||
@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);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2023 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-2023 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-2023 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-2023 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
|
||||
|
@ -37,11 +37,6 @@ public class IntArrayMappings implements Mappings {
|
|||
return new IntArrayMappings(mappings, mappedIds);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Builder<IntArrayMappings> builder() {
|
||||
return Mappings.builder(IntArrayMappings::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewId(int id) {
|
||||
return id >= 0 && id < mappings.length ? mappings[id] : -1;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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
|
||||
|
@ -79,6 +79,8 @@ public interface MappingData {
|
|||
*/
|
||||
int getNewParticleId(int id);
|
||||
|
||||
int getNewAttributeId(int id);
|
||||
|
||||
/**
|
||||
* Returns a list of tags to send if present.
|
||||
*
|
||||
|
@ -87,8 +89,21 @@ public interface MappingData {
|
|||
*/
|
||||
@Nullable List<TagData> getTags(RegistryType type);
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
@ -105,9 +120,15 @@ public interface MappingData {
|
|||
|
||||
@Nullable Mappings getEnchantmentMappings();
|
||||
|
||||
@Nullable Mappings getAttributeMappings();
|
||||
|
||||
@Nullable Mappings getPaintingMappings();
|
||||
|
||||
@Nullable FullMappings getEntityMappings();
|
||||
|
||||
@Nullable FullMappings getArgumentTypeMappings();
|
||||
|
||||
@Nullable Mappings getPaintingMappings();
|
||||
@Nullable FullMappings getRecipeSerializerMappings();
|
||||
|
||||
@Nullable FullMappings getDataComponentSerializerMappings();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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,7 +24,6 @@ package com.viaversion.viaversion.api.data;
|
|||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
|
@ -34,7 +33,6 @@ import java.util.EnumMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class MappingDataBase implements MappingData {
|
||||
|
@ -44,6 +42,8 @@ public class MappingDataBase implements MappingData {
|
|||
protected BiMappings itemMappings;
|
||||
protected FullMappings argumentTypeMappings;
|
||||
protected FullMappings entityMappings;
|
||||
protected FullMappings recipeSerializerMappings;
|
||||
protected FullMappings itemDataSerializerMappings;
|
||||
protected ParticleMappings particleMappings;
|
||||
protected Mappings blockMappings;
|
||||
protected Mappings blockStateMappings;
|
||||
|
@ -53,6 +53,7 @@ public class MappingDataBase implements MappingData {
|
|||
protected Mappings enchantmentMappings;
|
||||
protected Mappings paintingMappings;
|
||||
protected Mappings menuMappings;
|
||||
protected Mappings attributeMappings;
|
||||
protected Map<RegistryType, List<TagData>> tags;
|
||||
|
||||
public MappingDataBase(final String unmappedVersion, final String mappedVersion) {
|
||||
|
@ -66,7 +67,7 @@ public class MappingDataBase implements MappingData {
|
|||
getLogger().info("Loading " + unmappedVersion + " -> " + mappedVersion + " mappings...");
|
||||
}
|
||||
|
||||
final CompoundTag data = readNBTFile("mappings-" + unmappedVersion + "to" + mappedVersion + ".nbt");
|
||||
final CompoundTag data = readMappingsFile("mappings-" + unmappedVersion + "to" + mappedVersion + ".nbt");
|
||||
blockMappings = loadMappings(data, "blocks");
|
||||
blockStateMappings = loadMappings(data, "blockstates");
|
||||
blockEntityMappings = loadMappings(data, "blockentities");
|
||||
|
@ -75,29 +76,33 @@ public class MappingDataBase implements MappingData {
|
|||
menuMappings = loadMappings(data, "menus");
|
||||
enchantmentMappings = loadMappings(data, "enchantments");
|
||||
paintingMappings = loadMappings(data, "paintings");
|
||||
itemMappings = loadBiMappings(data, "items");
|
||||
attributeMappings = loadMappings(data, "attributes");
|
||||
|
||||
final CompoundTag unmappedIdentifierData = MappingDataLoader.loadNBT("identifiers-" + unmappedVersion + ".nbt", true);
|
||||
final CompoundTag mappedIdentifierData = MappingDataLoader.loadNBT("identifiers-" + mappedVersion + ".nbt", true);
|
||||
|
||||
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 ListTag unmappedParticles = unmappedIdentifierData.get("particles");
|
||||
final ListTag mappedParticles = mappedIdentifierData.get("particles");
|
||||
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());
|
||||
}
|
||||
|
||||
final List<String> identifiers = unmappedParticles.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList());
|
||||
final List<String> mappedIdentifiers = mappedParticles.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList());
|
||||
this.particleMappings = new ParticleMappings(identifiers, mappedIdentifiers, particleMappings);
|
||||
this.particleMappings = new ParticleMappings(unmappedParticles, mappedParticles, particleMappings);
|
||||
}
|
||||
} else {
|
||||
// Might not have identifiers in older versions
|
||||
itemMappings = loadBiMappings(data, "items");
|
||||
}
|
||||
|
||||
final CompoundTag tagsTag = data.get("tags");
|
||||
final CompoundTag tagsTag = data.getCompoundTag("tags");
|
||||
if (tagsTag != null) {
|
||||
this.tags = new EnumMap<>(RegistryType.class);
|
||||
loadTags(RegistryType.ITEM, tagsTag);
|
||||
|
@ -107,16 +112,39 @@ public class MappingDataBase implements MappingData {
|
|||
loadExtras(data);
|
||||
}
|
||||
|
||||
protected @Nullable CompoundTag readNBTFile(final String name) {
|
||||
return MappingDataLoader.loadNBT(name);
|
||||
protected @Nullable List<String> identifiersFromGlobalIds(final CompoundTag mappingsTag, final String key) {
|
||||
return MappingDataLoader.INSTANCE.identifiersFromGlobalIds(mappingsTag, key);
|
||||
}
|
||||
|
||||
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.loadMappings(data, key);
|
||||
return MappingDataLoader.INSTANCE.loadMappings(data, key);
|
||||
}
|
||||
|
||||
protected @Nullable FullMappings loadFullMappings(final CompoundTag data, final CompoundTag unmappedIdentifiers, final CompoundTag mappedIdentifiers, final String key) {
|
||||
return MappingDataLoader.loadFullMappings(data, unmappedIdentifiers, mappedIdentifiers, 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) {
|
||||
|
@ -125,7 +153,7 @@ public class MappingDataBase implements MappingData {
|
|||
}
|
||||
|
||||
private void loadTags(final RegistryType type, final CompoundTag data) {
|
||||
final CompoundTag tag = data.get(type.resourceLocation());
|
||||
final CompoundTag tag = data.getCompoundTag(type.resourceLocation());
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -164,6 +192,11 @@ public class MappingDataBase implements MappingData {
|
|||
return checkValidity(id, particleMappings.getNewId(id), "particles");
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
@ -174,6 +207,14 @@ public class MappingDataBase implements MappingData {
|
|||
return itemMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getFullItemMappings() {
|
||||
if (itemMappings instanceof FullMappings) {
|
||||
return (FullMappings) itemMappings;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ParticleMappings getParticleMappings() {
|
||||
return particleMappings;
|
||||
|
@ -214,6 +255,11 @@ public class MappingDataBase implements MappingData {
|
|||
return enchantmentMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Mappings getAttributeMappings() {
|
||||
return attributeMappings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FullMappings getEntityMappings() {
|
||||
return entityMappings;
|
||||
|
@ -224,11 +270,21 @@ public class MappingDataBase implements MappingData {
|
|||
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() {
|
||||
return Via.getPlatform().getLogger();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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,12 +22,15 @@
|
|||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.github.steveice10.opennbt.NBTIO;
|
||||
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;
|
||||
|
@ -38,33 +41,76 @@ import com.viaversion.viaversion.api.Via;
|
|||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
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.stream.Collectors;
|
||||
import java.util.logging.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class MappingDataLoader {
|
||||
public class MappingDataLoader {
|
||||
|
||||
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;
|
||||
private static final Map<String, CompoundTag> MAPPINGS_CACHE = new HashMap<>();
|
||||
private static boolean cacheValid = true;
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public static void enableMappingsCache() {
|
||||
// Always enabled
|
||||
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 clearCache() {
|
||||
MAPPINGS_CACHE.clear();
|
||||
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 global id of the identifier in the registry.
|
||||
*
|
||||
* @param registry registry key
|
||||
* @param globalId global id
|
||||
* @return identifier
|
||||
* @throws IllegalArgumentException if the registry key is invalid
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -73,8 +119,8 @@ public final class MappingDataLoader {
|
|||
*
|
||||
* @return loaded json object, or null if not found or invalid
|
||||
*/
|
||||
public static @Nullable JsonObject loadFromDataDir(final String name) {
|
||||
final File file = new File(Via.getPlatform().getDataFolder(), name);
|
||||
public @Nullable JsonObject loadFromDataDir(final String name) {
|
||||
final File file = new File(getDataFolder(), name);
|
||||
if (!file.exists()) {
|
||||
return loadData(name);
|
||||
}
|
||||
|
@ -84,7 +130,7 @@ public final class MappingDataLoader {
|
|||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} 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!");
|
||||
getLogger().warning(name + " is badly formatted!");
|
||||
throw new RuntimeException(e);
|
||||
} catch (final IOException | JsonIOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
@ -96,7 +142,7 @@ public final class MappingDataLoader {
|
|||
*
|
||||
* @return loaded json object from bundled resources if present
|
||||
*/
|
||||
public static @Nullable JsonObject loadData(final String name) {
|
||||
public @Nullable JsonObject loadData(final String name) {
|
||||
final InputStream stream = getResource(name);
|
||||
if (stream == null) {
|
||||
return null;
|
||||
|
@ -109,12 +155,12 @@ public final class MappingDataLoader {
|
|||
}
|
||||
}
|
||||
|
||||
public static @Nullable CompoundTag loadNBT(final String name, final boolean cache) {
|
||||
public @Nullable CompoundTag loadNBT(final String name, final boolean cache) {
|
||||
if (!cacheValid) {
|
||||
return loadNBTFromFile(name);
|
||||
}
|
||||
|
||||
CompoundTag data = MAPPINGS_CACHE.get(name);
|
||||
CompoundTag data = mappingsCache.get(name);
|
||||
if (data != null) {
|
||||
return data;
|
||||
}
|
||||
|
@ -122,29 +168,29 @@ public final class MappingDataLoader {
|
|||
data = loadNBTFromFile(name);
|
||||
|
||||
if (cache && data != null) {
|
||||
MAPPINGS_CACHE.put(name, data);
|
||||
mappingsCache.put(name, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static @Nullable CompoundTag loadNBT(final String name) {
|
||||
public @Nullable CompoundTag loadNBT(final String name) {
|
||||
return loadNBT(name, false);
|
||||
}
|
||||
|
||||
private static @Nullable CompoundTag loadNBTFromFile(final String name) {
|
||||
public @Nullable CompoundTag loadNBTFromFile(final String name) {
|
||||
final InputStream resource = getResource(name);
|
||||
if (resource == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try (final InputStream stream = resource) {
|
||||
return NBTIO.readTag(stream);
|
||||
try (final InputStream stream = new BufferedInputStream(resource)) {
|
||||
return MAPPINGS_READER.read(stream);
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable Mappings loadMappings(final CompoundTag mappingsTag, final String key) {
|
||||
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);
|
||||
|
@ -153,29 +199,29 @@ public final class MappingDataLoader {
|
|||
}
|
||||
|
||||
@Beta
|
||||
public static <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
|
||||
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.get(key);
|
||||
final CompoundTag tag = mappingsTag.getCompoundTag(key);
|
||||
if (tag == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final ByteTag serializationStragetyTag = tag.get("id");
|
||||
final IntTag mappedSizeTag = tag.get("mappedSize");
|
||||
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.get("val");
|
||||
final IntArrayTag valuesTag = tag.getIntArrayTag("val");
|
||||
return IntArrayMappings.of(valuesTag.getValue(), mappedSizeTag.asInt());
|
||||
} else if (strategy == SHIFTS_ID) {
|
||||
final IntArrayTag shiftsAtTag = tag.get("at");
|
||||
final IntArrayTag shiftsTag = tag.get("to");
|
||||
final IntTag sizeTag = tag.get("size");
|
||||
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();
|
||||
|
@ -199,9 +245,9 @@ public final class MappingDataLoader {
|
|||
}
|
||||
}
|
||||
} else if (strategy == CHANGES_ID) {
|
||||
final IntArrayTag changesAtTag = tag.get("at");
|
||||
final IntArrayTag valuesTag = tag.get("val");
|
||||
final IntTag sizeTag = tag.get("size");
|
||||
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();
|
||||
|
@ -221,7 +267,7 @@ public final class MappingDataLoader {
|
|||
addConsumer.addTo(mappings, id, values[i]);
|
||||
}
|
||||
} else if (strategy == IDENTITY_ID) {
|
||||
final IntTag sizeTag = tag.get("size");
|
||||
final IntTag sizeTag = tag.getUnchecked("size");
|
||||
return new IdentityMappings(sizeTag.asInt(), mappedSizeTag.asInt());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown serialization strategy: " + strategy);
|
||||
|
@ -229,73 +275,17 @@ public final class MappingDataLoader {
|
|||
return mappingsSupplier.create(mappings, mappedSizeTag.asInt());
|
||||
}
|
||||
|
||||
public static FullMappings loadFullMappings(final CompoundTag mappingsTag, final CompoundTag unmappedIdentifiers, final CompoundTag mappedIdentifiers, final String key) {
|
||||
final ListTag unmappedElements = unmappedIdentifiers.get(key);
|
||||
final ListTag mappedElements = mappedIdentifiers.get(key);
|
||||
if (unmappedElements == null || mappedElements == null) {
|
||||
public @Nullable List<String> identifiersFromGlobalIds(final CompoundTag mappingsTag, final String key) {
|
||||
final Mappings mappings = loadMappings(mappingsTag, key);
|
||||
if (mappings == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Mappings mappings = loadMappings(mappingsTag, key);
|
||||
if (mappings == null) {
|
||||
mappings = new IdentityMappings(unmappedElements.size(), mappedElements.size());
|
||||
}
|
||||
|
||||
return new FullMappingsBase(
|
||||
unmappedElements.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList()),
|
||||
mappedElements.getValue().stream().map(t -> (String) t.getValue()).collect(Collectors.toList()),
|
||||
mappings
|
||||
);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void mapIdentifiers(final int[] output, final JsonObject unmappedIdentifiers, final JsonObject mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
|
||||
final Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(mappedIdentifiers);
|
||||
for (final Map.Entry<String, JsonElement> entry : unmappedIdentifiers.entrySet()) {
|
||||
final int id = Integer.parseInt(entry.getKey());
|
||||
final int mappedId = mapIdentifierEntry(id, entry.getValue().getAsString(), newIdentifierMap, diffIdentifiers, warnOnMissing);
|
||||
if (mappedId != -1) {
|
||||
output[id] = mappedId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int mapIdentifierEntry(final int id, final String val, final Object2IntMap<String> mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
|
||||
int mappedId = mappedIdentifiers.getInt(val);
|
||||
if (mappedId == -1) {
|
||||
// Search in diff mappings
|
||||
if (diffIdentifiers != null) {
|
||||
JsonElement diffElement = diffIdentifiers.get(val);
|
||||
if (diffElement != null || (diffElement = diffIdentifiers.get(Integer.toString(id))) != null) {
|
||||
final String mappedName = diffElement.getAsString();
|
||||
if (mappedName.isEmpty()) {
|
||||
return -1; // "empty" remaps without warnings
|
||||
}
|
||||
|
||||
mappedId = mappedIdentifiers.getInt(mappedName);
|
||||
|
||||
}
|
||||
}
|
||||
if (mappedId == -1) {
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("No key for " + val + " :( ");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return mappedId;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void mapIdentifiers(final int[] output, final JsonArray unmappedIdentifiers, final JsonArray mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
|
||||
final Object2IntMap<String> newIdentifierMap = MappingDataLoader.arrayToMap(mappedIdentifiers);
|
||||
for (int id = 0; id < unmappedIdentifiers.size(); id++) {
|
||||
final JsonElement unmappedIdentifier = unmappedIdentifiers.get(id);
|
||||
final int mappedId = mapIdentifierEntry(id, unmappedIdentifier.getAsString(), newIdentifierMap, diffIdentifiers, warnOnMissing);
|
||||
if (mappedId != -1) {
|
||||
output[id] = mappedId;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -304,7 +294,7 @@ public final class MappingDataLoader {
|
|||
* @param object json object
|
||||
* @return map with indexes hashed by their id value
|
||||
*/
|
||||
public static Object2IntMap<String> indexedObjectToMap(final JsonObject object) {
|
||||
public Object2IntMap<String> indexedObjectToMap(final JsonObject object) {
|
||||
final Object2IntMap<String> map = new Object2IntOpenHashMap<>(object.size(), .99F);
|
||||
map.defaultReturnValue(-1);
|
||||
for (final Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
|
@ -319,7 +309,7 @@ public final class MappingDataLoader {
|
|||
* @param array json array
|
||||
* @return map with indexes hashed by their id value
|
||||
*/
|
||||
public static Object2IntMap<String> arrayToMap(final JsonArray array) {
|
||||
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++) {
|
||||
|
@ -328,8 +318,16 @@ public final class MappingDataLoader {
|
|||
return map;
|
||||
}
|
||||
|
||||
public static @Nullable InputStream getResource(final 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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,6 @@
|
|||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.util.Arrays;
|
||||
|
||||
public interface Mappings {
|
||||
|
||||
/**
|
||||
|
@ -89,123 +84,4 @@ public interface Mappings {
|
|||
* @return mappings with keys and values swapped
|
||||
*/
|
||||
Mappings inverse();
|
||||
|
||||
static <T extends Mappings> Builder<T> builder(final MappingsSupplier<T> supplier) {
|
||||
return new Builder<>(supplier);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface MappingsSupplier<T extends Mappings> {
|
||||
|
||||
T supply(int[] mappings, int mappedIds);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
class Builder<T extends Mappings> {
|
||||
|
||||
protected final MappingsSupplier<T> supplier;
|
||||
protected JsonElement unmapped;
|
||||
protected JsonElement mapped;
|
||||
protected JsonObject diffMappings;
|
||||
protected int mappedSize = -1;
|
||||
protected int size = -1;
|
||||
protected boolean warnOnMissing = true;
|
||||
|
||||
protected Builder(final MappingsSupplier<T> supplier) {
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a custom entry size different to the size of the unmapped collection.
|
||||
*
|
||||
* @param size custom entry size
|
||||
* @return self
|
||||
*/
|
||||
public Builder<T> customEntrySize(final int size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a custom entry mapped ids count different to the size of the mapped collection.
|
||||
*
|
||||
* @param size custom mapped id count
|
||||
* @return self
|
||||
*/
|
||||
public Builder<T> customMappedSize(final int size) {
|
||||
this.mappedSize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether warnings should be logged for missing mapped ids.
|
||||
*
|
||||
* @param warnOnMissing whether warnings should be logged for missing mapped ids
|
||||
* @return self
|
||||
*/
|
||||
public Builder<T> warnOnMissing(final boolean warnOnMissing) {
|
||||
this.warnOnMissing = warnOnMissing;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> unmapped(final JsonArray unmappedArray) {
|
||||
this.unmapped = unmappedArray;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> unmapped(final JsonObject unmappedObject) {
|
||||
this.unmapped = unmappedObject;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> mapped(final JsonArray mappedArray) {
|
||||
this.mapped = mappedArray;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> mapped(final JsonObject mappedObject) {
|
||||
this.mapped = mappedObject;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> diffMappings(final JsonObject diffMappings) {
|
||||
this.diffMappings = diffMappings;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T build() {
|
||||
final int size = this.size != -1 ? this.size : size(unmapped);
|
||||
final int mappedSize = this.mappedSize != -1 ? this.mappedSize : size(mapped);
|
||||
final int[] mappings = new int[size];
|
||||
Arrays.fill(mappings, -1);
|
||||
|
||||
// Do conversion if one is an array and the other an object, otherwise directly map
|
||||
if (unmapped.isJsonArray()) {
|
||||
if (mapped.isJsonObject()) {
|
||||
MappingDataLoader.mapIdentifiers(mappings, toJsonObject(unmapped.getAsJsonArray()), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
|
||||
} else {
|
||||
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonArray(), mapped.getAsJsonArray(), diffMappings, warnOnMissing);
|
||||
}
|
||||
} else if (mapped.isJsonArray()) {
|
||||
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), toJsonObject(mapped.getAsJsonArray()), diffMappings, warnOnMissing);
|
||||
} else {
|
||||
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
|
||||
}
|
||||
|
||||
return supplier.supply(mappings, mappedSize);
|
||||
}
|
||||
|
||||
protected int size(final JsonElement element) {
|
||||
return element.isJsonObject() ? element.getAsJsonObject().size() : element.getAsJsonArray().size();
|
||||
}
|
||||
|
||||
protected JsonObject toJsonObject(final JsonArray array) {
|
||||
final JsonObject object = new JsonObject();
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
final JsonElement element = array.get(i);
|
||||
object.add(Integer.toString(i), element);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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
|
||||
|
@ -35,6 +35,7 @@ public class ParticleMappings extends FullMappingsBase {
|
|||
addBlockParticle("block");
|
||||
addBlockParticle("falling_dust");
|
||||
addBlockParticle("block_marker");
|
||||
addBlockParticle("dust_pillar");
|
||||
addItemParticle("item");
|
||||
}
|
||||
|
||||
|
@ -55,19 +56,4 @@ public class ParticleMappings extends FullMappingsBase {
|
|||
public boolean isItemParticle(final int id) {
|
||||
return itemParticleIds.contains(id);
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public int getBlockId() {
|
||||
return id("block");
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public int getFallingDustId() {
|
||||
return id("falling_dust");
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public int getItemId() {
|
||||
return id("item");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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-2023 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,8 @@ package com.viaversion.viaversion.api.data.entity;
|
|||
|
||||
public interface DimensionData {
|
||||
|
||||
int id();
|
||||
|
||||
int minY();
|
||||
|
||||
int height();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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,7 @@ public interface EntityTracker {
|
|||
*
|
||||
* @return user connection
|
||||
*/
|
||||
@Deprecated
|
||||
UserConnection user();
|
||||
|
||||
/**
|
||||
|
@ -87,7 +88,7 @@ public interface EntityTracker {
|
|||
*
|
||||
* @param id entity id
|
||||
* @return stored entity data if an entity with the id is tracked, else null
|
||||
* @throws IllegalArgumentException if entitiy data storage has not been enabled via the implementation
|
||||
* @throws IllegalArgumentException if entity data storage has not been enabled via the implementation
|
||||
*/
|
||||
@Nullable StoredEntityData entityData(int id);
|
||||
|
||||
|
@ -96,7 +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 entitiy data storage has not been enabled via the implementation
|
||||
* @throws IllegalArgumentException if entity data storage has not been enabled via the implementation
|
||||
*/
|
||||
@Nullable StoredEntityData entityDataIfPresent(int id);
|
||||
|
||||
|
@ -165,6 +166,8 @@ public interface EntityTracker {
|
|||
|
||||
@Nullable DimensionData dimensionData(String dimension);
|
||||
|
||||
@Nullable DimensionData dimensionData(int dimensionId);
|
||||
|
||||
void setDimensions(Map<String, DimensionData> dimensions);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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-2023 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-2023 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,11 @@
|
|||
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 {
|
||||
|
@ -102,4 +104,16 @@ public interface DebugHandler {
|
|||
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-2023 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-2023 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
|
||||
|
@ -66,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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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
|
||||
|
|
|
@ -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-2023 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-2023 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
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* 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 java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class GameProfile {
|
||||
|
||||
private final String name;
|
||||
private final UUID id;
|
||||
private final Property[] properties;
|
||||
|
||||
public GameProfile(@Nullable final String name, @Nullable final UUID id, final Property[] properties) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public @Nullable String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public @Nullable UUID id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Property[] properties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static final class Property {
|
||||
private final String name;
|
||||
private final String value;
|
||||
private final String signature;
|
||||
|
||||
public Property(final String name, final String value, @Nullable final String signature) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public @Nullable String signature() {
|
||||
return signature;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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
|
||||
|
|
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2023 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-2023 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-2023 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-2023 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-2023 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
|
||||
|
|
|
@ -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-2023 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
|
||||
|
@ -57,11 +57,6 @@ public enum RegistryType {
|
|||
this.resourceLocation = resourceLocation;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)*/
|
||||
public String getResourceLocation() {
|
||||
return resourceLocation;
|
||||
}
|
||||
|
||||
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-2023 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,8 @@
|
|||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class TagData {
|
||||
private final String identifier;
|
||||
private final int[] 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* 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.data;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
final class EmptyStructuredData<T> implements StructuredData<T> {
|
||||
|
||||
private final StructuredDataKey<T> key;
|
||||
private int id;
|
||||
|
||||
EmptyStructuredData(final StructuredDataKey<T> key, final int id) {
|
||||
this.key = key;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final T value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructuredDataKey<T> key() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T value() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final EmptyStructuredData<?> that = (EmptyStructuredData<?>) o;
|
||||
if (id != that.id) return false;
|
||||
return key.equals(that.key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = key.hashCode();
|
||||
result = 31 * result + id;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EmptyStructuredData{" +
|
||||
"key=" + key +
|
||||
", id=" + id +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* 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.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Objects;
|
||||
|
||||
final class FilledStructuredData<T> implements StructuredData<T> {
|
||||
|
||||
private final StructuredDataKey<T> key;
|
||||
private T value;
|
||||
private int id;
|
||||
|
||||
FilledStructuredData(final StructuredDataKey<T> key, final T value, final int id) {
|
||||
Preconditions.checkNotNull(key);
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer) throws Exception {
|
||||
key.type().write(buffer, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructuredDataKey<T> key() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
final FilledStructuredData<?> that = (FilledStructuredData<?>) o;
|
||||
if (id != that.id) return false;
|
||||
if (!key.equals(that.key)) return false;
|
||||
return Objects.equals(value, that.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = key.hashCode();
|
||||
result = 31 * result + (value != null ? value.hashCode() : 0);
|
||||
result = 31 * result + id;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FilledStructuredData{" +
|
||||
"key=" + key +
|
||||
", value=" + value +
|
||||
", id=" + id +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* 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.data;
|
||||
|
||||
import com.viaversion.viaversion.util.IdHolder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface StructuredData<T> extends IdHolder {
|
||||
|
||||
/**
|
||||
* Returns filled structured data, equivalent to an Optional with a value in vanilla.
|
||||
*
|
||||
* @param key serializer key
|
||||
* @param value value
|
||||
* @param id serializer id
|
||||
* @param <T> serializer type
|
||||
* @return filled structured data
|
||||
*/
|
||||
static <T> StructuredData<T> of(final StructuredDataKey<T> key, final T value, final int id) {
|
||||
return new FilledStructuredData<>(key, value, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns empty structured data, equivalent to an empty Optional in vanilla.
|
||||
*
|
||||
* @param key serializer key
|
||||
* @param id serializer id
|
||||
* @return empty structured data
|
||||
*/
|
||||
static <T> StructuredData<T> empty(final StructuredDataKey<T> key, final int id) {
|
||||
return new EmptyStructuredData<>(key, id);
|
||||
}
|
||||
|
||||
void setValue(final T value);
|
||||
|
||||
void write(final ByteBuf buffer) throws Exception;
|
||||
|
||||
void setId(final int id);
|
||||
|
||||
StructuredDataKey<T> key();
|
||||
|
||||
@Nullable T value();
|
||||
|
||||
/**
|
||||
* Returns whether the structured data is present. Even if true, the value may be null.
|
||||
*
|
||||
* @return true if the structured data is present
|
||||
*/
|
||||
default boolean isPresent() {
|
||||
return !isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the structured data is empty. Not to be confused with a null value.
|
||||
*
|
||||
* @return true if the structured data is empty
|
||||
*/
|
||||
boolean isEmpty();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue