Compare commits
434
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bb90aa0de | ||
|
|
9b1e92b555 | ||
|
|
104615edb5 | ||
|
|
9f54ca6843 | ||
|
|
46919017e1 | ||
|
|
0a1ce38c7e | ||
|
|
f60d5230c3 | ||
|
|
8034f5dc89 | ||
|
|
265ade55d0 | ||
|
|
cffcbaf596 | ||
|
|
4dc90a2920 | ||
|
|
b5f6a7f6b8 | ||
|
|
f916addda3 | ||
|
|
d275fb8d8b | ||
|
|
3ce8971215 | ||
|
|
5866e4ede1 | ||
|
|
a47040e18a | ||
|
|
631b41d9d0 | ||
|
|
8b9cf0c283 | ||
|
|
e7afd771f8 | ||
|
|
98446b5afc | ||
|
|
0fbfca81a1 | ||
|
|
33f1eab93b | ||
|
|
38fcccd7c9 | ||
|
|
053768ccfa | ||
|
|
d11a0406cb | ||
|
|
5966ca1355 | ||
|
|
72944a00c0 | ||
|
|
671c935134 | ||
|
|
c931974779 | ||
|
|
5e6d0bffde | ||
|
|
c08719acc7 | ||
|
|
e76b00c880 | ||
|
|
b30d56ed0b | ||
|
|
211b85a51b | ||
|
|
f895ff0e0a | ||
|
|
6f0f6eaa24 | ||
|
|
d6ee3b356e | ||
|
|
7b800a9015 | ||
|
|
ba0feb31f0 | ||
|
|
36b73752f7 | ||
|
|
6f0586ce23 | ||
|
|
59159d47a0 | ||
|
|
23c0fc9bff | ||
|
|
c34690197d | ||
|
|
c98425cb99 | ||
|
|
55f4280ccb | ||
|
|
b9299dfa96 | ||
|
|
b1fb30163c | ||
|
|
50b8776aa9 | ||
|
|
d47b450307 | ||
|
|
1f41447a02 | ||
|
|
a306ac26b9 | ||
|
|
df6a334a00 | ||
|
|
c43ea28f59 | ||
|
|
596f1b57ce | ||
|
|
386238aae8 | ||
|
|
e7dcb4c96e | ||
|
|
6049e37d87 | ||
|
|
a41e747da7 | ||
|
|
c4c61dff3c | ||
|
|
84b85c8f00 | ||
|
|
f9b3786c16 | ||
|
|
d2350ad383 | ||
|
|
f6c554da02 | ||
|
|
7ff8c40402 | ||
|
|
df6d7fa741 | ||
|
|
3a5aa401f0 | ||
|
|
9c5263bf20 | ||
|
|
838426e1bf | ||
|
|
d486863a64 | ||
|
|
cd98e8488b | ||
|
|
a7c6f88a11 | ||
|
|
c15b88e77f | ||
|
|
1a2d39d68f | ||
|
|
fe8ca640cc | ||
|
|
e8bdd02838 | ||
|
|
b962876dfd | ||
|
|
f0135204e3 | ||
|
|
5bedb44e11 | ||
|
|
4e3ada1bd8 | ||
|
|
38d68418dc | ||
|
|
5f8efaaf0f | ||
|
|
9b8de173e4 | ||
|
|
de4594fbdc | ||
|
|
5eae00ef0b | ||
|
|
3c418473d8 | ||
|
|
1e919053c6 | ||
|
|
30ff648bad | ||
|
|
6c5d9beb76 | ||
|
|
3e828ea9ee | ||
|
|
4ef8b381d7 | ||
|
|
24838cd7d9 | ||
|
|
e17b877b5f | ||
|
|
8b85bc8d4d | ||
|
|
fca9ad22fe | ||
|
|
8f7ec3d38a | ||
|
|
41969994b2 | ||
|
|
667652bfb8 | ||
|
|
2da42185e8 | ||
|
|
fd1b918956 | ||
|
|
828013bf77 | ||
|
|
6e30fb393a | ||
|
|
cbfca6c5fa | ||
|
|
945ca46491 | ||
|
|
f7d5252bf0 | ||
|
|
a624a76427 | ||
|
|
39f9ed008c | ||
|
|
a0096b3032 | ||
|
|
ae1a0258fe | ||
|
|
f863ad026f | ||
|
|
abea90564f | ||
|
|
3bdd110864 | ||
|
|
b2e47f48a5 | ||
|
|
513de88321 | ||
|
|
4a2146d16d | ||
|
|
5a49cf2687 | ||
|
|
65fba0b83d | ||
|
|
5272557f58 | ||
|
|
51abf38d3f | ||
|
|
33abe17a2b | ||
|
|
593015dd0b | ||
|
|
079a2fcc53 | ||
|
|
b9d4ed6a60 | ||
|
|
aec45f19e4 | ||
|
|
0aaa4f42b1 | ||
|
|
75dfc63d3b | ||
|
|
ac501a26b2 | ||
|
|
3ebf39d3bd | ||
|
|
363931875f | ||
|
|
b1802fbc0c | ||
|
|
9f9cdca53a | ||
|
|
00c85f3e41 | ||
|
|
b48a91bcee | ||
|
|
709edd8b21 | ||
|
|
90edf6002e | ||
|
|
4e151f8dfb | ||
|
|
0165e8a4ac | ||
|
|
385000b608 | ||
|
|
a1b7c947a0 | ||
|
|
ab5163bc66 | ||
|
|
38b25b6d48 | ||
|
|
9d5d4858cf | ||
|
|
2e6c43ba06 | ||
|
|
f180a4a172 | ||
|
|
5ce6b8bf9e | ||
|
|
b61602741b | ||
|
|
13ba9e7b81 | ||
|
|
d4c9444fd5 | ||
|
|
b6c079af66 | ||
|
|
a18d288079 | ||
|
|
c3d8f91e85 | ||
|
|
0ca2f5c50a | ||
|
|
cdc7ed36e0 | ||
|
|
5d63308a22 | ||
|
|
214706dbb6 | ||
|
|
fa3b563c70 | ||
|
|
55e31483e7 | ||
|
|
aa34910468 | ||
|
|
5e44913a5e | ||
|
|
b8dc964112 | ||
|
|
890844fb60 | ||
|
|
fc57c9e077 | ||
|
|
f12ef113aa | ||
|
|
e8144ece97 | ||
|
|
b611ad5522 | ||
|
|
53e1014c8d | ||
|
|
69f992a984 | ||
|
|
fde9db39b7 | ||
|
|
6c6a2535c8 | ||
|
|
23d06075dd | ||
|
|
926fd1ae50 | ||
|
|
756add003f | ||
|
|
aaf00bf167 | ||
|
|
d72c8df72c | ||
|
|
800ffafb96 | ||
|
|
ba2d9ae9f0 | ||
|
|
31d07e4a39 | ||
|
|
ec36a5d1d8 | ||
|
|
08ba59e1d9 | ||
|
|
851c74e827 | ||
|
|
b31893e035 | ||
|
|
4718fb985d | ||
|
|
aed9bc14fa | ||
|
|
1daad13da3 | ||
|
|
65a984e805 | ||
|
|
a923b950f6 | ||
|
|
ac5790411f | ||
|
|
cd3449ade2 | ||
|
|
75af221f77 | ||
|
|
6f9b2cf5e9 | ||
|
|
4b4dd492cf | ||
|
|
68471d32c8 | ||
|
|
b7d0ce9518 | ||
|
|
58abfc0c1e | ||
|
|
a3f6adac2f | ||
|
|
f0c9af4464 | ||
|
|
f43fff899f | ||
|
|
9291fd8953 | ||
|
|
feb975010e | ||
|
|
5c34c8e6c3 | ||
|
|
8aaf40fc74 | ||
|
|
c6fcab2923 | ||
|
|
64006b91a4 | ||
|
|
625a66f45a | ||
|
|
0c6208f931 | ||
|
|
be32f464c5 | ||
|
|
3389baf40e | ||
|
|
edc85e68e8 | ||
|
|
3f9f093934 | ||
|
|
31426cc69c | ||
|
|
cec8c9789f | ||
|
|
f771e15ce0 | ||
|
|
68a3702cd6 | ||
|
|
8f4f688fb8 | ||
|
|
0a380344c5 | ||
|
|
ab458ded62 | ||
|
|
3bc78c1aec | ||
|
|
0feebb6819 | ||
|
|
cdb48e0ab6 | ||
|
|
85e819d72f | ||
|
|
10d44fe3cb | ||
|
|
6b5ada3c5d | ||
|
|
2f0861c7b7 | ||
|
|
abc8695a29 | ||
|
|
c6577646ce | ||
|
|
a6c68b2d0e | ||
|
|
23e0861192 | ||
|
|
7539aa345c | ||
|
|
2a076a61a0 | ||
|
|
bf0ec04cec | ||
|
|
fea687bba9 | ||
|
|
25e83d6181 | ||
|
|
95a91bb1f2 | ||
|
|
e1e057eabb | ||
|
|
f81120f8ed | ||
|
|
e44ad5edc2 | ||
|
|
c35d0854bc | ||
|
|
47dbb5e9c0 | ||
|
|
702894dd07 | ||
|
|
4801196942 | ||
|
|
c88a9c412c | ||
|
|
4012472404 | ||
|
|
54f3f3c221 | ||
|
|
873557151b | ||
|
|
32e96f3f51 | ||
|
|
cdffd10999 | ||
|
|
1524a546d8 | ||
|
|
40d7be6236 | ||
|
|
98b2b7b631 | ||
|
|
54704811b3 | ||
|
|
54241497b5 | ||
|
|
99637743f5 | ||
|
|
702452c3a1 | ||
|
|
7e424cd46b | ||
|
|
58401fc18e | ||
|
|
7285eeff5a | ||
|
|
cfb57e7a99 | ||
|
|
93cd6f39f9 | ||
|
|
9975706ba8 | ||
|
|
9b88a9ef98 | ||
|
|
548c6183a4 | ||
|
|
19d271881c | ||
|
|
a64978cb0a | ||
|
|
527beda70f | ||
|
|
127421a1d2 | ||
|
|
4a188bd116 | ||
|
|
cd6db40a0d | ||
|
|
d050c10eab | ||
|
|
82e5b68119 | ||
|
|
3f00e1d817 | ||
|
|
7296072bcb | ||
|
|
132ae43496 | ||
|
|
2465ba9306 | ||
|
|
2e10b151c9 | ||
|
|
9a338cd897 | ||
|
|
7c0bac33df | ||
|
|
db8c4ce08d | ||
|
|
af52640237 | ||
|
|
b6d71a79a1 | ||
|
|
407257c2ce | ||
|
|
19e7bc6190 | ||
|
|
e0beccff4d | ||
|
|
1728e667ea | ||
|
|
c2cce6fac7 | ||
|
|
9cf38bc325 | ||
|
|
c0522d7836 | ||
|
|
dc1ac3beb3 | ||
|
|
d59a11a340 | ||
|
|
a8e95c23ac | ||
|
|
607b8dde56 | ||
|
|
a0ccfb4875 | ||
|
|
afcf98e2c8 | ||
|
|
51d74ae7ea | ||
|
|
7b6308c4e0 | ||
|
|
cdbe0df0f3 | ||
|
|
d799ba7190 | ||
|
|
8c03d2e3a0 | ||
|
|
7c2994e54d | ||
|
|
e1e61feebf | ||
|
|
e6fb117182 | ||
|
|
a7aa3eae68 | ||
|
|
d38089a46a | ||
|
|
e2a980adde | ||
|
|
a4e116d34f | ||
|
|
6b61682fe4 | ||
|
|
0c4709ac57 | ||
|
|
c6a542d206 | ||
|
|
d67028f568 | ||
|
|
af48ee3938 | ||
|
|
945919c1e0 | ||
|
|
38de7a4b94 | ||
|
|
419232a075 | ||
|
|
e705b2725d | ||
|
|
004702f642 | ||
|
|
4c29d39292 | ||
|
|
24e8ff4fb4 | ||
|
|
cf61f74ade | ||
|
|
72ab24b419 | ||
|
|
8c8357bfbc | ||
|
|
59d36b6e55 | ||
|
|
decf5579a3 | ||
|
|
187f5a54c6 | ||
|
|
647c05fe98 | ||
|
|
a089b98f6d | ||
|
|
9d21b834cc | ||
|
|
069e872204 | ||
|
|
e945c9c56f | ||
|
|
b8058b57d8 | ||
|
|
7ce167157a | ||
|
|
0503e99c50 | ||
|
|
413d5e1eb5 | ||
|
|
51ebbb7914 | ||
|
|
2b98d5c90b | ||
|
|
099ea9b7e9 | ||
|
|
ce703febc3 | ||
|
|
dce59f99fd | ||
|
|
5ff498b6f0 | ||
|
|
32b85dce18 | ||
|
|
89b8d823c4 | ||
|
|
fc0f1eec68 | ||
|
|
765fb79321 | ||
|
|
eb42c1b473 | ||
|
|
ce484ecac5 | ||
|
|
cb3e4d33a7 | ||
|
|
12c01eb2fa | ||
|
|
c4b8a17437 | ||
|
|
5dde544e07 | ||
|
|
d16ad2154d | ||
|
|
245da7a870 | ||
|
|
2a0b217718 | ||
|
|
582cfa7b57 | ||
|
|
1b295dc827 | ||
|
|
a83248f70d | ||
|
|
42a1375c00 | ||
|
|
fbe89306f5 | ||
|
|
faeb2f55d3 | ||
|
|
239cc09c9f | ||
|
|
6aac1faac4 | ||
|
|
ea4ab05bff | ||
|
|
d53f39bbc7 | ||
|
|
8f28b71ee2 | ||
|
|
58df1fcc91 | ||
|
|
060b919fa3 | ||
|
|
7d0d4aa672 | ||
|
|
e3cde54ab2 | ||
|
|
d681345e41 | ||
|
|
3939b534ad | ||
|
|
a8afbd2a0b | ||
|
|
7d7cbb4445 | ||
|
|
1c5dceb47d | ||
|
|
876fbf6fbf | ||
|
|
b469ce2a69 | ||
|
|
6f7823e8cb | ||
|
|
2619a4398d | ||
|
|
d411fe44fe | ||
|
|
67af517510 | ||
|
|
cce862bc57 | ||
|
|
319750e3f9 | ||
|
|
78ccd8b2d5 | ||
|
|
50ef62f4fb | ||
|
|
05a5b5284b | ||
|
|
8c6865405d | ||
|
|
a204b5d521 | ||
|
|
da0128b330 | ||
|
|
84b005a3b0 | ||
|
|
38fd7eae6d | ||
|
|
e3d08fa0de | ||
|
|
0da59c3585 | ||
|
|
b4145fda44 | ||
|
|
5df58a116d | ||
|
|
7899d8cb46 | ||
|
|
b47e0f20ef | ||
|
|
63a7121653 | ||
|
|
7927c89ba2 | ||
|
|
db5c97a324 | ||
|
|
d4b919430f | ||
|
|
d52df749fa | ||
|
|
63eac8f0f6 | ||
|
|
0d7a618d87 | ||
|
|
7a8d440475 | ||
|
|
89b63802ac | ||
|
|
17e8b51205 | ||
|
|
8bb12b6913 | ||
|
|
8a194d1ff6 | ||
|
|
45bc1e3d80 | ||
|
|
a812e22312 | ||
|
|
b7c9015b39 | ||
|
|
98c7c0d49c | ||
|
|
dc10e3cca6 | ||
|
|
54ae21fd5d | ||
|
|
5d851e849a | ||
|
|
09ef7c2e80 | ||
|
|
e8d7fc30a5 | ||
|
|
5fbb6d7349 | ||
|
|
28b67601c1 | ||
|
|
ba02780727 | ||
|
|
2c756925a1 | ||
|
|
ac37b708c0 | ||
|
|
6b92403dea | ||
|
|
f63da3d3d2 | ||
|
|
de763c948c | ||
|
|
4469b93ed9 | ||
|
|
873c09d224 | ||
|
|
646b0a1050 | ||
|
|
470975ca77 | ||
|
|
2005daa11f | ||
|
|
e28f4e3993 | ||
|
|
f9390aa69d | ||
|
|
3f6bb1a03d | ||
|
|
911dffccc2 | ||
|
|
3368b7fcc5 | ||
|
|
ea273ba4b6 | ||
|
|
f3b14030b1 |
No files matched your search
@@ -11,44 +11,45 @@ jobs:
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '8'
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||
|
||||
- name: Build with Gradle
|
||||
run: gradle shadowJar
|
||||
run: chmod +x gradlew && ./gradlew build
|
||||
|
||||
- name: Upload build artifacts api
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: api-build
|
||||
path: api/build/libs
|
||||
|
||||
- name: Upload build artifacts spigot
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: spigot-build
|
||||
path: spigot/build/libs
|
||||
|
||||
- name: Upload build artifacts netty-common
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: netty-common-build
|
||||
path: netty-common/build/libs
|
||||
|
||||
- name: Upload build artifacts bungeecord
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bungeecord-build
|
||||
path: bungeecord/build/libs
|
||||
|
||||
- name: Upload build artifacts velocity
|
||||
uses: actions/upload-artifact@v1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: velocity-build
|
||||
path: velocity/build/libs
|
||||
@@ -102,6 +102,7 @@ $RECYCLE.BIN/
|
||||
|
||||
.gradle
|
||||
build/
|
||||
bin/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
@@ -118,3 +119,7 @@ run/
|
||||
!gradle-wrapper.jar
|
||||
/src/main/resources/plugin.yml
|
||||
/.idea/
|
||||
.vscode/
|
||||
.project
|
||||
.settings/
|
||||
.classpath
|
||||
@@ -1,15 +1,20 @@
|
||||
# packetevents
|
||||
|
||||
[](https://jitpack.io/#retrooper/packetevents)
|
||||
[](https://github.com/retrooper/packetevents/blob/2.0/LICENSE) [](https://github.com/retrooper/packetevents/actions) [](https://discord.gg/prqzNg9tRU)
|
||||
|
||||
PacketEvents is a powerful packet library. Our packet wrappers are efficient and easy to use. With our API, you can write code that runs on many platforms including Spigot, BungeeCord, Velocity, and even client-sided Fabric! Switch to PacketEvents today by joining \
|
||||
PacketEvents is a fast and efficient multi-platform packet processing library. Our packet wrappers are easy to use with multi-version support. With our API you can write code that runs on Spigot, BungeeCord, Velocity, and Fabric! Switch to PacketEvents today by joining \
|
||||
our [Discord Server](https://discord.me/packetevents) for help.
|
||||
|
||||
### Links
|
||||
* [Find release builds on SpigotMC](https://www.spigotmc.org/resources/packetevents-api.80279/)
|
||||
* [Find release builds on Modrinth](https://modrinth.com/plugin/packetevents)
|
||||
* [Find development builds on Jenkins](https://ci.codemc.io/job/retrooper/job/packetevents)
|
||||
* [View documentation on our JavaDocs Page](https://packetevents.github.io/javadocs)
|
||||
|
||||
### Setup
|
||||
[Learn more](https://github.com/retrooper/packetevents/wiki/Setup-2.0)
|
||||
[How to Setup PacketEvents](https://github.com/retrooper/packetevents/wiki/Depending-on-pre%E2%80%90built-PacketEvents)
|
||||
|
||||
### Examples / How to use PacketEvents
|
||||
[Example repository](https://github.com/retrooper/packetevents-example)
|
||||
|
||||
### Sponsorships
|
||||
[](https://www.ej-technologies.com/products/jprofiler/overview.html)
|
||||
@@ -18,15 +23,6 @@ our [Discord Server](https://discord.me/packetevents) for help.
|
||||
PacketEvents optionally collects statistics using [bStats](https://bstats.org/)\
|
||||
Check out our [bStats page](https://bstats.org/plugin/bukkit/packetevents/11327)
|
||||
|
||||
This library is licensed under the GPLv3 (General Public License version 3). Here are a few sources to learn more about the license.\
|
||||
[](https://github.com/retrooper/packetevents/blob/2.0/LICENSE)
|
||||
### GPL Resources
|
||||
* https://www.gnu.org/philosophy/free-sw.html
|
||||
* https://www.gnu.org/philosophy/free-sw.html#clarifying
|
||||
* https://www.gnu.org/licenses/copyleft.en.html
|
||||
* https://www.gnu.org/licenses/quick-guide-gplv3.html
|
||||
* https://gpl-violations.org/faq/sourcecode-faq/
|
||||
|
||||
### Credit to these projects
|
||||
[wiki.vg/Protocol](https://wiki.vg/Protocol)\
|
||||
[netty](https://github.com/netty/netty)\
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
// papermc repo + disableAutoTargetJvm needed for mockbukkit
|
||||
repositories {
|
||||
maven { url 'https://repo.papermc.io/repository/maven-public/' }
|
||||
}
|
||||
|
||||
java {
|
||||
disableAutoTargetJvm()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(adventureDependencies)
|
||||
|
||||
testImplementation(adventureDependencies)
|
||||
testImplementation(project(":netty-common"))
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.9.0")
|
||||
testImplementation("org.slf4j:slf4j-simple:2.0.7")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.0")
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
@@ -18,20 +18,15 @@
|
||||
|
||||
package com.github.retrooper.packetevents;
|
||||
|
||||
import com.github.retrooper.packetevents.injector.ChannelInjector;
|
||||
import com.github.retrooper.packetevents.manager.player.PlayerManager;
|
||||
import com.github.retrooper.packetevents.manager.protocol.ProtocolManager;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerManager;
|
||||
import com.github.retrooper.packetevents.netty.NettyManager;
|
||||
import com.github.retrooper.packetevents.settings.PacketEventsSettings;
|
||||
import com.github.retrooper.packetevents.util.LogManager;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
public final class PacketEvents {
|
||||
private static PacketEventsAPI<?> API;
|
||||
|
||||
//Put these variable names anywhere else, they are really only for the injectors
|
||||
@ApiStatus.Internal
|
||||
public static String IDENTIFIER, ENCODER_NAME, DECODER_NAME, CONNECTION_HANDLER_NAME, SERVER_CHANNEL_HANDLER_NAME,
|
||||
TIMEOUT_HANDLER_NAME;
|
||||
TIMEOUT_HANDLER_NAME;
|
||||
|
||||
public static PacketEventsAPI<?> getAPI() {
|
||||
return API;
|
||||
@@ -40,87 +35,4 @@ public final class PacketEvents {
|
||||
public static void setAPI(PacketEventsAPI<?> api) {
|
||||
API = api;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public abstract static class Context<T> {
|
||||
private final Object pluginInstance;
|
||||
private final ProtocolManager protocolManager;
|
||||
private final ServerManager serverManager;
|
||||
private final PlayerManager playerManager;
|
||||
private final NettyManager nettyManager;
|
||||
private final ChannelInjector injector;
|
||||
private final LogManager logManager;
|
||||
protected boolean lateBind = false;
|
||||
|
||||
public Context(Object pluginInstance, ProtocolManager protocolManager, ServerManager serverManager, PlayerManager playerManager,
|
||||
NettyManager nettyManager, ChannelInjector injector, LogManager logManager) {
|
||||
this.pluginInstance = pluginInstance;
|
||||
this.protocolManager = protocolManager;
|
||||
this.serverManager = serverManager;
|
||||
this.playerManager = playerManager;
|
||||
this.nettyManager = nettyManager;
|
||||
this.injector = injector;
|
||||
this.logManager = logManager;
|
||||
}
|
||||
|
||||
protected abstract PacketEventsAPI<T> build();
|
||||
|
||||
public Object getPluginInstance() {
|
||||
return pluginInstance;
|
||||
}
|
||||
|
||||
public ProtocolManager getProtocolManager() {
|
||||
return protocolManager;
|
||||
}
|
||||
|
||||
public ServerManager getServerManager() {
|
||||
return serverManager;
|
||||
}
|
||||
|
||||
public PlayerManager getPlayerManager() {
|
||||
return playerManager;
|
||||
}
|
||||
|
||||
public NettyManager getNettyManager() {
|
||||
return nettyManager;
|
||||
}
|
||||
|
||||
public ChannelInjector getInjector() {
|
||||
return injector;
|
||||
}
|
||||
|
||||
public LogManager getLogManager() {
|
||||
return logManager;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private Context<?> context = null;
|
||||
private PacketEventsSettings settings = new PacketEventsSettings();
|
||||
public Builder context(Context<?> context) {
|
||||
this.context = context;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder settings(PacketEventsSettings settings) {
|
||||
this.settings = settings;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PacketEventsAPI<?> build() {
|
||||
if (context == null) {
|
||||
throw new IllegalStateException("Failed to build a PacketEvents instance. Please specify a PacketEvents context in the PacketEvents builder to allow PacketEvents to load the correct implementation.");
|
||||
}
|
||||
PacketEventsAPI<?> api = context.build();
|
||||
api.setSettings(settings);
|
||||
//The implementation may have already set the API.
|
||||
if (getAPI() == null) {
|
||||
setAPI(api);
|
||||
}
|
||||
return api;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,23 +33,19 @@ import java.util.logging.Logger;
|
||||
|
||||
public abstract class PacketEventsAPI<T> {
|
||||
private static final EventManager EVENT_MANAGER = new EventManager();
|
||||
private static final PacketEventsSettings SETTINGS = new PacketEventsSettings();
|
||||
private static final UpdateChecker UPDATE_CHECKER = new UpdateChecker();
|
||||
private static final LogManager LOG_MANAGER = new LogManager();
|
||||
private final Logger LOGGER = Logger.getLogger(PacketEventsAPI.class.getName());
|
||||
private PacketEventsSettings settings = new PacketEventsSettings();
|
||||
private static final LogManager LOG_MANAGER = new LogManager();
|
||||
//TODO UPDATE
|
||||
private static final PEVersion VERSION = new PEVersion(2, 0, 0);
|
||||
private static final PEVersion VERSION = new PEVersion(2, 2, 1);
|
||||
|
||||
public EventManager getEventManager() {
|
||||
return EVENT_MANAGER;
|
||||
}
|
||||
|
||||
public PacketEventsSettings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public void setSettings(PacketEventsSettings settings) {
|
||||
this.settings = settings;
|
||||
return SETTINGS;
|
||||
}
|
||||
|
||||
public UpdateChecker getUpdateChecker() {
|
||||
|
||||
@@ -19,15 +19,16 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.exception.InvalidHandshakeException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class EventManager {
|
||||
private final Map<Byte, HashSet<PacketListenerCommon>> listenersMap = new ConcurrentHashMap<>();
|
||||
private final Map<Byte, Set<PacketListenerCommon>> listenersMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Call the PacketEvent.
|
||||
@@ -44,13 +45,16 @@ public class EventManager {
|
||||
|
||||
public void callEvent(PacketEvent event, @Nullable Runnable postCallListenerAction) {
|
||||
for (byte priority = PacketListenerPriority.LOWEST.getId(); priority <= PacketListenerPriority.MONITOR.getId(); priority++) {
|
||||
HashSet<PacketListenerCommon> listeners = listenersMap.get(priority);
|
||||
Set<PacketListenerCommon> listeners = listenersMap.get(priority);
|
||||
if (listeners != null) {
|
||||
for (PacketListenerCommon listener : listeners) {
|
||||
try {
|
||||
event.call(listener);
|
||||
} catch (Throwable t) {
|
||||
PacketEvents.getAPI().getLogger().log(Level.WARNING, "PacketEvents caught an unhandled exception while calling your listener.", t);
|
||||
} catch (Exception t) {
|
||||
// ignore handshake exceptions
|
||||
if (t.getClass() != InvalidHandshakeException.class) {
|
||||
PacketEvents.getAPI().getLogger().log(Level.WARNING, "PacketEvents caught an unhandled exception while calling your listener.", t);
|
||||
}
|
||||
}
|
||||
if (postCallListenerAction != null) {
|
||||
postCallListenerAction.run();
|
||||
@@ -58,7 +62,8 @@ public class EventManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event instanceof ProtocolPacketEvent && PacketEvents.getAPI().getSettings().shouldListenersReadOnly()) {
|
||||
// For performance reasons, we don't want to re-encode the packet if it's not needed.
|
||||
if (event instanceof ProtocolPacketEvent && !((ProtocolPacketEvent<?>) event).needsReEncode()) {
|
||||
((ProtocolPacketEvent<?>) event).setLastUsedWrapper(null);
|
||||
}
|
||||
|
||||
@@ -76,9 +81,9 @@ public class EventManager {
|
||||
*/
|
||||
public PacketListenerCommon registerListener(PacketListenerCommon listener) {
|
||||
byte priority = listener.getPriority().getId();
|
||||
HashSet<PacketListenerCommon> listenerSet = listenersMap.get(priority);
|
||||
Set<PacketListenerCommon> listenerSet = listenersMap.get(priority);
|
||||
if (listenerSet == null) {
|
||||
listenerSet = new HashSet<>();
|
||||
listenerSet = ConcurrentHashMap.newKeySet();
|
||||
}
|
||||
listenerSet.add(listener);
|
||||
listenersMap.put(priority, listenerSet);
|
||||
@@ -98,7 +103,7 @@ public class EventManager {
|
||||
}
|
||||
|
||||
public void unregisterListener(PacketListenerCommon listener) {
|
||||
HashSet<PacketListenerCommon> listenerSet = listenersMap.get(listener.getPriority().getId());
|
||||
Set<PacketListenerCommon> listenerSet = listenersMap.get(listener.getPriority().getId());
|
||||
if (listenerSet == null) return;
|
||||
listenerSet.remove(listener);
|
||||
}
|
||||
|
||||
@@ -47,20 +47,13 @@ public class PacketReceiveEvent extends ProtocolPacketEvent<Object> {
|
||||
|
||||
@Override
|
||||
public PacketReceiveEvent clone() {
|
||||
if (this instanceof PacketHandshakeReceiveEvent) {
|
||||
return ((PacketHandshakeReceiveEvent)this).clone();
|
||||
}
|
||||
else if (this instanceof PacketStatusReceiveEvent) {
|
||||
return ((PacketStatusReceiveEvent)this).clone();
|
||||
}
|
||||
else if (this instanceof PacketLoginReceiveEvent) {
|
||||
return ((PacketLoginReceiveEvent)this).clone();
|
||||
}
|
||||
else if (this instanceof PacketPlayReceiveEvent) {
|
||||
return ((PacketPlayReceiveEvent)this).clone();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.event.simple.PacketLoginSendEvent;
|
||||
import com.github.retrooper.packetevents.event.simple.PacketPlaySendEvent;
|
||||
import com.github.retrooper.packetevents.event.simple.PacketStatusSendEvent;
|
||||
import com.github.retrooper.packetevents.event.simple.PacketHandshakeSendEvent;
|
||||
import com.github.retrooper.packetevents.exception.PacketProcessException;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
@@ -28,7 +26,12 @@ import com.github.retrooper.packetevents.protocol.PacketSide;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PacketSendEvent extends ProtocolPacketEvent<Object> {
|
||||
private List<Runnable> tasksAfterSend = null;
|
||||
|
||||
protected PacketSendEvent(Object channel, User user, Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
super(PacketSide.SERVER, channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
@@ -48,19 +51,27 @@ public class PacketSendEvent extends ProtocolPacketEvent<Object> {
|
||||
listener.onPacketSend(this);
|
||||
}
|
||||
|
||||
|
||||
public List<Runnable> getTasksAfterSend() {
|
||||
if (tasksAfterSend == null) {
|
||||
tasksAfterSend = new ArrayList<>();
|
||||
}
|
||||
return tasksAfterSend;
|
||||
}
|
||||
|
||||
public boolean hasTasksAfterSend() {
|
||||
return tasksAfterSend != null && !tasksAfterSend.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketSendEvent clone() {
|
||||
if (this instanceof PacketStatusSendEvent) {
|
||||
return ((PacketStatusSendEvent)this).clone();
|
||||
}
|
||||
else if (this instanceof PacketLoginSendEvent) {
|
||||
return ((PacketLoginSendEvent)this).clone();
|
||||
}
|
||||
else if (this instanceof PacketPlaySendEvent) {
|
||||
return ((PacketPlaySendEvent)this).clone();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.event;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.exception.InvalidDisconnectPacketSend;
|
||||
import com.github.retrooper.packetevents.exception.PacketProcessException;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
@@ -51,6 +52,7 @@ public abstract class ProtocolPacketEvent<T> extends PacketEvent implements Play
|
||||
private PacketWrapper<?> lastUsedWrapper;
|
||||
private List<Runnable> postTasks = null;
|
||||
private boolean cloned;
|
||||
private boolean needsReEncode = PacketEvents.getAPI().getSettings().reEncodeByDefault();
|
||||
|
||||
public ProtocolPacketEvent(PacketSide packetSide, Object channel,
|
||||
User user, T player, Object byteBuf,
|
||||
@@ -76,12 +78,17 @@ public abstract class ProtocolPacketEvent<T> extends PacketEvent implements Play
|
||||
throw new PacketProcessException("Failed to read the Packet ID of a packet. (Size: " + size + ")");
|
||||
}
|
||||
ClientVersion version = serverVersion.toClientVersion();
|
||||
this.packetType = PacketType.getById(packetSide, user.getConnectionState(),
|
||||
ConnectionState state = packetSide == PacketSide.CLIENT ? user.getDecoderState() : user.getEncoderState();
|
||||
this.packetType = PacketType.getById(packetSide, state,
|
||||
version, packetID);
|
||||
if (this.packetType == null) {
|
||||
throw new PacketProcessException("Failed to map the Packet ID " + packetID + " to a PacketType constant. Bound: " + packetSide.getOpposite() + ", Connection state: " + user.getConnectionState() + ", Server version: " + serverVersion.getReleaseName());
|
||||
// mojang messed up and keeps sending disconnect packets in the wrong protocol state
|
||||
if (PacketType.getById(packetSide, ConnectionState.PLAY, version, packetID) == PacketType.Play.Server.DISCONNECT) {
|
||||
throw new InvalidDisconnectPacketSend();
|
||||
}
|
||||
throw new PacketProcessException("Failed to map the Packet ID " + packetID + " to a PacketType constant. Bound: " + packetSide.getOpposite() + ", Connection state: " + user.getDecoderState() + ", Server version: " + serverVersion.getReleaseName());
|
||||
}
|
||||
this.connectionState = user.getConnectionState();
|
||||
this.connectionState = state;
|
||||
}
|
||||
|
||||
public ProtocolPacketEvent(int packetID, PacketTypeCommon packetType, ServerVersion serverVersion, Object channel,
|
||||
@@ -93,10 +100,21 @@ public abstract class ProtocolPacketEvent<T> extends PacketEvent implements Play
|
||||
this.byteBuf = byteBuf;
|
||||
this.packetID = packetID;
|
||||
this.packetType = packetType;
|
||||
this.connectionState = user.getConnectionState();
|
||||
|
||||
this.connectionState = (packetType != null && packetType.getSide() == PacketSide.SERVER)
|
||||
? user.getEncoderState() : user.getDecoderState();
|
||||
cloned = true;
|
||||
}
|
||||
|
||||
public void markForReEncode(boolean needsReEncode) {
|
||||
this.needsReEncode = needsReEncode;
|
||||
}
|
||||
|
||||
public boolean needsReEncode() {
|
||||
return needsReEncode;
|
||||
}
|
||||
|
||||
|
||||
public boolean isClone() {
|
||||
return cloned;
|
||||
}
|
||||
@@ -151,7 +169,6 @@ public abstract class ProtocolPacketEvent<T> extends PacketEvent implements Play
|
||||
this.byteBuf = byteBuf;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getPacketId() {
|
||||
return packetID;
|
||||
}
|
||||
|
||||
+16
-2
@@ -41,7 +41,11 @@ public abstract class SimplePacketListenerAbstract extends PacketListenerCommon
|
||||
onPacketStatusReceive((PacketStatusReceiveEvent) event);
|
||||
} else if (event instanceof PacketLoginReceiveEvent) {
|
||||
onPacketLoginReceive((PacketLoginReceiveEvent) event);
|
||||
} else if (event instanceof PacketPlayReceiveEvent) {
|
||||
}
|
||||
else if (event instanceof PacketConfigReceiveEvent) {
|
||||
onPacketConfigReceive((PacketConfigReceiveEvent) event);
|
||||
}
|
||||
else if (event instanceof PacketPlayReceiveEvent) {
|
||||
onPacketPlayReceive((PacketPlayReceiveEvent) event);
|
||||
}
|
||||
}
|
||||
@@ -52,7 +56,11 @@ public abstract class SimplePacketListenerAbstract extends PacketListenerCommon
|
||||
onPacketStatusSend((PacketStatusSendEvent) event);
|
||||
} else if (event instanceof PacketLoginSendEvent) {
|
||||
onPacketLoginSend((PacketLoginSendEvent) event);
|
||||
} else if (event instanceof PacketPlaySendEvent) {
|
||||
}
|
||||
else if (event instanceof PacketConfigSendEvent) {
|
||||
onPacketConfigSend((PacketConfigSendEvent) event);
|
||||
}
|
||||
else if (event instanceof PacketPlaySendEvent) {
|
||||
onPacketPlaySend((PacketPlaySendEvent) event);
|
||||
}
|
||||
}
|
||||
@@ -72,6 +80,12 @@ public abstract class SimplePacketListenerAbstract extends PacketListenerCommon
|
||||
public void onPacketLoginSend(PacketLoginSendEvent event) {
|
||||
}
|
||||
|
||||
public void onPacketConfigReceive(PacketConfigReceiveEvent event) {
|
||||
}
|
||||
|
||||
public void onPacketConfigSend(PacketConfigSendEvent event) {
|
||||
}
|
||||
|
||||
public void onPacketPlayReceive(PacketPlayReceiveEvent event) {
|
||||
}
|
||||
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.event.simple;
|
||||
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.exception.PacketProcessException;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
|
||||
public class PacketConfigReceiveEvent extends PacketReceiveEvent {
|
||||
|
||||
public PacketConfigReceiveEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketConfigReceiveEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketConfigReceiveEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigReceiveEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PacketType.Configuration.Client getPacketType() {
|
||||
return (PacketType.Configuration.Client) super.getPacketType();
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.event.simple;
|
||||
|
||||
import com.github.retrooper.packetevents.event.PacketSendEvent;
|
||||
import com.github.retrooper.packetevents.exception.PacketProcessException;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
|
||||
public class PacketConfigSendEvent extends PacketSendEvent {
|
||||
|
||||
public PacketConfigSendEvent(Object channel, User user,
|
||||
Object player, Object rawByteBuf,
|
||||
boolean autoProtocolTranslation) throws PacketProcessException {
|
||||
super(channel, user, player, rawByteBuf, autoProtocolTranslation);
|
||||
}
|
||||
|
||||
protected PacketConfigSendEvent(int packetId, PacketTypeCommon packetType,
|
||||
ServerVersion serverVersion,
|
||||
Object channel,
|
||||
User user, Object player, Object byteBuf) throws PacketProcessException {
|
||||
super(packetId, packetType, serverVersion, channel, user, player, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketConfigSendEvent clone() {
|
||||
try {
|
||||
Object clonedBuffer = ByteBufHelper.retainedDuplicate(getByteBuf());
|
||||
return new PacketConfigSendEvent(getPacketId(), getPacketType(), getServerVersion(),
|
||||
getChannel(), getUser(), getPlayer(), clonedBuffer);
|
||||
} catch (PacketProcessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PacketType.Configuration.Server getPacketType() {
|
||||
return (PacketType.Configuration.Server) super.getPacketType();
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.github.retrooper.packetevents.exception;
|
||||
|
||||
public class CancelPacketException extends RuntimeException {
|
||||
public static final CancelPacketException INSTANCE = new CancelPacketException();
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package com.github.retrooper.packetevents.exception;
|
||||
|
||||
public class InvalidDisconnectPacketSend extends RuntimeException {
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package com.github.retrooper.packetevents.exception;
|
||||
|
||||
public class InvalidHandshakeException extends RuntimeException {
|
||||
}
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.exception;
|
||||
|
||||
public class PacketProcessException extends Exception {
|
||||
public class PacketProcessException extends RuntimeException {
|
||||
public PacketProcessException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.injector;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.ConnectionState;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface ChannelInjector {
|
||||
default boolean isServerBound() {
|
||||
@@ -31,13 +29,9 @@ public interface ChannelInjector {
|
||||
|
||||
void uninject();
|
||||
|
||||
User getUser(Object channel);
|
||||
|
||||
void changeConnectionState(Object channel, @Nullable ConnectionState connectionState);
|
||||
|
||||
void updateUser(Object channel, User user);
|
||||
|
||||
void setPlayer(Object channel, Object player);
|
||||
|
||||
boolean hasPlayer(Object player);
|
||||
boolean isProxy();
|
||||
}
|
||||
+60
-27
@@ -32,6 +32,7 @@ import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||
import com.github.retrooper.packetevents.wrapper.configuration.server.WrapperConfigServerRegistryData;
|
||||
import com.github.retrooper.packetevents.wrapper.handshaking.client.WrapperHandshakingClientHandshake;
|
||||
import com.github.retrooper.packetevents.wrapper.login.server.WrapperLoginServerLoginSuccess;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerJoinGame;
|
||||
@@ -71,44 +72,76 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
|
||||
PacketEvents.getAPI().getLogManager().debug("Mapped player UUID with their channel.");
|
||||
|
||||
//Update connection state(injectors might do some adjustments when we transition into PLAY state)
|
||||
//This also updates it for the user instance
|
||||
event.getPostTasks().add(() -> {
|
||||
PacketEvents.getAPI().getInjector().changeConnectionState(channel, ConnectionState.PLAY);
|
||||
PacketEvents.getAPI().getLogManager().debug("Transitioned " + profile.getName() + " into the PLAY state!");
|
||||
});
|
||||
// Switch the user's connection state to new state, but the variable event.getConnectionState() remains LOGIN
|
||||
// We switch user state immediately to remain in sync with vanilla, allowing you to encode packets immediately
|
||||
boolean proxy = PacketEvents.getAPI().getInjector().isProxy();
|
||||
if (proxy ? event.getUser().getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_20_2)
|
||||
: event.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_20_2)) {
|
||||
user.setEncoderState(ConnectionState.CONFIGURATION);
|
||||
} else {
|
||||
user.setConnectionState(ConnectionState.PLAY);
|
||||
}
|
||||
}
|
||||
|
||||
// Join game can be used to update world height, and sets dimension data
|
||||
// The server sends dimension information in configuration phase >= 1.20.2
|
||||
else if (event.getPacketType() == PacketType.Configuration.Server.REGISTRY_DATA) {
|
||||
WrapperConfigServerRegistryData registryData = new WrapperConfigServerRegistryData(event);
|
||||
|
||||
// Store world data
|
||||
NBTCompound registryDataTag = registryData.getRegistryData();
|
||||
if (registryDataTag != null) {
|
||||
NBTList<NBTCompound> list = registryDataTag
|
||||
.getCompoundTagOrNull("minecraft:dimension_type")
|
||||
.getCompoundListTagOrNull("value");
|
||||
user.setWorldNBT(list);
|
||||
}
|
||||
}
|
||||
|
||||
// The server sends dimension information in login packet for >= 1.17 and < 1.20.2
|
||||
else if (event.getPacketType() == PacketType.Play.Server.JOIN_GAME) {
|
||||
WrapperPlayServerJoinGame joinGame = new WrapperPlayServerJoinGame(event);
|
||||
user.setEntityId(joinGame.getEntityId());
|
||||
user.setDimension(joinGame.getDimension());
|
||||
if (event.getServerVersion().isOlderThanOrEquals(ServerVersion.V_1_16_5)) {
|
||||
return; // Fixed world height, no tags are sent to the client
|
||||
}
|
||||
|
||||
// Store world height
|
||||
NBTList<NBTCompound> list = joinGame.getDimensionCodec().getCompoundTagOrNull("minecraft:dimension_type").getCompoundListTagOrNull("value");
|
||||
user.setWorldNBT(list);
|
||||
// Store world data
|
||||
NBTCompound dimensionCodec = joinGame.getDimensionCodec();
|
||||
if (dimensionCodec != null) {
|
||||
NBTList<NBTCompound> list = dimensionCodec
|
||||
.getCompoundTagOrNull("minecraft:dimension_type")
|
||||
.getCompoundListTagOrNull("value");
|
||||
user.setWorldNBT(list);
|
||||
}
|
||||
|
||||
// Update world height
|
||||
NBTCompound worldNBT = user.getWorldNBT(joinGame.getDimension().getDimensionName()).getCompoundTagOrNull("element");
|
||||
user.setMinWorldHeight(worldNBT.getNumberTagOrNull("min_y").getAsInt());
|
||||
user.setTotalWorldHeight(worldNBT.getNumberTagOrNull("height").getAsInt());
|
||||
NBTCompound dimension = user.getWorldNBT(joinGame.getDimension().getDimensionName());
|
||||
if (dimension != null) {
|
||||
NBTCompound worldNBT = dimension.getCompoundTagOrNull("element");
|
||||
user.setMinWorldHeight(worldNBT.getNumberTagOrNull("min_y").getAsInt());
|
||||
user.setTotalWorldHeight(worldNBT.getNumberTagOrNull("height").getAsInt());
|
||||
}
|
||||
}
|
||||
|
||||
// Respawn is used to switch dimensions
|
||||
else if (event.getPacketType() == PacketType.Play.Server.RESPAWN) {
|
||||
WrapperPlayServerRespawn respawn = new WrapperPlayServerRespawn(event);
|
||||
user.setDimension(respawn.getDimension());
|
||||
if (event.getServerVersion().isOlderThanOrEquals(ServerVersion.V_1_16_5)) {
|
||||
return; // Fixed world height, no tags are sent to the client
|
||||
}
|
||||
|
||||
WrapperPlayServerRespawn respawn = new WrapperPlayServerRespawn(event);
|
||||
|
||||
NBTCompound worldNBT = user.getWorldNBT(respawn.getDimension().getDimensionName()).getCompoundTagOrNull("element"); // This is 1.17+, it always sends the world name
|
||||
user.setMinWorldHeight(worldNBT.getNumberTagOrNull("min_y").getAsInt());
|
||||
user.setTotalWorldHeight(worldNBT.getNumberTagOrNull("height").getAsInt());
|
||||
NBTCompound dimension = user.getWorldNBT(respawn.getDimension().getDimensionName());
|
||||
if (dimension != null) {
|
||||
NBTCompound worldNBT = dimension.getCompoundTagOrNull("element"); // This is 1.17+, it always sends the world name
|
||||
user.setMinWorldHeight(worldNBT.getNumberTagOrNull("min_y").getAsInt());
|
||||
user.setTotalWorldHeight(worldNBT.getNumberTagOrNull("height").getAsInt());
|
||||
}
|
||||
} else if (event.getPacketType() == PacketType.Play.Server.CONFIGURATION_START) {
|
||||
user.setEncoderState(ConnectionState.CONFIGURATION);
|
||||
} else if (event.getPacketType() == PacketType.Configuration.Server.CONFIGURATION_END) {
|
||||
user.setEncoderState(ConnectionState.PLAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,17 +154,17 @@ public class InternalPacketListener extends PacketListenerAbstract {
|
||||
WrapperHandshakingClientHandshake handshake = new WrapperHandshakingClientHandshake(event);
|
||||
ConnectionState nextState = handshake.getNextConnectionState();
|
||||
ClientVersion clientVersion = handshake.getClientVersion();
|
||||
if (clientVersion == ClientVersion.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
//Update client version for this event call(and user)
|
||||
user.setClientVersion(clientVersion);
|
||||
PacketEvents.getAPI().getLogManager().debug("Processed " + address.getHostString() + ":" + address.getPort() + "'s client version. Client Version: " + clientVersion.getReleaseName());
|
||||
event.getPostTasks().add(() -> {
|
||||
//Transition into the LOGIN OR STATUS connection state
|
||||
PacketEvents.getAPI().getInjector().changeConnectionState(channel, nextState);
|
||||
PacketEvents.getAPI().getLogManager().debug("Transitioned " + address.getHostString() + ":" + address.getPort() + " into the " + nextState + " state!");
|
||||
});
|
||||
//Transition into LOGIN or STATUS connection state immediately, to remain in sync with vanilla
|
||||
user.setConnectionState(nextState);
|
||||
} else if (event.getPacketType() == PacketType.Login.Client.LOGIN_SUCCESS_ACK) {
|
||||
user.setDecoderState(ConnectionState.CONFIGURATION);
|
||||
} else if (event.getPacketType() == PacketType.Play.Client.CONFIGURATION_ACK) {
|
||||
user.setDecoderState(ConnectionState.CONFIGURATION);
|
||||
} else if (event.getPacketType() == PacketType.Configuration.Client.CONFIGURATION_END_ACK) {
|
||||
user.setDecoderState(ConnectionState.PLAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
-18
@@ -20,12 +20,12 @@ package com.github.retrooper.packetevents.manager.protocol;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.netty.channel.ChannelHelper;
|
||||
import com.github.retrooper.packetevents.protocol.ConnectionState;
|
||||
import com.github.retrooper.packetevents.protocol.ProtocolVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.util.PacketTransformationUtil;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
@@ -34,6 +34,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public interface ProtocolManager {
|
||||
Map<UUID, Object> CHANNELS = new ConcurrentHashMap<>();
|
||||
// Use SocketAddress because ProtocolLib wraps Channels with NettyChannelProxy class
|
||||
Map<Object, User> USERS = new ConcurrentHashMap<>();
|
||||
|
||||
default Collection<User> getUsers() {
|
||||
@@ -91,67 +92,70 @@ public interface ProtocolManager {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO Make it clear that this only updates the connection state in our user.
|
||||
//Sometimes you should use getInjector().changeConnectionState because that can allow the injector to make adjustments.
|
||||
//This is very important, especially on Spigot.
|
||||
//As soon as we switch to the play state on spigot, our injector makes some adjustments.
|
||||
default void changeConnectionState(Object channel, ConnectionState connectionState) {
|
||||
getUser(channel).setConnectionState(connectionState);
|
||||
}
|
||||
|
||||
default void setClientVersion(Object channel, ClientVersion version) {
|
||||
getUser(channel).setClientVersion(version);
|
||||
}
|
||||
|
||||
default Object[] transformWrappers(PacketWrapper<?> wrapper) {
|
||||
@ApiStatus.Internal
|
||||
default Object[] transformWrappers(PacketWrapper<?> wrapper, Object channel, boolean outgoing) {
|
||||
//It is possible that our packet transformer util decides to transform one wrapper into multiple packets.
|
||||
//(Correcting some mistakes on your end)
|
||||
PacketWrapper<?>[] wrappers = PacketTransformationUtil.transform(wrapper);
|
||||
Object[] buffers = new Object[wrappers.length];
|
||||
for (int i = 0; i < wrappers.length; i++) {
|
||||
wrappers[i].prepareForSend();
|
||||
wrappers[i].prepareForSend(channel, outgoing);
|
||||
buffers[i] = wrappers[i].buffer;
|
||||
// Fix race condition when sending packets to multiple people (due to when the buffer is freed)
|
||||
wrappers[i].buffer = null;
|
||||
}
|
||||
return buffers;
|
||||
}
|
||||
|
||||
default void sendPacket(Object channel, PacketWrapper<?> wrapper) {
|
||||
Object[] transformed = transformWrappers(wrapper);
|
||||
Object[] transformed = transformWrappers(wrapper, channel, true);
|
||||
sendPackets(channel, transformed);
|
||||
}
|
||||
|
||||
default void sendPacketSilently(Object channel, PacketWrapper<?> wrapper) {
|
||||
Object[] transformed = transformWrappers(wrapper);
|
||||
Object[] transformed = transformWrappers(wrapper, channel, true);
|
||||
sendPacketsSilently(channel, transformed);
|
||||
}
|
||||
|
||||
default void writePacket(Object channel, PacketWrapper<?> wrapper) {
|
||||
Object[] transformed = transformWrappers(wrapper);
|
||||
Object[] transformed = transformWrappers(wrapper, channel, true);
|
||||
writePackets(channel, transformed);
|
||||
}
|
||||
|
||||
default void writePacketSilently(Object channel, PacketWrapper<?> wrapper) {
|
||||
Object[] transformed = transformWrappers(wrapper);
|
||||
Object[] transformed = transformWrappers(wrapper, channel, true);
|
||||
writePacketsSilently(channel, transformed);
|
||||
}
|
||||
|
||||
default void receivePacket(Object channel, PacketWrapper<?> wrapper) {
|
||||
Object[] transformed = transformWrappers(wrapper);
|
||||
Object[] transformed = transformWrappers(wrapper, channel, false);
|
||||
receivePackets(channel, transformed);
|
||||
}
|
||||
|
||||
default void receivePacketSilently(Object channel, PacketWrapper<?> wrapper) {
|
||||
Object[] transformed = transformWrappers(wrapper);
|
||||
Object[] transformed = transformWrappers(wrapper, channel, false);
|
||||
receivePacketsSilently(channel, transformed);
|
||||
}
|
||||
|
||||
default User getUser(Object channel) {
|
||||
return USERS.get(channel);
|
||||
Object pipeline = ChannelHelper.getPipeline(channel);
|
||||
return USERS.get(pipeline);
|
||||
}
|
||||
|
||||
default User removeUser(Object channel) {
|
||||
Object pipeline = ChannelHelper.getPipeline(channel);
|
||||
return USERS.remove(pipeline);
|
||||
}
|
||||
|
||||
default void setUser(Object channel, User user) {
|
||||
synchronized (channel) {
|
||||
USERS.put(channel, user);
|
||||
Object pipeline = ChannelHelper.getPipeline(channel);
|
||||
USERS.put(pipeline, user);
|
||||
}
|
||||
PacketEvents.getAPI().getInjector().updateUser(channel, user);
|
||||
}
|
||||
|
||||
+3
-1
@@ -46,7 +46,9 @@ public enum ServerVersion {
|
||||
V_1_17(755), V_1_17_1(756),
|
||||
V_1_18(757), V_1_18_1(757), V_1_18_2(758),
|
||||
//1.19.1 and 1.19.2 have the same protocol version
|
||||
V_1_19(759), V_1_19_1(760), V_1_19_2(760),
|
||||
V_1_19(759), V_1_19_1(760), V_1_19_2(760), V_1_19_3(761), V_1_19_4(762),
|
||||
//1.20 and 1.20.1 have the same protocol version. 1.20.3 and 1.20.4 have the same protocol version.
|
||||
V_1_20(763), V_1_20_1(763), V_1_20_2(764), V_1_20_3(765), V_1_20_4(765),
|
||||
//TODO UPDATE Add server version constant
|
||||
ERROR(-1, true);
|
||||
|
||||
|
||||
@@ -81,6 +81,10 @@ public class ChannelHelper {
|
||||
return Arrays.toString(pipelineHandlerNames(channel).toArray(new String[0]));
|
||||
}
|
||||
|
||||
public static Object getPipeline(Object channel) {
|
||||
return PacketEvents.getAPI().getNettyManager().getChannelOperator().getPipeline(channel);
|
||||
}
|
||||
|
||||
public static Object getPipelineHandler(Object channel, String name) {
|
||||
return PacketEvents.getAPI().getNettyManager().getChannelOperator().getPipelineHandler(channel, name);
|
||||
}
|
||||
@@ -89,6 +93,10 @@ public class ChannelHelper {
|
||||
return PacketEvents.getAPI().getNettyManager().getChannelOperator().getPipelineContext(channel, handlerName);
|
||||
}
|
||||
|
||||
public static Object pooledByteBuf(Object channel) {
|
||||
return PacketEvents.getAPI().getNettyManager().getChannelOperator().pooledByteBuf(channel);
|
||||
}
|
||||
|
||||
public static void runInEventLoop(Object channel, Runnable runnable) {
|
||||
PacketEvents.getAPI().getNettyManager().getChannelOperator().runInEventLoop(channel, runnable);
|
||||
}
|
||||
|
||||
+18
-3
@@ -20,26 +20,41 @@ package com.github.retrooper.packetevents.netty.channel;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ChannelOperator {
|
||||
Set<Class<? extends Throwable>> getIgnoredHandlerExceptions();
|
||||
|
||||
SocketAddress remoteAddress(Object channel);
|
||||
|
||||
SocketAddress localAddress(Object channel);
|
||||
|
||||
boolean isOpen(Object channel);
|
||||
|
||||
Object close(Object channel);
|
||||
|
||||
Object write(Object channel, Object buffer);
|
||||
|
||||
Object flush(Object channel);
|
||||
|
||||
Object writeAndFlush(Object channel, Object buffer);
|
||||
|
||||
Object fireChannelRead(Object channel, Object buffer);
|
||||
|
||||
Object writeInContext(Object channel, String ctx, Object buffer);
|
||||
|
||||
Object flushInContext(Object channel, String ctx);
|
||||
|
||||
Object writeAndFlushInContext(Object channel, String ctx, Object buffer);
|
||||
|
||||
Object fireChannelReadInContext(Object channel, String ctx, Object buffer);
|
||||
|
||||
List<String> pipelineHandlerNames(Object channel);
|
||||
|
||||
Object getPipelineHandler(Object channel, String name);
|
||||
|
||||
Object getPipelineContext(Object channel, String name);
|
||||
|
||||
Object getPipeline(Object channel);
|
||||
|
||||
void runInEventLoop(Object channel, Runnable runnable);
|
||||
|
||||
Object pooledByteBuf(Object channel);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ package com.github.retrooper.packetevents.protocol;
|
||||
* @since 1.8
|
||||
*/
|
||||
public enum ConnectionState {
|
||||
HANDSHAKING, STATUS, LOGIN, PLAY;
|
||||
HANDSHAKING, STATUS, LOGIN, PLAY, CONFIGURATION;
|
||||
|
||||
public static ConnectionState getById(int id) {
|
||||
if (id >= values().length || id < 0) {
|
||||
|
||||
+37
-2
@@ -5,6 +5,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -32,6 +33,22 @@ public class LastSeenMessages {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public static class Packed {
|
||||
private List<MessageSignature.Packed> packedMessageSignatures;
|
||||
|
||||
public Packed(List<MessageSignature.Packed> packedMessageSignatures) {
|
||||
this.packedMessageSignatures = packedMessageSignatures;
|
||||
}
|
||||
|
||||
public List<MessageSignature.Packed> getPackedMessageSignatures() {
|
||||
return packedMessageSignatures;
|
||||
}
|
||||
|
||||
public void setPackedMessageSignatures(List<MessageSignature.Packed> packedMessageSignatures) {
|
||||
this.packedMessageSignatures = packedMessageSignatures;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Entry {
|
||||
private final UUID uuid;
|
||||
private final byte[] signature;
|
||||
@@ -50,11 +67,11 @@ public class LastSeenMessages {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Update {
|
||||
public static class LegacyUpdate {
|
||||
private final LastSeenMessages lastSeenMessages;
|
||||
private final @Nullable Entry lastReceived;
|
||||
|
||||
public Update(LastSeenMessages lastSeenMessages, @Nullable Entry lastReceived) {
|
||||
public LegacyUpdate(LastSeenMessages lastSeenMessages, @Nullable Entry lastReceived) {
|
||||
this.lastSeenMessages = lastSeenMessages;
|
||||
this.lastReceived = lastReceived;
|
||||
}
|
||||
@@ -67,4 +84,22 @@ public class LastSeenMessages {
|
||||
return lastReceived;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Update {
|
||||
private final int offset;
|
||||
private final BitSet acknowledged;
|
||||
|
||||
public Update(int offset, BitSet acknowledged) {
|
||||
this.offset = offset;
|
||||
this.acknowledged = acknowledged;
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public BitSet getAcknowledged() {
|
||||
return acknowledged;
|
||||
}
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2023 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MessageSignature {
|
||||
private byte[] bytes;
|
||||
|
||||
public MessageSignature(byte[] bytes) {
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public void setBytes(byte[] bytes) {
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public static class Packed {
|
||||
private int id;
|
||||
private @Nullable MessageSignature fullSignature;
|
||||
|
||||
public Packed(@Nullable MessageSignature fullSignature) {
|
||||
this.id = -1;
|
||||
this.fullSignature = fullSignature;
|
||||
}
|
||||
|
||||
public Packed(int id) {
|
||||
this.id = id;
|
||||
this.fullSignature = null;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Optional<MessageSignature> getFullSignature() {
|
||||
return Optional.ofNullable(fullSignature);
|
||||
}
|
||||
|
||||
public void setFullSignature(@Nullable MessageSignature fullSignature) {
|
||||
this.fullSignature = fullSignature;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Node {
|
||||
private byte flags;
|
||||
private List<Integer> children;
|
||||
private Optional<Integer> redirectNodeIndex;
|
||||
private Optional<String> name;
|
||||
private Optional<Integer> parserID;
|
||||
private Optional<List<Object>> properties;
|
||||
private Optional<ResourceLocation> suggestionsType;
|
||||
|
||||
public Node(byte flags, List<Integer> children, @Nullable Integer redirectNodeIndex, @Nullable String name, @Nullable Integer parserID, @Nullable List<Object> properties, @Nullable ResourceLocation suggestionsType) {
|
||||
this.flags = flags;
|
||||
this.children = children;
|
||||
this.redirectNodeIndex = Optional.ofNullable(redirectNodeIndex);
|
||||
this.name = Optional.ofNullable(name);
|
||||
this.parserID = Optional.ofNullable(parserID);
|
||||
this.properties = Optional.ofNullable(properties);
|
||||
this.suggestionsType = Optional.ofNullable(suggestionsType);
|
||||
}
|
||||
|
||||
public byte getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void setFlags(byte flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
public List<Integer> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<Integer> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public Optional<Integer> getRedirectNodeIndex() {
|
||||
return redirectNodeIndex;
|
||||
}
|
||||
|
||||
public void setRedirectNodeIndex(Optional<Integer> redirectNodeIndex) {
|
||||
this.redirectNodeIndex = redirectNodeIndex;
|
||||
}
|
||||
|
||||
public Optional<String> getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(Optional<String> name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Optional<Integer> getParserID() {
|
||||
return parserID;
|
||||
}
|
||||
|
||||
public void setParserID(Optional<Integer> parserID) {
|
||||
this.parserID = parserID;
|
||||
}
|
||||
|
||||
public Optional<List<Object>> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Optional<List<Object>> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Optional<ResourceLocation> getSuggestionsType() {
|
||||
return suggestionsType;
|
||||
}
|
||||
|
||||
public void setSuggestionsType(Optional<ResourceLocation> suggestionsType) {
|
||||
this.suggestionsType = suggestionsType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Parsers {
|
||||
private static final List<Parser> parsers = Arrays.asList(
|
||||
new Parser("brigadier:bool", null, null),
|
||||
new Parser("brigadier:float",
|
||||
packetWrapper -> {
|
||||
byte flags = packetWrapper.readByte();
|
||||
float min = (flags & 0x01) != 0 ? packetWrapper.readFloat() : -Float.MAX_VALUE;
|
||||
float max = (flags & 0x02) != 0 ? packetWrapper.readFloat() : Float.MAX_VALUE;
|
||||
return Arrays.asList(flags, min, max);
|
||||
},
|
||||
(packetWrapper, properties) -> {
|
||||
byte flags = (byte) properties.get(0);
|
||||
packetWrapper.writeByte(flags);
|
||||
if ((flags & 0x01) != 0) packetWrapper.writeFloat((float) properties.get(1));
|
||||
if ((flags & 0x02) != 0) packetWrapper.writeFloat((float) properties.get(2));
|
||||
}
|
||||
),
|
||||
new Parser("brigadier:double",
|
||||
packetWrapper -> {
|
||||
byte flags = packetWrapper.readByte();
|
||||
double min = (flags & 0x01) != 0 ? packetWrapper.readDouble() : -Double.MAX_VALUE;
|
||||
double max = (flags & 0x02) != 0 ? packetWrapper.readDouble() : Double.MAX_VALUE;
|
||||
return Arrays.asList(flags, min, max);
|
||||
},
|
||||
(packetWrapper, properties) -> {
|
||||
byte flags = (byte) properties.get(0);
|
||||
packetWrapper.writeByte(flags);
|
||||
if ((flags & 0x01) != 0) packetWrapper.writeDouble((double) properties.get(1));
|
||||
if ((flags & 0x02) != 0) packetWrapper.writeDouble((double) properties.get(2));
|
||||
}
|
||||
),
|
||||
new Parser("brigadier:integer",
|
||||
packetWrapper -> {
|
||||
byte flags = packetWrapper.readByte();
|
||||
int min = (flags & 0x01) != 0 ? packetWrapper.readInt() : Integer.MIN_VALUE;
|
||||
int max = (flags & 0x02) != 0 ? packetWrapper.readInt() : Integer.MAX_VALUE;
|
||||
return Arrays.asList(flags, min, max);
|
||||
},
|
||||
(packetWrapper, properties) -> {
|
||||
byte flags = (byte) properties.get(0);
|
||||
packetWrapper.writeByte(flags);
|
||||
if ((flags & 0x01) != 0) packetWrapper.writeInt((int) properties.get(1));
|
||||
if ((flags & 0x02) != 0) packetWrapper.writeInt((int) properties.get(2));
|
||||
}
|
||||
),
|
||||
new Parser("brigadier:long",
|
||||
packetWrapper -> {
|
||||
byte flags = packetWrapper.readByte();
|
||||
long min = (flags & 0x01) != 0 ? packetWrapper.readLong() : Long.MIN_VALUE;
|
||||
long max = (flags & 0x02) != 0 ? packetWrapper.readLong() : Long.MAX_VALUE;
|
||||
return Arrays.asList(flags, min, max);
|
||||
},
|
||||
(packetWrapper, properties) -> {
|
||||
byte flags = (byte) properties.get(0);
|
||||
packetWrapper.writeByte(flags);
|
||||
if ((flags & 0x01) != 0) packetWrapper.writeLong((long) properties.get(1));
|
||||
if ((flags & 0x02) != 0) packetWrapper.writeLong((long) properties.get(2));
|
||||
}
|
||||
),
|
||||
new Parser("brigadier:string",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readVarInt()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeVarInt((Integer) properties.get(0))
|
||||
),
|
||||
new Parser("minecraft:entity",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readByte()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeByte(((Byte) properties.get(0)).intValue())
|
||||
),
|
||||
new Parser("minecraft:game_profile", null, null),
|
||||
new Parser("minecraft:block_pos", null, null),
|
||||
new Parser("minecraft:column_pos", null, null),
|
||||
new Parser("minecraft:vec3", null, null),
|
||||
new Parser("minecraft:vec2", null, null),
|
||||
new Parser("minecraft:block_state", null, null),
|
||||
new Parser("minecraft:block_predicate", null, null),
|
||||
new Parser("minecraft:item_stack", null, null),
|
||||
new Parser("minecraft:item_predicate", null, null),
|
||||
new Parser("minecraft:color", null, null),
|
||||
new Parser("minecraft:component", null, null),
|
||||
new Parser("minecraft:style", null, null),
|
||||
new Parser("minecraft:message", null, null),
|
||||
new Parser("minecraft:nbt", null, null),
|
||||
new Parser("minecraft:nbt_tag", null, null),
|
||||
new Parser("minecraft:nbt_path", null, null),
|
||||
new Parser("minecraft:objective", null, null),
|
||||
new Parser("minecraft:objective_criteria", null, null),
|
||||
new Parser("minecraft:operation", null, null),
|
||||
new Parser("minecraft:particle", null, null),
|
||||
new Parser("minecraft:angle", null, null),
|
||||
new Parser("minecraft:rotation", null, null),
|
||||
new Parser("minecraft:scoreboard_slot", null, null),
|
||||
new Parser("minecraft:score_holder",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readByte()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeByte(((Byte) properties.get(0)).intValue())
|
||||
),
|
||||
new Parser("minecraft:swizzle", null, null),
|
||||
new Parser("minecraft:team", null, null),
|
||||
new Parser("minecraft:item_slot", null, null),
|
||||
new Parser("minecraft:resource_location", null, null),
|
||||
new Parser("minecraft:function", null, null),
|
||||
new Parser("minecraft:entity_anchor", null, null),
|
||||
new Parser("minecraft:int_range", null, null),
|
||||
new Parser("minecraft:float_range", null, null),
|
||||
new Parser("minecraft:dimension", null, null),
|
||||
new Parser("minecraft:gamemode", null, null),
|
||||
new Parser("minecraft:time",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readInt()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeInt((int) properties.get(0))
|
||||
),
|
||||
new Parser("minecraft:resource_or_tag",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readIdentifier()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeIdentifier((ResourceLocation) properties.get(0))
|
||||
),
|
||||
new Parser("minecraft:resource_or_tag_key",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readIdentifier()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeIdentifier((ResourceLocation) properties.get(0))
|
||||
),
|
||||
new Parser("minecraft:resource",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readIdentifier()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeIdentifier((ResourceLocation) properties.get(0))
|
||||
),
|
||||
new Parser("minecraft:resource_key",
|
||||
packetWrapper -> Collections.singletonList(packetWrapper.readIdentifier()),
|
||||
(packetWrapper, properties) -> packetWrapper.writeIdentifier((ResourceLocation) properties.get(0))
|
||||
),
|
||||
new Parser("minecraft:template_mirror", null, null),
|
||||
new Parser("minecraft:template_rotation", null, null),
|
||||
new Parser("minecraft:heightmap", null, null),
|
||||
new Parser("minecraft:uuid", null, null)
|
||||
);
|
||||
|
||||
public static List<Parser> getParsers() {
|
||||
return parsers;
|
||||
}
|
||||
|
||||
public static final class Parser {
|
||||
private final String name; //not really needed, just for toString or something
|
||||
private final Optional<Function<PacketWrapper<?>, List<Object>>> read;
|
||||
private final Optional<BiConsumer<PacketWrapper<?>, List<Object>>> write;
|
||||
|
||||
public Parser(String name, @Nullable Function<PacketWrapper<?>, List<Object>> read, @Nullable BiConsumer<PacketWrapper<?>, List<Object>> write) {
|
||||
this.name = name;
|
||||
this.read = Optional.ofNullable(read);
|
||||
this.write = Optional.ofNullable(write);
|
||||
}
|
||||
|
||||
public Optional<List<Object>> readProperties(PacketWrapper<?> packetWrapper) {
|
||||
return read.map(fn -> fn.apply(packetWrapper));
|
||||
}
|
||||
|
||||
public void writeProperties(PacketWrapper<?> packetWrapper, List<Object> properties) {
|
||||
write.ifPresent(fn -> fn.accept(packetWrapper, properties));
|
||||
}
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.PublicProfileKey;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class RemoteChatSession {
|
||||
private final UUID sessionId;
|
||||
private final PublicProfileKey publicProfileKey;
|
||||
|
||||
public RemoteChatSession(UUID sessionId, PublicProfileKey publicProfileKey) {
|
||||
this.sessionId = sessionId;
|
||||
this.publicProfileKey = publicProfileKey;
|
||||
}
|
||||
|
||||
public UUID getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public PublicProfileKey getPublicProfileKey() {
|
||||
return publicProfileKey;
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.github.retrooper.packetevents.protocol.chat;
|
||||
|
||||
public class SignedCommandArgument {
|
||||
private String argument;
|
||||
private byte[] signature;
|
||||
|
||||
public SignedCommandArgument(String argument, byte[] signature) {
|
||||
this.argument = argument;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public String getArgument() {
|
||||
return argument;
|
||||
}
|
||||
|
||||
public void setArgument(String argument) {
|
||||
this.argument = argument;
|
||||
}
|
||||
|
||||
public byte[] getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(byte[] signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
}
|
||||
+3
-13
@@ -24,10 +24,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatMessage_v1_19 extends ChatMessage {
|
||||
//We'll extend ChatMessage_v1_16 for now, hopefully no breaking changes in the future
|
||||
public class ChatMessage_v1_19 extends ChatMessage_v1_16 {
|
||||
private @Nullable Component unsignedChatContent;
|
||||
private UUID senderUUID;
|
||||
private Component senderDisplayName;
|
||||
private @Nullable Component teamName;
|
||||
private Instant timestamp;
|
||||
@@ -37,9 +36,8 @@ public class ChatMessage_v1_19 extends ChatMessage {
|
||||
public ChatMessage_v1_19(Component chatContent, @Nullable Component unsignedChatContent, ChatType type,
|
||||
UUID senderUUID, Component senderDisplayName, @Nullable Component teamName, Instant timestamp,
|
||||
long salt, byte[] signature) {
|
||||
super(chatContent, type);
|
||||
super(chatContent, type, senderUUID);
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
this.senderUUID = senderUUID;
|
||||
this.senderDisplayName = senderDisplayName;
|
||||
this.teamName = teamName;
|
||||
this.timestamp = timestamp;
|
||||
@@ -51,10 +49,6 @@ public class ChatMessage_v1_19 extends ChatMessage {
|
||||
return unsignedChatContent;
|
||||
}
|
||||
|
||||
public UUID getSenderUUID() {
|
||||
return senderUUID;
|
||||
}
|
||||
|
||||
public Component getSenderDisplayName() {
|
||||
return senderDisplayName;
|
||||
}
|
||||
@@ -79,10 +73,6 @@ public class ChatMessage_v1_19 extends ChatMessage {
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
}
|
||||
|
||||
public void setSenderUUID(UUID senderUUID) {
|
||||
this.senderUUID = senderUUID;
|
||||
}
|
||||
|
||||
public void setSenderDisplayName(Component senderDisplayName) {
|
||||
this.senderDisplayName = senderDisplayName;
|
||||
}
|
||||
|
||||
+3
-13
@@ -26,11 +26,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatMessage_v1_19_1 extends ChatMessage {
|
||||
//We'll extend ChatMessage_v1_16 for now, hopefully no breaking changes in the future
|
||||
public class ChatMessage_v1_19_1 extends ChatMessage_v1_16 {
|
||||
private String plainContent;
|
||||
private @Nullable Component unsignedChatContent;
|
||||
private UUID senderUUID;
|
||||
private ChatTypeBoundNetwork chatType;
|
||||
private byte @Nullable [] previousSignature;
|
||||
private byte[] signature;
|
||||
@@ -46,10 +45,9 @@ public class ChatMessage_v1_19_1 extends ChatMessage {
|
||||
Instant timestamp, long salt,
|
||||
LastSeenMessages lastSeenMessages,
|
||||
FilterMask filterMask) {
|
||||
super(decoratedChatContent, chatType.getType());
|
||||
super(decoratedChatContent, chatType.getType(), senderUUID);
|
||||
this.plainContent = plainContent;
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
this.senderUUID = senderUUID;
|
||||
this.chatType = chatType;
|
||||
this.previousSignature = previousSignature;
|
||||
this.signature = signature;
|
||||
@@ -79,14 +77,6 @@ public class ChatMessage_v1_19_1 extends ChatMessage {
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
}
|
||||
|
||||
public UUID getSenderUUID() {
|
||||
return senderUUID;
|
||||
}
|
||||
|
||||
public void setSenderUUID(UUID senderUUID) {
|
||||
this.senderUUID = senderUUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatType getType() {
|
||||
return chatType.getType();
|
||||
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
package com.github.retrooper.packetevents.protocol.chat.message;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.LastSeenMessages;
|
||||
import com.github.retrooper.packetevents.protocol.chat.filter.FilterMask;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
//We'll extend ChatMessage_v1_16 for now, hopefully no breaking changes in the future
|
||||
public class ChatMessage_v1_19_3 extends ChatMessage_v1_16 {
|
||||
int index;
|
||||
byte[] signature;
|
||||
String plainContent;
|
||||
Instant timestamp;
|
||||
long salt;
|
||||
LastSeenMessages.Packed lastSeenMessagesPacked;
|
||||
@Nullable Component unsignedChatContent;
|
||||
FilterMask filterMask;
|
||||
ChatMessage_v1_19_1.ChatTypeBoundNetwork chatType;
|
||||
|
||||
public ChatMessage_v1_19_3(UUID senderUUID, int index, byte[] signature, String plainContent, Instant timestamp, long salt, LastSeenMessages.Packed lastSeenMessagesPacked, @Nullable Component unsignedChatContent, FilterMask filterMask, ChatMessage_v1_19_1.ChatTypeBoundNetwork chatType) {
|
||||
super(Component.text(plainContent), chatType.getType(), senderUUID);
|
||||
this.index = index;
|
||||
this.signature = signature;
|
||||
this.plainContent = plainContent;
|
||||
this.timestamp = timestamp;
|
||||
this.salt = salt;
|
||||
this.lastSeenMessagesPacked = lastSeenMessagesPacked;
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
this.filterMask = filterMask;
|
||||
this.chatType = chatType;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public byte[] getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(byte[] signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getChatContent() {
|
||||
return Component.text(plainContent);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setChatContent(Component chatContent) {
|
||||
throw new UnsupportedOperationException("PacketEvents is not able to serialize components to plain-text. Please use the #setPlainContent instead to update the content.");
|
||||
}
|
||||
|
||||
public String getPlainContent() {
|
||||
return plainContent;
|
||||
}
|
||||
|
||||
public void setPlainContent(String plainContent) {
|
||||
this.plainContent = plainContent;
|
||||
}
|
||||
|
||||
public Instant getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Instant timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public long getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
public void setSalt(long salt) {
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
public LastSeenMessages.Packed getLastSeenMessagesPacked() {
|
||||
return lastSeenMessagesPacked;
|
||||
}
|
||||
|
||||
public void setLastSeenMessagesPacked(LastSeenMessages.Packed lastSeenMessagesPacked) {
|
||||
this.lastSeenMessagesPacked = lastSeenMessagesPacked;
|
||||
}
|
||||
|
||||
public Optional<Component> getUnsignedChatContent() {
|
||||
return Optional.ofNullable(unsignedChatContent);
|
||||
}
|
||||
|
||||
public void setUnsignedChatContent(@Nullable Component unsignedChatContent) {
|
||||
this.unsignedChatContent = unsignedChatContent;
|
||||
}
|
||||
|
||||
public FilterMask getFilterMask() {
|
||||
return filterMask;
|
||||
}
|
||||
|
||||
public void setFilterMask(FilterMask filterMask) {
|
||||
this.filterMask = filterMask;
|
||||
}
|
||||
|
||||
public ChatMessage_v1_19_1.ChatTypeBoundNetwork getChatType() {
|
||||
return chatType;
|
||||
}
|
||||
|
||||
public void setChatType(ChatMessage_v1_19_1.ChatTypeBoundNetwork chatType) {
|
||||
this.chatType = chatType;
|
||||
}
|
||||
}
|
||||
+5
-11
@@ -40,7 +40,9 @@ public class ChatMessageProcessor_v1_19_1 implements ChatMessageProcessor {
|
||||
byte[] signature = wrapper.readByteArray();
|
||||
String plainContent = wrapper.readString(256);
|
||||
Component chatContent = wrapper.readOptional(PacketWrapper::readComponent);
|
||||
if (chatContent == null) {
|
||||
if (chatContent == null && plainContent.isEmpty()) {
|
||||
chatContent = Component.empty();
|
||||
} else if (chatContent == null) {
|
||||
chatContent = Component.text(plainContent);
|
||||
}
|
||||
Instant timestamp = wrapper.readTimestamp();
|
||||
@@ -48,13 +50,7 @@ public class ChatMessageProcessor_v1_19_1 implements ChatMessageProcessor {
|
||||
LastSeenMessages lastSeenMessages = wrapper.readLastSeenMessages();
|
||||
Component unsignedChatContent = wrapper.readOptional(PacketWrapper::readComponent);
|
||||
FilterMask filterMask = wrapper.readFilterMask();
|
||||
|
||||
int id = wrapper.readVarInt();
|
||||
ChatType type = ChatTypes.getById(wrapper.getServerVersion().toClientVersion(), id);
|
||||
Component name = wrapper.readComponent();
|
||||
Component targetName = wrapper.readOptional(PacketWrapper::readComponent);
|
||||
ChatMessage_v1_19_1.ChatTypeBoundNetwork chatType = new ChatMessage_v1_19_1.ChatTypeBoundNetwork(type, name, targetName);
|
||||
|
||||
ChatMessage_v1_19_1.ChatTypeBoundNetwork chatType = wrapper.readChatTypeBoundNetwork();
|
||||
return new ChatMessage_v1_19_1(plainContent, chatContent, unsignedChatContent, senderUUID, chatType,
|
||||
previousSignature, signature, timestamp, salt, lastSeenMessages, filterMask);
|
||||
}
|
||||
@@ -72,8 +68,6 @@ public class ChatMessageProcessor_v1_19_1 implements ChatMessageProcessor {
|
||||
wrapper.writeLastSeenMessages(newData.getLastSeenMessages());
|
||||
wrapper.writeOptional(newData.getUnsignedChatContent(), PacketWrapper::writeComponent);
|
||||
wrapper.writeFilterMask(newData.getFilterMask());
|
||||
wrapper.writeVarInt(newData.getChatType().getType().getId(wrapper.getServerVersion().toClientVersion()));
|
||||
wrapper.writeComponent(newData.getChatType().getName());
|
||||
wrapper.writeOptional(newData.getChatType().getTargetName(), PacketWrapper::writeComponent);
|
||||
wrapper.writeChatTypeBoundNetwork(newData.getChatType());
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.github.retrooper.packetevents.protocol.chat.message.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.chat.LastSeenMessages;
|
||||
import com.github.retrooper.packetevents.protocol.chat.filter.FilterMask;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage_v1_19_1;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage_v1_19_3;
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.reader.ChatMessageProcessor;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatMessageProcessor_v1_19_3 implements ChatMessageProcessor {
|
||||
@Override
|
||||
public ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper) {
|
||||
UUID senderUUID = wrapper.readUUID();
|
||||
int index = wrapper.readVarInt();
|
||||
byte[] signature = wrapper.readOptional((w) -> w.readBytes(256));
|
||||
String plainContent = wrapper.readString(256);
|
||||
Instant timestamp = wrapper.readTimestamp();
|
||||
long salt = wrapper.readLong();
|
||||
LastSeenMessages.Packed lastSeenMessagesPacked = wrapper.readLastSeenMessagesPacked();
|
||||
Component unsignedChatContent = wrapper.readOptional(PacketWrapper::readComponent);
|
||||
FilterMask filterMask = wrapper.readFilterMask();
|
||||
ChatMessage_v1_19_1.ChatTypeBoundNetwork chatType = wrapper.readChatTypeBoundNetwork();
|
||||
|
||||
return new ChatMessage_v1_19_3(senderUUID, index, signature, plainContent, timestamp, salt, lastSeenMessagesPacked, unsignedChatContent, filterMask, chatType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data) {
|
||||
ChatMessage_v1_19_3 newData = (ChatMessage_v1_19_3) data;
|
||||
wrapper.writeUUID(newData.getSenderUUID());
|
||||
wrapper.writeVarInt(newData.getIndex());
|
||||
wrapper.writeOptional(newData.getSignature(), PacketWrapper::writeBytes);
|
||||
wrapper.writeString(newData.getPlainContent());
|
||||
wrapper.writeTimestamp(newData.getTimestamp());
|
||||
wrapper.writeLong(newData.getSalt());
|
||||
wrapper.writeLastSeenMessagesPacked(newData.getLastSeenMessagesPacked());
|
||||
wrapper.writeOptional(newData.getUnsignedChatContent().orElse(null), PacketWrapper::writeComponent);
|
||||
wrapper.writeFilterMask(newData.getFilterMask());
|
||||
wrapper.writeChatTypeBoundNetwork(newData.getChatType());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.color;
|
||||
|
||||
import net.kyori.adventure.util.RGBLike;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
public final class Color implements RGBLike {
|
||||
|
||||
private static final int BIT_MASK = 0xFF;
|
||||
|
||||
private final int red, green, blue;
|
||||
|
||||
public Color(@Range(from = 0L, to = 255L) int red, @Range(from = 0L, to = 255L) int green, @Range(from = 0L, to = 255L) int blue) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
public Color(int rgb) {
|
||||
this((rgb >> 16) & BIT_MASK, (rgb >> 8) & BIT_MASK, rgb & BIT_MASK);
|
||||
}
|
||||
|
||||
public @NotNull Color withRed(@Range(from = 0L, to = 255L) int red) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public @NotNull Color withGreen(@Range(from = 0L, to = 255L) int green) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public @NotNull Color withBlue(@Range(from = 0L, to = 255L) int blue) {
|
||||
return new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public int asRGB() {
|
||||
int rgb = red;
|
||||
rgb = (rgb << 8) + green;
|
||||
return (rgb << 8) + blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int red() {
|
||||
return red;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int green() {
|
||||
return green;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Range(from = 0L, to = 255L) int blue() {
|
||||
return blue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.color;
|
||||
|
||||
import net.kyori.adventure.util.RGBLike;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum DyeColor implements RGBLike {
|
||||
WHITE(new Color(0xf9fffe), new Color(0xffffff), new Color(0xf0f0f0), 8),
|
||||
|
||||
ORANGE(new Color(0xf9801d), new Color(0xff681f), new Color(0xeb8844), 15),
|
||||
|
||||
MAGENTA(new Color(0xc74ebd), new Color(0xff00ff), new Color(0xc354cd), 16),
|
||||
|
||||
LIGHT_BLUE(new Color(0x3ab3da), new Color(0x9ac0cd), new Color(0x6689d3), 17),
|
||||
|
||||
YELLOW(new Color(0xfed83d), new Color(0xffff00), new Color(0xdecf2a), 18),
|
||||
|
||||
LIME(new Color(0x80c71f), new Color(0xbfff00), new Color(0x41cd34), 19),
|
||||
|
||||
PINK(new Color(0xf38baa), new Color(0xff69b4), new Color(0xd88198), 20),
|
||||
|
||||
GRAY(new Color(0x474f52), new Color(0x808080), new Color(0x434343), 21),
|
||||
|
||||
LIGHT_GRAY(new Color(0x9d9d97), new Color(0xd3d3d3), new Color(0xababab), 22),
|
||||
|
||||
CYAN(new Color(0x169c9c), new Color(0xffff), new Color(0x287697), 23),
|
||||
|
||||
PURPLE(new Color(0x8932b8), new Color(0xa020f0), new Color(0x7b2fbe), 24),
|
||||
|
||||
BLUE(new Color(0x3c44aa), new Color(0xff), new Color(0x253192), 25),
|
||||
|
||||
BROWN(new Color(0x835432), new Color(0x8b4513), new Color(0x51301a), 26),
|
||||
|
||||
GREEN(new Color(0x5e7c16), new Color(0xff00), new Color(0x3b511a), 27),
|
||||
|
||||
RED(new Color(0xb02e26), new Color(0xff0000), new Color(0xb3312c), 28),
|
||||
|
||||
BLACK(new Color(0x1d1d21), new Color(0x0), new Color(0x1e1b1b), 29);
|
||||
|
||||
private final Color textureDiffuseColor;
|
||||
|
||||
private final Color textColor;
|
||||
|
||||
private final Color fireworkColor;
|
||||
|
||||
private final int mapColorId;
|
||||
|
||||
DyeColor(@NotNull Color textureDiffuseColor, @NotNull Color textColor,
|
||||
@NotNull Color fireworkColor, int mapColorId) {
|
||||
this.textureDiffuseColor = textureDiffuseColor;
|
||||
this.textColor = textColor;
|
||||
this.fireworkColor = fireworkColor;
|
||||
this.mapColorId = mapColorId;
|
||||
}
|
||||
|
||||
public @NotNull Color color() {
|
||||
return this.textureDiffuseColor;
|
||||
}
|
||||
|
||||
public @NotNull Color textColor() {
|
||||
return this.textColor;
|
||||
}
|
||||
|
||||
public @NotNull Color fireworkColor() {
|
||||
return this.fireworkColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int red() {
|
||||
return this.textureDiffuseColor.red();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int green() {
|
||||
return this.textureDiffuseColor.green();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int blue() {
|
||||
return this.textureDiffuseColor.blue();
|
||||
}
|
||||
|
||||
public int mapColorId() {
|
||||
return this.mapColorId;
|
||||
}
|
||||
}
|
||||
+70
-16
@@ -21,6 +21,7 @@ package com.github.retrooper.packetevents.protocol.entity.data;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||
import com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState;
|
||||
import com.github.retrooper.packetevents.protocol.entity.villager.VillagerData;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
@@ -31,6 +32,7 @@ import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.protocol.world.BlockFace;
|
||||
import com.github.retrooper.packetevents.protocol.world.WorldBlockPosition;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.Quaternion4f;
|
||||
import com.github.retrooper.packetevents.util.TypesBuilder;
|
||||
import com.github.retrooper.packetevents.util.TypesBuilderData;
|
||||
import com.github.retrooper.packetevents.util.Vector3f;
|
||||
@@ -59,7 +61,9 @@ public class EntityDataTypes {
|
||||
ClientVersion.V_1_11,
|
||||
ClientVersion.V_1_13,
|
||||
ClientVersion.V_1_14,
|
||||
ClientVersion.V_1_19);
|
||||
ClientVersion.V_1_19,
|
||||
ClientVersion.V_1_19_3,
|
||||
ClientVersion.V_1_19_4);
|
||||
|
||||
public static final EntityDataType<Byte> BYTE = define("byte", PacketWrapper::readByte, PacketWrapper::writeByte);
|
||||
|
||||
@@ -79,13 +83,19 @@ public class EntityDataTypes {
|
||||
}
|
||||
});
|
||||
|
||||
public static final EntityDataType<Long> LONG = define("long", PacketWrapper::readVarLong, PacketWrapper::writeVarLong);
|
||||
|
||||
public static final EntityDataType<Float> FLOAT = define("float", PacketWrapper::readFloat, PacketWrapper::writeFloat);
|
||||
|
||||
public static final EntityDataType<String> STRING = define("string", PacketWrapper::readString, PacketWrapper::writeString);
|
||||
|
||||
public static final EntityDataType<Component> COMPONENT = define("component", PacketWrapper::readComponent, PacketWrapper::writeComponent);
|
||||
@Deprecated
|
||||
public static final EntityDataType<String> COMPONENT = define("component", PacketWrapper::readComponentJSON, PacketWrapper::writeComponentJSON);
|
||||
public static final EntityDataType<Component> ADV_COMPONENT = define("component", PacketWrapper::readComponent, PacketWrapper::writeComponent);
|
||||
|
||||
public static final EntityDataType<Optional<Component>> OPTIONAL_COMPONENT = define("optional_component", readOptionalComponentDeserializer(), writeOptionalComponentSerializer());
|
||||
@Deprecated
|
||||
public static final EntityDataType<Optional<String>> OPTIONAL_COMPONENT = define("optional_component", readOptionalComponentJSONDeserializer(), writeOptionalComponentJSONSerializer());
|
||||
public static final EntityDataType<Optional<Component>> OPTIONAL_ADV_COMPONENT = define("optional_component", readOptionalComponentDeserializer(), writeOptionalComponentSerializer());
|
||||
|
||||
public static final EntityDataType<ItemStack> ITEMSTACK = define("itemstack", PacketWrapper::readItemStack, PacketWrapper::writeItemStack);
|
||||
|
||||
@@ -136,6 +146,9 @@ public class EntityDataTypes {
|
||||
(PacketWrapper<?> wrapper, Optional<UUID> value) ->
|
||||
wrapper.writeOptional(value.orElse(null), PacketWrapper::writeUUID));
|
||||
|
||||
public static final EntityDataType<Integer> BLOCK_STATE = define("block_state",
|
||||
readIntDeserializer(), writeIntSerializer());
|
||||
|
||||
public static final EntityDataType<Integer> OPTIONAL_BLOCK_STATE = define("optional_block_state", readIntDeserializer(), writeIntSerializer());
|
||||
|
||||
public static final EntityDataType<NBTCompound> NBT = define("nbt", PacketWrapper::readNBT, PacketWrapper::writeNBT);
|
||||
@@ -176,6 +189,29 @@ public class EntityDataTypes {
|
||||
|
||||
public static final EntityDataType<Integer> PAINTING_VARIANT_TYPE = define("painting_variant_type", readIntDeserializer(), writeIntSerializer());
|
||||
|
||||
public static final EntityDataType<SnifferState> SNIFFER_STATE = define("sniffer_state", (PacketWrapper<?> wrapper) -> {
|
||||
int id = wrapper.readVarInt();
|
||||
return SnifferState.values()[id];
|
||||
}, (PacketWrapper<?> wrapper, SnifferState value) -> wrapper.writeVarInt(value.ordinal()));
|
||||
|
||||
|
||||
public static final EntityDataType<Vector3f> VECTOR3F = define("vector3f",
|
||||
(PacketWrapper<?> wrapper) -> new Vector3f(wrapper.readFloat(), wrapper.readFloat(), wrapper.readFloat()),
|
||||
(PacketWrapper<?> wrapper, Vector3f value) -> {
|
||||
wrapper.writeFloat(value.x);
|
||||
wrapper.writeFloat(value.y);
|
||||
wrapper.writeFloat(value.z);
|
||||
});
|
||||
|
||||
public static final EntityDataType<Quaternion4f> QUATERNION = define("quaternion",
|
||||
(PacketWrapper<?> wrapper) -> new Quaternion4f(wrapper.readFloat(), wrapper.readFloat(), wrapper.readFloat(), wrapper.readFloat()),
|
||||
(PacketWrapper<?> wrapper, Quaternion4f value) -> {
|
||||
wrapper.writeFloat(value.getX());
|
||||
wrapper.writeFloat(value.getY());
|
||||
wrapper.writeFloat(value.getZ());
|
||||
wrapper.writeFloat(value.getW());
|
||||
});
|
||||
|
||||
public static EntityDataType<?> getById(ClientVersion version, int id) {
|
||||
int index = TYPES_BUILDER.getDataIndex(version);
|
||||
Map<Integer, EntityDataType<?>> typeIdMap = ENTITY_DATA_TYPE_ID_MAP.get((byte) index);
|
||||
@@ -229,26 +265,44 @@ public class EntityDataTypes {
|
||||
};
|
||||
}
|
||||
|
||||
private static <T> Function<PacketWrapper<?>, T> readOptionalComponentDeserializer() {
|
||||
@Deprecated
|
||||
private static Function<PacketWrapper<?>, Optional<String>> readOptionalComponentJSONDeserializer() {
|
||||
return (PacketWrapper<?> wrapper) -> {
|
||||
if (wrapper.readBoolean()) {
|
||||
return (T) Optional.of(wrapper.readComponent());
|
||||
return Optional.of(wrapper.readComponentJSON());
|
||||
} else {
|
||||
return (T) Optional.empty();
|
||||
return Optional.empty();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static <T> BiConsumer<PacketWrapper<?>, T> writeOptionalComponentSerializer() {
|
||||
return (PacketWrapper<?> wrapper, T value) -> {
|
||||
if (value instanceof Optional) {
|
||||
Optional<Component> optional = (Optional<Component>) value;
|
||||
if (optional.isPresent()) {
|
||||
wrapper.writeBoolean(true);
|
||||
wrapper.writeComponent(optional.get());
|
||||
} else {
|
||||
wrapper.writeBoolean(false);
|
||||
}
|
||||
@Deprecated
|
||||
private static BiConsumer<PacketWrapper<?>, Optional<String>> writeOptionalComponentJSONSerializer() {
|
||||
return (PacketWrapper<?> wrapper, Optional<String> value) -> {
|
||||
if (value != null && value.isPresent()) {
|
||||
wrapper.writeBoolean(true);
|
||||
wrapper.writeComponentJSON(value.get());
|
||||
} else {
|
||||
wrapper.writeBoolean(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static Function<PacketWrapper<?>, Optional<Component>> readOptionalComponentDeserializer() {
|
||||
return (PacketWrapper<?> wrapper) -> {
|
||||
if (wrapper.readBoolean()) {
|
||||
return Optional.of(wrapper.readComponent());
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static BiConsumer<PacketWrapper<?>, Optional<Component>> writeOptionalComponentSerializer() {
|
||||
return (PacketWrapper<?> wrapper, Optional<Component> value) -> {
|
||||
if (value != null && value.isPresent()) {
|
||||
wrapper.writeBoolean(true);
|
||||
wrapper.writeComponent(value.get());
|
||||
} else {
|
||||
wrapper.writeBoolean(false);
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.github.retrooper.packetevents.protocol.entity.data;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is an interface that provides a list of entity data.
|
||||
* This allows custom addon libraries to implement metadata classes for various entities
|
||||
* which can then be used in our API.
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public interface EntityMetadataProvider {
|
||||
/**
|
||||
* PacketEvents is retrieving the metadata of this specific entity.
|
||||
* PacketEvents provides you with the protocol version that the library is running on
|
||||
* to allow you tu specify different metadata depending on the version.
|
||||
* You are free to ignore it at the cost of your features not working on all versions.
|
||||
* @param version The protocol version of the format we expect the metadata to be in.
|
||||
* @return Metadata (list of entity data)
|
||||
*/
|
||||
List<EntityData> entityData(ClientVersion version);
|
||||
|
||||
/**
|
||||
* Similar to {@link #entityData(ClientVersion)} but does not provide a protocol version.
|
||||
* It is not advised to use nor implement this.
|
||||
* It is deprecated because it restricts you by not providing you the format in which the metadata should be.
|
||||
* @return Metadata (list of entity data)
|
||||
* @deprecated Does not specify format of metadata, therefore not advised to use this. It will assume the current latest version.
|
||||
*/
|
||||
@Deprecated
|
||||
default List<EntityData> entityData() {
|
||||
return entityData(ClientVersion.getLatest());
|
||||
}
|
||||
}
|
||||
-343
@@ -1,343 +0,0 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.data.provider;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class EntityDataProvider implements DataProvider {
|
||||
@Nullable
|
||||
private Component customName;
|
||||
|
||||
private boolean customNameVisible;
|
||||
private EntityPose pose = EntityPose.STANDING;
|
||||
private int airTicks;
|
||||
private int ticksFrozenInPowderedSnow = 0;
|
||||
private boolean onFire;
|
||||
private boolean crouching;
|
||||
//Now unused
|
||||
private boolean riding;
|
||||
|
||||
private boolean sprinting;
|
||||
private boolean swimming;
|
||||
private boolean invisible;
|
||||
private boolean glowing;
|
||||
private boolean flyingWithElytra;
|
||||
private boolean silent;
|
||||
private boolean hasGravity = true;
|
||||
|
||||
@Nullable
|
||||
public Component getCustomName() {
|
||||
return customName;
|
||||
}
|
||||
|
||||
public void setCustomName(@Nullable Component customName) {
|
||||
this.customName = customName;
|
||||
}
|
||||
|
||||
public boolean isCustomNameVisible() {
|
||||
return customNameVisible;
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean customNameVisible) {
|
||||
this.customNameVisible = customNameVisible;
|
||||
}
|
||||
|
||||
public EntityPose getPose() {
|
||||
return pose;
|
||||
}
|
||||
|
||||
public void setPose(EntityPose pose) {
|
||||
this.pose = pose;
|
||||
}
|
||||
|
||||
public int getAirTicks() {
|
||||
return airTicks;
|
||||
}
|
||||
|
||||
public void setAirTicks(int airTicks) {
|
||||
this.airTicks = airTicks;
|
||||
}
|
||||
|
||||
public int getTicksFrozenInPowderedSnow() {
|
||||
return ticksFrozenInPowderedSnow;
|
||||
}
|
||||
|
||||
public void setTicksFrozenInPowderedSnow(int ticksFrozenInPowderedSnow) {
|
||||
this.ticksFrozenInPowderedSnow = ticksFrozenInPowderedSnow;
|
||||
}
|
||||
|
||||
public boolean isOnFire() {
|
||||
return onFire;
|
||||
}
|
||||
|
||||
public void setOnFire(boolean onFire) {
|
||||
this.onFire = onFire;
|
||||
}
|
||||
|
||||
public boolean isCrouching() {
|
||||
return crouching;
|
||||
}
|
||||
|
||||
public void setCrouching(boolean crouching) {
|
||||
this.crouching = crouching;
|
||||
}
|
||||
|
||||
public boolean isRiding() {
|
||||
return riding;
|
||||
}
|
||||
|
||||
public void setRiding(boolean riding) {
|
||||
this.riding = riding;
|
||||
}
|
||||
|
||||
public boolean isSprinting() {
|
||||
return sprinting;
|
||||
}
|
||||
|
||||
public void setSprinting(boolean sprinting) {
|
||||
this.sprinting = sprinting;
|
||||
}
|
||||
|
||||
public boolean isSwimming() {
|
||||
return swimming;
|
||||
}
|
||||
|
||||
public void setSwimming(boolean swimming) {
|
||||
this.swimming = swimming;
|
||||
}
|
||||
|
||||
public boolean isInvisible() {
|
||||
return invisible;
|
||||
}
|
||||
|
||||
public void setInvisible(boolean invisible) {
|
||||
this.invisible = invisible;
|
||||
}
|
||||
|
||||
public boolean isGlowing() {
|
||||
return glowing;
|
||||
}
|
||||
|
||||
public void setGlowing(boolean glowing) {
|
||||
this.glowing = glowing;
|
||||
}
|
||||
|
||||
public boolean isFlyingWithElytra() {
|
||||
return flyingWithElytra;
|
||||
}
|
||||
|
||||
public void setFlyingWithElytra(boolean flyingWithElytra) {
|
||||
this.flyingWithElytra = flyingWithElytra;
|
||||
}
|
||||
|
||||
public boolean isSilent() {
|
||||
return silent;
|
||||
}
|
||||
|
||||
public void setSilent(boolean silent) {
|
||||
this.silent = silent;
|
||||
}
|
||||
|
||||
public boolean isHasGravity() {
|
||||
return hasGravity;
|
||||
}
|
||||
|
||||
public void setHasGravity(boolean hasGravity) {
|
||||
this.hasGravity = hasGravity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntityData> encode() {
|
||||
byte mask = 0x00;
|
||||
if (onFire) {
|
||||
mask |= 0x01;
|
||||
}
|
||||
if (crouching) {
|
||||
mask |= 0x02;
|
||||
}
|
||||
//TODO Rethink, should we add this?
|
||||
if (riding) {
|
||||
mask |= 0x04;
|
||||
}
|
||||
if (sprinting) {
|
||||
mask |= 0x08;
|
||||
}
|
||||
if (swimming) {
|
||||
mask |= 0x10;
|
||||
}
|
||||
if (invisible) {
|
||||
mask |= 0x20;
|
||||
}
|
||||
if (glowing) {
|
||||
mask |= 0x40;
|
||||
}
|
||||
if (flyingWithElytra) {
|
||||
mask |= 0x80;
|
||||
}
|
||||
List<EntityData> metadata = new ArrayList<>(8);
|
||||
metadata.add(new EntityData(0, EntityDataTypes.BYTE, mask));
|
||||
metadata.add(new EntityData(1, EntityDataTypes.INT, airTicks));
|
||||
metadata.add(new EntityData(2, EntityDataTypes.OPTIONAL_COMPONENT, Optional.ofNullable(customName)));
|
||||
metadata.add(new EntityData(3, EntityDataTypes.BOOLEAN, customNameVisible));
|
||||
metadata.add(new EntityData(4, EntityDataTypes.BOOLEAN, silent));
|
||||
metadata.add(new EntityData(5, EntityDataTypes.BOOLEAN, !hasGravity));
|
||||
metadata.add(new EntityData(6, EntityDataTypes.ENTITY_POSE, pose));
|
||||
metadata.add(new EntityData(7, EntityDataTypes.INT, ticksFrozenInPowderedSnow));
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(List<EntityData> data) {
|
||||
for (EntityData entityData : data) {
|
||||
switch (entityData.getIndex()) {
|
||||
case 0:
|
||||
byte mask = (byte) entityData.getValue();
|
||||
onFire = (mask & 0x01) != 0;
|
||||
crouching = (mask & 0x02) != 0;
|
||||
riding = (mask & 0x04) != 0;
|
||||
sprinting = (mask & 0x08) != 0;
|
||||
swimming = (mask & 0x10) != 0;
|
||||
invisible = (mask & 0x20) != 0;
|
||||
glowing = (mask & 0x40) != 0;
|
||||
flyingWithElytra = (mask & 0x80) != 0;
|
||||
break;
|
||||
case 1:
|
||||
airTicks = (int) entityData.getValue();
|
||||
break;
|
||||
case 2:
|
||||
customName = ((Optional<Component>) entityData.getValue()).orElse(null);
|
||||
break;
|
||||
case 3:
|
||||
customNameVisible = (boolean) entityData.getValue();
|
||||
break;
|
||||
case 4:
|
||||
silent = (boolean) entityData.getValue();
|
||||
break;
|
||||
case 5:
|
||||
hasGravity = !(boolean) entityData.getValue();
|
||||
break;
|
||||
case 6:
|
||||
pose = (EntityPose) entityData.getValue();
|
||||
break;
|
||||
case 7:
|
||||
ticksFrozenInPowderedSnow = (int) entityData.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityBuilder<EntityBuilder> builderEntity() {
|
||||
return new EntityBuilder<>(new EntityDataProvider());
|
||||
}
|
||||
|
||||
public static class EntityBuilder<T extends EntityBuilder> {
|
||||
protected EntityDataProvider provider;
|
||||
|
||||
public EntityBuilder(EntityDataProvider provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public T customName(@Nullable Component customName) {
|
||||
((EntityDataProvider) provider).setCustomName(customName);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T customNameVisible(boolean customNameVisible) {
|
||||
((EntityDataProvider) provider).setCustomNameVisible(customNameVisible);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T pose(EntityPose pose) {
|
||||
((EntityDataProvider) provider).setPose(pose);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T onFire(boolean onFire) {
|
||||
((EntityDataProvider) provider).setOnFire(onFire);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T crouching(boolean crouching) {
|
||||
((EntityDataProvider) provider).setCrouching(crouching);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T riding(boolean riding) {
|
||||
((EntityDataProvider) provider).setRiding(riding);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T sprinting(boolean sprinting) {
|
||||
((EntityDataProvider) provider).setSprinting(sprinting);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T swimming(boolean swimming) {
|
||||
((EntityDataProvider) provider).setSwimming(swimming);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T invisible(boolean invisible) {
|
||||
((EntityDataProvider) provider).setInvisible(invisible);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T glowing(boolean glowing) {
|
||||
((EntityDataProvider) provider).setGlowing(glowing);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T flyingWithElytra(boolean flyingWithElytra) {
|
||||
((EntityDataProvider) provider).setFlyingWithElytra(flyingWithElytra);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T silent(boolean silent) {
|
||||
((EntityDataProvider) provider).setSilent(silent);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T hasGravity(boolean hasGravity) {
|
||||
((EntityDataProvider) provider).setHasGravity(hasGravity);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T airTicks(int airTicks) {
|
||||
((EntityDataProvider) provider).setAirTicks(airTicks);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T ticksFrozenInPowderedSnow(int ticksFrozenInPowderedSnow) {
|
||||
((EntityDataProvider) provider).setTicksFrozenInPowderedSnow(ticksFrozenInPowderedSnow);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public <K extends EntityDataProvider> K build() {
|
||||
return (K) provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
-232
@@ -1,232 +0,0 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.data.provider;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.player.InteractionHand;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class LivingEntityDataProvider extends EntityDataProvider {
|
||||
private boolean handActive;
|
||||
private InteractionHand hand = InteractionHand.MAIN_HAND;
|
||||
private boolean isInRiptideSpinAttack;
|
||||
private float health = 1.0f;
|
||||
private int potionEffectColor;
|
||||
private boolean potionEffectAmbient;
|
||||
private int arrowInBodyCount;
|
||||
private int beeStingsInBodyCount;
|
||||
@Nullable
|
||||
private Vector3i sleepingPosition;
|
||||
|
||||
|
||||
public boolean isHandActive() {
|
||||
return handActive;
|
||||
}
|
||||
|
||||
public void setHandActive(boolean handActive) {
|
||||
this.handActive = handActive;
|
||||
}
|
||||
|
||||
public InteractionHand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public void setHand(InteractionHand hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
public boolean isInRiptideSpinAttack() {
|
||||
return isInRiptideSpinAttack;
|
||||
}
|
||||
|
||||
public void setInRiptideSpinAttack(boolean inRiptideSpinAttack) {
|
||||
isInRiptideSpinAttack = inRiptideSpinAttack;
|
||||
}
|
||||
|
||||
public float getHealth() {
|
||||
return health;
|
||||
}
|
||||
|
||||
public void setHealth(float health) {
|
||||
this.health = health;
|
||||
}
|
||||
|
||||
public int getPotionEffectColor() {
|
||||
return potionEffectColor;
|
||||
}
|
||||
|
||||
public void setPotionEffectColor(int potionEffectColor) {
|
||||
this.potionEffectColor = potionEffectColor;
|
||||
}
|
||||
|
||||
public boolean isPotionEffectAmbient() {
|
||||
return potionEffectAmbient;
|
||||
}
|
||||
|
||||
public void setPotionEffectAmbient(boolean potionEffectAmbient) {
|
||||
this.potionEffectAmbient = potionEffectAmbient;
|
||||
}
|
||||
|
||||
public int getArrowInBodyCount() {
|
||||
return arrowInBodyCount;
|
||||
}
|
||||
|
||||
public void setArrowInBodyCount(int arrowInBodyCount) {
|
||||
this.arrowInBodyCount = arrowInBodyCount;
|
||||
}
|
||||
|
||||
public int getBeeStingsInBodyCount() {
|
||||
return beeStingsInBodyCount;
|
||||
}
|
||||
|
||||
public void setBeeStingsInBodyCount(int beeStingsInBodyCount) {
|
||||
this.beeStingsInBodyCount = beeStingsInBodyCount;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Vector3i getSleepingPosition() {
|
||||
return sleepingPosition;
|
||||
}
|
||||
|
||||
public void setSleepingPosition(@Nullable Vector3i sleepingPosition) {
|
||||
this.sleepingPosition = sleepingPosition;
|
||||
}
|
||||
|
||||
public static LivingEntityBuilder<LivingEntityBuilder> builderLivingEntity() {
|
||||
return new LivingEntityBuilder<>(new LivingEntityDataProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntityData> encode() {
|
||||
List<EntityData> metadata = super.encode();
|
||||
byte mask = 0x00;
|
||||
if (handActive) {
|
||||
mask |= 0x01;
|
||||
}
|
||||
|
||||
//TODO Confirm
|
||||
if (hand == InteractionHand.OFF_HAND) {
|
||||
mask |= 0x02;
|
||||
}
|
||||
|
||||
if (isInRiptideSpinAttack) {
|
||||
mask |= 0x04;
|
||||
}
|
||||
|
||||
|
||||
metadata.add(new EntityData(8, EntityDataTypes.BYTE, mask));
|
||||
metadata.add(new EntityData(9, EntityDataTypes.FLOAT, health));
|
||||
metadata.add(new EntityData(10, EntityDataTypes.INT, potionEffectColor));
|
||||
metadata.add(new EntityData(11, EntityDataTypes.BOOLEAN, potionEffectAmbient));
|
||||
metadata.add(new EntityData(12, EntityDataTypes.INT, arrowInBodyCount));
|
||||
metadata.add(new EntityData(13, EntityDataTypes.INT, beeStingsInBodyCount));
|
||||
metadata.add(new EntityData(14, EntityDataTypes.OPTIONAL_BLOCK_POSITION, Optional.ofNullable(sleepingPosition)));
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(List<EntityData> data) {
|
||||
super.decode(data);
|
||||
for (EntityData entityData : data) {
|
||||
switch (entityData.getIndex()) {
|
||||
case 8:
|
||||
byte mask = (byte) entityData.getValue();
|
||||
handActive = (mask & 0x01) != 0;
|
||||
//TODO Test, look into
|
||||
hand = (mask & 0x02) != 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
|
||||
isInRiptideSpinAttack = (mask & 0x04) != 0;
|
||||
break;
|
||||
case 9:
|
||||
health = (float) entityData.getValue();
|
||||
break;
|
||||
case 10:
|
||||
potionEffectColor = (int) entityData.getValue();
|
||||
break;
|
||||
case 11:
|
||||
potionEffectAmbient = (boolean) entityData.getValue();
|
||||
break;
|
||||
case 12:
|
||||
arrowInBodyCount = (int) entityData.getValue();
|
||||
break;
|
||||
case 13:
|
||||
beeStingsInBodyCount = (int) entityData.getValue();
|
||||
break;
|
||||
case 14:
|
||||
sleepingPosition = ((Optional<Vector3i>) entityData.getValue()).orElse(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LivingEntityBuilder<T extends LivingEntityBuilder> extends EntityDataProvider.EntityBuilder<T> {
|
||||
public LivingEntityBuilder(LivingEntityDataProvider livingEntityDataProvider) {
|
||||
super(livingEntityDataProvider);
|
||||
}
|
||||
|
||||
public T handActive(boolean handActive) {
|
||||
((LivingEntityDataProvider) provider).setHandActive(handActive);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T hand(InteractionHand hand) {
|
||||
((LivingEntityDataProvider) provider).setHand(hand);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T isInRiptideSpinAttack(boolean isInRiptideSpinAttack) {
|
||||
((LivingEntityDataProvider) provider).setInRiptideSpinAttack(isInRiptideSpinAttack);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T health(float health) {
|
||||
((LivingEntityDataProvider) provider).setHealth(health);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T potionEffectColor(int potionEffectColor) {
|
||||
((LivingEntityDataProvider) provider).setPotionEffectColor(potionEffectColor);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T potionEffectAmbient(boolean potionEffectAmbient) {
|
||||
((LivingEntityDataProvider) provider).setPotionEffectAmbient(potionEffectAmbient);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T arrowInBodyCount(int arrowInBodyCount) {
|
||||
((LivingEntityDataProvider) provider).setArrowInBodyCount(arrowInBodyCount);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T beeStingsInBodyCount(int beeStingsInBodyCount) {
|
||||
((LivingEntityDataProvider) provider).setBeeStingsInBodyCount(beeStingsInBodyCount);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T sleepingPosition(@Nullable Vector3i sleepingPosition) {
|
||||
((LivingEntityDataProvider) provider).setSleepingPosition(sleepingPosition);
|
||||
return (T) this;
|
||||
}
|
||||
}
|
||||
}
|
||||
-168
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.data.provider;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.player.HumanoidArm;
|
||||
import com.github.retrooper.packetevents.protocol.player.SkinSection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerDataProvider extends LivingEntityDataProvider {
|
||||
private float additionalHealth;
|
||||
private int score;
|
||||
private byte skinPartsMask = SkinSection.ALL.getMask();
|
||||
private HumanoidArm mainArm = HumanoidArm.RIGHT;
|
||||
private NBTCompound leftShoulderNBT = new NBTCompound();
|
||||
private NBTCompound rightShoulderNBT = new NBTCompound();
|
||||
|
||||
public float getAdditionalHealth() {
|
||||
return additionalHealth;
|
||||
}
|
||||
|
||||
public void setAdditionalHealth(float additionalHealth) {
|
||||
this.additionalHealth = additionalHealth;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(int score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public byte getSkinPartsMask() {
|
||||
return skinPartsMask;
|
||||
}
|
||||
|
||||
public void setSkinPartsMask(byte skinPartsMask) {
|
||||
this.skinPartsMask = skinPartsMask;
|
||||
}
|
||||
|
||||
public HumanoidArm getMainArm() {
|
||||
return mainArm;
|
||||
}
|
||||
|
||||
public void setMainArm(HumanoidArm mainArm) {
|
||||
this.mainArm = mainArm;
|
||||
}
|
||||
|
||||
public NBTCompound getLeftShoulderNBT() {
|
||||
return leftShoulderNBT;
|
||||
}
|
||||
|
||||
public void setLeftShoulderNBT(NBTCompound leftShoulderNBT) {
|
||||
this.leftShoulderNBT = leftShoulderNBT;
|
||||
}
|
||||
|
||||
public NBTCompound getRightShoulderNBT() {
|
||||
return rightShoulderNBT;
|
||||
}
|
||||
|
||||
public void setRightShoulderNBT(NBTCompound rightShoulderNBT) {
|
||||
this.rightShoulderNBT = rightShoulderNBT;
|
||||
}
|
||||
|
||||
public static PlayerBuilder<PlayerBuilder> builderPlayer() {
|
||||
return new PlayerBuilder<>(new PlayerDataProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntityData> encode() {
|
||||
List<EntityData> metadata = super.encode();
|
||||
metadata.add(new EntityData(15, EntityDataTypes.FLOAT, additionalHealth));
|
||||
metadata.add(new EntityData(16, EntityDataTypes.INT, score));
|
||||
metadata.add(new EntityData(17, EntityDataTypes.BYTE, skinPartsMask));
|
||||
metadata.add(new EntityData(18, EntityDataTypes.BYTE, (byte) mainArm.ordinal()));
|
||||
metadata.add(new EntityData(19, EntityDataTypes.NBT, leftShoulderNBT));
|
||||
metadata.add(new EntityData(20, EntityDataTypes.NBT, rightShoulderNBT));
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(List<EntityData> data) {
|
||||
super.decode(data);
|
||||
for (EntityData entityData : data) {
|
||||
switch (entityData.getIndex()) {
|
||||
case 15:
|
||||
additionalHealth = (float) entityData.getValue();
|
||||
break;
|
||||
case 16:
|
||||
score = (int) entityData.getValue();
|
||||
break;
|
||||
case 17:
|
||||
skinPartsMask = (byte) entityData.getValue();
|
||||
break;
|
||||
case 18:
|
||||
mainArm = HumanoidArm.VALUES[(byte) entityData.getValue()];
|
||||
break;
|
||||
case 19:
|
||||
leftShoulderNBT = (NBTCompound) entityData.getValue();
|
||||
break;
|
||||
case 20:
|
||||
rightShoulderNBT = (NBTCompound) entityData.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerBuilder<T extends PlayerBuilder> extends LivingEntityDataProvider.LivingEntityBuilder<T> {
|
||||
public PlayerBuilder(PlayerDataProvider entityDataProvider) {
|
||||
super(entityDataProvider);
|
||||
}
|
||||
|
||||
public T additionalHealth(float additionalHealth) {
|
||||
((PlayerDataProvider)provider).setAdditionalHealth(additionalHealth);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T score(int score) {
|
||||
((PlayerDataProvider)provider).setScore(score);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T skinPartsMask(byte skinPartsMask) {
|
||||
((PlayerDataProvider)provider).setSkinPartsMask(skinPartsMask);
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
public T skinParts(SkinSection skinSections) {
|
||||
((PlayerDataProvider)provider).setSkinPartsMask(skinSections.getMask());
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
public T mainArm(HumanoidArm mainArm) {
|
||||
((PlayerDataProvider)provider).setMainArm(mainArm);
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
public T leftShoulderNBT(NBTCompound leftShoulderNBT) {
|
||||
((PlayerDataProvider)provider).setLeftShoulderNBT(leftShoulderNBT);
|
||||
return (T)this;
|
||||
}
|
||||
|
||||
public T rightShoulderNBT(NBTCompound rightShoulderNBT) {
|
||||
((PlayerDataProvider)provider).setRightShoulderNBT(rightShoulderNBT);
|
||||
return (T)this;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-1
@@ -31,15 +31,23 @@ public enum EntityPose {
|
||||
DYING,
|
||||
CROAKING,
|
||||
USING_TONGUE,
|
||||
SITTING,
|
||||
ROARING,
|
||||
SNIFFING,
|
||||
EMERGING,
|
||||
DIGGING;
|
||||
DIGGING,
|
||||
//Added in 1.20.4
|
||||
SLIDING,
|
||||
SHOOTING,
|
||||
INHALING;
|
||||
|
||||
public int getId(ClientVersion version) {
|
||||
if (this == DYING && version.isOlderThan(ClientVersion.V_1_17)) {
|
||||
return 6;
|
||||
}
|
||||
if (this.ordinal() >= 11 && version.isOlderThan(ClientVersion.V_1_19_3)) {
|
||||
return this.ordinal() - 1;
|
||||
}
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@@ -48,6 +56,10 @@ public enum EntityPose {
|
||||
if (id == 6 && version.isOlderThan(ClientVersion.V_1_17)) {
|
||||
return DYING;
|
||||
}
|
||||
// The SITTING pose was added in 1.19.3, shifting Warden's poses by 1
|
||||
if (id >= 10 && version.isOlderThan(ClientVersion.V_1_19_3)) {
|
||||
id++;
|
||||
}
|
||||
return values()[id];
|
||||
}
|
||||
}
|
||||
+9
-8
@@ -16,13 +16,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.data.provider;
|
||||
package com.github.retrooper.packetevents.protocol.entity.sniffer;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DataProvider {
|
||||
List<EntityData> encode();
|
||||
void decode(List<EntityData> data);
|
||||
public enum SnifferState {
|
||||
IDLING,
|
||||
FEELING_HAPPY,
|
||||
SCENTING,
|
||||
SNIFFING,
|
||||
SEARCHING,
|
||||
DIGGING,
|
||||
RISING
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.transform;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.player.UserProfile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class EntityTransformType {
|
||||
public static final EntityTransformType IDENTITY = new EntityTransformType(null, 1.0F, null);
|
||||
|
||||
private @Nullable TypeModifier typeModifier;
|
||||
private float scale;
|
||||
private @Nullable UserProfile playerSkin;
|
||||
|
||||
//Scale must be between 0.1F and 16.0F
|
||||
public EntityTransformType(@Nullable TypeModifier typeModifier, float scale, @Nullable UserProfile playerSkin) {
|
||||
this.typeModifier = typeModifier;
|
||||
this.scale = scale;
|
||||
this.playerSkin = playerSkin;
|
||||
}
|
||||
|
||||
public Optional<TypeModifier> getTypeModifier() {
|
||||
return Optional.ofNullable(typeModifier);
|
||||
}
|
||||
|
||||
public void setTypeModifier(@Nullable TypeModifier typeModifier) {
|
||||
this.typeModifier = typeModifier;
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public void setScale(float scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public Optional<UserProfile> getPlayerSkin() {
|
||||
return Optional.ofNullable(playerSkin);
|
||||
}
|
||||
|
||||
public void setPlayerSkin(@Nullable UserProfile playerSkin) {
|
||||
this.playerSkin = playerSkin;
|
||||
}
|
||||
|
||||
public static class TypeModifier {
|
||||
private EntityType entityType;
|
||||
private @Nullable NBTCompound tag;
|
||||
|
||||
public TypeModifier(EntityType entityType, @Nullable NBTCompound tag) {
|
||||
this.entityType = entityType;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public EntityType getEntityType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
public void setEntityType(EntityType entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
public Optional<NBTCompound> getTag() {
|
||||
return Optional.ofNullable(tag);
|
||||
}
|
||||
|
||||
public void setTag(@Nullable NBTCompound tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-1
@@ -43,7 +43,10 @@ public class EntityTypes {
|
||||
ClientVersion.V_1_16,
|
||||
ClientVersion.V_1_16_2,
|
||||
ClientVersion.V_1_17,
|
||||
ClientVersion.V_1_19);
|
||||
ClientVersion.V_1_19,
|
||||
ClientVersion.V_1_19_3,
|
||||
ClientVersion.V_1_19_4,
|
||||
ClientVersion.V_1_20_3);
|
||||
private static final TypesBuilder LEGACY_TYPES_BUILDER = new TypesBuilder("entity/legacy_entity_type_mappings",
|
||||
ClientVersion.V_1_8,
|
||||
ClientVersion.V_1_9,
|
||||
@@ -178,6 +181,7 @@ public class EntityTypes {
|
||||
public static final EntityType BOAT = define("boat", ENTITY);
|
||||
public static final EntityType CHEST_BOAT = define("chest_boat", BOAT);
|
||||
public static final EntityType CAT = define("cat", ABSTRACT_TAMEABLE_ANIMAL);
|
||||
public static final EntityType CAMEL = define("camel", ABSTRACT_HORSE);
|
||||
public static final EntityType SPIDER = define("spider", ABSTRACT_MONSTER);
|
||||
public static final EntityType CAVE_SPIDER = define("cave_spider", SPIDER);
|
||||
public static final EntityType CHICKEN = define("chicken", ABSTRACT_ANIMAL);
|
||||
@@ -298,4 +302,16 @@ public class EntityTypes {
|
||||
public static final EntityType MINECART_TNT = define("minecart_tnt", MINECART_ABSTRACT);
|
||||
public static final EntityType MINECART_HOPPER = define("minecart_hopper", MINECART_ABSTRACT);
|
||||
public static final EntityType MINECART_MOB_SPAWNER = define("minecart_mob_spawner", MINECART_ABSTRACT);
|
||||
|
||||
// Added in 1.19.4
|
||||
public static final EntityType DISPLAY = define("display", ENTITY);
|
||||
public static final EntityType BLOCK_DISPLAY = define("block_display", DISPLAY);
|
||||
public static final EntityType ITEM_DISPLAY = define("item_display", DISPLAY);
|
||||
public static final EntityType TEXT_DISPLAY = define("text_display", DISPLAY);
|
||||
public static final EntityType INTERACTION = define("interaction", DISPLAY);
|
||||
public static final EntityType SNIFFER = define("sniffer", ABSTRACT_ANIMAL);
|
||||
|
||||
// Added in 1.20.3
|
||||
public static final EntityType BREEZE = define("breeze", ABSTRACT_MONSTER);
|
||||
public static final EntityType WIND_CHARGE = define("wind_charge", PROJECTILE_ABSTRACT);
|
||||
}
|
||||
+16
-1
@@ -18,16 +18,23 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.villager;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.villager.level.VillagerLevel;
|
||||
import com.github.retrooper.packetevents.protocol.entity.villager.profession.VillagerProfession;
|
||||
import com.github.retrooper.packetevents.protocol.entity.villager.profession.VillagerProfessions;
|
||||
import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerType;
|
||||
import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerTypes;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class VillagerData {
|
||||
|
||||
private VillagerType type;
|
||||
private VillagerProfession profession;
|
||||
private int level;
|
||||
|
||||
public VillagerData(VillagerType type, VillagerProfession profession, VillagerLevel level) {
|
||||
this(type, profession, level.getId());
|
||||
}
|
||||
|
||||
public VillagerData(VillagerType type, VillagerProfession profession, int level) {
|
||||
this.type = type;
|
||||
this.profession = profession;
|
||||
@@ -55,10 +62,18 @@ public class VillagerData {
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
return this.level;
|
||||
}
|
||||
|
||||
public @Nullable VillagerLevel getVillagerLevel() {
|
||||
return VillagerLevel.getById(this.level);
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public void setLevel(VillagerLevel level) {
|
||||
this.level = level.getId();
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.entity.villager.level;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public enum VillagerLevel {
|
||||
|
||||
NOVICE,
|
||||
APPRENTICE,
|
||||
JOURNEYMAN,
|
||||
EXPERT,
|
||||
MASTER;
|
||||
|
||||
private static final VillagerLevel[] VALUES = values();
|
||||
|
||||
public static @Nullable VillagerLevel getById(int id) {
|
||||
if (id >= 1 && id <= VALUES.length) {
|
||||
return VALUES[id - 1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.ordinal() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -50,7 +50,6 @@ public class VillagerProfessions {
|
||||
return VILLAGER_PROFESSION_ID_MAP.get((byte)id);
|
||||
}
|
||||
|
||||
|
||||
public static VillagerProfession getByName(String name) {
|
||||
return VILLAGER_PROFESSION_MAP.get(name);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class ItemStack {
|
||||
}
|
||||
|
||||
public ItemStack copy() {
|
||||
return cachedIsEmpty ? EMPTY : new ItemStack(type, amount, nbt == null ? new NBTCompound() : nbt.copy(), legacyData);
|
||||
return cachedIsEmpty ? EMPTY : new ItemStack(type, amount, nbt == null ? null : nbt.copy(), legacyData);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -192,7 +192,9 @@ public class ItemStack {
|
||||
for (NBTCompound base : nbt.getCompoundListTagOrNull(tagName).getTags()) {
|
||||
EnchantmentType type = getEnchantmentTypeFromTag(base, version);
|
||||
if (enchantment == type) {
|
||||
return base.getTagOfTypeOrNull("lvl", NBTShort.class).getAsInt();
|
||||
NBTShort nbtShort = base.getTagOfTypeOrNull("lvl", NBTShort.class);
|
||||
if (nbtShort == null) return 0; // this might need to be set to 1
|
||||
return nbtShort.getAsInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,7 +260,16 @@ public class ItemStack {
|
||||
}
|
||||
|
||||
public static boolean tagMatches(ItemStack left, ItemStack right) {
|
||||
return left.isEmpty() && right.isEmpty() || (!left.isEmpty() && !right.isEmpty() && ((left.nbt != null || right.nbt == null) && (left.nbt == null || left.nbt.equals(right.nbt))));
|
||||
if (left == right) {
|
||||
return true;
|
||||
}
|
||||
if (left == null) {
|
||||
return right.isEmpty();
|
||||
}
|
||||
if (right == null) {
|
||||
return left.isEmpty();
|
||||
}
|
||||
return Objects.equals(left.nbt, right.nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+195
-8
@@ -27,7 +27,14 @@ import com.github.retrooper.packetevents.util.TypesBuilderData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemTypes {
|
||||
@@ -44,7 +51,11 @@ public class ItemTypes {
|
||||
ClientVersion.V_1_16_2,
|
||||
ClientVersion.V_1_17,
|
||||
ClientVersion.V_1_18,
|
||||
ClientVersion.V_1_19);
|
||||
ClientVersion.V_1_19,
|
||||
ClientVersion.V_1_19_3,
|
||||
ClientVersion.V_1_19_4,
|
||||
ClientVersion.V_1_20,
|
||||
ClientVersion.V_1_20_3);
|
||||
|
||||
public static final ItemType GILDED_BLACKSTONE = builder("gilded_blackstone").setMaxAmount(64).setPlacedType(StateTypes.GILDED_BLACKSTONE).build();
|
||||
public static final ItemType NETHER_BRICK_SLAB = builder("nether_brick_slab").setMaxAmount(64).setPlacedType(StateTypes.NETHER_BRICK_SLAB).build();
|
||||
@@ -119,7 +130,7 @@ public class ItemTypes {
|
||||
public static final ItemType STRIPPED_OAK_LOG = builder("stripped_oak_log").setMaxAmount(64).setAttributes(ItemAttribute.FUEL).setPlacedType(StateTypes.STRIPPED_OAK_LOG).build();
|
||||
public static final ItemType LIGHT_GRAY_CONCRETE_POWDER = builder("light_gray_concrete_powder").setMaxAmount(64).setPlacedType(StateTypes.LIGHT_GRAY_CONCRETE_POWDER).build();
|
||||
public static final ItemType COOKED_PORKCHOP = builder("cooked_porkchop").setMaxAmount(64).setAttributes(ItemAttribute.EDIBLE).build();
|
||||
public static final ItemType NETHERITE_HELMET = builder("netherite_helmet").setMaxAmount(1).setAttributes(ItemAttribute.FIRE_RESISTANT).build();
|
||||
public static final ItemType NETHERITE_HELMET = builder("netherite_helmet").setMaxAmount(1).setAttributes(ItemAttribute.FIRE_RESISTANT).setMaxDurability(407).build();
|
||||
public static final ItemType BLACK_CANDLE = builder("black_candle").setMaxAmount(64).setPlacedType(StateTypes.BLACK_CANDLE).build();
|
||||
public static final ItemType CYAN_CONCRETE_POWDER = builder("cyan_concrete_powder").setMaxAmount(64).setPlacedType(StateTypes.CYAN_CONCRETE_POWDER).build();
|
||||
public static final ItemType SADDLE = builder("saddle").setMaxAmount(1).build();
|
||||
@@ -562,7 +573,7 @@ public class ItemTypes {
|
||||
public static final ItemType GREEN_GLAZED_TERRACOTTA = builder("green_glazed_terracotta").setMaxAmount(64).setPlacedType(StateTypes.GREEN_GLAZED_TERRACOTTA).build();
|
||||
public static final ItemType SCUTE = builder("scute").setMaxAmount(64).build();
|
||||
public static final ItemType GOLDEN_CHESTPLATE = builder("golden_chestplate").setMaxAmount(1).setMaxDurability(112).build();
|
||||
public static final ItemType NETHERITE_LEGGINGS = builder("netherite_leggings").setMaxAmount(1).setAttributes(ItemAttribute.FIRE_RESISTANT).build();
|
||||
public static final ItemType NETHERITE_LEGGINGS = builder("netherite_leggings").setMaxAmount(1).setAttributes(ItemAttribute.FIRE_RESISTANT).setMaxDurability(555).build();
|
||||
public static final ItemType GOLDEN_SHOVEL = builder("golden_shovel").setMaxAmount(1).setAttributes(ItemAttribute.SHOVEL, ItemAttribute.GOLD_TIER).setMaxDurability(32).build();
|
||||
public static final ItemType SPRUCE_STAIRS = builder("spruce_stairs").setMaxAmount(64).setAttributes(ItemAttribute.FUEL).setPlacedType(StateTypes.SPRUCE_STAIRS).build();
|
||||
public static final ItemType BIRCH_PLANKS = builder("birch_planks").setMaxAmount(64).setAttributes(ItemAttribute.FUEL).setPlacedType(StateTypes.BIRCH_PLANKS).build();
|
||||
@@ -625,7 +636,11 @@ public class ItemTypes {
|
||||
public static final ItemType RAW_COPPER_BLOCK = builder("raw_copper_block").setMaxAmount(64).setPlacedType(StateTypes.RAW_COPPER_BLOCK).build();
|
||||
public static final ItemType LIGHT_GRAY_CARPET = builder("light_gray_carpet").setMaxAmount(64).setAttributes(ItemAttribute.FUEL).setPlacedType(StateTypes.LIGHT_GRAY_CARPET).build();
|
||||
public static final ItemType MUSIC_DISC_WARD = builder("music_disc_ward").setMaxAmount(1).setAttributes(ItemAttribute.MUSIC_DISC).build();
|
||||
public static final ItemType GRASS = builder("grass").setMaxAmount(64).setPlacedType(StateTypes.GRASS).build();
|
||||
public static final ItemType SHORT_GRASS = builder("short_grass").setMaxAmount(64).setPlacedType(StateTypes.SHORT_GRASS).build();
|
||||
|
||||
@Deprecated
|
||||
public static final ItemType GRASS = SHORT_GRASS;
|
||||
|
||||
public static final ItemType END_CRYSTAL = builder("end_crystal").setMaxAmount(64).build();
|
||||
public static final ItemType VINDICATOR_SPAWN_EGG = builder("vindicator_spawn_egg").setMaxAmount(64).build();
|
||||
public static final ItemType WHEAT = builder("wheat").setMaxAmount(64).build();
|
||||
@@ -773,7 +788,7 @@ public class ItemTypes {
|
||||
public static final ItemType MOOSHROOM_SPAWN_EGG = builder("mooshroom_spawn_egg").setMaxAmount(64).build();
|
||||
public static final ItemType MAP = builder("map").setMaxAmount(64).build();
|
||||
public static final ItemType DARK_OAK_SIGN = builder("dark_oak_sign").setMaxAmount(16).setAttributes(ItemAttribute.FUEL).setPlacedType(StateTypes.DARK_OAK_SIGN).build();
|
||||
public static final ItemType NETHERITE_BOOTS = builder("netherite_boots").setMaxAmount(1).setAttributes(ItemAttribute.FIRE_RESISTANT).build();
|
||||
public static final ItemType NETHERITE_BOOTS = builder("netherite_boots").setMaxAmount(1).setAttributes(ItemAttribute.FIRE_RESISTANT).setMaxDurability(481).build();
|
||||
public static final ItemType BREAD = builder("bread").setMaxAmount(64).setAttributes(ItemAttribute.EDIBLE).build();
|
||||
public static final ItemType DEEPSLATE_TILE_SLAB = builder("deepslate_tile_slab").setMaxAmount(64).setPlacedType(StateTypes.DEEPSLATE_TILE_SLAB).build();
|
||||
public static final ItemType POLISHED_BLACKSTONE_BUTTON = builder("polished_blackstone_button").setMaxAmount(64).setPlacedType(StateTypes.POLISHED_BLACKSTONE_BUTTON).build();
|
||||
@@ -856,7 +871,7 @@ public class ItemTypes {
|
||||
public static final ItemType YELLOW_DYE = builder("yellow_dye").setMaxAmount(64).build();
|
||||
public static final ItemType CYAN_STAINED_GLASS = builder("cyan_stained_glass").setMaxAmount(64).setPlacedType(StateTypes.CYAN_STAINED_GLASS).build();
|
||||
public static final ItemType BRICKS = builder("bricks").setMaxAmount(64).setPlacedType(StateTypes.BRICKS).build();
|
||||
public static final ItemType NETHERITE_CHESTPLATE = builder("netherite_chestplate").setMaxAmount(1).setAttributes(ItemAttribute.FIRE_RESISTANT).build();
|
||||
public static final ItemType NETHERITE_CHESTPLATE = builder("netherite_chestplate").setMaxAmount(1).setAttributes(ItemAttribute.FIRE_RESISTANT).setMaxDurability(592).build();
|
||||
public static final ItemType ORANGE_BED = builder("orange_bed").setMaxAmount(1).setPlacedType(StateTypes.ORANGE_BED).build();
|
||||
public static final ItemType PETRIFIED_OAK_SLAB = builder("petrified_oak_slab").setMaxAmount(64).setPlacedType(StateTypes.PETRIFIED_OAK_SLAB).build();
|
||||
public static final ItemType SALMON_SPAWN_EGG = builder("salmon_spawn_egg").setMaxAmount(64).build();
|
||||
@@ -1198,6 +1213,175 @@ public class ItemTypes {
|
||||
public static final ItemType DARK_OAK_CHEST_BOAT = builder("dark_oak_chest_boat").setMaxAmount(1).build();
|
||||
public static final ItemType MANGROVE_BOAT = builder("mangrove_boat").setMaxAmount(1).build();
|
||||
public static final ItemType MANGROVE_CHEST_BOAT = builder("mangrove_chest_boat").setMaxAmount(1).build();
|
||||
public static ItemType CHERRY_PLANKS = builder("CHERRY_PLANKS").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_PLANKS).build();
|
||||
public static ItemType BAMBOO_PLANKS = builder("BAMBOO_PLANKS").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_PLANKS).build();
|
||||
public static ItemType BAMBOO_MOSAIC = builder("BAMBOO_MOSAIC").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_MOSAIC).build();
|
||||
public static ItemType CHERRY_SAPLING = builder("CHERRY_SAPLING").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_SAPLING).build();
|
||||
public static ItemType SUSPICIOUS_SAND = builder("SUSPICIOUS_SAND").setMaxAmount(64).setPlacedType(StateTypes.SUSPICIOUS_SAND).build();
|
||||
public static ItemType CHERRY_LOG = builder("CHERRY_LOG").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_LOG).build();
|
||||
public static ItemType BAMBOO_BLOCK = builder("BAMBOO_BLOCK").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_BLOCK).build();
|
||||
public static ItemType STRIPPED_CHERRY_LOG = builder("STRIPPED_CHERRY_LOG").setMaxAmount(64).setPlacedType(StateTypes.STRIPPED_CHERRY_LOG).build();
|
||||
public static ItemType STRIPPED_CHERRY_WOOD = builder("STRIPPED_CHERRY_WOOD").setMaxAmount(64).setPlacedType(StateTypes.STRIPPED_CHERRY_WOOD).build();
|
||||
public static ItemType STRIPPED_BAMBOO_BLOCK = builder("STRIPPED_BAMBOO_BLOCK").setMaxAmount(64).setPlacedType(StateTypes.STRIPPED_BAMBOO_BLOCK).build();
|
||||
public static ItemType CHERRY_WOOD = builder("CHERRY_WOOD").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_WOOD).build();
|
||||
public static ItemType CHERRY_LEAVES = builder("CHERRY_LEAVES").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_LEAVES).build();
|
||||
public static ItemType TORCHFLOWER = builder("TORCHFLOWER").setMaxAmount(64).setPlacedType(StateTypes.TORCHFLOWER).build();
|
||||
public static ItemType PINK_PETALS = builder("PINK_PETALS").setMaxAmount(64).setPlacedType(StateTypes.PINK_PETALS).build();
|
||||
public static ItemType CHERRY_SLAB = builder("CHERRY_SLAB").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_SLAB).build();
|
||||
public static ItemType BAMBOO_SLAB = builder("BAMBOO_SLAB").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_SLAB).build();
|
||||
public static ItemType BAMBOO_MOSAIC_SLAB = builder("BAMBOO_MOSAIC_SLAB").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_MOSAIC_SLAB).build();
|
||||
public static ItemType CHISELED_BOOKSHELF = builder("CHISELED_BOOKSHELF").setMaxAmount(64).setPlacedType(StateTypes.CHISELED_BOOKSHELF).build();
|
||||
public static ItemType DECORATED_POT = builder("DECORATED_POT").setMaxAmount(1).setPlacedType(StateTypes.DECORATED_POT).build();
|
||||
public static ItemType CHERRY_FENCE = builder("CHERRY_FENCE").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_FENCE).build();
|
||||
public static ItemType BAMBOO_FENCE = builder("BAMBOO_FENCE").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_FENCE).build();
|
||||
public static ItemType CHERRY_STAIRS = builder("CHERRY_STAIRS").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_STAIRS).build();
|
||||
public static ItemType MANGROVE_STAIRS = builder("MANGROVE_STAIRS").setMaxAmount(64).setPlacedType(StateTypes.MANGROVE_STAIRS).build();
|
||||
public static ItemType BAMBOO_STAIRS = builder("BAMBOO_STAIRS").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_STAIRS).build();
|
||||
public static ItemType BAMBOO_MOSAIC_STAIRS = builder("BAMBOO_MOSAIC_STAIRS").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_MOSAIC_STAIRS).build();
|
||||
public static ItemType CHERRY_BUTTON = builder("CHERRY_BUTTON").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_BUTTON).build();
|
||||
public static ItemType BAMBOO_BUTTON = builder("BAMBOO_BUTTON").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_BUTTON).build();
|
||||
public static ItemType CHERRY_PRESSURE_PLATE = builder("CHERRY_PRESSURE_PLATE").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_PRESSURE_PLATE).build();
|
||||
public static ItemType BAMBOO_PRESSURE_PLATE = builder("BAMBOO_PRESSURE_PLATE").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_PRESSURE_PLATE).build();
|
||||
public static ItemType CHERRY_DOOR = builder("CHERRY_DOOR").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_DOOR).build();
|
||||
public static ItemType BAMBOO_DOOR = builder("BAMBOO_DOOR").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_DOOR).build();
|
||||
public static ItemType CHERRY_TRAPDOOR = builder("CHERRY_TRAPDOOR").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_TRAPDOOR).build();
|
||||
public static ItemType BAMBOO_TRAPDOOR = builder("BAMBOO_TRAPDOOR").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_TRAPDOOR).build();
|
||||
public static ItemType CHERRY_FENCE_GATE = builder("CHERRY_FENCE_GATE").setMaxAmount(64).setPlacedType(StateTypes.CHERRY_FENCE_GATE).build();
|
||||
public static ItemType BAMBOO_FENCE_GATE = builder("BAMBOO_FENCE_GATE").setMaxAmount(64).setPlacedType(StateTypes.BAMBOO_FENCE_GATE).build();
|
||||
public static ItemType CHERRY_BOAT = builder("CHERRY_BOAT").setMaxAmount(1).build();
|
||||
public static ItemType CHERRY_CHEST_BOAT = builder("CHERRY_CHEST_BOAT").setMaxAmount(1).build();
|
||||
public static ItemType BAMBOO_RAFT = builder("BAMBOO_RAFT").setMaxAmount(1).build();
|
||||
public static ItemType BAMBOO_CHEST_RAFT = builder("BAMBOO_CHEST_RAFT").setMaxAmount(1).build();
|
||||
public static ItemType CHERRY_SIGN = builder("CHERRY_SIGN").setMaxAmount(16).setPlacedType(StateTypes.CHERRY_SIGN).build();
|
||||
public static ItemType BAMBOO_SIGN = builder("BAMBOO_SIGN").setMaxAmount(16).setPlacedType(StateTypes.BAMBOO_SIGN).build();
|
||||
public static ItemType OAK_HANGING_SIGN = builder("OAK_HANGING_SIGN").setMaxAmount(16).setPlacedType(StateTypes.OAK_HANGING_SIGN).build();
|
||||
public static ItemType SPRUCE_HANGING_SIGN = builder("SPRUCE_HANGING_SIGN").setMaxAmount(16).setPlacedType(StateTypes.SPRUCE_HANGING_SIGN).build();
|
||||
public static ItemType BIRCH_HANGING_SIGN = builder("BIRCH_HANGING_SIGN").setMaxAmount(16).setPlacedType(StateTypes.BIRCH_HANGING_SIGN).build();
|
||||
public static ItemType JUNGLE_HANGING_SIGN = builder("JUNGLE_HANGING_SIGN").setMaxAmount(16).setPlacedType(StateTypes.JUNGLE_HANGING_SIGN).build();
|
||||
public static ItemType ACACIA_HANGING_SIGN = builder("ACACIA_HANGING_SIGN").setMaxAmount(16).setPlacedType(StateTypes.ACACIA_HANGING_SIGN).build();
|
||||
public static ItemType CHERRY_HANGING_SIGN = builder("CHERRY_HANGING_SIGN").setMaxAmount(16).setPlacedType(StateTypes.CHERRY_HANGING_SIGN).build();
|
||||
public static ItemType DARK_OAK_HANGING_SIGN = builder("DARK_OAK_HANGING_SIGN").setMaxAmount(16).setPlacedType(StateTypes.DARK_OAK_HANGING_SIGN).build();
|
||||
public static ItemType MANGROVE_HANGING_SIGN = builder("MANGROVE_HANGING_SIGN").setMaxAmount(16).setPlacedType(StateTypes.MANGROVE_HANGING_SIGN).build();
|
||||
public static ItemType BAMBOO_HANGING_SIGN = builder("BAMBOO_HANGING_SIGN").setMaxAmount(16).setPlacedType(StateTypes.BAMBOO_HANGING_SIGN).build();
|
||||
public static ItemType CRIMSON_HANGING_SIGN = builder("CRIMSON_HANGING_SIGN").setMaxAmount(16).setPlacedType(StateTypes.CRIMSON_HANGING_SIGN).build();
|
||||
public static ItemType WARPED_HANGING_SIGN = builder("WARPED_HANGING_SIGN").setMaxAmount(16).setPlacedType(StateTypes.WARPED_HANGING_SIGN).build();
|
||||
public static ItemType CAMEL_SPAWN_EGG = builder("CAMEL_SPAWN_EGG").setMaxAmount(64).build();
|
||||
public static ItemType ENDER_DRAGON_SPAWN_EGG = builder("ENDER_DRAGON_SPAWN_EGG").setMaxAmount(64).build();
|
||||
public static ItemType IRON_GOLEM_SPAWN_EGG = builder("IRON_GOLEM_SPAWN_EGG").setMaxAmount(64).build();
|
||||
public static ItemType SNIFFER_SPAWN_EGG = builder("SNIFFER_SPAWN_EGG").setMaxAmount(64).build();
|
||||
public static ItemType SNOW_GOLEM_SPAWN_EGG = builder("SNOW_GOLEM_SPAWN_EGG").setMaxAmount(64).build();
|
||||
public static ItemType WITHER_SPAWN_EGG = builder("WITHER_SPAWN_EGG").setMaxAmount(64).build();
|
||||
public static ItemType PIGLIN_HEAD = builder("PIGLIN_HEAD").setMaxAmount(64).setPlacedType(StateTypes.PIGLIN_HEAD).build();
|
||||
public static ItemType TORCHFLOWER_SEEDS = builder("TORCHFLOWER_SEEDS").setMaxAmount(64).build();
|
||||
public static ItemType BRUSH = builder("BRUSH").setMaxAmount(1).build();
|
||||
public static ItemType NETHERITE_UPGRADE_SMITHING_TEMPLATE = builder("NETHERITE_UPGRADE_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE = builder("SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType DUNE_ARMOR_TRIM_SMITHING_TEMPLATE = builder("DUNE_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType COAST_ARMOR_TRIM_SMITHING_TEMPLATE = builder("COAST_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType WILD_ARMOR_TRIM_SMITHING_TEMPLATE = builder("WILD_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType WARD_ARMOR_TRIM_SMITHING_TEMPLATE = builder("WARD_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType EYE_ARMOR_TRIM_SMITHING_TEMPLATE = builder("EYE_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType VEX_ARMOR_TRIM_SMITHING_TEMPLATE = builder("VEX_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType TIDE_ARMOR_TRIM_SMITHING_TEMPLATE = builder("TIDE_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE = builder("SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType RIB_ARMOR_TRIM_SMITHING_TEMPLATE = builder("RIB_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE = builder("SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType POTTERY_SHARD_ARCHER = builder("POTTERY_SHARD_ARCHER").setMaxAmount(64).build();
|
||||
public static ItemType POTTERY_SHARD_PRIZE = builder("POTTERY_SHARD_PRIZE").setMaxAmount(64).build();
|
||||
public static ItemType POTTERY_SHARD_ARMS_UP = builder("POTTERY_SHARD_ARMS_UP").setMaxAmount(64).build();
|
||||
public static ItemType POTTERY_SHARD_SKULL = builder("POTTERY_SHARD_SKULL").setMaxAmount(64).build();
|
||||
//1.20 items
|
||||
public static ItemType SUSPICIOUS_GRAVEL = builder("SUSPICIOUS_GRAVEL").setMaxAmount(64).build();
|
||||
public static ItemType PITCHER_PLANT = builder("PITCHER_PLANT").setMaxAmount(64).build();
|
||||
public static ItemType SNIFFER_EGG = builder("SNIFFER_EGG").setMaxAmount(64).build();
|
||||
public static ItemType CALIBRATED_SCULK_SENSOR = builder("CALIBRATED_SCULK_SENSOR").setMaxAmount(64).build();
|
||||
public static ItemType PITCHER_POD = builder("PITCHER_POD").setMaxAmount(64).build();
|
||||
public static ItemType MUSIC_DISC_RELIC = builder("MUSIC_DISC_RELIC").setMaxAmount(1).setAttributes(ItemAttribute.MUSIC_DISC).build();
|
||||
public static ItemType WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE = builder("WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE = builder("SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE = builder("SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType RAISER_ARMOR_TRIM_SMITHING_TEMPLATE = builder("RAISER_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType HOST_ARMOR_TRIM_SMITHING_TEMPLATE = builder("HOST_ARMOR_TRIM_SMITHING_TEMPLATE").setMaxAmount(64).build();
|
||||
public static ItemType ANGLER_POTTERY_SHERD = builder("ANGLER_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType ARCHER_POTTERY_SHERD = builder("ARCHER_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType ARMS_UP_POTTERY_SHERD = builder("ARMS_UP_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType BLADE_POTTERY_SHERD = builder("BLADE_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType BREWER_POTTERY_SHERD = builder("BREWER_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType BURN_POTTERY_SHERD = builder("BURN_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType DANGER_POTTERY_SHERD = builder("DANGER_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType EXPLORER_POTTERY_SHERD = builder("EXPLORER_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType FRIEND_POTTERY_SHERD = builder("FRIEND_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType HEART_POTTERY_SHERD = builder("HEART_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType HEARTBREAK_POTTERY_SHERD = builder("HEARTBREAK_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType HOWL_POTTERY_SHERD = builder("HOWL_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType MINER_POTTERY_SHERD = builder("MINER_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType MOURNER_POTTERY_SHERD = builder("MOURNER_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType PLENTY_POTTERY_SHERD = builder("PLENTY_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType PRIZE_POTTERY_SHERD = builder("PRIZE_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType SHEAF_POTTERY_SHERD = builder("SHEAF_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType SHELTER_POTTERY_SHERD = builder("SHELTER_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType SKULL_POTTERY_SHERD = builder("SKULL_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
public static ItemType SNORT_POTTERY_SHERD = builder("SNORT_POTTERY_SHERD").setMaxAmount(64).build();
|
||||
|
||||
// 1.20.3 items
|
||||
public static ItemType TUFF_SLAB = builder("tuff_slab").setMaxAmount(64).setPlacedType(StateTypes.TUFF_SLAB).build();
|
||||
public static ItemType TUFF_STAIRS = builder("tuff_stairs").setMaxAmount(64).setPlacedType(StateTypes.TUFF_STAIRS).build();
|
||||
public static ItemType TUFF_WALL = builder("tuff_wall").setMaxAmount(64).setPlacedType(StateTypes.TUFF_WALL).build();
|
||||
public static ItemType CHISELED_TUFF = builder("chiseled_tuff").setMaxAmount(64).setPlacedType(StateTypes.CHISELED_TUFF).build();
|
||||
public static ItemType POLISHED_TUFF = builder("polished_tuff").setMaxAmount(64).setPlacedType(StateTypes.POLISHED_TUFF).build();
|
||||
public static ItemType POLISHED_TUFF_SLAB = builder("polished_tuff_slab").setMaxAmount(64).setPlacedType(StateTypes.POLISHED_TUFF_SLAB).build();
|
||||
public static ItemType POLISHED_TUFF_STAIRS = builder("polished_tuff_stairs").setMaxAmount(64).setPlacedType(StateTypes.POLISHED_TUFF_STAIRS).build();
|
||||
public static ItemType POLISHED_TUFF_WALL = builder("polished_tuff_wall").setMaxAmount(64).setPlacedType(StateTypes.POLISHED_TUFF_WALL).build();
|
||||
public static ItemType TUFF_BRICKS = builder("tuff_bricks").setMaxAmount(64).setPlacedType(StateTypes.TUFF_BRICKS).build();
|
||||
public static ItemType TUFF_BRICK_SLAB = builder("tuff_brick_slab").setMaxAmount(64).setPlacedType(StateTypes.TUFF_BRICK_SLAB).build();
|
||||
public static ItemType TUFF_BRICK_STAIRS = builder("tuff_brick_stairs").setMaxAmount(64).setPlacedType(StateTypes.TUFF_BRICK_STAIRS).build();
|
||||
public static ItemType TUFF_BRICK_WALL = builder("tuff_brick_wall").setMaxAmount(64).setPlacedType(StateTypes.TUFF_BRICK_WALL).build();
|
||||
public static ItemType CHISELED_TUFF_BRICKS = builder("chiseled_tuff_bricks").setMaxAmount(64).setPlacedType(StateTypes.CHISELED_TUFF_BRICKS).build();
|
||||
public static ItemType CHISELED_COPPER = builder("chiseled_copper").setMaxAmount(64).setPlacedType(StateTypes.CHISELED_COPPER).build();
|
||||
public static ItemType EXPOSED_CHISELED_COPPER = builder("exposed_chiseled_copper").setMaxAmount(64).setPlacedType(StateTypes.EXPOSED_CHISELED_COPPER).build();
|
||||
public static ItemType WEATHERED_CHISELED_COPPER = builder("weathered_chiseled_copper").setMaxAmount(64).setPlacedType(StateTypes.WEATHERED_CHISELED_COPPER).build();
|
||||
public static ItemType OXIDIZED_CHISELED_COPPER = builder("oxidized_chiseled_copper").setMaxAmount(64).setPlacedType(StateTypes.OXIDIZED_CHISELED_COPPER).build();
|
||||
public static ItemType WAXED_CHISELED_COPPER = builder("waxed_chiseled_copper").setMaxAmount(64).setPlacedType(StateTypes.WAXED_CHISELED_COPPER).build();
|
||||
public static ItemType WAXED_EXPOSED_CHISELED_COPPER = builder("waxed_exposed_chiseled_copper").setMaxAmount(64).setPlacedType(StateTypes.WAXED_EXPOSED_CHISELED_COPPER).build();
|
||||
public static ItemType WAXED_WEATHERED_CHISELED_COPPER = builder("waxed_weathered_chiseled_copper").setMaxAmount(64).setPlacedType(StateTypes.WAXED_WEATHERED_CHISELED_COPPER).build();
|
||||
public static ItemType WAXED_OXIDIZED_CHISELED_COPPER = builder("waxed_oxidized_chiseled_copper").setMaxAmount(64).setPlacedType(StateTypes.WAXED_OXIDIZED_CHISELED_COPPER).build();
|
||||
public static ItemType COPPER_DOOR = builder("copper_door").setMaxAmount(64).setPlacedType(StateTypes.COPPER_DOOR).build();
|
||||
public static ItemType EXPOSED_COPPER_DOOR = builder("exposed_copper_door").setMaxAmount(64).setPlacedType(StateTypes.EXPOSED_COPPER_DOOR).build();
|
||||
public static ItemType WEATHERED_COPPER_DOOR = builder("weathered_copper_door").setMaxAmount(64).setPlacedType(StateTypes.WEATHERED_COPPER_DOOR).build();
|
||||
public static ItemType OXIDIZED_COPPER_DOOR = builder("oxidized_copper_door").setMaxAmount(64).setPlacedType(StateTypes.OXIDIZED_COPPER_DOOR).build();
|
||||
public static ItemType WAXED_COPPER_DOOR = builder("waxed_copper_door").setMaxAmount(64).setPlacedType(StateTypes.WAXED_COPPER_DOOR).build();
|
||||
public static ItemType WAXED_EXPOSED_COPPER_DOOR = builder("waxed_exposed_copper_door").setMaxAmount(64).setPlacedType(StateTypes.WAXED_EXPOSED_COPPER_DOOR).build();
|
||||
public static ItemType WAXED_WEATHERED_COPPER_DOOR = builder("waxed_weathered_copper_door").setMaxAmount(64).setPlacedType(StateTypes.WAXED_WEATHERED_COPPER_DOOR).build();
|
||||
public static ItemType WAXED_OXIDIZED_COPPER_DOOR = builder("waxed_oxidized_copper_door").setMaxAmount(64).setPlacedType(StateTypes.WAXED_OXIDIZED_COPPER_DOOR).build();
|
||||
public static ItemType COPPER_TRAPDOOR = builder("copper_trapdoor").setMaxAmount(64).setPlacedType(StateTypes.COPPER_TRAPDOOR).build();
|
||||
public static ItemType EXPOSED_COPPER_TRAPDOOR = builder("exposed_copper_trapdoor").setMaxAmount(64).setPlacedType(StateTypes.EXPOSED_COPPER_TRAPDOOR).build();
|
||||
public static ItemType WEATHERED_COPPER_TRAPDOOR = builder("weathered_copper_trapdoor").setMaxAmount(64).setPlacedType(StateTypes.WEATHERED_COPPER_TRAPDOOR).build();
|
||||
public static ItemType OXIDIZED_COPPER_TRAPDOOR = builder("oxidized_copper_trapdoor").setMaxAmount(64).setPlacedType(StateTypes.OXIDIZED_COPPER_TRAPDOOR).build();
|
||||
public static ItemType WAXED_COPPER_TRAPDOOR = builder("waxed_copper_trapdoor").setMaxAmount(64).setPlacedType(StateTypes.WAXED_COPPER_TRAPDOOR).build();
|
||||
public static ItemType WAXED_EXPOSED_COPPER_TRAPDOOR = builder("waxed_exposed_copper_trapdoor").setMaxAmount(64).setPlacedType(StateTypes.WAXED_EXPOSED_COPPER_TRAPDOOR).build();
|
||||
public static ItemType WAXED_WEATHERED_COPPER_TRAPDOOR = builder("waxed_weathered_copper_trapdoor").setMaxAmount(64).setPlacedType(StateTypes.WAXED_WEATHERED_COPPER_TRAPDOOR).build();
|
||||
public static ItemType WAXED_OXIDIZED_COPPER_TRAPDOOR = builder("waxed_oxidized_copper_trapdoor").setMaxAmount(64).setPlacedType(StateTypes.WAXED_OXIDIZED_COPPER_TRAPDOOR).build();
|
||||
public static ItemType CRAFTER = builder("crafter").setMaxAmount(64).setPlacedType(StateTypes.CRAFTER).build();
|
||||
public static ItemType BREEZE_SPAWN_EGG = builder("breeze_spawn_egg").setMaxAmount(64).build();
|
||||
public static ItemType COPPER_GRATE = builder("copper_grate").setMaxAmount(64).setPlacedType(StateTypes.COPPER_GRATE).build();
|
||||
public static ItemType EXPOSED_COPPER_GRATE = builder("exposed_copper_grate").setMaxAmount(64).setPlacedType(StateTypes.EXPOSED_COPPER_GRATE).build();
|
||||
public static ItemType WEATHERED_COPPER_GRATE = builder("weathered_copper_grate").setMaxAmount(64).setPlacedType(StateTypes.WEATHERED_COPPER_GRATE).build();
|
||||
public static ItemType OXIDIZED_COPPER_GRATE = builder("oxidized_copper_grate").setMaxAmount(64).setPlacedType(StateTypes.OXIDIZED_COPPER_GRATE).build();
|
||||
public static ItemType WAXED_COPPER_GRATE = builder("waxed_copper_grate").setMaxAmount(64).setPlacedType(StateTypes.WAXED_COPPER_GRATE).build();
|
||||
public static ItemType WAXED_EXPOSED_COPPER_GRATE = builder("waxed_exposed_copper_grate").setMaxAmount(64).setPlacedType(StateTypes.WAXED_EXPOSED_COPPER_GRATE).build();
|
||||
public static ItemType WAXED_WEATHERED_COPPER_GRATE = builder("waxed_weathered_copper_grate").setMaxAmount(64).setPlacedType(StateTypes.WAXED_WEATHERED_COPPER_GRATE).build();
|
||||
public static ItemType WAXED_OXIDIZED_COPPER_GRATE = builder("waxed_oxidized_copper_grate").setMaxAmount(64).setPlacedType(StateTypes.WAXED_OXIDIZED_COPPER_GRATE).build();
|
||||
public static ItemType COPPER_BULB = builder("copper_bulb").setMaxAmount(64).setPlacedType(StateTypes.COPPER_BULB).build();
|
||||
public static ItemType EXPOSED_COPPER_BULB = builder("exposed_copper_bulb").setMaxAmount(64).setPlacedType(StateTypes.EXPOSED_COPPER_BULB).build();
|
||||
public static ItemType WEATHERED_COPPER_BULB = builder("weathered_copper_bulb").setMaxAmount(64).setPlacedType(StateTypes.WEATHERED_COPPER_BULB).build();
|
||||
public static ItemType OXIDIZED_COPPER_BULB = builder("oxidized_copper_bulb").setMaxAmount(64).setPlacedType(StateTypes.OXIDIZED_COPPER_BULB).build();
|
||||
public static ItemType WAXED_COPPER_BULB = builder("waxed_copper_bulb").setMaxAmount(64).setPlacedType(StateTypes.WAXED_COPPER_BULB).build();
|
||||
public static ItemType WAXED_EXPOSED_COPPER_BULB = builder("waxed_exposed_copper_bulb").setMaxAmount(64).setPlacedType(StateTypes.WAXED_EXPOSED_COPPER_BULB).build();
|
||||
public static ItemType WAXED_WEATHERED_COPPER_BULB = builder("waxed_weathered_copper_bulb").setMaxAmount(64).setPlacedType(StateTypes.WAXED_WEATHERED_COPPER_BULB).build();
|
||||
public static ItemType WAXED_OXIDIZED_COPPER_BULB = builder("waxed_oxidized_copper_bulb").setMaxAmount(64).setPlacedType(StateTypes.WAXED_OXIDIZED_COPPER_BULB).build();
|
||||
public static ItemType TRIAL_SPAWNER = builder("trial_spawner").setMaxAmount(64).setPlacedType(StateTypes.TRIAL_SPAWNER).build();
|
||||
public static ItemType TRIAL_KEY = builder("trial_key").setMaxAmount(64).build();
|
||||
|
||||
/**
|
||||
* @deprecated Burning furnace shows up as a missing texture, removed in 1.9
|
||||
*/
|
||||
@@ -1206,14 +1390,17 @@ public class ItemTypes {
|
||||
/**
|
||||
* @deprecated Fire was removed in 1.8 as an item
|
||||
*/
|
||||
@Deprecated
|
||||
public static final ItemType FIRE = builder("fire").setMaxAmount(64).build();
|
||||
/**
|
||||
* @deprecated Nether portals were removed in 1.8 as an item
|
||||
*/
|
||||
@Deprecated
|
||||
public static final ItemType NETHER_PORTAL = builder("nether_portal").setMaxAmount(1).build();
|
||||
/**
|
||||
* @deprecated End portals were removed in 1.8 as an item
|
||||
*/
|
||||
@Deprecated
|
||||
public static final ItemType END_PORTAL = builder("end_portal").setMaxAmount(1).build();
|
||||
|
||||
public static Collection<ItemType> values() {
|
||||
@@ -1221,7 +1408,7 @@ public class ItemTypes {
|
||||
}
|
||||
|
||||
public static Builder builder(String key) {
|
||||
return new Builder(key);
|
||||
return new Builder(key.toLowerCase());
|
||||
}
|
||||
|
||||
public static ItemType define(int maxAmount, String key, ItemType craftRemainder, StateType placedType, int maxDurability, List<ItemAttribute> attributesArr) {
|
||||
|
||||
+25
-4
@@ -33,6 +33,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
@@ -130,6 +131,16 @@ public class NBTCodec {
|
||||
else if (nbt instanceof NBTEnd) {
|
||||
throw new IllegalStateException("Encountered the NBTEnd tag during the NBT to JSON conversion: " + nbt.toString());
|
||||
}
|
||||
else if (nbt instanceof NBTCompound) {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
Map<String, NBT> compoundTags = ((NBTCompound)nbt).getTags();
|
||||
for (String tagName : compoundTags.keySet()) {
|
||||
NBT tag = compoundTags.get(tagName);
|
||||
JsonElement jsonValue = nbtToJson(tag, parseByteAsBool);
|
||||
jsonObject.add(tagName, jsonValue);
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("Failed to convert NBT to JSON.");
|
||||
}
|
||||
@@ -137,10 +148,15 @@ public class NBTCodec {
|
||||
//PacketEvents end
|
||||
|
||||
public static NBTCompound readNBTFromBuffer(Object byteBuf, ServerVersion serverVersion) {
|
||||
return (NBTCompound) readRawNBTFromBuffer(byteBuf, serverVersion);
|
||||
}
|
||||
|
||||
public static NBT readRawNBTFromBuffer(Object byteBuf, ServerVersion serverVersion) {
|
||||
if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) {
|
||||
try {
|
||||
return (NBTCompound) DefaultNBTSerializer.INSTANCE.deserializeTag(
|
||||
new ByteBufInputStream(byteBuf));
|
||||
final boolean named = serverVersion.isOlderThan(ServerVersion.V_1_20_2);
|
||||
return DefaultNBTSerializer.INSTANCE.deserializeTag(
|
||||
new ByteBufInputStream(byteBuf), named);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -154,7 +170,7 @@ public class NBTCodec {
|
||||
Object slicedBuffer = ByteBufHelper.readSlice(byteBuf, length);
|
||||
try (DataInputStream stream = new DataInputStream(
|
||||
new GZIPInputStream(new ByteBufInputStream(slicedBuffer)))) {
|
||||
return (NBTCompound) DefaultNBTSerializer.INSTANCE.deserializeTag(stream);
|
||||
return DefaultNBTSerializer.INSTANCE.deserializeTag(stream);
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
@@ -165,10 +181,15 @@ public class NBTCodec {
|
||||
}
|
||||
|
||||
public static void writeNBTToBuffer(Object byteBuf, ServerVersion serverVersion, NBTCompound tag) {
|
||||
writeNBTToBuffer(byteBuf, serverVersion, (NBT) tag);
|
||||
}
|
||||
|
||||
public static void writeNBTToBuffer(Object byteBuf, ServerVersion serverVersion, NBT tag) {
|
||||
if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) {
|
||||
try (ByteBufOutputStream outputStream = new ByteBufOutputStream(byteBuf)) {
|
||||
if (tag != null) {
|
||||
DefaultNBTSerializer.INSTANCE.serializeTag(outputStream, tag);
|
||||
boolean named = serverVersion.isOlderThan(ServerVersion.V_1_20_2);
|
||||
DefaultNBTSerializer.INSTANCE.serializeTag(outputStream, tag, named);
|
||||
} else {
|
||||
DefaultNBTSerializer.INSTANCE.serializeTag(outputStream, NBTEnd.INSTANCE);
|
||||
}
|
||||
|
||||
+14
-2
@@ -47,21 +47,33 @@ public class NBTSerializer<IN, OUT> {
|
||||
}
|
||||
|
||||
public NBT deserializeTag(IN from) throws IOException {
|
||||
return deserializeTag(from, true);
|
||||
}
|
||||
|
||||
public NBT deserializeTag(IN from, boolean named) throws IOException {
|
||||
NBTType<?> type = readTagType(from);
|
||||
if (type == NBTType.END) {
|
||||
return null;
|
||||
}
|
||||
readTagName(from);
|
||||
if (named) {
|
||||
readTagName(from);
|
||||
}
|
||||
return readTag(from, type);
|
||||
}
|
||||
|
||||
public void serializeTag(OUT to, NBT tag) throws IOException {
|
||||
serializeTag(to, tag, true);
|
||||
}
|
||||
|
||||
public void serializeTag(OUT to, NBT tag, boolean named) throws IOException {
|
||||
NBTType<?> type = tag.getType();
|
||||
writeTagType(to, type);
|
||||
if (tag.getType() == NBTType.END) {
|
||||
return;
|
||||
}
|
||||
writeTagName(to, "");
|
||||
if (named) {
|
||||
writeTagName(to, "");
|
||||
}
|
||||
writeTag(to, tag);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,11 @@ package com.github.retrooper.packetevents.protocol.npc;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.player.*;
|
||||
import com.github.retrooper.packetevents.protocol.world.Location;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
@@ -33,6 +35,7 @@ import java.util.*;
|
||||
public class NPC {
|
||||
private final int id;
|
||||
private final UserProfile profile;
|
||||
private GameMode gamemode;
|
||||
private Component tabName;
|
||||
private NamedTextColor nameColor;
|
||||
private Component prefixName;
|
||||
@@ -47,10 +50,11 @@ public class NPC {
|
||||
private ItemStack boots = null;
|
||||
private final Set<Object> channels = new HashSet<>();
|
||||
|
||||
public NPC(UserProfile profile, int entityId, @Nullable Component tabName, @Nullable NamedTextColor nameColor,
|
||||
public NPC(UserProfile profile, int entityId, GameMode gamemode, @Nullable Component tabName, @Nullable NamedTextColor nameColor,
|
||||
@Nullable Component prefixName, @Nullable Component suffixName) {
|
||||
this.profile = profile;
|
||||
this.id = entityId;
|
||||
this.gamemode = gamemode;
|
||||
|
||||
this.tabName = tabName;
|
||||
this.nameColor = nameColor;
|
||||
@@ -59,7 +63,7 @@ public class NPC {
|
||||
}
|
||||
|
||||
public NPC(UserProfile profile, int entityId, @Nullable Component tabName) {
|
||||
this(profile, entityId, tabName, null, null, null);
|
||||
this(profile, entityId, GameMode.SURVIVAL, tabName, null, null, null);
|
||||
}
|
||||
|
||||
public NPC(UserProfile profile, int entityId) {
|
||||
@@ -72,15 +76,28 @@ public class NPC {
|
||||
|
||||
public void spawn(Object channel) {
|
||||
if (hasSpawned(channel)) return;
|
||||
WrapperPlayServerPlayerInfo playerInfoPacket =
|
||||
new WrapperPlayServerPlayerInfo(WrapperPlayServerPlayerInfo.Action.ADD_PLAYER, getPlayerInfoData());
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(channel, playerInfoPacket);
|
||||
PacketWrapper<?> playerInfo;
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_19_3)) {
|
||||
playerInfo = new WrapperPlayServerPlayerInfoUpdate(WrapperPlayServerPlayerInfoUpdate.Action.ADD_PLAYER,
|
||||
getModernPlayerInfoData());
|
||||
}
|
||||
else {
|
||||
playerInfo = new WrapperPlayServerPlayerInfo(WrapperPlayServerPlayerInfo.Action.ADD_PLAYER, getLegacyPlayerInfoData());
|
||||
}
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(channel, playerInfo);
|
||||
|
||||
//TODO Later if we want entity metadata, its not supported on newer server versions though(confirm if its mandatory on older versions)
|
||||
WrapperPlayServerSpawnPlayer spawnPlayer = new WrapperPlayServerSpawnPlayer(getId(),
|
||||
getProfile().getUUID(),
|
||||
getLocation());
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(channel, spawnPlayer);
|
||||
|
||||
PacketWrapper<?> spawnPacket;
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_20_2)) {
|
||||
spawnPacket = new WrapperPlayServerSpawnEntity(getId(), getProfile().getUUID(), EntityTypes.PLAYER, getLocation(), getLocation().getYaw(), 0, null);
|
||||
}
|
||||
else {
|
||||
spawnPacket = new WrapperPlayServerSpawnPlayer(getId(),
|
||||
getProfile().getUUID(),
|
||||
getLocation());
|
||||
}
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(channel, spawnPacket);
|
||||
|
||||
//Create team
|
||||
if (getNameColor() != null || getPrefixName() != null
|
||||
@@ -181,16 +198,44 @@ public class NPC {
|
||||
public void updateTabPing(int ping) {
|
||||
setDisplayPing(ping);
|
||||
for (Object channel : channels) {
|
||||
WrapperPlayServerPlayerInfo playerInfo =
|
||||
new WrapperPlayServerPlayerInfo(WrapperPlayServerPlayerInfo.Action.UPDATE_LATENCY, getPlayerInfoData());
|
||||
PacketWrapper<?> playerInfo;
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_19_3)) {
|
||||
playerInfo = new WrapperPlayServerPlayerInfoUpdate(WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_LATENCY, getModernPlayerInfoData());
|
||||
}
|
||||
else {
|
||||
playerInfo =
|
||||
new WrapperPlayServerPlayerInfo(WrapperPlayServerPlayerInfo.Action.UPDATE_LATENCY, getLegacyPlayerInfoData());
|
||||
}
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(channel, playerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateGameMode(GameMode gamemode) {
|
||||
setGameMode(gamemode);
|
||||
for (Object channel : channels) {
|
||||
PacketWrapper<?> playerInfo;
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_19_3)) {
|
||||
playerInfo = new WrapperPlayServerPlayerInfoUpdate(WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_GAME_MODE,
|
||||
getModernPlayerInfoData());
|
||||
}
|
||||
else {
|
||||
playerInfo =
|
||||
new WrapperPlayServerPlayerInfo(WrapperPlayServerPlayerInfo.Action.UPDATE_GAME_MODE, getLegacyPlayerInfoData());
|
||||
}
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(channel, playerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeSkin(UUID skinUUID, List<TextureProperty> skinTextureProperties) {
|
||||
for (Object channel : channels) {
|
||||
WrapperPlayServerPlayerInfo playerInfoRemove =
|
||||
new WrapperPlayServerPlayerInfo(WrapperPlayServerPlayerInfo.Action.REMOVE_PLAYER, getPlayerInfoData());
|
||||
PacketWrapper<?> playerInfoRemove;
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_19_3)) {
|
||||
playerInfoRemove = new WrapperPlayServerPlayerInfoRemove(getProfile().getUUID());
|
||||
}
|
||||
else {
|
||||
playerInfoRemove =
|
||||
new WrapperPlayServerPlayerInfo(WrapperPlayServerPlayerInfo.Action.REMOVE_PLAYER, getLegacyPlayerInfoData());
|
||||
}
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(channel, playerInfoRemove);
|
||||
|
||||
WrapperPlayServerDestroyEntities destroyEntities =
|
||||
@@ -199,8 +244,15 @@ public class NPC {
|
||||
|
||||
getProfile().setTextureProperties(skinTextureProperties);
|
||||
getProfile().setUUID(skinUUID);
|
||||
WrapperPlayServerPlayerInfo playerInfoAdd =
|
||||
new WrapperPlayServerPlayerInfo(WrapperPlayServerPlayerInfo.Action.ADD_PLAYER, getPlayerInfoData());
|
||||
PacketWrapper<?> playerInfoAdd;
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_19_3)) {
|
||||
playerInfoAdd = new WrapperPlayServerPlayerInfoUpdate(WrapperPlayServerPlayerInfoUpdate.Action.ADD_PLAYER,
|
||||
getModernPlayerInfoData());
|
||||
}
|
||||
else {
|
||||
playerInfoAdd =
|
||||
new WrapperPlayServerPlayerInfo(WrapperPlayServerPlayerInfo.Action.ADD_PLAYER, getLegacyPlayerInfoData());
|
||||
}
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(channel, playerInfoAdd);
|
||||
|
||||
WrapperPlayServerSpawnPlayer spawnPlayer =
|
||||
@@ -209,7 +261,7 @@ public class NPC {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateNameTag(NPC npc) {
|
||||
public void updateNameTag() {
|
||||
for (Object channel : channels) {
|
||||
//Destroy team
|
||||
WrapperPlayServerTeams removeTeam =
|
||||
@@ -218,8 +270,8 @@ public class NPC {
|
||||
Optional.empty());
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(channel, removeTeam);
|
||||
|
||||
if (npc.getNameColor() != null || npc.getPrefixName() != null
|
||||
|| npc.getSuffixName() != null) {
|
||||
if (this.getNameColor() != null || this.getPrefixName() != null
|
||||
|| this.getSuffixName() != null) {
|
||||
PacketEvents.getAPI().getProtocolManager().sendPacket(channel, generateTeamsData());
|
||||
}
|
||||
}
|
||||
@@ -367,6 +419,14 @@ public class NPC {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public GameMode getGameMode() {
|
||||
return gamemode;
|
||||
}
|
||||
|
||||
public void setGameMode(GameMode gamemode) {
|
||||
this.gamemode = gamemode;
|
||||
}
|
||||
|
||||
private WrapperPlayServerTeams generateTeamsData() {
|
||||
return new WrapperPlayServerTeams("custom_name_team",
|
||||
WrapperPlayServerTeams.TeamMode.CREATE,
|
||||
@@ -383,12 +443,17 @@ public class NPC {
|
||||
getProfile().getName());
|
||||
}
|
||||
|
||||
public WrapperPlayServerPlayerInfo.PlayerData getPlayerInfoData() {
|
||||
public WrapperPlayServerPlayerInfo.PlayerData getLegacyPlayerInfoData() {
|
||||
return new WrapperPlayServerPlayerInfo.PlayerData(getTabName(),
|
||||
getProfile(), GameMode.SURVIVAL,
|
||||
getProfile(), getGameMode(),
|
||||
getDisplayPing());
|
||||
}
|
||||
|
||||
public WrapperPlayServerPlayerInfoUpdate.PlayerInfo getModernPlayerInfoData() {
|
||||
return new WrapperPlayServerPlayerInfoUpdate.PlayerInfo(getProfile(), true,
|
||||
getDisplayPing(), getGameMode(), getTabName(), null);
|
||||
}
|
||||
|
||||
public int getDisplayPing() {
|
||||
return displayPing;
|
||||
}
|
||||
@@ -404,4 +469,8 @@ public class NPC {
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public Set<Object> getChannels() {
|
||||
return channels;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.github.retrooper.packetevents.protocol.packettype;
|
||||
|
||||
/**
|
||||
* A Marker interface used to indicate that this packet is originating on
|
||||
* the server, and is bound to the client.
|
||||
*/
|
||||
public interface ClientBoundPacket {
|
||||
|
||||
}
|
||||
+293
-23
@@ -20,8 +20,46 @@ package com.github.retrooper.packetevents.protocol.packettype;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.ConnectionState;
|
||||
import com.github.retrooper.packetevents.protocol.PacketSide;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.*;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.*;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_12;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_12_1;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_13;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_14;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_14_4;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_15;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_15_2;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_16;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_16_2;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_17;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_18;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_19;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_19_1;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_19_3;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_19_4;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_20_2;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_20_3;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_7_10;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_8;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_9;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.clientbound.ClientboundPacketType_1_9_3;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.config.clientbound.ClientboundConfigPacketType_1_20_2;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.config.clientbound.ClientboundConfigPacketType_1_20_3;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_12;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_12_1;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_13;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_14;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_15_2;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_16;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_16_2;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_17;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_19;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_19_1;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_19_3;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_19_4;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_20_2;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_20_3;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_7_10;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_8;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.serverbound.ServerboundPacketType_1_9;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.util.VersionMapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -50,7 +88,11 @@ public final class PacketType {
|
||||
ClientVersion.V_1_17,
|
||||
ClientVersion.V_1_18,
|
||||
ClientVersion.V_1_19,
|
||||
ClientVersion.V_1_19_1);
|
||||
ClientVersion.V_1_19_1,
|
||||
ClientVersion.V_1_19_3,
|
||||
ClientVersion.V_1_19_4,
|
||||
ClientVersion.V_1_20_2,
|
||||
ClientVersion.V_1_20_3);
|
||||
|
||||
//TODO UPDATE Update packet type mappings (serverbound pt. 1)
|
||||
private static final VersionMapper SERVERBOUND_PLAY_VERSION_MAPPER = new VersionMapper(
|
||||
@@ -66,11 +108,21 @@ public final class PacketType {
|
||||
ClientVersion.V_1_16_2,
|
||||
ClientVersion.V_1_17,
|
||||
ClientVersion.V_1_19,
|
||||
ClientVersion.V_1_19_1);
|
||||
ClientVersion.V_1_19_1,
|
||||
ClientVersion.V_1_19_3,
|
||||
ClientVersion.V_1_19_4,
|
||||
ClientVersion.V_1_20_2,
|
||||
ClientVersion.V_1_20_3);
|
||||
|
||||
//TODO UPDATE Update packet type mappings (config clientbound pt. 1)
|
||||
private static final VersionMapper CLIENTBOUND_CONFIG_VERSION_MAPPER = new VersionMapper(
|
||||
ClientVersion.V_1_20_2,
|
||||
ClientVersion.V_1_20_3);
|
||||
|
||||
public static void prepare() {
|
||||
PacketType.Play.Client.load();
|
||||
PacketType.Play.Server.load();
|
||||
PacketType.Configuration.Server.load();
|
||||
PREPARED = true;
|
||||
}
|
||||
|
||||
@@ -104,13 +156,19 @@ public final class PacketType {
|
||||
} else {
|
||||
return Play.Server.getById(version, packetID);
|
||||
}
|
||||
case CONFIGURATION:
|
||||
if (side == PacketSide.CLIENT) {
|
||||
return Configuration.Client.getById(packetID);
|
||||
} else {
|
||||
return Configuration.Server.getById(version, packetID);
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handshaking {
|
||||
public enum Client implements PacketTypeConstant {
|
||||
public enum Client implements PacketTypeConstant, ServerBoundPacket {
|
||||
HANDSHAKE(0),
|
||||
/**
|
||||
* Technically not part of the current protocol, but clients older than 1.7 will send this to initiate Server List Ping.
|
||||
@@ -138,9 +196,14 @@ public final class PacketType {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketSide getSide() {
|
||||
return PacketSide.CLIENT;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Server implements PacketTypeConstant {
|
||||
public enum Server implements PacketTypeConstant, ClientBoundPacket {
|
||||
LEGACY_SERVER_LIST_RESPONSE(254); //0xFE in hex
|
||||
|
||||
private final int id;
|
||||
@@ -157,11 +220,16 @@ public final class PacketType {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketSide getSide() {
|
||||
return PacketSide.SERVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Status {
|
||||
public enum Client implements PacketTypeConstant {
|
||||
public enum Client implements PacketTypeConstant, ServerBoundPacket {
|
||||
REQUEST(0),
|
||||
PING(1);
|
||||
|
||||
@@ -185,9 +253,15 @@ public final class PacketType {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PacketSide getSide() {
|
||||
return PacketSide.CLIENT;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Server implements PacketTypeConstant {
|
||||
public enum Server implements PacketTypeConstant, ClientBoundPacket {
|
||||
RESPONSE(0),
|
||||
PONG(1);
|
||||
|
||||
@@ -211,15 +285,22 @@ public final class PacketType {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketSide getSide() {
|
||||
return PacketSide.SERVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Login {
|
||||
public enum Client implements PacketTypeConstant {
|
||||
public enum Client implements PacketTypeConstant, ServerBoundPacket {
|
||||
LOGIN_START(0),
|
||||
ENCRYPTION_RESPONSE(1),
|
||||
///Added in 1.13
|
||||
LOGIN_PLUGIN_RESPONSE(2);
|
||||
LOGIN_PLUGIN_RESPONSE(2),
|
||||
//Added in 1.20.2
|
||||
LOGIN_SUCCESS_ACK(3);
|
||||
|
||||
private final int id;
|
||||
|
||||
@@ -235,6 +316,8 @@ public final class PacketType {
|
||||
return ENCRYPTION_RESPONSE;
|
||||
} else if (packetID == 2) {
|
||||
return LOGIN_PLUGIN_RESPONSE;
|
||||
} else if (packetID == 3) {
|
||||
return LOGIN_SUCCESS_ACK;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -243,9 +326,14 @@ public final class PacketType {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketSide getSide() {
|
||||
return PacketSide.CLIENT;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Server implements PacketTypeConstant {
|
||||
public enum Server implements PacketTypeConstant, ClientBoundPacket {
|
||||
DISCONNECT(0),
|
||||
ENCRYPTION_REQUEST(1),
|
||||
LOGIN_SUCCESS(2),
|
||||
@@ -281,11 +369,144 @@ public final class PacketType {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketSide getSide() {
|
||||
return PacketSide.SERVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Added in 1.20.2
|
||||
public static class Configuration {
|
||||
|
||||
public enum Client implements PacketTypeConstant, ServerBoundPacket {
|
||||
|
||||
CLIENT_SETTINGS(0x00),
|
||||
PLUGIN_MESSAGE(0x01),
|
||||
CONFIGURATION_END_ACK(0x02),
|
||||
KEEP_ALIVE(0x03),
|
||||
PONG(0x04),
|
||||
RESOURCE_PACK_STATUS(0x05);
|
||||
|
||||
private final int id;
|
||||
|
||||
Client(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static @Nullable PacketTypeCommon getById(int packetId) {
|
||||
switch (packetId) {
|
||||
case 0x00:
|
||||
return CLIENT_SETTINGS;
|
||||
case 0x01:
|
||||
return PLUGIN_MESSAGE;
|
||||
case 0x02:
|
||||
return CONFIGURATION_END_ACK;
|
||||
case 0x03:
|
||||
return KEEP_ALIVE;
|
||||
case 0x04:
|
||||
return PONG;
|
||||
case 0x05:
|
||||
return RESOURCE_PACK_STATUS;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketSide getSide() {
|
||||
return PacketSide.CLIENT;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Server implements PacketTypeCommon, ClientBoundPacket {
|
||||
|
||||
PLUGIN_MESSAGE,
|
||||
DISCONNECT,
|
||||
CONFIGURATION_END,
|
||||
KEEP_ALIVE,
|
||||
PING,
|
||||
REGISTRY_DATA,
|
||||
RESOURCE_PACK_SEND,
|
||||
UPDATE_ENABLED_FEATURES,
|
||||
UPDATE_TAGS,
|
||||
|
||||
// added in 1.20.3
|
||||
RESOURCE_PACK_REMOVE;
|
||||
|
||||
private static int INDEX = 0;
|
||||
private static final Map<Byte, Map<Integer, PacketTypeCommon>> PACKET_TYPE_ID_MAP = new HashMap<>();
|
||||
private final int[] ids;
|
||||
|
||||
Server() {
|
||||
this.ids = new int[CLIENTBOUND_CONFIG_VERSION_MAPPER.getVersions().length];
|
||||
Arrays.fill(this.ids, -1);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
INDEX = 0;
|
||||
loadPacketIds(ClientboundConfigPacketType_1_20_2.values());
|
||||
loadPacketIds(ClientboundConfigPacketType_1_20_3.values());
|
||||
// TODO UPDATE Update packet type mappings (config clientbound pt. 2)
|
||||
}
|
||||
|
||||
private static void loadPacketIds(Enum<?>[] enumConstants) {
|
||||
int index = INDEX;
|
||||
for (Enum<?> constant : enumConstants) {
|
||||
int id = constant.ordinal();
|
||||
Configuration.Server value = Configuration.Server.valueOf(constant.name());
|
||||
value.ids[index] = id;
|
||||
Map<Integer, PacketTypeCommon> packetIdMap = PACKET_TYPE_ID_MAP.computeIfAbsent((byte) index, k -> new HashMap<>());
|
||||
packetIdMap.put(id, value);
|
||||
}
|
||||
INDEX++;
|
||||
}
|
||||
|
||||
public static @Nullable PacketTypeCommon getById(int packetId) {
|
||||
return getById(ClientVersion.getLatest(), packetId);
|
||||
}
|
||||
|
||||
public static @Nullable PacketTypeCommon getById(ClientVersion version, int packetId) {
|
||||
if (!PREPARED) {
|
||||
PacketType.prepare();
|
||||
}
|
||||
int index = CLIENTBOUND_CONFIG_VERSION_MAPPER.getIndex(version);
|
||||
Map<Integer, PacketTypeCommon> map = PACKET_TYPE_ID_MAP.get((byte) index);
|
||||
return map.get(packetId);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getId() {
|
||||
return this.getId(ClientVersion.getLatest());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId(ClientVersion version) {
|
||||
if (!PREPARED) {
|
||||
PacketType.prepare();
|
||||
}
|
||||
int index = CLIENTBOUND_CONFIG_VERSION_MAPPER.getIndex(version);
|
||||
return this.ids[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketSide getSide() {
|
||||
return PacketSide.SERVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Play {
|
||||
public enum Client implements PacketTypeCommon {
|
||||
public enum Client implements PacketTypeCommon, ServerBoundPacket {
|
||||
//Packets that no longer exist on the latest version
|
||||
CHAT_PREVIEW,
|
||||
|
||||
TELEPORT_CONFIRM,
|
||||
QUERY_BLOCK_NBT,
|
||||
SET_DIFFICULTY,
|
||||
@@ -338,9 +559,16 @@ public final class PacketType {
|
||||
USE_ITEM,
|
||||
//Added in 1.19
|
||||
CHAT_COMMAND,
|
||||
CHAT_PREVIEW,
|
||||
//Added in 1.19.1
|
||||
CHAT_ACK;
|
||||
CHAT_ACK,
|
||||
//Added in 1.19.3
|
||||
CHAT_SESSION_UPDATE,
|
||||
//Added in 1.20.2
|
||||
CHUNK_BATCH_ACK,
|
||||
CONFIGURATION_ACK,
|
||||
DEBUG_PING,
|
||||
//Added in 1.20.3
|
||||
SLOT_STATE_CHANGE;
|
||||
|
||||
private static int INDEX = 0;
|
||||
private static final Map<Byte, Map<Integer, PacketTypeCommon>> PACKET_TYPE_ID_MAP = new HashMap<>();
|
||||
@@ -357,7 +585,7 @@ public final class PacketType {
|
||||
PacketType.prepare();
|
||||
}
|
||||
int index = SERVERBOUND_PLAY_VERSION_MAPPER.getIndex(version);
|
||||
Map<Integer, PacketTypeCommon> packetIdMap = PACKET_TYPE_ID_MAP.computeIfAbsent((byte)index, k -> new HashMap<>());
|
||||
Map<Integer, PacketTypeCommon> packetIdMap = PACKET_TYPE_ID_MAP.computeIfAbsent((byte) index, k -> new HashMap<>());
|
||||
return packetIdMap.get(packetId);
|
||||
}
|
||||
|
||||
@@ -389,6 +617,10 @@ public final class PacketType {
|
||||
loadPacketIds(ServerboundPacketType_1_17.values());
|
||||
loadPacketIds(ServerboundPacketType_1_19.values());
|
||||
loadPacketIds(ServerboundPacketType_1_19_1.values());
|
||||
loadPacketIds(ServerboundPacketType_1_19_3.values());
|
||||
loadPacketIds(ServerboundPacketType_1_19_4.values());
|
||||
loadPacketIds(ServerboundPacketType_1_20_2.values());
|
||||
loadPacketIds(ServerboundPacketType_1_20_3.values());
|
||||
//TODO UPDATE Update packet type mappings (serverbound pt. 2)
|
||||
}
|
||||
|
||||
@@ -399,9 +631,14 @@ public final class PacketType {
|
||||
int index = SERVERBOUND_PLAY_VERSION_MAPPER.getIndex(version);
|
||||
return ids[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketSide getSide() {
|
||||
return PacketSide.CLIENT;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Server implements PacketTypeCommon {
|
||||
public enum Server implements PacketTypeCommon, ClientBoundPacket {
|
||||
//Packets that are no longer present on latest version
|
||||
SET_COMPRESSION,
|
||||
MAP_CHUNK_BULK,
|
||||
@@ -417,12 +654,18 @@ public final class PacketType {
|
||||
SPAWN_PAINTING,
|
||||
SCULK_VIBRATION_SIGNAL,
|
||||
ACKNOWLEDGE_PLAYER_DIGGING,
|
||||
CHAT_PREVIEW_PACKET,
|
||||
NAMED_SOUND_EFFECT,
|
||||
PLAYER_CHAT_HEADER,
|
||||
PLAYER_INFO,
|
||||
DISPLAY_CHAT_PREVIEW,
|
||||
UPDATE_ENABLED_FEATURES,
|
||||
SPAWN_PLAYER,
|
||||
|
||||
//Okay these are normal ones
|
||||
WINDOW_CONFIRMATION,
|
||||
SPAWN_ENTITY,
|
||||
SPAWN_EXPERIENCE_ORB,
|
||||
SPAWN_PLAYER,
|
||||
ENTITY_ANIMATION,
|
||||
STATISTICS,
|
||||
BLOCK_BREAK_ANIMATION,
|
||||
@@ -441,7 +684,6 @@ public final class PacketType {
|
||||
SET_SLOT,
|
||||
SET_COOLDOWN,
|
||||
PLUGIN_MESSAGE,
|
||||
NAMED_SOUND_EFFECT,
|
||||
DISCONNECT,
|
||||
ENTITY_STATUS,
|
||||
EXPLOSION,
|
||||
@@ -470,7 +712,6 @@ public final class PacketType {
|
||||
END_COMBAT_EVENT,
|
||||
ENTER_COMBAT_EVENT,
|
||||
DEATH_COMBAT_EVENT,
|
||||
PLAYER_INFO,
|
||||
FACE_PLAYER,
|
||||
PLAYER_POSITION_AND_LOOK,
|
||||
UNLOCK_RECIPES,
|
||||
@@ -523,15 +764,35 @@ public final class PacketType {
|
||||
|
||||
//Added in 1.19
|
||||
ACKNOWLEDGE_BLOCK_CHANGES,
|
||||
CHAT_PREVIEW_PACKET,
|
||||
SERVER_DATA,
|
||||
DISPLAY_CHAT_PREVIEW,
|
||||
SYSTEM_CHAT_MESSAGE,
|
||||
|
||||
//Added in 1.19.1
|
||||
DELETE_CHAT,
|
||||
PLAYER_CHAT_HEADER,
|
||||
CUSTOM_CHAT_COMPLETIONS;
|
||||
CUSTOM_CHAT_COMPLETIONS,
|
||||
|
||||
//Added in 1.19.3
|
||||
DISGUISED_CHAT,
|
||||
PLAYER_INFO_REMOVE,
|
||||
PLAYER_INFO_UPDATE,
|
||||
|
||||
//Added in 1.19.4
|
||||
DAMAGE_EVENT,
|
||||
HURT_ANIMATION,
|
||||
BUNDLE,
|
||||
CHUNK_BIOMES,
|
||||
|
||||
//Added in 1.20.2
|
||||
CHUNK_BATCH_END,
|
||||
CHUNK_BATCH_BEGIN,
|
||||
DEBUG_PONG,
|
||||
CONFIGURATION_START,
|
||||
|
||||
//Added in 1.20.3
|
||||
RESET_SCORE,
|
||||
RESOURCE_PACK_REMOVE,
|
||||
TICKING_STATE,
|
||||
TICKING_STEP;
|
||||
|
||||
private static int INDEX = 0;
|
||||
private static final Map<Byte, Map<Integer, PacketTypeCommon>> PACKET_TYPE_ID_MAP = new HashMap<>();
|
||||
@@ -560,6 +821,11 @@ public final class PacketType {
|
||||
return map.get(packetId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketSide getSide() {
|
||||
return PacketSide.SERVER;
|
||||
}
|
||||
|
||||
private static void loadPacketIds(Enum<?>[] enumConstants) {
|
||||
int index = INDEX;
|
||||
for (Enum<?> constant : enumConstants) {
|
||||
@@ -591,6 +857,10 @@ public final class PacketType {
|
||||
loadPacketIds(ClientboundPacketType_1_18.values());
|
||||
loadPacketIds(ClientboundPacketType_1_19.values());
|
||||
loadPacketIds(ClientboundPacketType_1_19_1.values());
|
||||
loadPacketIds(ClientboundPacketType_1_19_3.values());
|
||||
loadPacketIds(ClientboundPacketType_1_19_4.values());
|
||||
loadPacketIds(ClientboundPacketType_1_20_2.values());
|
||||
loadPacketIds(ClientboundPacketType_1_20_3.values());
|
||||
//TODO UPDATE Update packet type mappings (clientbound pt. 2)
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.packettype;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.PacketSide;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
|
||||
public interface PacketTypeCommon {
|
||||
@@ -27,4 +28,6 @@ public interface PacketTypeCommon {
|
||||
}
|
||||
|
||||
int getId(ClientVersion version);
|
||||
|
||||
PacketSide getSide();
|
||||
}
|
||||
+1
-1
@@ -20,7 +20,7 @@ package com.github.retrooper.packetevents.protocol.packettype;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
|
||||
public interface PacketTypeConstant extends PacketTypeCommon{
|
||||
public interface PacketTypeConstant extends PacketTypeCommon {
|
||||
default int getId(ClientVersion version) {
|
||||
return getId();
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.github.retrooper.packetevents.protocol.packettype;
|
||||
|
||||
/**
|
||||
* A Marker interface used to indicate that this packet is originating on
|
||||
* the client, and is bound to the server.
|
||||
*/
|
||||
public interface ServerBoundPacket {
|
||||
}
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.packettype.clientbound;
|
||||
|
||||
public enum ClientboundPacketType_1_19_3 {
|
||||
SPAWN_ENTITY,
|
||||
SPAWN_EXPERIENCE_ORB,
|
||||
|
||||
//Removed in 1.19
|
||||
//SPAWN_LIVING_ENTITY,
|
||||
//SPAWN_PAINTING,
|
||||
|
||||
SPAWN_PLAYER,
|
||||
|
||||
//Removed in 1.19
|
||||
//SCULK_VIBRATION_SIGNAL,
|
||||
|
||||
ENTITY_ANIMATION,
|
||||
STATISTICS,
|
||||
//Removed in 1.19 and replaced with ACKNOWLEDGE_BLOCK_CHANGES
|
||||
//ACKNOWLEDGE_PLAYER_DIGGING,
|
||||
|
||||
//Added in 1.19
|
||||
ACKNOWLEDGE_BLOCK_CHANGES,
|
||||
|
||||
BLOCK_BREAK_ANIMATION,
|
||||
BLOCK_ENTITY_DATA,
|
||||
BLOCK_ACTION,
|
||||
BLOCK_CHANGE,
|
||||
BOSS_BAR,
|
||||
SERVER_DIFFICULTY,
|
||||
|
||||
//Removed in 1.19.3
|
||||
//CHAT_PREVIEW_PACKET,
|
||||
|
||||
CLEAR_TITLES,
|
||||
TAB_COMPLETE,
|
||||
DECLARE_COMMANDS,
|
||||
CLOSE_WINDOW,
|
||||
WINDOW_ITEMS,
|
||||
WINDOW_PROPERTY,
|
||||
SET_SLOT,
|
||||
SET_COOLDOWN,
|
||||
|
||||
//Added in 1.19.1
|
||||
CUSTOM_CHAT_COMPLETIONS,
|
||||
|
||||
PLUGIN_MESSAGE,
|
||||
|
||||
//Removed in 1.19.3
|
||||
//NAMED_SOUND_EFFECT,
|
||||
|
||||
//Added in 1.19.1
|
||||
DELETE_CHAT,
|
||||
|
||||
DISCONNECT,
|
||||
|
||||
//Added in 1.19.3
|
||||
DISGUISED_CHAT,
|
||||
|
||||
ENTITY_STATUS,
|
||||
EXPLOSION,
|
||||
UNLOAD_CHUNK,
|
||||
CHANGE_GAME_STATE,
|
||||
OPEN_HORSE_WINDOW,
|
||||
INITIALIZE_WORLD_BORDER,
|
||||
KEEP_ALIVE,
|
||||
//This is also used for lighting
|
||||
CHUNK_DATA,
|
||||
EFFECT,
|
||||
PARTICLE,
|
||||
UPDATE_LIGHT,
|
||||
JOIN_GAME,
|
||||
MAP_DATA,
|
||||
MERCHANT_OFFERS,
|
||||
ENTITY_RELATIVE_MOVE,
|
||||
ENTITY_RELATIVE_MOVE_AND_ROTATION,
|
||||
ENTITY_ROTATION,
|
||||
VEHICLE_MOVE,
|
||||
OPEN_BOOK,
|
||||
OPEN_WINDOW,
|
||||
OPEN_SIGN_EDITOR,
|
||||
PING,
|
||||
CRAFT_RECIPE_RESPONSE,
|
||||
PLAYER_ABILITIES,
|
||||
|
||||
//Removed in 1.19.3
|
||||
//PLAYER_CHAT_HEADER,
|
||||
|
||||
//Interesting changes in 1.19. This is used by vanilla to broadcast messages sent by clients to all connected clients.
|
||||
CHAT_MESSAGE,
|
||||
|
||||
END_COMBAT_EVENT,
|
||||
ENTER_COMBAT_EVENT,
|
||||
DEATH_COMBAT_EVENT,
|
||||
|
||||
//Removed in 1.19.3 and replaced with PLAYER_INFO_REMOVE and PLAYER_INFO_UPDATE
|
||||
//PLAYER_INFO,
|
||||
|
||||
//Added in 1.19.3 (read comment above)
|
||||
PLAYER_INFO_REMOVE,
|
||||
PLAYER_INFO_UPDATE,
|
||||
|
||||
FACE_PLAYER,
|
||||
PLAYER_POSITION_AND_LOOK,
|
||||
UNLOCK_RECIPES,
|
||||
|
||||
DESTROY_ENTITIES,
|
||||
|
||||
REMOVE_ENTITY_EFFECT,
|
||||
RESOURCE_PACK_SEND,
|
||||
RESPAWN,
|
||||
ENTITY_HEAD_LOOK,
|
||||
MULTI_BLOCK_CHANGE,
|
||||
SELECT_ADVANCEMENTS_TAB,
|
||||
|
||||
//Added in 1.19. Seems like cancelling it surpresses the warning of messages not being verified on the client.
|
||||
SERVER_DATA,
|
||||
|
||||
ACTION_BAR,
|
||||
WORLD_BORDER_CENTER,
|
||||
WORLD_BORDER_LERP_SIZE,
|
||||
WORLD_BORDER_SIZE,
|
||||
WORLD_BORDER_WARNING_DELAY,
|
||||
WORLD_BORDER_WARNING_REACH,
|
||||
CAMERA,
|
||||
HELD_ITEM_CHANGE,
|
||||
UPDATE_VIEW_POSITION,
|
||||
UPDATE_VIEW_DISTANCE,
|
||||
SPAWN_POSITION,
|
||||
|
||||
//Deleted in 1.19.3
|
||||
//DISPLAY_CHAT_PREVIEW,
|
||||
|
||||
DISPLAY_SCOREBOARD,
|
||||
ENTITY_METADATA,
|
||||
ATTACH_ENTITY,
|
||||
ENTITY_VELOCITY,
|
||||
ENTITY_EQUIPMENT,
|
||||
SET_EXPERIENCE,
|
||||
UPDATE_HEALTH,
|
||||
SCOREBOARD_OBJECTIVE,
|
||||
SET_PASSENGERS,
|
||||
TEAMS,
|
||||
UPDATE_SCORE,
|
||||
UPDATE_SIMULATION_DISTANCE,
|
||||
SET_TITLE_SUBTITLE,
|
||||
TIME_UPDATE,
|
||||
SET_TITLE_TEXT,
|
||||
SET_TITLE_TIMES,
|
||||
ENTITY_SOUND_EFFECT,
|
||||
SOUND_EFFECT,
|
||||
STOP_SOUND,
|
||||
|
||||
//Added in 1.19. This is now used only for system messages by vanilla.
|
||||
SYSTEM_CHAT_MESSAGE,
|
||||
|
||||
PLAYER_LIST_HEADER_AND_FOOTER,
|
||||
NBT_QUERY_RESPONSE,
|
||||
COLLECT_ITEM,
|
||||
ENTITY_TELEPORT,
|
||||
UPDATE_ADVANCEMENTS,
|
||||
UPDATE_ATTRIBUTES,
|
||||
|
||||
//Added in 1.19.3
|
||||
UPDATE_ENABLED_FEATURES,
|
||||
|
||||
ENTITY_EFFECT,
|
||||
DECLARE_RECIPES,
|
||||
TAGS
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.packettype.clientbound;
|
||||
|
||||
public enum ClientboundPacketType_1_19_4 {
|
||||
BUNDLE, // New packet
|
||||
SPAWN_ENTITY,
|
||||
SPAWN_EXPERIENCE_ORB,
|
||||
SPAWN_PLAYER,
|
||||
ENTITY_ANIMATION,
|
||||
STATISTICS,
|
||||
ACKNOWLEDGE_BLOCK_CHANGES,
|
||||
BLOCK_BREAK_ANIMATION,
|
||||
BLOCK_ENTITY_DATA,
|
||||
BLOCK_ACTION,
|
||||
BLOCK_CHANGE,
|
||||
BOSS_BAR,
|
||||
SERVER_DIFFICULTY,
|
||||
CHUNK_BIOMES,
|
||||
CLEAR_TITLES,
|
||||
TAB_COMPLETE,
|
||||
DECLARE_COMMANDS,
|
||||
CLOSE_WINDOW,
|
||||
WINDOW_ITEMS,
|
||||
WINDOW_PROPERTY,
|
||||
SET_SLOT,
|
||||
SET_COOLDOWN,
|
||||
CUSTOM_CHAT_COMPLETIONS,
|
||||
PLUGIN_MESSAGE,
|
||||
DAMAGE_EVENT, // New packet
|
||||
DELETE_CHAT,
|
||||
DISCONNECT,
|
||||
DISGUISED_CHAT,
|
||||
ENTITY_STATUS,
|
||||
EXPLOSION,
|
||||
UNLOAD_CHUNK,
|
||||
CHANGE_GAME_STATE,
|
||||
OPEN_HORSE_WINDOW,
|
||||
HURT_ANIMATION, // New packet (?)
|
||||
INITIALIZE_WORLD_BORDER,
|
||||
KEEP_ALIVE,
|
||||
CHUNK_DATA,
|
||||
EFFECT,
|
||||
PARTICLE,
|
||||
UPDATE_LIGHT,
|
||||
JOIN_GAME,
|
||||
MAP_DATA,
|
||||
MERCHANT_OFFERS,
|
||||
ENTITY_RELATIVE_MOVE,
|
||||
ENTITY_RELATIVE_MOVE_AND_ROTATION,
|
||||
ENTITY_ROTATION,
|
||||
VEHICLE_MOVE,
|
||||
OPEN_BOOK,
|
||||
OPEN_WINDOW,
|
||||
OPEN_SIGN_EDITOR,
|
||||
PING,
|
||||
CRAFT_RECIPE_RESPONSE,
|
||||
PLAYER_ABILITIES,
|
||||
CHAT_MESSAGE,
|
||||
END_COMBAT_EVENT,
|
||||
ENTER_COMBAT_EVENT,
|
||||
DEATH_COMBAT_EVENT,
|
||||
PLAYER_INFO_REMOVE,
|
||||
PLAYER_INFO_UPDATE,
|
||||
FACE_PLAYER,
|
||||
PLAYER_POSITION_AND_LOOK,
|
||||
UNLOCK_RECIPES,
|
||||
DESTROY_ENTITIES,
|
||||
REMOVE_ENTITY_EFFECT,
|
||||
RESOURCE_PACK_SEND,
|
||||
RESPAWN,
|
||||
ENTITY_HEAD_LOOK,
|
||||
MULTI_BLOCK_CHANGE,
|
||||
SELECT_ADVANCEMENTS_TAB,
|
||||
SERVER_DATA,
|
||||
ACTION_BAR,
|
||||
WORLD_BORDER_CENTER,
|
||||
WORLD_BORDER_LERP_SIZE,
|
||||
WORLD_BORDER_SIZE,
|
||||
WORLD_BORDER_WARNING_DELAY,
|
||||
WORLD_BORDER_WARNING_REACH,
|
||||
CAMERA,
|
||||
HELD_ITEM_CHANGE,
|
||||
UPDATE_VIEW_POSITION,
|
||||
UPDATE_VIEW_DISTANCE,
|
||||
SPAWN_POSITION,
|
||||
DISPLAY_SCOREBOARD,
|
||||
ENTITY_METADATA,
|
||||
ATTACH_ENTITY,
|
||||
ENTITY_VELOCITY,
|
||||
ENTITY_EQUIPMENT,
|
||||
SET_EXPERIENCE,
|
||||
UPDATE_HEALTH,
|
||||
SCOREBOARD_OBJECTIVE,
|
||||
SET_PASSENGERS,
|
||||
TEAMS,
|
||||
UPDATE_SCORE,
|
||||
UPDATE_SIMULATION_DISTANCE,
|
||||
SET_TITLE_SUBTITLE,
|
||||
TIME_UPDATE,
|
||||
SET_TITLE_TEXT,
|
||||
SET_TITLE_TIMES,
|
||||
ENTITY_SOUND_EFFECT,
|
||||
SOUND_EFFECT,
|
||||
STOP_SOUND,
|
||||
SYSTEM_CHAT_MESSAGE,
|
||||
PLAYER_LIST_HEADER_AND_FOOTER,
|
||||
NBT_QUERY_RESPONSE,
|
||||
COLLECT_ITEM,
|
||||
ENTITY_TELEPORT,
|
||||
UPDATE_ADVANCEMENTS,
|
||||
UPDATE_ATTRIBUTES,
|
||||
UPDATE_ENABLED_FEATURES,
|
||||
ENTITY_EFFECT,
|
||||
DECLARE_RECIPES,
|
||||
TAGS
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.packettype.clientbound;
|
||||
|
||||
public enum ClientboundPacketType_1_20_2 {
|
||||
|
||||
BUNDLE,
|
||||
SPAWN_ENTITY,
|
||||
SPAWN_EXPERIENCE_ORB,
|
||||
ENTITY_ANIMATION,
|
||||
STATISTICS,
|
||||
ACKNOWLEDGE_BLOCK_CHANGES,
|
||||
BLOCK_BREAK_ANIMATION,
|
||||
BLOCK_ENTITY_DATA,
|
||||
BLOCK_ACTION,
|
||||
BLOCK_CHANGE,
|
||||
BOSS_BAR,
|
||||
SERVER_DIFFICULTY,
|
||||
CHUNK_BATCH_END, // New packet
|
||||
CHUNK_BATCH_BEGIN, // New packet
|
||||
CHUNK_BIOMES,
|
||||
CLEAR_TITLES,
|
||||
TAB_COMPLETE,
|
||||
DECLARE_COMMANDS,
|
||||
CLOSE_WINDOW,
|
||||
WINDOW_ITEMS,
|
||||
WINDOW_PROPERTY,
|
||||
SET_SLOT,
|
||||
SET_COOLDOWN,
|
||||
CUSTOM_CHAT_COMPLETIONS,
|
||||
PLUGIN_MESSAGE,
|
||||
DAMAGE_EVENT,
|
||||
DELETE_CHAT,
|
||||
DISCONNECT,
|
||||
DISGUISED_CHAT,
|
||||
ENTITY_STATUS,
|
||||
EXPLOSION,
|
||||
UNLOAD_CHUNK,
|
||||
CHANGE_GAME_STATE,
|
||||
OPEN_HORSE_WINDOW,
|
||||
HURT_ANIMATION,
|
||||
INITIALIZE_WORLD_BORDER,
|
||||
KEEP_ALIVE,
|
||||
CHUNK_DATA,
|
||||
EFFECT,
|
||||
PARTICLE,
|
||||
UPDATE_LIGHT,
|
||||
JOIN_GAME,
|
||||
MAP_DATA,
|
||||
MERCHANT_OFFERS,
|
||||
ENTITY_RELATIVE_MOVE,
|
||||
ENTITY_RELATIVE_MOVE_AND_ROTATION,
|
||||
ENTITY_ROTATION,
|
||||
VEHICLE_MOVE,
|
||||
OPEN_BOOK,
|
||||
OPEN_WINDOW,
|
||||
OPEN_SIGN_EDITOR,
|
||||
PING,
|
||||
DEBUG_PONG, // New packet
|
||||
CRAFT_RECIPE_RESPONSE,
|
||||
PLAYER_ABILITIES,
|
||||
CHAT_MESSAGE,
|
||||
END_COMBAT_EVENT,
|
||||
ENTER_COMBAT_EVENT,
|
||||
DEATH_COMBAT_EVENT,
|
||||
PLAYER_INFO_REMOVE,
|
||||
PLAYER_INFO_UPDATE,
|
||||
FACE_PLAYER,
|
||||
PLAYER_POSITION_AND_LOOK,
|
||||
UNLOCK_RECIPES,
|
||||
DESTROY_ENTITIES,
|
||||
REMOVE_ENTITY_EFFECT,
|
||||
RESOURCE_PACK_SEND,
|
||||
RESPAWN,
|
||||
ENTITY_HEAD_LOOK,
|
||||
MULTI_BLOCK_CHANGE,
|
||||
SELECT_ADVANCEMENTS_TAB,
|
||||
SERVER_DATA,
|
||||
ACTION_BAR,
|
||||
WORLD_BORDER_CENTER,
|
||||
WORLD_BORDER_LERP_SIZE,
|
||||
WORLD_BORDER_SIZE,
|
||||
WORLD_BORDER_WARNING_DELAY,
|
||||
WORLD_BORDER_WARNING_REACH,
|
||||
CAMERA,
|
||||
HELD_ITEM_CHANGE,
|
||||
UPDATE_VIEW_POSITION,
|
||||
UPDATE_VIEW_DISTANCE,
|
||||
SPAWN_POSITION,
|
||||
DISPLAY_SCOREBOARD,
|
||||
ENTITY_METADATA,
|
||||
ATTACH_ENTITY,
|
||||
ENTITY_VELOCITY,
|
||||
ENTITY_EQUIPMENT,
|
||||
SET_EXPERIENCE,
|
||||
UPDATE_HEALTH,
|
||||
SCOREBOARD_OBJECTIVE,
|
||||
SET_PASSENGERS,
|
||||
TEAMS,
|
||||
UPDATE_SCORE,
|
||||
UPDATE_SIMULATION_DISTANCE,
|
||||
SET_TITLE_SUBTITLE,
|
||||
TIME_UPDATE,
|
||||
SET_TITLE_TEXT,
|
||||
SET_TITLE_TIMES,
|
||||
ENTITY_SOUND_EFFECT,
|
||||
SOUND_EFFECT,
|
||||
CONFIGURATION_START, // New packet
|
||||
STOP_SOUND,
|
||||
SYSTEM_CHAT_MESSAGE,
|
||||
PLAYER_LIST_HEADER_AND_FOOTER,
|
||||
NBT_QUERY_RESPONSE,
|
||||
COLLECT_ITEM,
|
||||
ENTITY_TELEPORT,
|
||||
UPDATE_ADVANCEMENTS,
|
||||
UPDATE_ATTRIBUTES,
|
||||
// UPDATE_ENABLED_FEATURES, removed
|
||||
ENTITY_EFFECT,
|
||||
DECLARE_RECIPES,
|
||||
TAGS,
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.packettype.clientbound;
|
||||
|
||||
public enum ClientboundPacketType_1_20_3 {
|
||||
|
||||
BUNDLE,
|
||||
SPAWN_ENTITY,
|
||||
SPAWN_EXPERIENCE_ORB,
|
||||
ENTITY_ANIMATION,
|
||||
STATISTICS,
|
||||
ACKNOWLEDGE_BLOCK_CHANGES,
|
||||
BLOCK_BREAK_ANIMATION,
|
||||
BLOCK_ENTITY_DATA,
|
||||
BLOCK_ACTION,
|
||||
BLOCK_CHANGE,
|
||||
BOSS_BAR,
|
||||
SERVER_DIFFICULTY,
|
||||
CHUNK_BATCH_END,
|
||||
CHUNK_BATCH_BEGIN,
|
||||
CHUNK_BIOMES,
|
||||
CLEAR_TITLES,
|
||||
TAB_COMPLETE,
|
||||
DECLARE_COMMANDS,
|
||||
CLOSE_WINDOW,
|
||||
WINDOW_ITEMS,
|
||||
WINDOW_PROPERTY,
|
||||
SET_SLOT,
|
||||
SET_COOLDOWN,
|
||||
CUSTOM_CHAT_COMPLETIONS,
|
||||
PLUGIN_MESSAGE,
|
||||
DAMAGE_EVENT,
|
||||
DELETE_CHAT,
|
||||
DISCONNECT,
|
||||
DISGUISED_CHAT,
|
||||
ENTITY_STATUS,
|
||||
EXPLOSION,
|
||||
UNLOAD_CHUNK,
|
||||
CHANGE_GAME_STATE,
|
||||
OPEN_HORSE_WINDOW,
|
||||
HURT_ANIMATION,
|
||||
INITIALIZE_WORLD_BORDER,
|
||||
KEEP_ALIVE,
|
||||
CHUNK_DATA,
|
||||
EFFECT,
|
||||
PARTICLE,
|
||||
UPDATE_LIGHT,
|
||||
JOIN_GAME,
|
||||
MAP_DATA,
|
||||
MERCHANT_OFFERS,
|
||||
ENTITY_RELATIVE_MOVE,
|
||||
ENTITY_RELATIVE_MOVE_AND_ROTATION,
|
||||
ENTITY_ROTATION,
|
||||
VEHICLE_MOVE,
|
||||
OPEN_BOOK,
|
||||
OPEN_WINDOW,
|
||||
OPEN_SIGN_EDITOR,
|
||||
PING,
|
||||
DEBUG_PONG,
|
||||
CRAFT_RECIPE_RESPONSE,
|
||||
PLAYER_ABILITIES,
|
||||
CHAT_MESSAGE,
|
||||
END_COMBAT_EVENT,
|
||||
ENTER_COMBAT_EVENT,
|
||||
DEATH_COMBAT_EVENT,
|
||||
PLAYER_INFO_REMOVE,
|
||||
PLAYER_INFO_UPDATE,
|
||||
FACE_PLAYER,
|
||||
PLAYER_POSITION_AND_LOOK,
|
||||
UNLOCK_RECIPES,
|
||||
DESTROY_ENTITIES,
|
||||
REMOVE_ENTITY_EFFECT,
|
||||
RESET_SCORE, // New packet
|
||||
RESOURCE_PACK_REMOVE, // New packet
|
||||
RESOURCE_PACK_SEND,
|
||||
RESPAWN,
|
||||
ENTITY_HEAD_LOOK,
|
||||
MULTI_BLOCK_CHANGE,
|
||||
SELECT_ADVANCEMENTS_TAB,
|
||||
SERVER_DATA,
|
||||
ACTION_BAR,
|
||||
WORLD_BORDER_CENTER,
|
||||
WORLD_BORDER_LERP_SIZE,
|
||||
WORLD_BORDER_SIZE,
|
||||
WORLD_BORDER_WARNING_DELAY,
|
||||
WORLD_BORDER_WARNING_REACH,
|
||||
CAMERA,
|
||||
HELD_ITEM_CHANGE,
|
||||
UPDATE_VIEW_POSITION,
|
||||
UPDATE_VIEW_DISTANCE,
|
||||
SPAWN_POSITION,
|
||||
DISPLAY_SCOREBOARD,
|
||||
ENTITY_METADATA,
|
||||
ATTACH_ENTITY,
|
||||
ENTITY_VELOCITY,
|
||||
ENTITY_EQUIPMENT,
|
||||
SET_EXPERIENCE,
|
||||
UPDATE_HEALTH,
|
||||
SCOREBOARD_OBJECTIVE,
|
||||
SET_PASSENGERS,
|
||||
TEAMS,
|
||||
UPDATE_SCORE,
|
||||
UPDATE_SIMULATION_DISTANCE,
|
||||
SET_TITLE_SUBTITLE,
|
||||
TIME_UPDATE,
|
||||
SET_TITLE_TEXT,
|
||||
SET_TITLE_TIMES,
|
||||
ENTITY_SOUND_EFFECT,
|
||||
SOUND_EFFECT,
|
||||
CONFIGURATION_START,
|
||||
STOP_SOUND,
|
||||
SYSTEM_CHAT_MESSAGE,
|
||||
PLAYER_LIST_HEADER_AND_FOOTER,
|
||||
NBT_QUERY_RESPONSE,
|
||||
COLLECT_ITEM,
|
||||
ENTITY_TELEPORT,
|
||||
TICKING_STATE, // New packet
|
||||
TICKING_STEP, // New packet
|
||||
UPDATE_ADVANCEMENTS,
|
||||
UPDATE_ATTRIBUTES,
|
||||
ENTITY_EFFECT,
|
||||
DECLARE_RECIPES,
|
||||
TAGS,
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2023 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.packettype.config.clientbound;
|
||||
|
||||
public enum ClientboundConfigPacketType_1_20_2 {
|
||||
|
||||
PLUGIN_MESSAGE,
|
||||
DISCONNECT,
|
||||
CONFIGURATION_END,
|
||||
KEEP_ALIVE,
|
||||
PING,
|
||||
REGISTRY_DATA,
|
||||
RESOURCE_PACK_SEND,
|
||||
UPDATE_ENABLED_FEATURES,
|
||||
UPDATE_TAGS,
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2023 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.packettype.config.clientbound;
|
||||
|
||||
public enum ClientboundConfigPacketType_1_20_3 {
|
||||
|
||||
PLUGIN_MESSAGE,
|
||||
DISCONNECT,
|
||||
CONFIGURATION_END,
|
||||
KEEP_ALIVE,
|
||||
PING,
|
||||
REGISTRY_DATA,
|
||||
RESOURCE_PACK_REMOVE, // New packet
|
||||
RESOURCE_PACK_SEND,
|
||||
UPDATE_ENABLED_FEATURES,
|
||||
UPDATE_TAGS,
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.packettype.serverbound;
|
||||
|
||||
public enum ServerboundPacketType_1_19_3 {
|
||||
TELEPORT_CONFIRM,
|
||||
QUERY_BLOCK_NBT,
|
||||
SET_DIFFICULTY,
|
||||
|
||||
//Added in 1.19.1
|
||||
CHAT_ACK,
|
||||
|
||||
//Added in 1.19
|
||||
CHAT_COMMAND,
|
||||
|
||||
//Interesting changes in 1.19
|
||||
CHAT_MESSAGE,
|
||||
|
||||
//Removed in 1.19.3
|
||||
//CHAT_PREVIEW,
|
||||
|
||||
CLIENT_STATUS,
|
||||
CLIENT_SETTINGS,
|
||||
TAB_COMPLETE,
|
||||
CLICK_WINDOW_BUTTON,
|
||||
CLICK_WINDOW,
|
||||
CLOSE_WINDOW,
|
||||
PLUGIN_MESSAGE,
|
||||
EDIT_BOOK,
|
||||
QUERY_ENTITY_NBT,
|
||||
INTERACT_ENTITY,
|
||||
GENERATE_STRUCTURE,
|
||||
KEEP_ALIVE,
|
||||
LOCK_DIFFICULTY,
|
||||
PLAYER_POSITION,
|
||||
PLAYER_POSITION_AND_ROTATION,
|
||||
PLAYER_ROTATION,
|
||||
PLAYER_FLYING,
|
||||
VEHICLE_MOVE,
|
||||
STEER_BOAT,
|
||||
PICK_ITEM,
|
||||
CRAFT_RECIPE_REQUEST,
|
||||
PLAYER_ABILITIES,
|
||||
PLAYER_DIGGING,
|
||||
ENTITY_ACTION,
|
||||
STEER_VEHICLE,
|
||||
PONG,
|
||||
|
||||
//Added in 1.19.3
|
||||
CHAT_SESSION_UPDATE,
|
||||
|
||||
SET_RECIPE_BOOK_STATE,
|
||||
SET_DISPLAYED_RECIPE,
|
||||
NAME_ITEM,
|
||||
RESOURCE_PACK_STATUS,
|
||||
ADVANCEMENT_TAB,
|
||||
SELECT_TRADE,
|
||||
SET_BEACON_EFFECT,
|
||||
HELD_ITEM_CHANGE,
|
||||
UPDATE_COMMAND_BLOCK,
|
||||
UPDATE_COMMAND_BLOCK_MINECART,
|
||||
CREATIVE_INVENTORY_ACTION,
|
||||
UPDATE_JIGSAW_BLOCK,
|
||||
UPDATE_STRUCTURE_BLOCK,
|
||||
UPDATE_SIGN,
|
||||
ANIMATION,
|
||||
SPECTATE,
|
||||
PLAYER_BLOCK_PLACEMENT,
|
||||
USE_ITEM
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.packettype.serverbound;
|
||||
|
||||
public enum ServerboundPacketType_1_19_4 {
|
||||
TELEPORT_CONFIRM,
|
||||
QUERY_BLOCK_NBT,
|
||||
SET_DIFFICULTY,
|
||||
|
||||
//Added in 1.19.1
|
||||
CHAT_ACK,
|
||||
|
||||
//Added in 1.19
|
||||
CHAT_COMMAND,
|
||||
|
||||
//Interesting changes in 1.19
|
||||
CHAT_MESSAGE,
|
||||
CHAT_SESSION_UPDATE, // Moved around in 1.19.4
|
||||
|
||||
//Removed in 1.19.3
|
||||
//CHAT_PREVIEW,
|
||||
|
||||
CLIENT_STATUS,
|
||||
CLIENT_SETTINGS,
|
||||
TAB_COMPLETE,
|
||||
CLICK_WINDOW_BUTTON,
|
||||
CLICK_WINDOW,
|
||||
CLOSE_WINDOW,
|
||||
PLUGIN_MESSAGE,
|
||||
EDIT_BOOK,
|
||||
QUERY_ENTITY_NBT,
|
||||
INTERACT_ENTITY,
|
||||
GENERATE_STRUCTURE,
|
||||
KEEP_ALIVE,
|
||||
LOCK_DIFFICULTY,
|
||||
PLAYER_POSITION,
|
||||
PLAYER_POSITION_AND_ROTATION,
|
||||
PLAYER_ROTATION,
|
||||
PLAYER_FLYING,
|
||||
VEHICLE_MOVE,
|
||||
STEER_BOAT,
|
||||
PICK_ITEM,
|
||||
CRAFT_RECIPE_REQUEST,
|
||||
PLAYER_ABILITIES,
|
||||
PLAYER_DIGGING,
|
||||
ENTITY_ACTION,
|
||||
STEER_VEHICLE,
|
||||
PONG,
|
||||
|
||||
SET_RECIPE_BOOK_STATE,
|
||||
SET_DISPLAYED_RECIPE,
|
||||
NAME_ITEM,
|
||||
RESOURCE_PACK_STATUS,
|
||||
ADVANCEMENT_TAB,
|
||||
SELECT_TRADE,
|
||||
SET_BEACON_EFFECT,
|
||||
HELD_ITEM_CHANGE,
|
||||
UPDATE_COMMAND_BLOCK,
|
||||
UPDATE_COMMAND_BLOCK_MINECART,
|
||||
CREATIVE_INVENTORY_ACTION,
|
||||
UPDATE_JIGSAW_BLOCK,
|
||||
UPDATE_STRUCTURE_BLOCK,
|
||||
UPDATE_SIGN,
|
||||
ANIMATION,
|
||||
SPECTATE,
|
||||
PLAYER_BLOCK_PLACEMENT,
|
||||
USE_ITEM
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.packettype.serverbound;
|
||||
|
||||
public enum ServerboundPacketType_1_20_2 {
|
||||
|
||||
TELEPORT_CONFIRM,
|
||||
QUERY_BLOCK_NBT,
|
||||
SET_DIFFICULTY,
|
||||
CHAT_ACK,
|
||||
CHAT_COMMAND,
|
||||
CHAT_MESSAGE,
|
||||
CHAT_SESSION_UPDATE,
|
||||
CHUNK_BATCH_ACK, // New packet
|
||||
CLIENT_STATUS,
|
||||
CLIENT_SETTINGS,
|
||||
TAB_COMPLETE,
|
||||
CONFIGURATION_ACK, // New packet
|
||||
CLICK_WINDOW_BUTTON,
|
||||
CLICK_WINDOW,
|
||||
CLOSE_WINDOW,
|
||||
PLUGIN_MESSAGE,
|
||||
EDIT_BOOK,
|
||||
QUERY_ENTITY_NBT,
|
||||
INTERACT_ENTITY,
|
||||
GENERATE_STRUCTURE,
|
||||
KEEP_ALIVE,
|
||||
LOCK_DIFFICULTY,
|
||||
PLAYER_POSITION,
|
||||
PLAYER_POSITION_AND_ROTATION,
|
||||
PLAYER_ROTATION,
|
||||
PLAYER_FLYING,
|
||||
VEHICLE_MOVE,
|
||||
STEER_BOAT,
|
||||
PICK_ITEM,
|
||||
DEBUG_PING, // New packet
|
||||
CRAFT_RECIPE_REQUEST,
|
||||
PLAYER_ABILITIES,
|
||||
PLAYER_DIGGING,
|
||||
ENTITY_ACTION,
|
||||
STEER_VEHICLE,
|
||||
PONG,
|
||||
SET_RECIPE_BOOK_STATE,
|
||||
SET_DISPLAYED_RECIPE,
|
||||
NAME_ITEM,
|
||||
RESOURCE_PACK_STATUS,
|
||||
ADVANCEMENT_TAB,
|
||||
SELECT_TRADE,
|
||||
SET_BEACON_EFFECT,
|
||||
HELD_ITEM_CHANGE,
|
||||
UPDATE_COMMAND_BLOCK,
|
||||
UPDATE_COMMAND_BLOCK_MINECART,
|
||||
CREATIVE_INVENTORY_ACTION,
|
||||
UPDATE_JIGSAW_BLOCK,
|
||||
UPDATE_STRUCTURE_BLOCK,
|
||||
UPDATE_SIGN,
|
||||
ANIMATION,
|
||||
SPECTATE,
|
||||
PLAYER_BLOCK_PLACEMENT,
|
||||
USE_ITEM,
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.packettype.serverbound;
|
||||
|
||||
public enum ServerboundPacketType_1_20_3 {
|
||||
|
||||
TELEPORT_CONFIRM,
|
||||
QUERY_BLOCK_NBT,
|
||||
SET_DIFFICULTY,
|
||||
CHAT_ACK,
|
||||
CHAT_COMMAND,
|
||||
CHAT_MESSAGE,
|
||||
CHAT_SESSION_UPDATE,
|
||||
CHUNK_BATCH_ACK,
|
||||
CLIENT_STATUS,
|
||||
CLIENT_SETTINGS,
|
||||
TAB_COMPLETE,
|
||||
CONFIGURATION_ACK,
|
||||
CLICK_WINDOW_BUTTON,
|
||||
CLICK_WINDOW,
|
||||
CLOSE_WINDOW,
|
||||
SLOT_STATE_CHANGE, // New packet
|
||||
PLUGIN_MESSAGE,
|
||||
EDIT_BOOK,
|
||||
QUERY_ENTITY_NBT,
|
||||
INTERACT_ENTITY,
|
||||
GENERATE_STRUCTURE,
|
||||
KEEP_ALIVE,
|
||||
LOCK_DIFFICULTY,
|
||||
PLAYER_POSITION,
|
||||
PLAYER_POSITION_AND_ROTATION,
|
||||
PLAYER_ROTATION,
|
||||
PLAYER_FLYING,
|
||||
VEHICLE_MOVE,
|
||||
STEER_BOAT,
|
||||
PICK_ITEM,
|
||||
DEBUG_PING,
|
||||
CRAFT_RECIPE_REQUEST,
|
||||
PLAYER_ABILITIES,
|
||||
PLAYER_DIGGING,
|
||||
ENTITY_ACTION,
|
||||
STEER_VEHICLE,
|
||||
PONG,
|
||||
SET_RECIPE_BOOK_STATE,
|
||||
SET_DISPLAYED_RECIPE,
|
||||
NAME_ITEM,
|
||||
RESOURCE_PACK_STATUS,
|
||||
ADVANCEMENT_TAB,
|
||||
SELECT_TRADE,
|
||||
SET_BEACON_EFFECT,
|
||||
HELD_ITEM_CHANGE,
|
||||
UPDATE_COMMAND_BLOCK,
|
||||
UPDATE_COMMAND_BLOCK_MINECART,
|
||||
CREATIVE_INVENTORY_ACTION,
|
||||
UPDATE_JIGSAW_BLOCK,
|
||||
UPDATE_STRUCTURE_BLOCK,
|
||||
UPDATE_SIGN,
|
||||
ANIMATION,
|
||||
SPECTATE,
|
||||
PLAYER_BLOCK_PLACEMENT,
|
||||
USE_ITEM,
|
||||
}
|
||||
+5
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.particle.data;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.color.Color;
|
||||
import com.github.retrooper.packetevents.util.Vector3f;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
@@ -51,6 +52,10 @@ public class ParticleDustColorTransitionData extends ParticleData {
|
||||
this(scale, startRGB.getX(), startRGB.getY(), startRGB.getZ(), endRGB.getX(), endRGB.getY(), endRGB.getZ());
|
||||
}
|
||||
|
||||
public ParticleDustColorTransitionData(float scale, Color start, Color end) {
|
||||
this(scale, start.red(), start.green(), start.blue(), end.red(), end.green(), end.blue());
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
+5
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.particle.data;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.color.Color;
|
||||
import com.github.retrooper.packetevents.util.Vector3f;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
@@ -41,6 +42,10 @@ public class ParticleDustData extends ParticleData {
|
||||
this(scale, rgb.getX(), rgb.getY(), rgb.getZ());
|
||||
}
|
||||
|
||||
public ParticleDustData(float scale, Color color) {
|
||||
this(scale, color.red(), color.green(), color.blue());
|
||||
}
|
||||
|
||||
public float getRed() {
|
||||
return red;
|
||||
}
|
||||
|
||||
+113
-33
@@ -18,54 +18,94 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.particle.data;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class ParticleVibrationData extends ParticleData {
|
||||
public enum PositionType {
|
||||
BLOCK("minecraft:block"), ENTITY("minecraft:entity");
|
||||
|
||||
private final String name;
|
||||
public enum PositionType implements MappedEntity {
|
||||
|
||||
PositionType(String name) {
|
||||
BLOCK(new ResourceLocation("minecraft:block")),
|
||||
ENTITY(new ResourceLocation("minecraft:entity"));
|
||||
|
||||
private final ResourceLocation name;
|
||||
|
||||
PositionType(ResourceLocation name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static PositionType getByName(String name) {
|
||||
for(PositionType type : values()) {
|
||||
if(type.getName().equals(name)) {
|
||||
public static PositionType getById(int id) {
|
||||
switch (id) {
|
||||
case 0x00:
|
||||
return BLOCK;
|
||||
case 0x01:
|
||||
return ENTITY;
|
||||
default:
|
||||
throw new IllegalArgumentException("Illegal position type id: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable PositionType getByName(String name) {
|
||||
return getByName(new ResourceLocation(name));
|
||||
}
|
||||
|
||||
public static @Nullable PositionType getByName(ResourceLocation name) {
|
||||
for (PositionType type : values()) {
|
||||
if (type.getName().equals(name)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId(ClientVersion version) {
|
||||
return this.ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3i startingPosition;
|
||||
private Vector3i startingPosition; // Removed in 1.19.4
|
||||
private PositionType type;
|
||||
private final Optional<Vector3i> blockPosition;
|
||||
private final Optional<Integer> entityId;
|
||||
private @Nullable Vector3i blockPosition;
|
||||
private @Nullable Integer entityId;
|
||||
private @Nullable Float entityEyeHeight; // Added in 1.19
|
||||
private int ticks;
|
||||
|
||||
public ParticleVibrationData(Vector3i startingPosition, Vector3i blockPosition, int ticks) {
|
||||
public ParticleVibrationData(Vector3i startingPosition, @Nullable Vector3i blockPosition, int ticks) {
|
||||
this.startingPosition = startingPosition;
|
||||
this.type = PositionType.BLOCK;
|
||||
this.blockPosition = Optional.of(blockPosition);
|
||||
this.entityId = Optional.empty();
|
||||
this.blockPosition = blockPosition;
|
||||
this.entityId = null;
|
||||
this.ticks = ticks;
|
||||
}
|
||||
|
||||
public ParticleVibrationData(Vector3i startingPosition, int entityId, int ticks) {
|
||||
this.startingPosition = startingPosition;
|
||||
this.type = PositionType.ENTITY;
|
||||
this.blockPosition = Optional.empty();
|
||||
this.entityId = Optional.of(entityId);
|
||||
this.blockPosition = null;
|
||||
this.entityId = entityId;
|
||||
this.entityEyeHeight = null;
|
||||
this.ticks = ticks;
|
||||
}
|
||||
|
||||
public ParticleVibrationData(Vector3i startingPosition, int entityId, float entityEyeHeight, int ticks) {
|
||||
this.startingPosition = startingPosition;
|
||||
this.type = PositionType.ENTITY;
|
||||
this.blockPosition = null;
|
||||
this.entityId = entityId;
|
||||
this.entityEyeHeight = entityEyeHeight;
|
||||
this.ticks = ticks;
|
||||
}
|
||||
|
||||
@@ -82,11 +122,27 @@ public class ParticleVibrationData extends ParticleData {
|
||||
}
|
||||
|
||||
public Optional<Vector3i> getBlockPosition() {
|
||||
return blockPosition;
|
||||
return Optional.ofNullable(blockPosition);
|
||||
}
|
||||
|
||||
public void setBlockPosition(@Nullable Vector3i blockPosition) {
|
||||
this.blockPosition = blockPosition;
|
||||
}
|
||||
|
||||
public Optional<Integer> getEntityId() {
|
||||
return entityId;
|
||||
return Optional.ofNullable(entityId);
|
||||
}
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public Optional<Float> getEntityEyeHeight() {
|
||||
return Optional.ofNullable(entityEyeHeight);
|
||||
}
|
||||
|
||||
public void setEntityEyeHeight(@Nullable Float entityEyeHeight) {
|
||||
this.entityEyeHeight = entityEyeHeight;
|
||||
}
|
||||
|
||||
public int getTicks() {
|
||||
@@ -98,29 +154,53 @@ public class ParticleVibrationData extends ParticleData {
|
||||
}
|
||||
|
||||
public static ParticleVibrationData read(PacketWrapper<?> wrapper) {
|
||||
Vector3i startingPos = wrapper.readBlockPosition();
|
||||
String positionTypeName = wrapper.readString();
|
||||
PositionType positionType = PositionType.getByName(positionTypeName);
|
||||
if (positionType == PositionType.BLOCK) {
|
||||
return new ParticleVibrationData(startingPos, wrapper.readBlockPosition(), wrapper.readVarInt());
|
||||
Vector3i startingPos = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_19_4)
|
||||
? Vector3i.zero() : wrapper.readBlockPosition();
|
||||
|
||||
PositionType positionType;
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_20_3)) {
|
||||
positionType = PositionType.getById(wrapper.readVarInt());
|
||||
} else {
|
||||
String positionTypeName = wrapper.readString();
|
||||
positionType = PositionType.getByName(positionTypeName);
|
||||
if (positionType == null) {
|
||||
throw new IllegalArgumentException("Unknown position type: " + positionTypeName);
|
||||
}
|
||||
}
|
||||
else if (positionType == PositionType.ENTITY) {
|
||||
return new ParticleVibrationData(startingPos, wrapper.readVarInt(), wrapper.readVarInt());
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Unknown position type: " + positionTypeName);
|
||||
|
||||
switch (positionType) {
|
||||
case BLOCK:
|
||||
return new ParticleVibrationData(startingPos, wrapper.readBlockPosition(), wrapper.readVarInt());
|
||||
case ENTITY:
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_19)) {
|
||||
return new ParticleVibrationData(startingPos, wrapper.readVarInt(),
|
||||
wrapper.readFloat(), wrapper.readVarInt());
|
||||
} else {
|
||||
return new ParticleVibrationData(startingPos, wrapper.readVarInt(), wrapper.readVarInt());
|
||||
}
|
||||
default:
|
||||
throw new IllegalArgumentException("Illegal position type: " + positionType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ParticleVibrationData data) {
|
||||
wrapper.writeBlockPosition(data.getStartingPosition());
|
||||
wrapper.writeString(data.getType().getName());
|
||||
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_19_4)) {
|
||||
wrapper.writeBlockPosition(data.getStartingPosition());
|
||||
}
|
||||
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_20_3)) {
|
||||
wrapper.writeVarInt(data.getType().getId(wrapper.getServerVersion().toClientVersion()));
|
||||
} else {
|
||||
wrapper.writeIdentifier(data.getType().getName());
|
||||
}
|
||||
|
||||
if (data.getType() == PositionType.BLOCK) {
|
||||
wrapper.writeBlockPosition(data.getBlockPosition().get());
|
||||
}
|
||||
else if (data.getType() == PositionType.ENTITY) {
|
||||
} else if (data.getType() == PositionType.ENTITY) {
|
||||
wrapper.writeVarInt(data.getEntityId().get());
|
||||
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_19)) {
|
||||
wrapper.writeFloat(data.getEntityEyeHeight().orElse(0f));
|
||||
}
|
||||
}
|
||||
wrapper.writeVarInt(data.getTicks());
|
||||
}
|
||||
|
||||
+18
-1
@@ -43,7 +43,10 @@ public class ParticleTypes {
|
||||
ClientVersion.V_1_16_2,
|
||||
ClientVersion.V_1_17,
|
||||
ClientVersion.V_1_18,
|
||||
ClientVersion.V_1_19);
|
||||
ClientVersion.V_1_19,
|
||||
ClientVersion.V_1_19_4,
|
||||
ClientVersion.V_1_20,
|
||||
ClientVersion.V_1_20_3);
|
||||
|
||||
public static ParticleType define(String key, Function<PacketWrapper<?>, ParticleData> readDataFunction, BiConsumer<PacketWrapper<?>, ParticleData> writeDataFunction) {
|
||||
TypesBuilderData data = TYPES_BUILDER.defineFromArray(key);
|
||||
@@ -202,6 +205,20 @@ public class ParticleTypes {
|
||||
public static final ParticleType ELECTRIC_SPARK = define("electric_spark");
|
||||
public static final ParticleType SCRAPE = define("scrape");
|
||||
public static final ParticleType SHRIEK = define("shriek", ParticleShriekData::read, (wrapper, data) -> ParticleShriekData.write(wrapper, (ParticleShriekData) data));
|
||||
//Added in 1.19.3, BUT REMOVED in 1.20, replaced with CHERRY_LEAVES
|
||||
public static final ParticleType DRIPPING_CHERRY_LEAVES = define("dripping_cherry_leaves");
|
||||
public static final ParticleType FALLING_CHERRY_LEAVES = define("falling_cherry_leaves");
|
||||
public static final ParticleType LANDING_CHERRY_LEAVES = define("landing_cherry_leaves");
|
||||
//Added in 1.20
|
||||
public static final ParticleType CHERRY_LEAVES = define("cherry_leaves");
|
||||
public static final ParticleType EGG_CRACK = define("egg_crack");
|
||||
//Added in 1.20.3
|
||||
public static final ParticleType GUST = define("gust");
|
||||
public static final ParticleType GUST_EMITTER = define("gust_emitter");
|
||||
public static final ParticleType WHITE_SMOKE = define("white_smoke");
|
||||
public static final ParticleType DUST_PLUME = define("dust_plume");
|
||||
public static final ParticleType GUST_DUST = define("gust_dust");
|
||||
public static final ParticleType TRIAL_SPAWNER_DETECTION = define("trial_spawner_detection");
|
||||
|
||||
static {
|
||||
TYPES_BUILDER.unloadFileMappings();
|
||||
|
||||
+21
-14
@@ -22,6 +22,10 @@ import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.manager.server.VersionComparison;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Client Version.
|
||||
* This is a nice tool for minecraft's client protocol versions.
|
||||
@@ -76,11 +80,21 @@ public enum ClientVersion {
|
||||
|
||||
V_1_19(759),
|
||||
V_1_19_1(760),
|
||||
V_1_19_3(761),
|
||||
V_1_19_4(762),
|
||||
V_1_20(763),
|
||||
V_1_20_2(764),
|
||||
/**
|
||||
* 1.20.3 and 1.20.4 have the same protocol version.
|
||||
*/
|
||||
V_1_20_3(765),
|
||||
//TODO UPDATE Add new protocol version field
|
||||
|
||||
@Deprecated
|
||||
LOWER_THAN_SUPPORTED_VERSIONS(V_1_7_10.protocolVersion - 1, true),
|
||||
//TODO UPDATE Update HIGHER_THAN_SUPPORTED_VERSIONS field
|
||||
HIGHER_THAN_SUPPORTED_VERSIONS(V_1_19_1.protocolVersion + 1, true),
|
||||
@Deprecated
|
||||
HIGHER_THAN_SUPPORTED_VERSIONS(V_1_20_3.protocolVersion + 1, true),
|
||||
|
||||
UNKNOWN(-1, true);
|
||||
|
||||
@@ -88,15 +102,9 @@ public enum ClientVersion {
|
||||
private static final ClientVersion[] REVERSED_VALUES;
|
||||
|
||||
static {
|
||||
REVERSED_VALUES = values();
|
||||
int i = 0;
|
||||
int j = REVERSED_VALUES.length - 1;
|
||||
ClientVersion tmp;
|
||||
while (j > i) {
|
||||
tmp = REVERSED_VALUES[j];
|
||||
REVERSED_VALUES[j--] = REVERSED_VALUES[i];
|
||||
REVERSED_VALUES[i++] = tmp;
|
||||
}
|
||||
List<ClientVersion> valuesAsList = Arrays.asList(values());
|
||||
Collections.reverse(valuesAsList);
|
||||
REVERSED_VALUES = valuesAsList.toArray(new ClientVersion[0]);
|
||||
}
|
||||
|
||||
private static final int LOWEST_SUPPORTED_PROTOCOL_VERSION = LOWER_THAN_SUPPORTED_VERSIONS.protocolVersion + 1;
|
||||
@@ -157,15 +165,14 @@ public enum ClientVersion {
|
||||
@NotNull
|
||||
public static ClientVersion getById(int protocolVersion) {
|
||||
if (protocolVersion < LOWEST_SUPPORTED_PROTOCOL_VERSION) {
|
||||
return LOWER_THAN_SUPPORTED_VERSIONS;
|
||||
return V_1_7_10;
|
||||
} else if (protocolVersion > HIGHEST_SUPPORTED_PROTOCOL_VERSION) {
|
||||
return HIGHER_THAN_SUPPORTED_VERSIONS;
|
||||
return V_1_20_3;
|
||||
} else {
|
||||
for (ClientVersion version : VALUES) {
|
||||
if (version.protocolVersion > protocolVersion) {
|
||||
break;
|
||||
} else if (version.protocolVersion == protocolVersion) {
|
||||
//Cache for next time
|
||||
return version;
|
||||
}
|
||||
}
|
||||
@@ -275,4 +282,4 @@ public enum ClientVersion {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.player;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Representation of a player's game mode.
|
||||
*
|
||||
@@ -38,11 +36,15 @@ public enum GameMode {
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GameMode getById(int id) {
|
||||
if (id == -1) {
|
||||
return null;
|
||||
// Minecraft defaults to a survival gamemode if invalid
|
||||
if (id < 0 || id >= VALUES.length) {
|
||||
return GameMode.SURVIVAL;
|
||||
}
|
||||
return VALUES[id];
|
||||
}
|
||||
|
||||
public static GameMode defaultGameMode() {
|
||||
return SURVIVAL;
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2022 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.player;
|
||||
|
||||
import java.security.PublicKey;
|
||||
import java.time.Instant;
|
||||
|
||||
public class PublicProfileKey {
|
||||
private final Instant expiresAt;
|
||||
private final PublicKey key;
|
||||
private final byte[] keySignature;
|
||||
|
||||
public PublicProfileKey(Instant expiresAt, PublicKey key, byte[] keySignature) {
|
||||
this.expiresAt = expiresAt;
|
||||
this.key = key;
|
||||
this.keySignature = keySignature;
|
||||
}
|
||||
|
||||
public Instant getExpiresAt() {
|
||||
return expiresAt;
|
||||
}
|
||||
|
||||
public PublicKey getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public byte[] getKeySignature() {
|
||||
return keySignature;
|
||||
}
|
||||
|
||||
public boolean hasExpired() {
|
||||
return expiresAt.isBefore(Instant.now());
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,8 @@ import com.github.retrooper.packetevents.protocol.chat.message.ChatMessageLegacy
|
||||
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage_v1_16;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTList;
|
||||
import com.github.retrooper.packetevents.util.AdventureSerializer;
|
||||
import com.github.retrooper.packetevents.protocol.world.Dimension;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -41,19 +42,22 @@ import java.util.UUID;
|
||||
|
||||
public class User {
|
||||
private final Object channel;
|
||||
private ConnectionState connectionState;
|
||||
private ConnectionState decoderState;
|
||||
private ConnectionState encoderState;
|
||||
private ClientVersion clientVersion;
|
||||
private final UserProfile profile;
|
||||
private int entityId = -1;
|
||||
private int minWorldHeight = 0;
|
||||
private int totalWorldHeight = 256;
|
||||
private List<NBTCompound> worldNBT;
|
||||
private Dimension dimension = new Dimension(0);
|
||||
|
||||
public User(Object channel,
|
||||
ConnectionState connectionState, ClientVersion clientVersion,
|
||||
UserProfile profile) {
|
||||
this.channel = channel;
|
||||
this.connectionState = connectionState;
|
||||
this.decoderState = connectionState;
|
||||
this.encoderState = connectionState;
|
||||
this.clientVersion = clientVersion;
|
||||
this.profile = profile;
|
||||
}
|
||||
@@ -67,11 +71,37 @@ public class User {
|
||||
}
|
||||
|
||||
public ConnectionState getConnectionState() {
|
||||
return connectionState;
|
||||
ConnectionState decoderState = this.decoderState;
|
||||
ConnectionState encoderState = this.encoderState;
|
||||
if (decoderState != encoderState) {
|
||||
throw new IllegalArgumentException("Can't get common connection state: " + decoderState + " != " + encoderState);
|
||||
}
|
||||
return decoderState;
|
||||
}
|
||||
|
||||
public void setConnectionState(ConnectionState connectionState) {
|
||||
this.connectionState = connectionState;
|
||||
this.setDecoderState(connectionState);
|
||||
this.setEncoderState(connectionState);
|
||||
}
|
||||
|
||||
public ConnectionState getDecoderState() {
|
||||
return this.decoderState;
|
||||
}
|
||||
|
||||
public void setDecoderState(ConnectionState decoderState) {
|
||||
this.decoderState = decoderState;
|
||||
PacketEvents.getAPI().getLogManager().debug(
|
||||
"Transitioned " + this.getName() + "'s decoder into " + decoderState + " state!");
|
||||
}
|
||||
|
||||
public ConnectionState getEncoderState() {
|
||||
return this.encoderState;
|
||||
}
|
||||
|
||||
public void setEncoderState(ConnectionState encoderState) {
|
||||
this.encoderState = encoderState;
|
||||
PacketEvents.getAPI().getLogManager().debug(
|
||||
"Transitioned " + this.getName() + "'s encoder into " + encoderState + " state!");
|
||||
}
|
||||
|
||||
public ClientVersion getClientVersion() {
|
||||
@@ -148,7 +178,8 @@ public class User {
|
||||
}
|
||||
|
||||
public void sendMessage(Component component, ChatType type) {
|
||||
ServerVersion version = PacketEvents.getAPI().getServerManager().getVersion();
|
||||
ServerVersion version = PacketEvents.getAPI().getInjector().isProxy() ? getClientVersion().toServerVersion() :
|
||||
PacketEvents.getAPI().getServerManager().getVersion();
|
||||
PacketWrapper<?> chatPacket;
|
||||
if (version.isNewerThanOrEquals(ServerVersion.V_1_19)) {
|
||||
chatPacket = new WrapperPlayServerSystemChatMessage(false, component);
|
||||
@@ -172,7 +203,9 @@ public class User {
|
||||
}
|
||||
|
||||
public void sendTitle(Component title, Component subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) {
|
||||
boolean modern = PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_17);
|
||||
ServerVersion version = PacketEvents.getAPI().getInjector().isProxy() ? getClientVersion().toServerVersion() :
|
||||
PacketEvents.getAPI().getServerManager().getVersion();
|
||||
boolean modern = version.isNewerThanOrEquals(ServerVersion.V_1_17);
|
||||
PacketWrapper<?> animation;
|
||||
PacketWrapper<?> setTitle = null;
|
||||
PacketWrapper<?> setSubtitle = null;
|
||||
@@ -230,8 +263,19 @@ public class User {
|
||||
this.worldNBT = worldNBT.getTags();
|
||||
}
|
||||
|
||||
public Dimension getDimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
public void setDimension(Dimension dimension) {
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NBTCompound getWorldNBT(String worldName) {
|
||||
if (worldNBT == null) {
|
||||
return null;
|
||||
}
|
||||
for (NBTCompound compound : worldNBT) {
|
||||
if (compound.getStringTagOrNull("name").getValue().equals(worldName)) {
|
||||
return compound;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.potion;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.StaticMappedEntity;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
|
||||
|
||||
public interface PotionType extends StaticMappedEntity {
|
||||
public interface PotionType extends MappedEntity {
|
||||
|
||||
}
|
||||
+57
-38
@@ -18,6 +18,8 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.potion;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -37,14 +39,17 @@ public class PotionTypes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
public int getId(ClientVersion version) {
|
||||
if (version.isOlderThan(ClientVersion.V_1_20_2)) {
|
||||
return id + 1;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof PotionType) {
|
||||
return getId() == ((PotionType)obj).getId();
|
||||
return getName().equals(((PotionType)obj).getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -52,7 +57,8 @@ public class PotionTypes {
|
||||
|
||||
//minecraft:speed would be a string for example
|
||||
POTION_TYPE_MAP.put(potionType.getName().toString(), potionType);
|
||||
POTION_TYPE_ID_MAP.put((byte) potionType.getId(), potionType);
|
||||
//We map the 1.20.2 IDs
|
||||
POTION_TYPE_ID_MAP.put((byte) potionType.getId(ClientVersion.V_1_20_2), potionType);
|
||||
return potionType;
|
||||
}
|
||||
|
||||
@@ -61,42 +67,55 @@ public class PotionTypes {
|
||||
return POTION_TYPE_MAP.get(name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PotionType getById(int id) {
|
||||
@Deprecated
|
||||
public static @Nullable PotionType getById(int id) {
|
||||
return getById(id, PacketEvents.getAPI().getServerManager().getVersion().toClientVersion());
|
||||
}
|
||||
|
||||
public static @Nullable PotionType getById(int id, com.github.retrooper.packetevents.manager.server.ServerVersion version) {
|
||||
return getById(id, version.toClientVersion());
|
||||
}
|
||||
|
||||
public static @Nullable PotionType getById(int id, ClientVersion version) {
|
||||
if (version.isOlderThan(ClientVersion.V_1_20_2)) {
|
||||
//We map the 1.20.2 values (starting from 0)
|
||||
//If the version is older than that, we must subtract one from the input ID (cause it starts from 1)
|
||||
id--; // potion effects ids where shifted by -1 in 1.20.2
|
||||
}
|
||||
return POTION_TYPE_ID_MAP.get((byte)id);
|
||||
}
|
||||
|
||||
public static final PotionType SPEED = define("speed", 1);
|
||||
public static final PotionType SLOWNESS = define("slowness", 2);
|
||||
public static final PotionType HASTE = define("haste", 3);
|
||||
public static final PotionType MINING_FATIGUE = define("mining_fatigue", 4);
|
||||
public static final PotionType STRENGTH = define("strength", 5);
|
||||
public static final PotionType INSTANT_HEALTH = define("instant_health", 6);
|
||||
public static final PotionType INSTANT_DAMAGE = define("instant_damage", 7);
|
||||
public static final PotionType JUMP_BOOST = define("jump_boost", 8);
|
||||
public static final PotionType NAUSEA = define("nausea", 9);
|
||||
public static final PotionType REGENERATION = define("regeneration", 10);
|
||||
public static final PotionType RESISTANCE = define("resistance", 11);
|
||||
public static final PotionType FIRE_RESISTANCE = define("fire_resistance", 12);
|
||||
public static final PotionType WATER_BREATHING = define("water_breathing", 13);
|
||||
public static final PotionType INVISIBILITY = define("invisibility", 14);
|
||||
public static final PotionType BLINDNESS = define("blindness", 15);
|
||||
public static final PotionType NIGHT_VISION = define("night_vision", 16);
|
||||
public static final PotionType HUNGER = define("hunger", 17);
|
||||
public static final PotionType WEAKNESS = define("weakness", 18);
|
||||
public static final PotionType POISON = define("poison", 19);
|
||||
public static final PotionType WITHER = define("wither", 20);
|
||||
public static final PotionType HEALTH_BOOST = define("health_boost", 21);
|
||||
public static final PotionType ABSORPTION = define("absorption", 22);
|
||||
public static final PotionType SATURATION = define("saturation", 23);
|
||||
public static final PotionType GLOWING = define("glowing", 24);
|
||||
public static final PotionType LEVITATION = define("levitation", 25);
|
||||
public static final PotionType LUCK = define("luck", 26);
|
||||
public static final PotionType UNLUCK = define("unluck", 27);
|
||||
public static final PotionType SLOW_FALLING = define("slow_falling", 28);
|
||||
public static final PotionType CONDUIT_POWER = define("conduit_power", 29);
|
||||
public static final PotionType DOLPHINS_GRACE = define("dolphins_grace", 30);
|
||||
public static final PotionType BAD_OMEN = define("bad_omen", 31);
|
||||
public static final PotionType HERO_OF_THE_VILLAGE = define("hero_of_the_village", 32);
|
||||
public static final PotionType DARKNESS = define("darkness", 33);
|
||||
public static final PotionType SPEED = define("speed", 0);
|
||||
public static final PotionType SLOWNESS = define("slowness", 1);
|
||||
public static final PotionType HASTE = define("haste", 2);
|
||||
public static final PotionType MINING_FATIGUE = define("mining_fatigue", 3);
|
||||
public static final PotionType STRENGTH = define("strength", 4);
|
||||
public static final PotionType INSTANT_HEALTH = define("instant_health", 5);
|
||||
public static final PotionType INSTANT_DAMAGE = define("instant_damage", 6);
|
||||
public static final PotionType JUMP_BOOST = define("jump_boost", 7);
|
||||
public static final PotionType NAUSEA = define("nausea", 8);
|
||||
public static final PotionType REGENERATION = define("regeneration", 9);
|
||||
public static final PotionType RESISTANCE = define("resistance", 10);
|
||||
public static final PotionType FIRE_RESISTANCE = define("fire_resistance", 11);
|
||||
public static final PotionType WATER_BREATHING = define("water_breathing", 12);
|
||||
public static final PotionType INVISIBILITY = define("invisibility", 13);
|
||||
public static final PotionType BLINDNESS = define("blindness", 14);
|
||||
public static final PotionType NIGHT_VISION = define("night_vision", 15);
|
||||
public static final PotionType HUNGER = define("hunger", 16);
|
||||
public static final PotionType WEAKNESS = define("weakness", 17);
|
||||
public static final PotionType POISON = define("poison", 18);
|
||||
public static final PotionType WITHER = define("wither", 19);
|
||||
public static final PotionType HEALTH_BOOST = define("health_boost", 20);
|
||||
public static final PotionType ABSORPTION = define("absorption", 21);
|
||||
public static final PotionType SATURATION = define("saturation", 22);
|
||||
public static final PotionType GLOWING = define("glowing", 23);
|
||||
public static final PotionType LEVITATION = define("levitation", 24);
|
||||
public static final PotionType LUCK = define("luck", 25);
|
||||
public static final PotionType UNLUCK = define("unluck", 26);
|
||||
public static final PotionType SLOW_FALLING = define("slow_falling", 27);
|
||||
public static final PotionType CONDUIT_POWER = define("conduit_power", 28);
|
||||
public static final PotionType DOLPHINS_GRACE = define("dolphins_grace", 29);
|
||||
public static final PotionType BAD_OMEN = define("bad_omen", 30);
|
||||
public static final PotionType HERO_OF_THE_VILLAGE = define("hero_of_the_village", 31);
|
||||
public static final PotionType DARKNESS = define("darkness", 32);
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.score;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public final class BlankScoreFormat implements ScoreFormat {
|
||||
|
||||
public static final BlankScoreFormat INSTANCE = new BlankScoreFormat();
|
||||
|
||||
private BlankScoreFormat() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component format(int score) {
|
||||
return Component.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreFormatType getType() {
|
||||
return ScoreFormatTypes.BLANK;
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.score;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public final class FixedScoreFormat implements ScoreFormat {
|
||||
|
||||
private final Component value;
|
||||
|
||||
public FixedScoreFormat(Component value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreFormatType getType() {
|
||||
return ScoreFormatTypes.FIXED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component format(int score) {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public Component getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.score;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.NonExtendable
|
||||
public interface ScoreFormat {
|
||||
|
||||
static BlankScoreFormat blankScore() {
|
||||
return BlankScoreFormat.INSTANCE;
|
||||
}
|
||||
|
||||
static StyledScoreFormat styledScore(Style style) {
|
||||
return new StyledScoreFormat(style);
|
||||
}
|
||||
|
||||
static FixedScoreFormat fixedScore(Component value) {
|
||||
return new FixedScoreFormat(value);
|
||||
}
|
||||
|
||||
Component format(int score);
|
||||
|
||||
ScoreFormatType getType();
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.score;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.mapper.StaticMappedEntity;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
|
||||
public interface ScoreFormatType extends StaticMappedEntity {
|
||||
|
||||
ScoreFormat read(PacketWrapper<?> wrapper);
|
||||
|
||||
void write(PacketWrapper<?> wrapper, ScoreFormat format);
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.score;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class ScoreFormatTypes {
|
||||
|
||||
private static final Map<String, ScoreFormatType> SCORE_FORMAT_TYPE_MAP = new HashMap<>();
|
||||
private static final Map<Byte, ScoreFormatType> SCORE_FORMAT_TYPE_ID_MAP = new HashMap<>();
|
||||
|
||||
public static final ScoreFormatType BLANK = define(0, "blank", BlankScoreFormat.class,
|
||||
wrapper -> ScoreFormat.blankScore(),
|
||||
(wrapper, format) -> { /**/ });
|
||||
public static final ScoreFormatType STYLED = define(1, "styled", StyledScoreFormat.class,
|
||||
wrapper -> ScoreFormat.styledScore(wrapper.readStyle()),
|
||||
(wrapper, format) -> wrapper.writeStyle(format.getStyle()));
|
||||
public static final ScoreFormatType FIXED = define(2, "fixed", FixedScoreFormat.class,
|
||||
wrapper -> ScoreFormat.fixedScore(wrapper.readComponent()),
|
||||
(wrapper, format) -> wrapper.writeComponent(format.getValue()));
|
||||
|
||||
private ScoreFormatTypes() {
|
||||
}
|
||||
|
||||
public static ScoreFormat read(PacketWrapper<?> wrapper) {
|
||||
int formatTypeId = wrapper.readVarInt();
|
||||
ScoreFormatType formatType = getById(wrapper.getServerVersion().toClientVersion(), formatTypeId);
|
||||
if (formatType == null) {
|
||||
throw new NullPointerException("Can't resolve format type " + formatTypeId);
|
||||
}
|
||||
return formatType.read(wrapper);
|
||||
}
|
||||
|
||||
public static void write(PacketWrapper<?> wrapper, ScoreFormat format) {
|
||||
int formatTypeId = format.getType().getId(wrapper.getServerVersion().toClientVersion());
|
||||
wrapper.writeVarInt(formatTypeId);
|
||||
format.getType().write(wrapper, format);
|
||||
}
|
||||
|
||||
public static <T extends ScoreFormat> ScoreFormatType define(int id, String name,
|
||||
Class<T> formatClass,
|
||||
Function<PacketWrapper<?>, T> reader,
|
||||
BiConsumer<PacketWrapper<?>, T> writer) {
|
||||
ResourceLocation location = new ResourceLocation(name);
|
||||
ScoreFormatType type = new ScoreFormatType() {
|
||||
@Override
|
||||
public ScoreFormat read(PacketWrapper<?> wrapper) {
|
||||
return reader.apply(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketWrapper<?> wrapper, ScoreFormat format) {
|
||||
writer.accept(wrapper, formatClass.cast(format));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
};
|
||||
SCORE_FORMAT_TYPE_MAP.put(location.toString(), type);
|
||||
SCORE_FORMAT_TYPE_ID_MAP.put((byte) id, type);
|
||||
return type;
|
||||
}
|
||||
|
||||
public static @Nullable ScoreFormatType getById(ClientVersion version, int id) {
|
||||
return SCORE_FORMAT_TYPE_ID_MAP.get((byte) id);
|
||||
}
|
||||
|
||||
public static @Nullable ScoreFormatType getByName(String name) {
|
||||
return getByName(new ResourceLocation(name));
|
||||
}
|
||||
|
||||
public static @Nullable ScoreFormatType getByName(ResourceLocation name) {
|
||||
return SCORE_FORMAT_TYPE_MAP.get(name.toString());
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.score;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
|
||||
public final class StyledScoreFormat implements ScoreFormat {
|
||||
|
||||
private final Style style;
|
||||
|
||||
public StyledScoreFormat(Style style) {
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component format(int score) {
|
||||
return Component.text()
|
||||
.content(Integer.toString(score))
|
||||
.style(this.style)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreFormatType getType() {
|
||||
return ScoreFormatTypes.STYLED;
|
||||
}
|
||||
|
||||
public Style getStyle() {
|
||||
return this.style;
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,8 @@ package com.github.retrooper.packetevents.protocol.stats;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.util.AdventureSerializer;
|
||||
import com.github.retrooper.packetevents.util.MappingHelper;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
+2
-1
@@ -67,5 +67,6 @@ public enum MaterialType {
|
||||
AMETHYST,
|
||||
POWDER_SNOW,
|
||||
FROGSPAWN,
|
||||
FROGLIGHT
|
||||
FROGLIGHT,
|
||||
DECORATED_POT
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2024 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.world;
|
||||
|
||||
public enum Rotation {
|
||||
|
||||
/**
|
||||
* No rotation
|
||||
*/
|
||||
NONE,
|
||||
/**
|
||||
* Rotated clockwise by 45 degrees
|
||||
*/
|
||||
CLOCKWISE_45,
|
||||
/**
|
||||
* Rotated clockwise by 90 degrees
|
||||
*/
|
||||
CLOCKWISE,
|
||||
/**
|
||||
* Rotated clockwise by 135 degrees
|
||||
*/
|
||||
CLOCKWISE_135,
|
||||
/**
|
||||
* Flipped upside-down, a 180-degree rotation
|
||||
*/
|
||||
FLIPPED,
|
||||
/**
|
||||
* Flipped upside-down + 45-degree rotation
|
||||
*/
|
||||
FLIPPED_45,
|
||||
/**
|
||||
* Rotated counter-clockwise by 90 degrees
|
||||
*/
|
||||
COUNTER_CLOCKWISE,
|
||||
/**
|
||||
* Rotated counter-clockwise by 45 degrees
|
||||
*/
|
||||
COUNTER_CLOCKWISE_45;
|
||||
}
|
||||
+19
-2
@@ -32,9 +32,26 @@ import com.github.retrooper.packetevents.protocol.world.chunk.storage.LegacyFlex
|
||||
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||
|
||||
public interface BaseChunk {
|
||||
WrappedBlockState get(ClientVersion version, int x, int y, int z);
|
||||
int getBlockId(int x, int y, int z);
|
||||
|
||||
void set(ClientVersion version, int x, int y, int z, int combinedID);
|
||||
default WrappedBlockState get(ClientVersion version, int x, int y, int z) {
|
||||
return WrappedBlockState.getByGlobalId(version, getBlockId(x, y, z));
|
||||
}
|
||||
|
||||
default WrappedBlockState get(int x, int y, int z) {
|
||||
return get(PacketEvents.getAPI().getServerManager().getVersion().toClientVersion(), x, y, z);
|
||||
}
|
||||
|
||||
default void set(int x, int y, int z, WrappedBlockState state) {
|
||||
set(x, y, z, state.getGlobalId());
|
||||
}
|
||||
|
||||
void set(int x, int y, int z, int combinedID);
|
||||
|
||||
// We don't use ClientVersion, but it's here to maintain backwards compatibility.
|
||||
default void set(ClientVersion version, int x, int y, int z, int combinedID) {
|
||||
set(x, y, z, combinedID);
|
||||
}
|
||||
|
||||
boolean isEmpty();
|
||||
|
||||
|
||||
+3
-3
@@ -84,11 +84,11 @@ public class Chunk_v1_9 implements BaseChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WrappedBlockState get(ClientVersion version, int x, int y, int z) {
|
||||
return WrappedBlockState.getByGlobalId(version, this.dataPalette.get(x, y, z));
|
||||
public int getBlockId(int x, int y, int z) {
|
||||
return this.dataPalette.get(x, y, z);
|
||||
}
|
||||
|
||||
public void set(ClientVersion version, int x, int y, int z, int state) {
|
||||
public void set(int x, int y, int z, int state) {
|
||||
int curr = this.dataPalette.set(x, y, z, state);
|
||||
// Pre-1.14 we don't get block counts
|
||||
if (blockCount == Integer.MAX_VALUE) return;
|
||||
|
||||
+3
-4
@@ -44,13 +44,12 @@ public class Chunk_v1_7 implements BaseChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WrappedBlockState get(ClientVersion version, int x, int y, int z) {
|
||||
int combinedID = blocks.get(x, y, z) | (extendedBlocks.get(x, y, z) << 12);
|
||||
return WrappedBlockState.getByGlobalId(version, combinedID);
|
||||
public int getBlockId(int x, int y, int z) {
|
||||
return blocks.get(x, y, z) | (extendedBlocks.get(x, y, z) << 12);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(ClientVersion version, int x, int y, int z, int combinedID) {
|
||||
public void set(int x, int y, int z, int combinedID) {
|
||||
blocks.set(x, y, z, combinedID & 0xFF);
|
||||
extendedBlocks.set(x, y, z, combinedID >> 12);
|
||||
}
|
||||
|
||||
+3
-4
@@ -52,13 +52,12 @@ public class Chunk_v1_8 implements BaseChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WrappedBlockState get(ClientVersion version, int x, int y, int z) {
|
||||
int combinedID = this.blocks.get(x, y, z);
|
||||
return WrappedBlockState.getByGlobalId(version, combinedID);
|
||||
public int getBlockId(int x, int y, int z) {
|
||||
return this.blocks.get(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(ClientVersion version, int x, int y, int z, int combinedID) {
|
||||
public void set(int x, int y, int z, int combinedID) {
|
||||
this.blocks.set(x, y, z, combinedID);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -61,12 +61,12 @@ public class Chunk_v1_18 implements BaseChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WrappedBlockState get(ClientVersion version, int x, int y, int z) {
|
||||
return WrappedBlockState.getByGlobalId(version, this.chunkData.get(x, y, z));
|
||||
public int getBlockId(int x, int y, int z) {
|
||||
return this.chunkData.get(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(ClientVersion version, int x, int y, int z, int state) {
|
||||
public void set(int x, int y, int z, int state) {
|
||||
int curr = this.chunkData.set(x, y, z, state);
|
||||
if (state != AIR && curr == AIR) {
|
||||
this.blockCount++;
|
||||
|
||||
+4
-2
@@ -27,7 +27,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DataPalette {
|
||||
public static final int GLOBAL_PALETTE_BITS_PER_ENTRY = 14;
|
||||
|
||||
// this is the amount of bits required to store the biggest state id number
|
||||
public static final int GLOBAL_PALETTE_BITS_PER_ENTRY = 15;
|
||||
|
||||
public @NotNull Palette palette;
|
||||
public BaseStorage storage;
|
||||
@@ -187,4 +189,4 @@ public class DataPalette {
|
||||
private static int index(int x, int y, int z) {
|
||||
return y << 8 | z << 4 | x;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -19,10 +19,11 @@
|
||||
package com.github.retrooper.packetevents.protocol.world.chunk.reader;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.stream.NetStreamInput;
|
||||
import com.github.retrooper.packetevents.protocol.world.Dimension;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.BaseChunk;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
public interface ChunkReader {
|
||||
BaseChunk[] read(BitSet set, BitSet sevenExtendedMask, boolean fullChunk, boolean hasSkyLight, boolean checkForSky, int chunkSize, byte[] data, NetStreamInput dataIn);
|
||||
BaseChunk[] read(Dimension dimension, BitSet set, BitSet sevenExtendedMask, boolean fullChunk, boolean hasSkyLight, boolean checkForSky, int chunkSize, byte[] data, NetStreamInput dataIn);
|
||||
}
|
||||
+2
-1
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.protocol.world.chunk.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.stream.NetStreamInput;
|
||||
import com.github.retrooper.packetevents.protocol.world.Dimension;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.BaseChunk;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.impl.v1_16.Chunk_v1_9;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.reader.ChunkReader;
|
||||
@@ -27,7 +28,7 @@ import java.util.BitSet;
|
||||
|
||||
public class ChunkReader_v1_16 implements ChunkReader {
|
||||
@Override
|
||||
public BaseChunk[] read(BitSet set, BitSet sevenExtendedMask, boolean fullChunk, boolean hasSkyLight, boolean checkForSky, int chunkSize, byte[] data, NetStreamInput dataIn) {
|
||||
public BaseChunk[] read(Dimension dimension, BitSet set, BitSet sevenExtendedMask, boolean fullChunk, boolean hasSkyLight, boolean checkForSky, int chunkSize, byte[] data, NetStreamInput dataIn) {
|
||||
BaseChunk[] chunks = new BaseChunk[chunkSize];
|
||||
|
||||
for (int index = 0; index < chunks.length; ++index) {
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.protocol.world.chunk.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.stream.NetStreamInput;
|
||||
import com.github.retrooper.packetevents.protocol.world.Dimension;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.BaseChunk;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.impl.v_1_18.Chunk_v1_18;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.reader.ChunkReader;
|
||||
@@ -27,7 +28,7 @@ import java.util.BitSet;
|
||||
|
||||
public class ChunkReader_v1_18 implements ChunkReader {
|
||||
@Override
|
||||
public BaseChunk[] read(BitSet set, BitSet sevenExtendedMask, boolean fullChunk, boolean hasSkyLight, boolean checkForSky, int chunkSize, byte[] data, NetStreamInput dataIn) {
|
||||
public BaseChunk[] read(Dimension dimension, BitSet set, BitSet sevenExtendedMask, boolean fullChunk, boolean hasSkyLight, boolean checkForSky, int chunkSize, byte[] data, NetStreamInput dataIn) {
|
||||
BaseChunk[] chunks = new BaseChunk[chunkSize];
|
||||
|
||||
for (int index = 0; index < chunkSize; ++index) {
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.protocol.world.chunk.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.stream.NetStreamInput;
|
||||
import com.github.retrooper.packetevents.protocol.world.Dimension;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.BaseChunk;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.ByteArray3d;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.NetworkChunkData;
|
||||
@@ -30,7 +31,7 @@ import java.util.BitSet;
|
||||
|
||||
public class ChunkReader_v1_7 implements ChunkReader {
|
||||
@Override
|
||||
public BaseChunk[] read(BitSet primarySet, BitSet sevenExtendedMask, boolean fullChunk, boolean hasSkyLight, boolean checkForSky, int chunkSize, byte[] data, NetStreamInput dataIn) {
|
||||
public BaseChunk[] read(Dimension dimension, BitSet primarySet, BitSet sevenExtendedMask, boolean fullChunk, boolean hasSkyLight, boolean checkForSky, int chunkSize, byte[] data, NetStreamInput dataIn) {
|
||||
Chunk_v1_7[] chunks = new Chunk_v1_7[16];
|
||||
int pos = 0;
|
||||
int expected = 0;
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@
|
||||
package com.github.retrooper.packetevents.protocol.world.chunk.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.stream.NetStreamInput;
|
||||
import com.github.retrooper.packetevents.protocol.world.Dimension;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.BaseChunk;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.NetworkChunkData;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.NibbleArray3d;
|
||||
@@ -34,7 +35,7 @@ import java.util.BitSet;
|
||||
public class ChunkReader_v1_8 implements ChunkReader {
|
||||
|
||||
@Override
|
||||
public BaseChunk[] read(BitSet set, BitSet sevenExtendedMask, boolean fullChunk, boolean hasSkyLight, boolean checkForSky, int chunkSize, byte[] data, NetStreamInput dataIn) {
|
||||
public BaseChunk[] read(Dimension dimension, BitSet set, BitSet sevenExtendedMask, boolean fullChunk, boolean hasSkyLight, boolean checkForSky, int chunkSize, byte[] data, NetStreamInput dataIn) {
|
||||
Chunk_v1_8[] chunks = new Chunk_v1_8[16];
|
||||
int pos = 0;
|
||||
int expected = fullChunk ? 256 : 0; // 256 if full chunk for the biome data, always sent if full chunk
|
||||
|
||||
+5
-30
@@ -18,49 +18,24 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.world.chunk.reader.impl;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.stream.NetStreamInput;
|
||||
import com.github.retrooper.packetevents.protocol.world.Dimension;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.BaseChunk;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.impl.v1_16.Chunk_v1_9;
|
||||
import com.github.retrooper.packetevents.protocol.world.chunk.reader.ChunkReader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.BitSet;
|
||||
|
||||
public class ChunkReader_v1_9 implements ChunkReader {
|
||||
|
||||
@Override
|
||||
public BaseChunk[] read(BitSet set, BitSet sevenExtendedMask, boolean fullChunk, boolean hasBlockLight, boolean hasSkyLight, int chunkSize, byte[] data, NetStreamInput dataIn) {
|
||||
public BaseChunk[] read(Dimension dimension, BitSet set, BitSet sevenExtendedMask, boolean fullChunk, boolean hasBlockLight, boolean hasSkyLight, int chunkSize, byte[] data, NetStreamInput dataIn) {
|
||||
BaseChunk[] chunks = new BaseChunk[chunkSize];
|
||||
|
||||
Throwable throwable = null;
|
||||
|
||||
try {
|
||||
for (int index = 0; index < chunks.length; ++index) {
|
||||
if (set.get(index)) {
|
||||
chunks[index] = new Chunk_v1_9(dataIn, hasBlockLight, hasSkyLight);
|
||||
}
|
||||
for (int index = 0; index < chunks.length; ++index) {
|
||||
if (set.get(index)) {
|
||||
chunks[index] = new Chunk_v1_9(dataIn, hasBlockLight, hasSkyLight);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
throwable = e;
|
||||
}
|
||||
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_14)) return chunks;
|
||||
|
||||
try {
|
||||
// Unfortunately, this is needed to detect whether the chunks contain skylight or not.
|
||||
// Yes, this hack is required all the way from 1.9 through 1.13!
|
||||
//
|
||||
// Minimum is more than 256 bytes when it is a full chunks for biome data
|
||||
// if not a full chunk, any leftover data means it has skylight
|
||||
int minimum = fullChunk ? 256 : 0;
|
||||
if ((dataIn.available() > minimum || throwable != null ) && !hasSkyLight) {
|
||||
dataIn.reset();
|
||||
return read(set, sevenExtendedMask, fullChunk, hasBlockLight, true, chunkSize, data, dataIn);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return chunks;
|
||||
|
||||
Loaded 100 of 282 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user