Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3a984ca72 | ||
|
|
f8fad9607b | ||
|
|
a9e40c2abc | ||
|
|
da12521d0b | ||
|
|
de1f91104d | ||
|
|
f02b77c0ba | ||
|
|
bf2e88ed8f | ||
|
|
f04a3c75a9 | ||
|
|
80408424dd | ||
|
|
cb897dabe5 | ||
|
|
92cb0d024d | ||
|
|
72e617624a | ||
|
|
239d712b5f | ||
|
|
9b9ab1ade6 | ||
|
|
63383579b4 | ||
|
|
a2e19f7020 | ||
|
|
7ff578e1c6 | ||
|
|
95952588f1 | ||
|
|
8d4d89f049 | ||
|
|
74ddbacff5 | ||
|
|
2b1d6c636d | ||
|
|
e47c10966e | ||
|
|
9153aa6945 | ||
|
|
34e4007f7d | ||
|
|
0528eb7035 | ||
|
|
3a25a933ff | ||
|
|
efa694c8e1 | ||
|
|
289a71106a | ||
|
|
012bcae2d5 | ||
|
|
c84641cc83 | ||
|
|
baf93f527c | ||
|
|
d95d5394eb | ||
|
|
2675b41c3e | ||
|
|
4d27d6e967 | ||
|
|
9ecadae4f9 | ||
|
|
5939573ee3 | ||
|
|
1bbc2cba77 | ||
|
|
1c35fe3b92 | ||
|
|
e6a7b7a3b1 | ||
|
|
3581e23923 | ||
|
|
33c0d9d934 | ||
|
|
70eaec04c7 | ||
|
|
be7aca69ef | ||
|
|
6777809d1c | ||
|
|
39ec3dc117 | ||
|
|
d52a96722d | ||
|
|
7e76aaa2af | ||
|
|
022c081527 | ||
|
|
0b3f49cc53 | ||
|
|
54a68013f8 | ||
|
|
3b947e7b9a | ||
|
|
01b201cef9 | ||
|
|
8fdd8e5676 | ||
|
|
7fd4015b4f | ||
|
|
4f2f355a98 | ||
|
|
62afe05c28 | ||
|
|
b910cd189f | ||
|
|
1692451244 | ||
|
|
26fde1e9a3 | ||
|
|
5e42bef488 | ||
|
|
f7aacf1ad6 | ||
|
|
87aedb23fd | ||
|
|
bf60cb0543 | ||
|
|
367f561eb3 | ||
|
|
bb9132a673 | ||
|
|
b843499ac6 | ||
|
|
8809088b66 | ||
|
|
d5d4a9bffc | ||
|
|
14f3d26630 | ||
|
|
dacf44dc29 | ||
|
|
b2d7219105 | ||
|
|
362bb8dbe7 | ||
|
|
59935293a6 | ||
|
|
1c0d932c48 | ||
|
|
c43d992619 | ||
|
|
c2e0fe6b4c | ||
|
|
14a783560c | ||
|
|
2767b99479 | ||
|
|
3d7a0d901f | ||
|
|
177e9b7f4e | ||
|
|
4711ede9bc | ||
|
|
6bd531efc0 | ||
|
|
d6f1bf972e | ||
|
|
3295b1fc89 | ||
|
|
f620e45a9c | ||
|
|
825b61a24e | ||
|
|
dc5d15ba85 | ||
|
|
0b458c2e4c | ||
|
|
bb9fe18a76 | ||
|
|
73420efbb7 | ||
|
|
c3bc1906b1 | ||
|
|
3c4a7323a0 | ||
|
|
0a4fedff09 | ||
|
|
d1fb535ca7 | ||
|
|
5865e056d8 | ||
|
|
eb561b98b2 | ||
|
|
13b3ac7107 | ||
|
|
1943ba2da1 | ||
|
|
f90925e09b | ||
|
|
e2ecb21892 | ||
|
|
80bc492370 | ||
|
|
691e8eb070 | ||
|
|
a83c3bac2a | ||
|
|
60a5357c34 | ||
|
|
af477f8479 | ||
|
|
6b82b38b59 | ||
|
|
77918bb771 | ||
|
|
c200b8fe35 | ||
|
|
01cac8ded9 | ||
|
|
d7a0d89d8e | ||
|
|
90ec7560b7 | ||
|
|
eb96c5216b | ||
|
|
176f2f7895 | ||
|
|
2489b7651b | ||
|
|
30981f8283 | ||
|
|
4537ac2d29 | ||
|
|
577d3476bb | ||
|
|
7adb2c2ecd | ||
|
|
1f02892284 | ||
|
|
590e94ffc0 | ||
|
|
d5c2619bb3 | ||
|
|
935c9782a1 | ||
|
|
33b92f59d5 | ||
|
|
6d7a06b93f | ||
|
|
0e42d7d14f | ||
|
|
5cbdcc4158 | ||
|
|
db8f291475 | ||
|
|
187084dca1 | ||
|
|
316bc8070a | ||
|
|
62685e9330 | ||
|
|
169105af78 | ||
|
|
398bb4b6db | ||
|
|
df56ea0aa6 | ||
|
|
95e73c775c | ||
|
|
b8823ce00f | ||
|
|
01658ce3c9 | ||
|
|
934c181753 | ||
|
|
0e3099e751 | ||
|
|
43ea7737ec | ||
|
|
905dd43a0d | ||
|
|
17f7c69b11 | ||
|
|
13965a4517 | ||
|
|
679d0ba037 | ||
|
|
67e82e6d25 | ||
|
|
9e58db6cb1 | ||
|
|
e1fe2b9d99 | ||
|
|
fd3b42ef6e | ||
|
|
cf708adf55 | ||
|
|
9f8a14b58a | ||
|
|
1d31e06679 | ||
|
|
a94e72ccd0 | ||
|
|
35bd312ecf | ||
|
|
362d021745 | ||
|
|
9d98af54e6 | ||
|
|
cb1438c86f | ||
|
|
75512add39 | ||
|
|
db1c913a3e | ||
|
|
9c2609f4ee | ||
|
|
8336017bb9 | ||
|
|
1ea4880ded | ||
|
|
f54b8d7138 | ||
|
|
52e7385864 | ||
|
|
5d1371c479 | ||
|
|
91916d0eaf | ||
|
|
73505209bc | ||
|
|
934d5378e5 | ||
|
|
1ac55ffd50 | ||
|
|
9f265ef9ee | ||
|
|
0595fb6e03 | ||
|
|
9172cd3c91 | ||
|
|
7f655ad54b | ||
|
|
51af277d48 | ||
|
|
8f566032aa | ||
|
|
d01fdce16a | ||
|
|
b956ca966b | ||
|
|
4887d040ed |
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: Bug report
|
name: Bug report
|
||||||
about: Report a bug to help us fix
|
about: Report bugs to help us improve our software.
|
||||||
title: "[BUG REPORT]"
|
title: ""
|
||||||
labels: bug
|
labels: bug
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
@@ -10,11 +10,21 @@ assignees: ''
|
|||||||
**Describe the bug**
|
**Describe the bug**
|
||||||
A clear and concise description of what the bug is.
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
**To Reproduce**
|
**Software brand**
|
||||||
|
Please let us know what software you are using.
|
||||||
|
Eg. Spigot 1.18.2, Paper 1.18.2, Tuinity 1.18.2, Pufferfish 1.18.2, etc...
|
||||||
|
Make sure to mention the version of the software.
|
||||||
|
|
||||||
|
**Plugins**
|
||||||
|
Please give us a list of your plugins. Sometimes we run into incompatibilities. Having an overview of the plugins on your server can really help identify the problem quicker.
|
||||||
|
Eg. ViaVersion, ProtocolLib, HolographicDisplays
|
||||||
|
You may also provide a screenshot.
|
||||||
|
|
||||||
|
**How To Reproduce**
|
||||||
Steps to reproduce the behavior:
|
Steps to reproduce the behavior:
|
||||||
*Example:*
|
*Example:*
|
||||||
1. Login on the 1.16.4 minecraft client.
|
1. Join with the 1.18.2 vanilla minecraft client.
|
||||||
2. Join the server while it is still starting up.
|
2. Spam
|
||||||
3. ....
|
3. ....
|
||||||
4. See error
|
4. See error
|
||||||
|
|
||||||
@@ -24,18 +34,5 @@ A clear and concise description of what you expected to happen.
|
|||||||
**Screenshots**
|
**Screenshots**
|
||||||
If applicable, add screenshots to help explain your problem.
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
**About your server (please complete the following information):**
|
|
||||||
- Spigot: [eg. Paper or Tuinity]
|
|
||||||
We only accept reports that are reproducible
|
|
||||||
on one of the supported spigots.
|
|
||||||
|
|
||||||
- Server Version: [eg. 1.16.4]
|
|
||||||
Feel free to report bugs for versions newer than 1.7.10, even if we
|
|
||||||
don’t support them yet, but be aware that we might have already
|
|
||||||
found the bug and fixed it in a dev build, just before you reported it.
|
|
||||||
Please don’t get frustrated in such cases.
|
|
||||||
|
|
||||||
- Plugins List if possible: [eg. ViaVersion, ProtocolLib, HolographicDisplays]
|
|
||||||
|
|
||||||
**Additional context**
|
**Additional context**
|
||||||
Add any other context about the problem here.
|
Add any other context about the problem here.
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
|
||||||
|
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
|
||||||
|
|
||||||
|
name: Gradle Package
|
||||||
|
|
||||||
|
on: [ push, pull_request ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up JDK 8
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: '8'
|
||||||
|
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 :clean :build
|
||||||
|
|
||||||
|
- name: Upload build artifacts
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: packetevents-dev-build.jar
|
||||||
|
path: build/libs
|
||||||
+5
-1
@@ -110,4 +110,8 @@ dependency-reduced-pom.xml
|
|||||||
buildNumber.properties
|
buildNumber.properties
|
||||||
.mvn/timing.properties
|
.mvn/timing.properties
|
||||||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
||||||
.mvn/wrapper/maven-wrapper.jar
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
|
/src/main/resources/
|
||||||
|
/.gradle/
|
||||||
|
/.idea/
|
||||||
|
/build/
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,29 +1,23 @@
|
|||||||
# packetevents
|
# packetevents
|
||||||
|
|
||||||
[](https://github.com/retrooper/packetevents/blob/dev/LICENSE)
|
[](https://github.com/retrooper/packetevents/blob/master/LICENSE)
|
||||||
[](https://jitpack.io/#retrooper/packetevents)
|
[](https://jitpack.io/#retrooper/packetevents)
|
||||||
|
|
||||||
PacketEvents is an open-source Packet API. It has many cross-version packet-wrappers. You can process incoming and outgoing packets on the server. You can even send packets with our packet-wrappers. We are here to save you a ton of time.
|
PacketEvents is a powerful packet library. Our packet wrappers are efficient and easy to use. We support many protocol versions. (1.8+)
|
||||||
|
|
||||||
### Resources
|
### Resources
|
||||||
* [SpigotMC](https://www.spigotmc.org/resources/packetevents-api.80279/)
|
* [SpigotMC](https://www.spigotmc.org/resources/packetevents-api.80279/)
|
||||||
* [JavaDoc](https://packetevents.github.io/javadocs)
|
* [JavaDoc](https://packetevents.github.io/javadocs)
|
||||||
|
* [Discord](https://discord.me/packetevents)
|
||||||
|
|
||||||
### Setup
|
### Setup
|
||||||
[Learn more](https://github.com/retrooper/packetevents/wiki/1.-Setup)
|
[Learn more](https://github.com/retrooper/packetevents/wiki/1.-Setup)
|
||||||
|
|
||||||
### Discord
|
|
||||||
[Learn more](https://discord.me/packetevents)
|
|
||||||
|
|
||||||
### Contributing/Forking
|
|
||||||
[Learn more](https://github.com/retrooper/packetevents/wiki/2.-Contributing-and-Forking)\
|
|
||||||
Our discord server has a role for contributors and forkers.
|
|
||||||
|
|
||||||
### Sponsorships
|
### Sponsorships
|
||||||
[](https://www.ej-technologies.com/products/jprofiler/overview.html)
|
[](https://www.ej-technologies.com/products/jprofiler/overview.html)
|
||||||
|
|
||||||
### Statistics
|
### Statistics
|
||||||
PacketEvents collects statistics anonymously through bStats. Participation is completely optional and you can opt-out at any time, although it is really helpful in figuring out what environments the plugin is running in (i.e. versions of Spigot, Java), so I can adjust development accordingly.
|
PacketEvents collects statistics anonymously using bStats. It helps give us an overview of what platforms use our project. If you really don't like, you can turn it off.
|
||||||
|
|
||||||
### Credit
|
### Credit
|
||||||
PacketEvents uses an injector that is extremely similar to ViaVersion's injector. I have included license and copyright holder notice in the files taken from ViaVersion. Thank you ViaVersion.
|
PacketEvents uses an injector that is extremely similar to ViaVersion's injector. I have included license and copyright holder notice in the files taken from ViaVersion. Thank you ViaVersion.
|
||||||
+9
-22
@@ -34,10 +34,6 @@ repositories {
|
|||||||
url = uri('https://jitpack.io/')
|
url = uri('https://jitpack.io/')
|
||||||
}
|
}
|
||||||
|
|
||||||
maven {
|
|
||||||
url = uri('https://nexus.funkemunky.cc/content/repositories/releases/')
|
|
||||||
}
|
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
url = uri('https://repo.viaversion.com/')
|
url = uri('https://repo.viaversion.com/')
|
||||||
}
|
}
|
||||||
@@ -49,36 +45,27 @@ repositories {
|
|||||||
maven {
|
maven {
|
||||||
url = uri('https://repo.maven.apache.org/maven2/')
|
url = uri('https://repo.maven.apache.org/maven2/')
|
||||||
}
|
}
|
||||||
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.jetbrains:annotations:20.1.0'
|
implementation 'org.jetbrains:annotations:23.0.0'
|
||||||
|
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
|
||||||
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
|
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
|
||||||
compileOnly 'org.geysermc:connector:1.2.1-SNAPSHOT'
|
|
||||||
compileOnly 'com.viaversion:viaversion-api:4.0.1'
|
compileOnly 'com.viaversion:viaversion-api:4.0.1'
|
||||||
compileOnly 'com.github.ProtocolSupport:ProtocolSupport:3d24efeda6'
|
compileOnly 'com.github.ProtocolSupport:ProtocolSupport:3d24efeda6'
|
||||||
|
|
||||||
/*compileOnly 'org.github.spigot:1.16.2:1.16.2'
|
compileOnly group: 'com.github.azbh111', name: 'craftbukkit-1.14.3', version: 'R'
|
||||||
compileOnly 'org.github.spigot:1.8.8:1.8.8'
|
compileOnly group: 'com.github.azbh111', name: 'craftbukkit-1.8.8', version: 'R'
|
||||||
compileOnly 'org.github.spigot:1.7.10:1.7.10'*/
|
compileOnly group: 'com.github.azbh111', name: 'craftbukkit-1.7.10', version: 'R'
|
||||||
compileOnly 'org.github.spigot:1.16.2:1.16.2'
|
|
||||||
compileOnly 'org.github.spigot:1.13.2:1.13.2'
|
|
||||||
compileOnly 'org.github.spigot:1.13:1.13'
|
|
||||||
compileOnly 'org.github.spigot:1.12.2:1.12.2'
|
|
||||||
compileOnly 'org.github.spigot:1.9.4:1.9.4'
|
|
||||||
compileOnly 'org.github.spigot:1.9:1.9'
|
|
||||||
compileOnly 'org.github.spigot:1.8.8:1.8.8'
|
|
||||||
compileOnly 'org.github.spigot:1.7.10:1.7.10'
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'io.github.retrooper'
|
group = 'io.github.retrooper'
|
||||||
version = '1.8-pre-17'
|
version = '1.8.4'
|
||||||
description = 'packetevents'
|
description = 'packetevents'
|
||||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
java.targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
maven(MavenPublication) {
|
maven(MavenPublication) {
|
||||||
@@ -89,4 +76,4 @@ publishing {
|
|||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
}
|
}
|
||||||
@@ -1,523 +0,0 @@
|
|||||||
io/github/retrooper/packetevents/event/impl/PacketPlayReceiveEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PacketPlayReceiveEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/updateattributes/WrappedPacketOutUpdateAttributes.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.updateattributes.WrappedPacketOutUpdateAttributes
|
|
||||||
io/github/retrooper/packetevents/utils/player/ClientHand.java
|
|
||||||
io.github.retrooper.packetevents.utils.player.ClientHand
|
|
||||||
io/github/retrooper/packetevents/event/manager/PEEventManager.java
|
|
||||||
io.github.retrooper.packetevents.event.manager.PEEventManager
|
|
||||||
io/github/retrooper/packetevents/injector/modern/early/PEChannelInitializerModern.java
|
|
||||||
io.github.retrooper.packetevents.injector.modern.early.PEChannelInitializerModern
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/vehiclemove/WrappedPacketInVehicleMove.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.vehiclemove.WrappedPacketInVehicleMove
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/title/WrappedPacketOutTitle.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.title.WrappedPacketOutTitle
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.title.WrappedPacketOutTitle$TitleAction
|
|
||||||
io/github/retrooper/packetevents/injector/ChannelInjector.java
|
|
||||||
io.github.retrooper.packetevents.injector.ChannelInjector
|
|
||||||
io/github/retrooper/packetevents/utils/versionlookup/v_1_7_10/SpigotVersionLookup_1_7.java
|
|
||||||
io.github.retrooper.packetevents.utils.versionlookup.v_1_7_10.SpigotVersionLookup_1_7
|
|
||||||
io/github/retrooper/packetevents/event/impl/PacketPlaySendEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PacketPlaySendEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/entityequipment/WrappedPacketOutEntityEquipment.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entityequipment.WrappedPacketOutEntityEquipment
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entityequipment.WrappedPacketOutEntityEquipment$EquipmentSlot
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/keepalive/WrappedPacketInKeepAlive.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.keepalive.WrappedPacketInKeepAlive
|
|
||||||
io/github/retrooper/packetevents/utils/immutableset/ImmutableSet_7.java
|
|
||||||
io.github.retrooper.packetevents.utils.immutableset.ImmutableSet_7
|
|
||||||
io/github/retrooper/packetevents/processor/BukkitEventProcessorInternal.java
|
|
||||||
io.github.retrooper.packetevents.processor.BukkitEventProcessorInternal
|
|
||||||
io/github/retrooper/packetevents/utils/list/ListWrapper.java
|
|
||||||
io.github.retrooper.packetevents.utils.list.ListWrapper
|
|
||||||
io/github/retrooper/packetevents/event/PacketListener.java
|
|
||||||
io.github.retrooper.packetevents.event.PacketListener
|
|
||||||
io/github/retrooper/packetevents/utils/vector/Vector3d.java
|
|
||||||
io.github.retrooper.packetevents.utils.vector.Vector3d
|
|
||||||
io/github/retrooper/packetevents/utils/version/PEVersion.java
|
|
||||||
io.github.retrooper.packetevents.utils.version.PEVersion
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/keepalive/WrappedPacketOutKeepAlive.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.keepalive.WrappedPacketOutKeepAlive
|
|
||||||
io/github/retrooper/packetevents/utils/versionlookup/protocolsupport/ProtocolSupportVersionLookupUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.versionlookup.protocolsupport.ProtocolSupportVersionLookupUtils
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/blockplace/WrappedPacketInBlockPlace_1_7_10.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.blockplace.WrappedPacketInBlockPlace_1_7_10
|
|
||||||
io/github/retrooper/packetevents/utils/netty/bytebuf/ByteBufUtil_8.java
|
|
||||||
io.github.retrooper.packetevents.utils.netty.bytebuf.ByteBufUtil_8
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/entityaction/WrappedPacketInEntityAction.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.entityaction.WrappedPacketInEntityAction
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.entityaction.WrappedPacketInEntityAction$PlayerAction
|
|
||||||
io/github/retrooper/packetevents/event/eventtypes/CancellableEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.eventtypes.CancellableEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/status/out/pong/WrappedPacketStatusPong.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.status.out.pong.WrappedPacketStatusPong
|
|
||||||
io/github/retrooper/packetevents/event/manager/EventManagerLegacy.java
|
|
||||||
io.github.retrooper.packetevents.event.manager.EventManagerLegacy
|
|
||||||
io/github/retrooper/packetevents/utils/nms/NMSUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.nms.NMSUtils
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/worldparticles/WrappedPacketOutWorldParticles.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.worldparticles.WrappedPacketOutWorldParticles
|
|
||||||
io/github/retrooper/packetevents/utils/player/PlayerUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.player.PlayerUtils
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/windowitems/WrappedPacketOutWindowItems.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.windowitems.WrappedPacketOutWindowItems
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/WrappedPacket.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.WrappedPacket
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.WrappedPacket$SupportedVersions
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/closewindow/WrappedPacketInCloseWindow.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.closewindow.WrappedPacketInCloseWindow
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/login/out/encryptionbegin/WrappedPacketLoginOutEncryptionBegin.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.login.out.encryptionbegin.WrappedPacketLoginOutEncryptionBegin
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/entitymetadata/WrappedWatchableObject.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entitymetadata.WrappedWatchableObject
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/entityeffect/WrappedPacketOutEntityEffect.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entityeffect.WrappedPacketOutEntityEffect
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/api/WrapperPacketWriter.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.api.WrapperPacketWriter
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/login/in/start/WrappedPacketLoginInStart.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.login.in.start.WrappedPacketLoginInStart
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/status/in/ping/WrappedPacketStatusPing.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.status.in.ping.WrappedPacketStatusPing
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/playerinfo/WrappedPacketOutPlayerInfo.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.playerinfo.WrappedPacketOutPlayerInfo
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.playerinfo.WrappedPacketOutPlayerInfo$PlayerInfo
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.playerinfo.WrappedPacketOutPlayerInfo$PlayerInfoAction
|
|
||||||
io/github/retrooper/packetevents/updatechecker/LowLevelUpdateCheckerLegacy.java
|
|
||||||
io.github.retrooper.packetevents.updatechecker.LowLevelUpdateCheckerLegacy
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/blockplace/WrappedPacketInBlockPlace_1_9.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.blockplace.WrappedPacketInBlockPlace_1_9
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/tabcomplete/WrappedPacketOutTabComplete.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.tabcomplete.WrappedPacketOutTabComplete
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/animation/WrappedPacketOutAnimation.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.animation.WrappedPacketOutAnimation
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.animation.WrappedPacketOutAnimation$EntityAnimationType
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/closewindow/WrappedPacketOutCloseWindow.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.closewindow.WrappedPacketOutCloseWindow
|
|
||||||
io/github/retrooper/packetevents/utils/google/GoogleOptionalUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.google.GoogleOptionalUtils
|
|
||||||
io/github/retrooper/packetevents/updatechecker/UpdateChecker.java
|
|
||||||
io.github.retrooper.packetevents.updatechecker.UpdateChecker
|
|
||||||
io.github.retrooper.packetevents.updatechecker.UpdateChecker$UpdateCheckerStatus
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/tabcomplete/WrappedPacketInTabComplete.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.tabcomplete.WrappedPacketInTabComplete
|
|
||||||
io/github/retrooper/packetevents/event/impl/PlayerInjectEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PlayerInjectEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/position/WrappedPacketOutPosition.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.position.WrappedPacketOutPosition
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.position.WrappedPacketOutPosition$PlayerTeleportFlags
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/teleportaccept/WrappedPacketInTeleportAccept.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.teleportaccept.WrappedPacketInTeleportAccept
|
|
||||||
io/github/retrooper/packetevents/utils/server/SystemOS.java
|
|
||||||
io.github.retrooper.packetevents.utils.server.SystemOS
|
|
||||||
io/github/retrooper/packetevents/utils/versionlookup/VersionLookupUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.versionlookup.VersionLookupUtils
|
|
||||||
io/github/retrooper/packetevents/utils/google/OptionalUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.google.OptionalUtils
|
|
||||||
io/github/retrooper/packetevents/utils/geyser/GeyserUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.geyser.GeyserUtils
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/experience/WrappedPacketOutExperience.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.experience.WrappedPacketOutExperience
|
|
||||||
io/github/retrooper/packetevents/event/eventtypes/PostTaskEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.eventtypes.PostTaskEvent
|
|
||||||
io/github/retrooper/packetevents/injector/EarlyInjector.java
|
|
||||||
io.github.retrooper.packetevents.injector.EarlyInjector
|
|
||||||
io/github/retrooper/packetevents/event/eventtypes/NMSPacketEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.eventtypes.NMSPacketEvent
|
|
||||||
io/github/retrooper/packetevents/processor/PacketProcessorInternal.java
|
|
||||||
io.github.retrooper.packetevents.processor.PacketProcessorInternal
|
|
||||||
io.github.retrooper.packetevents.processor.PacketProcessorInternal$1
|
|
||||||
io.github.retrooper.packetevents.processor.PacketProcessorInternal$PacketData
|
|
||||||
io/github/retrooper/packetevents/event/impl/PlayerEjectEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PlayerEjectEvent
|
|
||||||
io/github/retrooper/packetevents/event/PacketListenerPriority.java
|
|
||||||
io.github.retrooper.packetevents.event.PacketListenerPriority
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/blockdig/WrappedPacketInBlockDig.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.blockdig.WrappedPacketInBlockDig
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.blockdig.WrappedPacketInBlockDig$PlayerDigType
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/abilities/WrappedPacketOutAbilities.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.abilities.WrappedPacketOutAbilities
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/mapchunk/WrappedPacketOutMapChunk.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.mapchunk.WrappedPacketOutMapChunk
|
|
||||||
io/github/retrooper/packetevents/utils/versionlookup/viaversion/ViaVersionAccessorImplLegacy.java
|
|
||||||
io.github.retrooper.packetevents.utils.versionlookup.viaversion.ViaVersionAccessorImplLegacy
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/blockplace/WrappedPacketInBlockPlace.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.blockplace.WrappedPacketInBlockPlace
|
|
||||||
io/github/retrooper/packetevents/event/impl/PacketHandshakeReceiveEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PacketHandshakeReceiveEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/chat/WrappedPacketOutChat.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.chat.WrappedPacketOutChat
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.chat.WrappedPacketOutChat$ChatPosition
|
|
||||||
io/github/retrooper/packetevents/utils/server/ServerUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.server.ServerUtils
|
|
||||||
io/github/retrooper/packetevents/utils/pair/MojangPairUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.pair.MojangPairUtils
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/armanimation/WrappedPacketInArmAnimation.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.armanimation.WrappedPacketInArmAnimation
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/login/out/success/WrappedPacketLoginOutSuccess.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.login.out.success.WrappedPacketLoginOutSuccess
|
|
||||||
io/github/retrooper/packetevents/utils/world/Difficulty.java
|
|
||||||
io.github.retrooper.packetevents.utils.world.Difficulty
|
|
||||||
io/github/retrooper/packetevents/event/manager/EventManager.java
|
|
||||||
io.github.retrooper.packetevents.event.manager.EventManager
|
|
||||||
io/github/retrooper/packetevents/utils/immutableset/ImmutableSetCustom.java
|
|
||||||
io.github.retrooper.packetevents.utils.immutableset.ImmutableSetCustom
|
|
||||||
io/github/retrooper/packetevents/utils/netty/bytebuf/ByteBufUtil.java
|
|
||||||
io.github.retrooper.packetevents.utils.netty.bytebuf.ByteBufUtil
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/settings/WrappedPacketInSettings.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.settings.WrappedPacketInSettings
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.settings.WrappedPacketInSettings$ChatVisibility
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.settings.WrappedPacketInSettings$DisplayedSkinPart
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/viewdistance/WrappedPacketOutViewDistance.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.viewdistance.WrappedPacketOutViewDistance
|
|
||||||
io/github/retrooper/packetevents/utils/reflection/SubclassUtil.java
|
|
||||||
io.github.retrooper.packetevents.utils.reflection.SubclassUtil
|
|
||||||
io/github/retrooper/packetevents/utils/versionlookup/viaversion/ViaVersionAccessorImpl.java
|
|
||||||
io.github.retrooper.packetevents.utils.versionlookup.viaversion.ViaVersionAccessorImpl
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/useitem/WrappedPacketInUseItem.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.useitem.WrappedPacketInUseItem
|
|
||||||
io/github/retrooper/packetevents/injector/modern/late/LateChannelInjectorModern.java
|
|
||||||
io.github.retrooper.packetevents.injector.modern.late.LateChannelInjectorModern
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/entity/WrappedPacketOutEntity.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entity.WrappedPacketOutEntity
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entity.WrappedPacketOutEntity$WrappedPacketOutEntityLook
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entity.WrappedPacketOutEntity$WrappedPacketOutRelEntityMove
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entity.WrappedPacketOutEntity$WrappedPacketOutRelEntityMoveLook
|
|
||||||
io/github/retrooper/packetevents/packettype/PacketTypeClasses.java
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses$Handshaking
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses$Handshaking$Client
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses$Login
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses$Login$Client
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses$Login$Server
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses$Play
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses$Play$Client
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses$Play$Server
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses$Status
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses$Status$Client
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketTypeClasses$Status$Server
|
|
||||||
io/github/retrooper/packetevents/injector/legacy/PlayerChannelHandlerLegacy.java
|
|
||||||
io.github.retrooper.packetevents.injector.legacy.PlayerChannelHandlerLegacy
|
|
||||||
io/github/retrooper/packetevents/utils/gameprofile/WrappedGameProfile.java
|
|
||||||
io.github.retrooper.packetevents.utils.gameprofile.WrappedGameProfile
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/login/in/encryptionbegin/WrappedPacketLoginInEncryptionBegin.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.login.in.encryptionbegin.WrappedPacketLoginInEncryptionBegin
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/pickitem/WrappedPacketInPickItem.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.pickitem.WrappedPacketInPickItem
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/flying/WrappedPacketInFlying.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.flying.WrappedPacketInFlying
|
|
||||||
io/github/retrooper/packetevents/event/eventtypes/CallableEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.eventtypes.CallableEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/login/out/setcompression/WrappedPacketLoginOutSetCompression.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.login.out.setcompression.WrappedPacketLoginOutSetCompression
|
|
||||||
io/github/retrooper/packetevents/packettype/PacketState.java
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketState
|
|
||||||
io/github/retrooper/packetevents/bstats/Metrics.java
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$1
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$AdvancedBarChart
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$AdvancedPie
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$CustomChart
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$DrilldownPie
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$JsonObjectBuilder
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$JsonObjectBuilder$JsonObject
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$MetricsBase
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$MultiLineChart
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$SimpleBarChart
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$SimplePie
|
|
||||||
io.github.retrooper.packetevents.bstats.Metrics$SingleLineChart
|
|
||||||
io/github/retrooper/packetevents/updatechecker/LowLevelUpdateChecker.java
|
|
||||||
io.github.retrooper.packetevents.updatechecker.LowLevelUpdateChecker
|
|
||||||
io/github/retrooper/packetevents/exceptions/PacketEventsLoadFailureException.java
|
|
||||||
io.github.retrooper.packetevents.exceptions.PacketEventsLoadFailureException
|
|
||||||
io/github/retrooper/packetevents/injector/modern/PlayerChannelHandlerModern.java
|
|
||||||
io.github.retrooper.packetevents.injector.modern.PlayerChannelHandlerModern
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/entitystatus/WrappedPacketOutEntityStatus.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entitystatus.WrappedPacketOutEntityStatus
|
|
||||||
io/github/retrooper/packetevents/event/impl/PostPacketPlayReceiveEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PostPacketPlayReceiveEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/transaction/WrappedPacketOutTransaction.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.transaction.WrappedPacketOutTransaction
|
|
||||||
io/github/retrooper/packetevents/utils/gameprofile/GameProfileUtil_8.java
|
|
||||||
io.github.retrooper.packetevents.utils.gameprofile.GameProfileUtil_8
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/login/WrappedPacketOutLogin.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.login.WrappedPacketOutLogin
|
|
||||||
io/github/retrooper/packetevents/utils/enums/EnumUtil.java
|
|
||||||
io.github.retrooper.packetevents.utils.enums.EnumUtil
|
|
||||||
io/github/retrooper/packetevents/utils/netty/bytebuf/ByteBufUtil_7.java
|
|
||||||
io.github.retrooper.packetevents.utils.netty.bytebuf.ByteBufUtil_7
|
|
||||||
io/github/retrooper/packetevents/utils/boundingbox/BoundingBox.java
|
|
||||||
io.github.retrooper.packetevents.utils.boundingbox.BoundingBox
|
|
||||||
io/github/retrooper/packetevents/utils/guava/GuavaUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.guava.GuavaUtils
|
|
||||||
io/github/retrooper/packetevents/event/impl/PacketLoginSendEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PacketLoginSendEvent
|
|
||||||
io/github/retrooper/packetevents/utils/attributesnapshot/AttributeModifierWrapper.java
|
|
||||||
io.github.retrooper.packetevents.utils.attributesnapshot.AttributeModifierWrapper
|
|
||||||
io.github.retrooper.packetevents.utils.attributesnapshot.AttributeModifierWrapper$Operation
|
|
||||||
io/github/retrooper/packetevents/utils/world/Dimension.java
|
|
||||||
io.github.retrooper.packetevents.utils.world.Dimension
|
|
||||||
io/github/retrooper/packetevents/utils/npc/NPCManager.java
|
|
||||||
io.github.retrooper.packetevents.utils.npc.NPCManager
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/ping/WrappedPacketOutPing.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.ping.WrappedPacketOutPing
|
|
||||||
io/github/retrooper/packetevents/utils/immutableset/ImmutableSet_8.java
|
|
||||||
io.github.retrooper.packetevents.utils.immutableset.ImmutableSet_8
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/blockbreakanimation/WrappedPacketOutBlockBreakAnimation.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.blockbreakanimation.WrappedPacketOutBlockBreakAnimation
|
|
||||||
io/github/retrooper/packetevents/utils/vector/Vector3f.java
|
|
||||||
io.github.retrooper.packetevents.utils.vector.Vector3f
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/pong/WrappedPacketInPong.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.pong.WrappedPacketInPong
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/updatetime/WrappedPacketOutUpdateTime.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.updatetime.WrappedPacketOutUpdateTime
|
|
||||||
io/github/retrooper/packetevents/event/impl/PacketLoginReceiveEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PacketLoginReceiveEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/blockaction/WrappedPacketOutBlockAction.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.blockaction.WrappedPacketOutBlockAction
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/NMSPacket.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.NMSPacket
|
|
||||||
io/github/retrooper/packetevents/event/PacketListenerAbstract.java
|
|
||||||
io.github.retrooper.packetevents.event.PacketListenerAbstract
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/spawnentity/WrappedPacketOutSpawnEntity.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.spawnentity.WrappedPacketOutSpawnEntity
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/explosion/WrappedPacketOutExplosion.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.explosion.WrappedPacketOutExplosion
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/spectate/WrappedPacketInSpectate.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.spectate.WrappedPacketInSpectate
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/blockplace/WrappedPacketInBlockPlace_1_8.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.blockplace.WrappedPacketInBlockPlace_1_8
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/api/helper/WrappedPacketEntityAbstraction.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.api.helper.WrappedPacketEntityAbstraction
|
|
||||||
io/github/retrooper/packetevents/event/impl/PostPlayerInjectEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PostPlayerInjectEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/useentity/WrappedPacketInUseEntity.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.useentity.WrappedPacketInUseEntity
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.useentity.WrappedPacketInUseEntity$EntityUseAction
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/spawnentityliving/WrappedPacketOutSpawnEntityLiving.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.spawnentityliving.WrappedPacketOutSpawnEntityLiving
|
|
||||||
io/github/retrooper/packetevents/exceptions/WrapperUnsupportedUsageException.java
|
|
||||||
io.github.retrooper.packetevents.exceptions.WrapperUnsupportedUsageException
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/removeentityeffect/WrappedPacketOutRemoveEntityEffect.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.removeentityeffect.WrappedPacketOutRemoveEntityEffect
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/custompayload/WrappedPacketOutCustomPayload.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.custompayload.WrappedPacketOutCustomPayload
|
|
||||||
io/github/retrooper/packetevents/PacketEvents.java
|
|
||||||
io.github.retrooper.packetevents.PacketEvents
|
|
||||||
io/github/retrooper/packetevents/settings/PacketEventsSettings.java
|
|
||||||
io.github.retrooper.packetevents.settings.PacketEventsSettings
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/namedsoundeffect/WrappedPacketOutNamedSoundEffect.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.namedsoundeffect.WrappedPacketOutNamedSoundEffect
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.namedsoundeffect.WrappedPacketOutNamedSoundEffect$SoundCategory
|
|
||||||
io/github/retrooper/packetevents/utils/immutableset/ImmutableSetAbstract.java
|
|
||||||
io.github.retrooper.packetevents.utils.immutableset.ImmutableSetAbstract
|
|
||||||
io/github/retrooper/packetevents/event/manager/EventManagerModern.java
|
|
||||||
io.github.retrooper.packetevents.event.manager.EventManagerModern
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/updatehealth/WrappedPacketOutUpdateHealth.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.updatehealth.WrappedPacketOutUpdateHealth
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/openwindowhorse/WrappedPacketOutOpenWindowHorse.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.openwindowhorse.WrappedPacketOutOpenWindowHorse
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/entityheadrotation/WrappedPacketOutEntityHeadRotation.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entityheadrotation.WrappedPacketOutEntityHeadRotation
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/steervehicle/WrappedPacketInSteerVehicle.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.steervehicle.WrappedPacketInSteerVehicle
|
|
||||||
io/github/retrooper/packetevents/event/eventtypes/PlayerEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.eventtypes.PlayerEvent
|
|
||||||
io/github/retrooper/packetevents/utils/nms/PlayerAPIModern.java
|
|
||||||
io.github.retrooper.packetevents.utils.nms.PlayerAPIModern
|
|
||||||
io/github/retrooper/packetevents/utils/player/ClientVersion.java
|
|
||||||
io.github.retrooper.packetevents.utils.player.ClientVersion
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/setcreativeslot/WrappedPacketInSetCreativeSlot.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.setcreativeslot.WrappedPacketInSetCreativeSlot
|
|
||||||
io/github/retrooper/packetevents/PacketEventsPlugin.java
|
|
||||||
io.github.retrooper.packetevents.PacketEventsPlugin
|
|
||||||
io/github/retrooper/packetevents/updatechecker/LowLevelUpdateCheckerModern.java
|
|
||||||
io.github.retrooper.packetevents.updatechecker.LowLevelUpdateCheckerModern
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/setcooldown/WrappedPacketOutSetCooldown.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.setcooldown.WrappedPacketOutSetCooldown
|
|
||||||
io/github/retrooper/packetevents/injector/modern/early/PaperChannelInjector.java
|
|
||||||
io.github.retrooper.packetevents.injector.modern.early.PaperChannelInjector
|
|
||||||
io/github/retrooper/packetevents/injector/legacy/late/LateChannelInjectorLegacy.java
|
|
||||||
io.github.retrooper.packetevents.injector.legacy.late.LateChannelInjectorLegacy
|
|
||||||
io/github/retrooper/packetevents/utils/netty/channel/ChannelUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.netty.channel.ChannelUtils
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/collect/WrappedPacketOutCollect.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.collect.WrappedPacketOutCollect
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/entityteleport/WrappedPacketOutEntityTeleport.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entityteleport.WrappedPacketOutEntityTeleport
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/unloadchunk/WrappedPacketOutUnloadChunk.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.unloadchunk.WrappedPacketOutUnloadChunk
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/handshaking/setprotocol/WrappedPacketHandshakingInSetProtocol.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.handshaking.setprotocol.WrappedPacketHandshakingInSetProtocol
|
|
||||||
io/github/retrooper/packetevents/event/impl/PacketStatusReceiveEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PacketStatusReceiveEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/bedit/WrappedPacketInBEdit.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.bedit.WrappedPacketInBEdit
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/api/SendableWrapper.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/kickdisconnect/WrappedPacketOutKickDisconnect.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.kickdisconnect.WrappedPacketOutKickDisconnect
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/resourcepacksend/WrappedPacketOutResourcePackSend.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.resourcepacksend.WrappedPacketOutResourcePackSend
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/beacon/WrappedPacketInBeacon.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.beacon.WrappedPacketInBeacon
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/setslot/WrappedPacketOutSetSlot.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.setslot.WrappedPacketOutSetSlot
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/camera/WrappedPacketOutCamera.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.camera.WrappedPacketOutCamera
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/clientcommand/WrappedPacketInClientCommand.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.clientcommand.WrappedPacketInClientCommand
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.clientcommand.WrappedPacketInClientCommand$ClientCommand
|
|
||||||
io/github/retrooper/packetevents/utils/boundingbox/RayTraceResult.java
|
|
||||||
io.github.retrooper.packetevents.utils.boundingbox.RayTraceResult
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/custompayload/WrappedPacketInCustomPayload.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.custompayload.WrappedPacketInCustomPayload
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/login/out/custompayload/WrappedPacketLoginOutCustomPayload.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.login.out.custompayload.WrappedPacketLoginOutCustomPayload
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/transaction/WrappedPacketInTransaction.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.transaction.WrappedPacketInTransaction
|
|
||||||
io/github/retrooper/packetevents/utils/player/Direction.java
|
|
||||||
io.github.retrooper.packetevents.utils.player.Direction
|
|
||||||
io/github/retrooper/packetevents/utils/gameprofile/GameProfileUtil_7.java
|
|
||||||
io.github.retrooper.packetevents.utils.gameprofile.GameProfileUtil_7
|
|
||||||
io/github/retrooper/packetevents/event/impl/PacketStatusSendEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PacketStatusSendEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/login/out/disconnect/WrappedPacketLoginOutDisconnect.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.login.out.disconnect.WrappedPacketLoginOutDisconnect
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/respawn/WrappedPacketOutRespawn.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.respawn.WrappedPacketOutRespawn
|
|
||||||
io/github/retrooper/packetevents/packettype/PacketType.java
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Handshaking
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Handshaking$Client
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Login
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Login$Client
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Login$Server
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Play
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Play$Client
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Play$Client$Util
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Play$Server
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Play$Server$Util
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Status
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Status$Client
|
|
||||||
io.github.retrooper.packetevents.packettype.PacketType$Status$Server
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/blockchange/WrappedPacketOutBlockChange.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.blockchange.WrappedPacketOutBlockChange
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/resourcepackstatus/WrappedPacketInResourcePackStatus.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.resourcepackstatus.WrappedPacketInResourcePackStatus
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.resourcepackstatus.WrappedPacketInResourcePackStatus$ResourcePackStatus
|
|
||||||
io/github/retrooper/packetevents/injector/legacy/early/PEChannelInitializerLegacy.java
|
|
||||||
io.github.retrooper.packetevents.injector.legacy.early.PEChannelInitializerLegacy
|
|
||||||
io/github/retrooper/packetevents/event/PacketListenerDynamic.java
|
|
||||||
io.github.retrooper.packetevents.event.PacketListenerDynamic
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/difficultylock/WrappedPacketInDifficultyLock.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.difficultylock.WrappedPacketInDifficultyLock
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/entitymetadata/WrappedPacketOutEntityMetadata.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entitymetadata.WrappedPacketOutEntityMetadata
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/entityvelocity/WrappedPacketOutEntityVelocity.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entityvelocity.WrappedPacketOutEntityVelocity
|
|
||||||
io/github/retrooper/packetevents/event/priority/PacketEventPriority.java
|
|
||||||
io.github.retrooper.packetevents.event.priority.PacketEventPriority
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/api/WrapperPacketReader.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.api.WrapperPacketReader
|
|
||||||
io/github/retrooper/packetevents/utils/reflection/ClassUtil.java
|
|
||||||
io.github.retrooper.packetevents.utils.reflection.ClassUtil
|
|
||||||
io/github/retrooper/packetevents/utils/entityfinder/EntityFinderUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.entityfinder.EntityFinderUtils
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/enchantitem/WrappedPacketInEnchantItem.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.enchantitem.WrappedPacketInEnchantItem
|
|
||||||
io/github/retrooper/packetevents/utils/npc/NPC.java
|
|
||||||
io.github.retrooper.packetevents.utils.npc.NPC
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/openwindow/WrappedPacketOutOpenWindow.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.openwindow.WrappedPacketOutOpenWindow
|
|
||||||
io/github/retrooper/packetevents/utils/player/Skin.java
|
|
||||||
io.github.retrooper.packetevents.utils.player.Skin
|
|
||||||
io/github/retrooper/packetevents/utils/netty/channel/ChannelUtils7.java
|
|
||||||
io.github.retrooper.packetevents.utils.netty.channel.ChannelUtils7
|
|
||||||
io/github/retrooper/packetevents/utils/guava/GuavaUtils_7.java
|
|
||||||
io.github.retrooper.packetevents.utils.guava.GuavaUtils_7
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/abilities/WrappedPacketInAbilities.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.abilities.WrappedPacketInAbilities
|
|
||||||
io/github/retrooper/packetevents/utils/server/ServerVersion.java
|
|
||||||
io.github.retrooper.packetevents.utils.server.ServerVersion
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/chat/WrappedPacketInChat.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.chat.WrappedPacketInChat
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/trsel/WrappedPacketInTrSel.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.trsel.WrappedPacketInTrSel
|
|
||||||
io/github/retrooper/packetevents/utils/attributesnapshot/AttributeSnapshotWrapper.java
|
|
||||||
io.github.retrooper.packetevents.utils.attributesnapshot.AttributeSnapshotWrapper
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/updatesign/WrappedPacketInUpdateSign.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.updatesign.WrappedPacketInUpdateSign
|
|
||||||
io/github/retrooper/packetevents/utils/gameprofile/GameProfileUtil.java
|
|
||||||
io.github.retrooper.packetevents.utils.gameprofile.GameProfileUtil
|
|
||||||
io/github/retrooper/packetevents/utils/math/MathUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.math.MathUtils
|
|
||||||
io/github/retrooper/packetevents/exceptions/WrapperFieldNotFoundException.java
|
|
||||||
io.github.retrooper.packetevents.exceptions.WrapperFieldNotFoundException
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/login/in/custompayload/WrappedPacketLoginInCustomPayload.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.login.in.custompayload.WrappedPacketLoginInCustomPayload
|
|
||||||
io/github/retrooper/packetevents/utils/reflection/Reflection.java
|
|
||||||
io.github.retrooper.packetevents.utils.reflection.Reflection
|
|
||||||
io/github/retrooper/packetevents/utils/versionlookup/viaversion/ViaVersionLookupUtils.java
|
|
||||||
io.github.retrooper.packetevents.utils.versionlookup.viaversion.ViaVersionLookupUtils
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/scoreboardteam/WrappedPacketOutScoreboardTeam.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.scoreboardteam.WrappedPacketOutScoreboardTeam
|
|
||||||
io/github/retrooper/packetevents/utils/player/Hand.java
|
|
||||||
io.github.retrooper.packetevents.utils.player.Hand
|
|
||||||
io/github/retrooper/packetevents/event/eventtypes/CancellableNMSPacketEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.eventtypes.CancellableNMSPacketEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/jigsawgenerate/WrappedPacketInJigsawGenerate.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.jigsawgenerate.WrappedPacketInJigsawGenerate
|
|
||||||
io/github/retrooper/packetevents/injector/GlobalChannelInjector.java
|
|
||||||
io.github.retrooper.packetevents.injector.GlobalChannelInjector
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/entitydestroy/WrappedPacketOutEntityDestroy.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.entitydestroy.WrappedPacketOutEntityDestroy
|
|
||||||
io/github/retrooper/packetevents/event/impl/PostPacketPlaySendEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.impl.PostPacketPlaySendEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/windowclick/WrappedPacketInWindowClick.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.windowclick.WrappedPacketInWindowClick
|
|
||||||
io/github/retrooper/packetevents/injector/legacy/early/EarlyChannelInjectorLegacy.java
|
|
||||||
io.github.retrooper.packetevents.injector.legacy.early.EarlyChannelInjectorLegacy
|
|
||||||
io.github.retrooper.packetevents.injector.legacy.early.EarlyChannelInjectorLegacy$1
|
|
||||||
io/github/retrooper/packetevents/event/annotation/PacketHandler.java
|
|
||||||
io.github.retrooper.packetevents.event.annotation.PacketHandler
|
|
||||||
io/github/retrooper/packetevents/utils/versionlookup/viaversion/ViaVersionAccessor.java
|
|
||||||
io.github.retrooper.packetevents.utils.versionlookup.viaversion.ViaVersionAccessor
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/multiblockchange/WrappedPacketOutMultiBlockChange.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.multiblockchange.WrappedPacketOutMultiBlockChange
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/namedentityspawn/WrappedPacketOutNamedEntitySpawn.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.namedentityspawn.WrappedPacketOutNamedEntitySpawn
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/difficultychange/WrappedPacketInDifficultyChange.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.difficultychange.WrappedPacketInDifficultyChange
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/helditemslot/WrappedPacketOutHeldItemSlot.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.helditemslot.WrappedPacketOutHeldItemSlot
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/mount/WrappedPacketOutMount.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.mount.WrappedPacketOutMount
|
|
||||||
io/github/retrooper/packetevents/utils/pair/Pair.java
|
|
||||||
io.github.retrooper.packetevents.utils.pair.Pair
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/out/gamestatechange/WrappedPacketOutGameStateChange.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.out.gamestatechange.WrappedPacketOutGameStateChange
|
|
||||||
io/github/retrooper/packetevents/injector/LateInjector.java
|
|
||||||
io.github.retrooper.packetevents.injector.LateInjector
|
|
||||||
io/github/retrooper/packetevents/utils/vector/Vector3i.java
|
|
||||||
io.github.retrooper.packetevents.utils.vector.Vector3i
|
|
||||||
io/github/retrooper/packetevents/utils/list/ConcurrentList.java
|
|
||||||
io.github.retrooper.packetevents.utils.list.ConcurrentList
|
|
||||||
io.github.retrooper.packetevents.utils.list.ConcurrentList$Itr
|
|
||||||
io.github.retrooper.packetevents.utils.list.ConcurrentList$ListItr
|
|
||||||
io/github/retrooper/packetevents/event/PacketEvent.java
|
|
||||||
io.github.retrooper.packetevents.event.PacketEvent
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/helditemslot/WrappedPacketInHeldItemSlot.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.helditemslot.WrappedPacketInHeldItemSlot
|
|
||||||
io/github/retrooper/packetevents/utils/netty/channel/ChannelUtils8.java
|
|
||||||
io.github.retrooper.packetevents.utils.netty.channel.ChannelUtils8
|
|
||||||
io/github/retrooper/packetevents/utils/guava/GuavaUtils_8.java
|
|
||||||
io.github.retrooper.packetevents.utils.guava.GuavaUtils_8
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/itemname/WrappedPacketInItemName.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.itemname.WrappedPacketInItemName
|
|
||||||
io/github/retrooper/packetevents/injector/modern/early/EarlyChannelInjectorModern.java
|
|
||||||
io.github.retrooper.packetevents.injector.modern.early.EarlyChannelInjectorModern
|
|
||||||
io.github.retrooper.packetevents.injector.modern.early.EarlyChannelInjectorModern$1
|
|
||||||
io/github/retrooper/packetevents/utils/player/GameMode.java
|
|
||||||
io.github.retrooper.packetevents.utils.player.GameMode
|
|
||||||
io/github/retrooper/packetevents/packetwrappers/play/in/boatmove/WrappedPacketInBoatMove.java
|
|
||||||
io.github.retrooper.packetevents.packetwrappers.play.in.boatmove.WrappedPacketInBoatMove
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Manifest-Version: 1.0
|
|
||||||
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
@@ -57,7 +57,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
public final class PacketEvents implements Listener, EventManager {
|
public final class PacketEvents implements Listener, EventManager {
|
||||||
private static PacketEvents instance;
|
private static PacketEvents instance;
|
||||||
private static Plugin plugin;
|
private static Plugin plugin;
|
||||||
private final PEVersion version = new PEVersion(1, 7, 9, 17);
|
private final PEVersion version = new PEVersion(1, 8, 4);
|
||||||
private final EventManager eventManager = new PEEventManager();
|
private final EventManager eventManager = new PEEventManager();
|
||||||
private final PlayerUtils playerUtils = new PlayerUtils();
|
private final PlayerUtils playerUtils = new PlayerUtils();
|
||||||
private final ServerUtils serverUtils = new ServerUtils();
|
private final ServerUtils serverUtils = new ServerUtils();
|
||||||
@@ -161,10 +161,12 @@ public final class PacketEvents implements Listener, EventManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void loadAsyncNewThread() {
|
public void loadAsyncNewThread() {
|
||||||
new Thread(this::load).start();
|
new Thread(this::load).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void loadAsync(ExecutorService executorService) {
|
public void loadAsync(ExecutorService executorService) {
|
||||||
executorService.execute(this::load);
|
executorService.execute(this::load);
|
||||||
}
|
}
|
||||||
@@ -191,6 +193,10 @@ public final class PacketEvents implements Listener, EventManager {
|
|||||||
|
|
||||||
if (settings.isbStatsEnabled()) {
|
if (settings.isbStatsEnabled()) {
|
||||||
Metrics metrics = new Metrics((JavaPlugin) getPlugin(), 11327);
|
Metrics metrics = new Metrics((JavaPlugin) getPlugin(), 11327);
|
||||||
|
//Just to have an idea what versions of packetevents people use
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("packetevents_version", () -> {
|
||||||
|
return getVersion().toString();
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
//We must wait for the injector to initialize.
|
//We must wait for the injector to initialize.
|
||||||
|
|||||||
@@ -18,17 +18,34 @@
|
|||||||
|
|
||||||
package io.github.retrooper.packetevents;
|
package io.github.retrooper.packetevents;
|
||||||
|
|
||||||
|
import io.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||||
|
import io.github.retrooper.packetevents.event.impl.PacketConfigReceiveEvent;
|
||||||
|
import io.github.retrooper.packetevents.event.impl.PacketPlayReceiveEvent;
|
||||||
|
import io.github.retrooper.packetevents.event.impl.PacketPlaySendEvent;
|
||||||
|
import io.github.retrooper.packetevents.packettype.PacketType;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.play.in.blockdig.WrappedPacketInBlockDig;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.play.in.custompayload.WrappedPacketInCustomPayload;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.play.in.entityaction.WrappedPacketInEntityAction;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.play.in.flying.WrappedPacketInFlying;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.play.in.useentity.WrappedPacketInUseEntity;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.play.out.entity.WrappedPacketOutEntity;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.play.out.entityeffect.WrappedPacketOutEntityEffect;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.play.out.entityvelocity.WrappedPacketOutEntityVelocity;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.play.out.setslot.WrappedPacketOutSetSlot;
|
||||||
import io.github.retrooper.packetevents.settings.PacketEventsSettings;
|
import io.github.retrooper.packetevents.settings.PacketEventsSettings;
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public class PacketEventsPlugin extends JavaPlugin {
|
public class PacketEventsPlugin extends JavaPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
PacketEventsSettings settings = PacketEvents.create(this).getSettings();
|
PacketEventsSettings settings = PacketEvents.create(this).getSettings();
|
||||||
settings
|
settings
|
||||||
.fallbackServerVersion(ServerVersion.v_1_7_10)
|
.fallbackServerVersion(ServerVersion.getLatest())
|
||||||
.compatInjector(false)
|
|
||||||
.checkForUpdates(true)
|
.checkForUpdates(true)
|
||||||
.bStats(true);
|
.bStats(true);
|
||||||
PacketEvents.get().loadAsyncNewThread();
|
PacketEvents.get().loadAsyncNewThread();
|
||||||
@@ -37,6 +54,59 @@ public class PacketEventsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
/*PacketEvents.get().getEventManager().registerListener(new PacketListenerAbstract() {
|
||||||
|
@Override
|
||||||
|
public void onPacketPlayReceive(PacketPlayReceiveEvent event) {
|
||||||
|
if (event.getPacketId() == PacketType.Play.Client.USE_ENTITY) {
|
||||||
|
System.out.println("Yes");
|
||||||
|
WrappedPacketInUseEntity ue = new WrappedPacketInUseEntity(event.getNMSPacket());
|
||||||
|
event.getPlayer().sendMessage("action: " + ue.getAction());
|
||||||
|
event.getPlayer().sendMessage("target: " + ue.getTarget());
|
||||||
|
ItemStack stack = new ItemStack(Material.STICK);
|
||||||
|
WrappedPacketOutSetSlot setSlot = new WrappedPacketOutSetSlot(0, 37, stack);
|
||||||
|
PacketEvents.get().getPlayerUtils().sendPacket(event.getPlayer(), setSlot);
|
||||||
|
} else if (event.getPacketId() == PacketType.Play.Client.CUSTOM_PAYLOAD) {
|
||||||
|
WrappedPacketInCustomPayload cp = new WrappedPacketInCustomPayload(event.getNMSPacket());
|
||||||
|
String name = cp.getChannelName();
|
||||||
|
System.out.println("name play: " + name);
|
||||||
|
System.out.println("Data: " + ((new String(cp.getData(), StandardCharsets.UTF_8))));
|
||||||
|
}
|
||||||
|
else if (event.getPacketId() == PacketType.Play.Client.ENTITY_ACTION) {
|
||||||
|
WrappedPacketInEntityAction ea = new WrappedPacketInEntityAction(event.getNMSPacket());
|
||||||
|
event.getPlayer().sendMessage("EA: " + ea.getAction());
|
||||||
|
} else if (PacketType.Play.Client.BLOCK_DIG == event.getPacketId()) {
|
||||||
|
WrappedPacketInBlockDig bd = new WrappedPacketInBlockDig(event.getNMSPacket());
|
||||||
|
event.getPlayer().sendMessage("bd: " + bd.getDigType());
|
||||||
|
}
|
||||||
|
else if (PacketType.Play.Client.Util.isInstanceOfFlying(event.getPacketId())) {
|
||||||
|
WrappedPacketInFlying f = new WrappedPacketInFlying(event.getNMSPacket());
|
||||||
|
System.out.println("flying: " + f.getPosition().toString() + ", pitch and yaw: " + f.getPitch() + ", " + f.getYaw());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPacketConfigReceive(PacketConfigReceiveEvent event) {
|
||||||
|
if (event.getPacketId() == PacketType.Play.Client.CUSTOM_PAYLOAD) {
|
||||||
|
WrappedPacketInCustomPayload cp = new WrappedPacketInCustomPayload(event.getNMSPacket());
|
||||||
|
String name = cp.getChannelName();
|
||||||
|
System.out.println("name: " + name);
|
||||||
|
System.out.println("Data: " + ((new String(cp.getData(), StandardCharsets.UTF_8))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPacketPlaySend(PacketPlaySendEvent event) {
|
||||||
|
if (PacketType.Play.Server.Util.isInstanceOfEntity(event.getPacketId())) {
|
||||||
|
WrappedPacketOutEntity entity = new WrappedPacketOutEntity(event.getNMSPacket());
|
||||||
|
} else if (event.getPacketId() == PacketType.Play.Server.ENTITY_EFFECT) {
|
||||||
|
WrappedPacketOutEntityEffect eff = new WrappedPacketOutEntityEffect(event.getNMSPacket());
|
||||||
|
//TODO Broken on 1.20.5 eff.setEffectId(eff.getEffectId());
|
||||||
|
System.out.println("eff: " + eff.getEffectId() + ", ampl: " + eff.getAmplifier() + ", dur:" + eff.getDuration());
|
||||||
|
} else if (event.getPacketId() == PacketType.Play.Server.ENTITY_VELOCITY) {
|
||||||
|
WrappedPacketOutEntityVelocity ev = new WrappedPacketOutEntityVelocity(event.getNMSPacket());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});*/
|
||||||
PacketEvents.get().init();
|
PacketEvents.get().init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ public abstract class PacketListenerAbstract {
|
|||||||
public void onPacketLoginSend(PacketLoginSendEvent event) {
|
public void onPacketLoginSend(PacketLoginSendEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onPacketConfigReceive(PacketConfigReceiveEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPacketConfigSend(PacketConfigSendEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
public void onPacketPlayReceive(PacketPlayReceiveEvent event) {
|
public void onPacketPlayReceive(PacketPlayReceiveEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-4
@@ -29,10 +29,6 @@ public abstract class CancellableNMSPacketEvent extends NMSPacketEvent implement
|
|||||||
super(channel, packet);
|
super(channel, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CancellableNMSPacketEvent(InetSocketAddress address, NMSPacket packet) {
|
|
||||||
super(address, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
|||||||
+11
-6
@@ -35,17 +35,14 @@ import java.net.InetSocketAddress;
|
|||||||
* @since 1.8
|
* @since 1.8
|
||||||
*/
|
*/
|
||||||
public abstract class NMSPacketEvent extends PacketEvent implements CallableEvent {
|
public abstract class NMSPacketEvent extends PacketEvent implements CallableEvent {
|
||||||
|
private final Object channel;
|
||||||
private final InetSocketAddress socketAddress;
|
private final InetSocketAddress socketAddress;
|
||||||
private final byte packetID;
|
private final byte packetID;
|
||||||
protected NMSPacket packet;
|
protected NMSPacket packet;
|
||||||
protected boolean cancelled;
|
|
||||||
|
|
||||||
public NMSPacketEvent(Object channel, NMSPacket packet) {
|
public NMSPacketEvent(Object channel, NMSPacket packet) {
|
||||||
this(ChannelUtils.getSocketAddress(channel), packet);//Call the constructor below
|
this.channel = channel;
|
||||||
}
|
this.socketAddress = ChannelUtils.getSocketAddress(channel);
|
||||||
|
|
||||||
public NMSPacketEvent(InetSocketAddress address, NMSPacket packet) {
|
|
||||||
this.socketAddress = address;
|
|
||||||
this.packet = packet;
|
this.packet = packet;
|
||||||
packetID = PacketType.packetIDMap.getOrDefault(packet.getRawNMSPacket().getClass(), PacketType.INVALID);
|
packetID = PacketType.packetIDMap.getOrDefault(packet.getRawNMSPacket().getClass(), PacketType.INVALID);
|
||||||
}
|
}
|
||||||
@@ -59,6 +56,14 @@ public abstract class NMSPacketEvent extends PacketEvent implements CallableEven
|
|||||||
return socketAddress;
|
return socketAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the associated player's netty channel.
|
||||||
|
* @return Netty channel
|
||||||
|
*/
|
||||||
|
public Object getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the NMS name of the packet.
|
* This method returns the NMS name of the packet.
|
||||||
* To get the name of the packet we get the class of the packet and then the simple name of the class.
|
* To get the name of the packet we get the class of the packet and then the simple name of the class.
|
||||||
|
|||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||||
|
* Copyright (C) 2021 retrooper and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.retrooper.packetevents.event.impl;
|
||||||
|
|
||||||
|
import io.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||||
|
import io.github.retrooper.packetevents.event.eventtypes.CancellableNMSPacketEvent;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code PacketConfigReceiveEvent} event is fired whenever the a CONFIG packet is received from a client.
|
||||||
|
* Use the {@link #getSocketAddress()} to identify who sends the packet.
|
||||||
|
*
|
||||||
|
* @author retrooper
|
||||||
|
* @see <a href="https://wiki.vg/Protocol#Configuration">https://wiki.vg/Protocol#Configuration</a>
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
public class PacketConfigReceiveEvent extends CancellableNMSPacketEvent {
|
||||||
|
public PacketConfigReceiveEvent(Object channel, NMSPacket packet) {
|
||||||
|
super(channel, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void call(PacketListenerAbstract listener) {
|
||||||
|
if (listener.clientSidedLoginAllowance == null || listener.clientSidedLoginAllowance.contains(getPacketId())) {
|
||||||
|
listener.onPacketConfigReceive(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||||
|
* Copyright (C) 2021 retrooper and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.retrooper.packetevents.event.impl;
|
||||||
|
|
||||||
|
import io.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||||
|
import io.github.retrooper.packetevents.event.eventtypes.CancellableNMSPacketEvent;
|
||||||
|
import io.github.retrooper.packetevents.event.eventtypes.PostTaskEvent;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code PacketConfigSendEvent} event is fired whenever the a LOGIN packet is being planned to be sent to the client.
|
||||||
|
* Use the {@link #getSocketAddress()} to identify who sends the packet.
|
||||||
|
*
|
||||||
|
* @author retrooper
|
||||||
|
* @see <a href="https://wiki.vg/Protocol#Configuration">https://wiki.vg/Protocol#Configuration</a>
|
||||||
|
* @since 1.8
|
||||||
|
*/
|
||||||
|
public class PacketConfigSendEvent extends CancellableNMSPacketEvent implements PostTaskEvent {
|
||||||
|
private Runnable postTask;
|
||||||
|
public PacketConfigSendEvent(Object channel, NMSPacket packet) {
|
||||||
|
super(channel, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPostTaskAvailable() {
|
||||||
|
return postTask != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Runnable getPostTask() {
|
||||||
|
return postTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPostTask(@NotNull Runnable postTask) {
|
||||||
|
this.postTask = postTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void call(PacketListenerAbstract listener) {
|
||||||
|
if (listener.serverSidedLoginAllowance == null || listener.serverSidedLoginAllowance.contains(getPacketId())) {
|
||||||
|
listener.onPacketConfigSend(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-5
@@ -34,14 +34,10 @@ import java.net.InetSocketAddress;
|
|||||||
* @since 1.8
|
* @since 1.8
|
||||||
*/
|
*/
|
||||||
public class PacketHandshakeReceiveEvent extends CancellableNMSPacketEvent {
|
public class PacketHandshakeReceiveEvent extends CancellableNMSPacketEvent {
|
||||||
public PacketHandshakeReceiveEvent(final Object channel, final NMSPacket packet) {
|
public PacketHandshakeReceiveEvent(Object channel, NMSPacket packet) {
|
||||||
super(channel, packet);
|
super(channel, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketHandshakeReceiveEvent(final InetSocketAddress socketAddress, final NMSPacket packet) {
|
|
||||||
super(socketAddress, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(PacketListenerAbstract listener) {
|
public void call(PacketListenerAbstract listener) {
|
||||||
if (listener.clientSidedLoginAllowance == null || listener.clientSidedLoginAllowance.contains(getPacketId())) {
|
if (listener.clientSidedLoginAllowance == null || listener.clientSidedLoginAllowance.contains(getPacketId())) {
|
||||||
|
|||||||
+1
-5
@@ -34,14 +34,10 @@ import java.net.InetSocketAddress;
|
|||||||
* @since 1.8
|
* @since 1.8
|
||||||
*/
|
*/
|
||||||
public class PacketLoginReceiveEvent extends CancellableNMSPacketEvent {
|
public class PacketLoginReceiveEvent extends CancellableNMSPacketEvent {
|
||||||
public PacketLoginReceiveEvent(final Object channel, final NMSPacket packet) {
|
public PacketLoginReceiveEvent(Object channel, NMSPacket packet) {
|
||||||
super(channel, packet);
|
super(channel, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketLoginReceiveEvent(final InetSocketAddress socketAddress, final NMSPacket packet) {
|
|
||||||
super(socketAddress, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(PacketListenerAbstract listener) {
|
public void call(PacketListenerAbstract listener) {
|
||||||
if (listener.clientSidedLoginAllowance == null || listener.clientSidedLoginAllowance.contains(getPacketId())) {
|
if (listener.clientSidedLoginAllowance == null || listener.clientSidedLoginAllowance.contains(getPacketId())) {
|
||||||
|
|||||||
@@ -41,10 +41,6 @@ public class PacketLoginSendEvent extends CancellableNMSPacketEvent implements P
|
|||||||
super(channel, packet);
|
super(channel, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketLoginSendEvent(InetSocketAddress address, NMSPacket packet) {
|
|
||||||
super(address, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPostTaskAvailable() {
|
public boolean isPostTaskAvailable() {
|
||||||
return postTask != null;
|
return postTask != null;
|
||||||
|
|||||||
-4
@@ -38,10 +38,6 @@ public class PacketStatusReceiveEvent extends CancellableNMSPacketEvent {
|
|||||||
super(channel, packet);
|
super(channel, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketStatusReceiveEvent(final InetSocketAddress socketAddress, final NMSPacket packet) {
|
|
||||||
super(socketAddress, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(PacketListenerAbstract listener) {
|
public void call(PacketListenerAbstract listener) {
|
||||||
if (listener.clientSidedStatusAllowance == null || listener.clientSidedStatusAllowance.contains(getPacketId())) {
|
if (listener.clientSidedStatusAllowance == null || listener.clientSidedStatusAllowance.contains(getPacketId())) {
|
||||||
|
|||||||
@@ -44,10 +44,6 @@ public class PacketStatusSendEvent extends CancellableNMSPacketEvent implements
|
|||||||
super(channel, packet);
|
super(channel, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketStatusSendEvent(InetSocketAddress address, NMSPacket packet) {
|
|
||||||
super(address, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPostTaskAvailable() {
|
public boolean isPostTaskAvailable() {
|
||||||
return postTask != null;
|
return postTask != null;
|
||||||
|
|||||||
@@ -156,6 +156,30 @@ public interface EventManager {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister a PacketListenerAbstract listener.
|
||||||
|
*
|
||||||
|
* @param listener {@link PacketListenerAbstract}
|
||||||
|
* @return Same event manager instance.
|
||||||
|
*/
|
||||||
|
default EventManager unregisterListener(PacketListenerAbstract listener) {
|
||||||
|
if (listener != null) {
|
||||||
|
PEEventManager.EVENT_MANAGER_MODERN.unregisterListener(listener);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister multiple PacketListenerAbstract listeners.
|
||||||
|
*
|
||||||
|
* @param listeners {@link PacketListenerAbstract}
|
||||||
|
* @return Same event manager instance.
|
||||||
|
*/
|
||||||
|
default EventManager unregisterListeners(PacketListenerAbstract... listeners) {
|
||||||
|
PEEventManager.EVENT_MANAGER_MODERN.unregisterListeners(listeners);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister all registered event listeners.
|
* Unregister all registered event listeners.
|
||||||
* All the deprecated and the dynamic listeners will be unregistered.
|
* All the deprecated and the dynamic listeners will be unregistered.
|
||||||
|
|||||||
+24
-11
@@ -45,10 +45,6 @@ class EventManagerModern {
|
|||||||
* @see EventManagerLegacy#callEvent(PacketEvent, byte)
|
* @see EventManagerLegacy#callEvent(PacketEvent, byte)
|
||||||
*/
|
*/
|
||||||
public void callEvent(final PacketEvent event) {
|
public void callEvent(final PacketEvent event) {
|
||||||
boolean cancel = false;
|
|
||||||
if (event instanceof CancellableEvent) {
|
|
||||||
cancel = ((CancellableEvent) event).isCancelled();
|
|
||||||
}
|
|
||||||
byte highestReachedPriority = (byte) (PacketListenerPriority.LOWEST.getId() - 1);
|
byte highestReachedPriority = (byte) (PacketListenerPriority.LOWEST.getId() - 1);
|
||||||
for (byte priority = PacketListenerPriority.LOWEST.getId(); priority <= PacketListenerPriority.MONITOR.getId(); priority++) {
|
for (byte priority = PacketListenerPriority.LOWEST.getId(); priority <= PacketListenerPriority.MONITOR.getId(); priority++) {
|
||||||
HashSet<PacketListenerAbstract> listeners = listenersMap.get(priority);
|
HashSet<PacketListenerAbstract> listeners = listenersMap.get(priority);
|
||||||
@@ -63,17 +59,10 @@ class EventManagerModern {
|
|||||||
//TODO Remove, because its redundant. We are only keeping it for compatibility with the legacy event manager.
|
//TODO Remove, because its redundant. We are only keeping it for compatibility with the legacy event manager.
|
||||||
if (event instanceof CancellableEvent) {
|
if (event instanceof CancellableEvent) {
|
||||||
if (priority > highestReachedPriority) {
|
if (priority > highestReachedPriority) {
|
||||||
CancellableEvent ce = (CancellableEvent) event;
|
|
||||||
cancel = ce.isCancelled();
|
|
||||||
highestReachedPriority = priority;
|
highestReachedPriority = priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO Remove. This is also redundant. The listeners are always called in order, the event is always being modified by each listener. The last listener therefore has the last decision on the cancellation.
|
|
||||||
if (event instanceof CancellableEvent) {
|
|
||||||
CancellableEvent ce = (CancellableEvent) event;
|
|
||||||
ce.setCancelled(cancel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PEEventManager.EVENT_MANAGER_LEGACY.callEvent(event, highestReachedPriority);
|
PEEventManager.EVENT_MANAGER_LEGACY.callEvent(event, highestReachedPriority);
|
||||||
@@ -105,6 +94,30 @@ class EventManagerModern {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister the dynamic packet event listener.
|
||||||
|
*
|
||||||
|
* @param listener {@link PacketListenerAbstract}
|
||||||
|
*/
|
||||||
|
public synchronized void unregisterListener(final PacketListenerAbstract listener) {
|
||||||
|
byte priority = listener.getPriority().getId();
|
||||||
|
HashSet<PacketListenerAbstract> listenerSet = listenersMap.get(priority);
|
||||||
|
if (listenerSet != null) {
|
||||||
|
listenerSet.remove(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister multiple dynamic packet event listeners with one method.
|
||||||
|
*
|
||||||
|
* @param listeners {@link PacketListenerAbstract}
|
||||||
|
*/
|
||||||
|
public synchronized void unregisterListeners(PacketListenerAbstract... listeners) {
|
||||||
|
for (PacketListenerAbstract listener : listeners) {
|
||||||
|
unregisterListener(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister all dynamic packet event listeners.
|
* Unregister all dynamic packet event listeners.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+8
-1
@@ -20,11 +20,13 @@ package io.github.retrooper.packetevents.injector.legacy;
|
|||||||
|
|
||||||
import io.github.retrooper.packetevents.PacketEvents;
|
import io.github.retrooper.packetevents.PacketEvents;
|
||||||
import io.github.retrooper.packetevents.processor.PacketProcessorInternal;
|
import io.github.retrooper.packetevents.processor.PacketProcessorInternal;
|
||||||
|
import net.minecraft.util.io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.util.io.netty.channel.ChannelDuplexHandler;
|
import net.minecraft.util.io.netty.channel.ChannelDuplexHandler;
|
||||||
|
import net.minecraft.util.io.netty.channel.ChannelHandler;
|
||||||
import net.minecraft.util.io.netty.channel.ChannelHandlerContext;
|
import net.minecraft.util.io.netty.channel.ChannelHandlerContext;
|
||||||
import net.minecraft.util.io.netty.channel.ChannelPromise;
|
import net.minecraft.util.io.netty.channel.ChannelPromise;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ChannelHandler.Sharable
|
||||||
public class PlayerChannelHandlerLegacy extends ChannelDuplexHandler {
|
public class PlayerChannelHandlerLegacy extends ChannelDuplexHandler {
|
||||||
/**
|
/**
|
||||||
* Associated player.
|
* Associated player.
|
||||||
@@ -43,6 +45,11 @@ public class PlayerChannelHandlerLegacy extends ChannelDuplexHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(final ChannelHandlerContext ctx, Object packet, final ChannelPromise promise) throws Exception {
|
public void write(final ChannelHandlerContext ctx, Object packet, final ChannelPromise promise) throws Exception {
|
||||||
|
if (packet instanceof ByteBuf) {
|
||||||
|
//Ignore bytebufs!
|
||||||
|
super.write(ctx, packet, promise);
|
||||||
|
return;
|
||||||
|
}
|
||||||
PacketProcessorInternal.PacketData data = PacketEvents.get().getInternalPacketProcessor().write(player, ctx.channel(), packet);
|
PacketProcessorInternal.PacketData data = PacketEvents.get().getInternalPacketProcessor().write(player, ctx.channel(), packet);
|
||||||
if (data.postAction != null) {
|
if (data.postAction != null) {
|
||||||
promise.addListener(f -> {
|
promise.addListener(f -> {
|
||||||
|
|||||||
+21
-5
@@ -25,6 +25,7 @@ import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
|||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
import io.github.retrooper.packetevents.utils.list.ListWrapper;
|
import io.github.retrooper.packetevents.utils.list.ListWrapper;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.ClassUtil;
|
||||||
import net.minecraft.util.io.netty.channel.Channel;
|
import net.minecraft.util.io.netty.channel.Channel;
|
||||||
import net.minecraft.util.io.netty.channel.ChannelFuture;
|
import net.minecraft.util.io.netty.channel.ChannelFuture;
|
||||||
import net.minecraft.util.io.netty.channel.ChannelHandler;
|
import net.minecraft.util.io.netty.channel.ChannelHandler;
|
||||||
@@ -125,12 +126,12 @@ public class EarlyChannelInjectorLegacy implements EarlyInjector {
|
|||||||
List<Object> networkManagers = NMSUtils.getNetworkManagers();
|
List<Object> networkManagers = NMSUtils.getNetworkManagers();
|
||||||
synchronized (networkManagers) {
|
synchronized (networkManagers) {
|
||||||
for (Object networkManager : networkManagers) {
|
for (Object networkManager : networkManagers) {
|
||||||
WrappedPacket networkManagerWrapper = new WrappedPacket(new NMSPacket(networkManager));
|
WrappedPacket networkManagerWrapper = new WrappedPacket(new NMSPacket(networkManager), NMSUtils.networkManagerClass);
|
||||||
Channel channel = (Channel) networkManagerWrapper.readObject(0, NMSUtils.nettyChannelClass);
|
Channel channel = (Channel) networkManagerWrapper.readObject(0, NMSUtils.nettyChannelClass);
|
||||||
if (channel == null) {
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel.pipeline().get(PacketEvents.get().getHandlerName()) != null) {
|
if (channel.pipeline().get(PacketEvents.get().getHandlerName()) != null) {
|
||||||
channel.pipeline().remove(PacketEvents.get().getHandlerName());
|
channel.pipeline().remove(PacketEvents.get().getHandlerName());
|
||||||
}
|
}
|
||||||
@@ -226,7 +227,7 @@ public class EarlyChannelInjectorLegacy implements EarlyInjector {
|
|||||||
childHandlerField.set(bootstrapAcceptor, ((PEChannelInitializerLegacy) oldInit).getOldChannelInitializer());
|
childHandlerField.set(bootstrapAcceptor, ((PEChannelInitializerLegacy) oldInit).getOldChannelInitializer());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
PacketEvents.get().getPlugin().getLogger().severe("PacketEvents failed to eject the injection handler! Please reboot!");
|
//PacketEvents.get().getPlugin().getLogger().severe("PacketEvents failed to eject the injection handler! Please reboot!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
injectedFutures.clear();
|
injectedFutures.clear();
|
||||||
@@ -242,7 +243,7 @@ public class EarlyChannelInjectorLegacy implements EarlyInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
PacketEvents.get().getPlugin().getLogger().severe("PacketEvents failed to eject the injection handler! Please reboot!!");
|
//PacketEvents.get().getPlugin().getLogger().severe("PacketEvents failed to eject the injection handler! Please reboot!!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,18 +283,33 @@ public class EarlyChannelInjectorLegacy implements EarlyInjector {
|
|||||||
@Override
|
@Override
|
||||||
public void writePacket(Object ch, Object rawNMSPacket) {
|
public void writePacket(Object ch, Object rawNMSPacket) {
|
||||||
Channel channel = (Channel) ch;
|
Channel channel = (Channel) ch;
|
||||||
|
//Don't write packets to fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.write(rawNMSPacket);
|
channel.write(rawNMSPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flushPackets(Object ch) {
|
public void flushPackets(Object ch) {
|
||||||
Channel channel = (Channel) ch;
|
Channel channel = (Channel) ch;
|
||||||
|
//Don't flush packets for fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.flush();
|
channel.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPacket(Object ch, Object rawNMSPacket) {
|
public void sendPacket(Object ch, Object rawNMSPacket) {
|
||||||
Channel channel = (Channel) ch;
|
Channel channel = (Channel) ch;
|
||||||
|
//Don't send packets to fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.writeAndFlush(rawNMSPacket);
|
channel.writeAndFlush(rawNMSPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
@@ -20,6 +20,7 @@ package io.github.retrooper.packetevents.injector.legacy.early;
|
|||||||
|
|
||||||
import io.github.retrooper.packetevents.PacketEvents;
|
import io.github.retrooper.packetevents.PacketEvents;
|
||||||
import io.github.retrooper.packetevents.injector.legacy.PlayerChannelHandlerLegacy;
|
import io.github.retrooper.packetevents.injector.legacy.PlayerChannelHandlerLegacy;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.ClassUtil;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
import net.minecraft.util.io.netty.channel.Channel;
|
import net.minecraft.util.io.netty.channel.Channel;
|
||||||
import net.minecraft.util.io.netty.channel.ChannelInitializer;
|
import net.minecraft.util.io.netty.channel.ChannelInitializer;
|
||||||
@@ -47,6 +48,10 @@ public class PEChannelInitializerLegacy extends ChannelInitializer<Channel> {
|
|||||||
protected void initChannel(Channel channel) throws Exception {
|
protected void initChannel(Channel channel) throws Exception {
|
||||||
initChannelMethod.invoke(oldChannelInitializer, channel);
|
initChannelMethod.invoke(oldChannelInitializer, channel);
|
||||||
PlayerChannelHandlerLegacy channelHandler = new PlayerChannelHandlerLegacy();
|
PlayerChannelHandlerLegacy channelHandler = new PlayerChannelHandlerLegacy();
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (channel.pipeline().get("packet_handler") != null) {
|
if (channel.pipeline().get("packet_handler") != null) {
|
||||||
String handlerName = PacketEvents.get().getHandlerName();
|
String handlerName = PacketEvents.get().getHandlerName();
|
||||||
if (channel.pipeline().get(handlerName) != null) {
|
if (channel.pipeline().get(handlerName) != null) {
|
||||||
|
|||||||
+22
-2
@@ -21,6 +21,7 @@ package io.github.retrooper.packetevents.injector.legacy.late;
|
|||||||
import io.github.retrooper.packetevents.PacketEvents;
|
import io.github.retrooper.packetevents.PacketEvents;
|
||||||
import io.github.retrooper.packetevents.injector.LateInjector;
|
import io.github.retrooper.packetevents.injector.LateInjector;
|
||||||
import io.github.retrooper.packetevents.injector.legacy.PlayerChannelHandlerLegacy;
|
import io.github.retrooper.packetevents.injector.legacy.PlayerChannelHandlerLegacy;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.ClassUtil;
|
||||||
import net.minecraft.util.io.netty.channel.Channel;
|
import net.minecraft.util.io.netty.channel.Channel;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -40,7 +41,11 @@ public class LateChannelInjectorLegacy implements LateInjector {
|
|||||||
PlayerChannelHandlerLegacy playerChannelHandlerLegacy = new PlayerChannelHandlerLegacy();
|
PlayerChannelHandlerLegacy playerChannelHandlerLegacy = new PlayerChannelHandlerLegacy();
|
||||||
playerChannelHandlerLegacy.player = player;
|
playerChannelHandlerLegacy.player = player;
|
||||||
Channel channel = (Channel) PacketEvents.get().getPlayerUtils().getChannel(player);
|
Channel channel = (Channel) PacketEvents.get().getPlayerUtils().getChannel(player);
|
||||||
channel.pipeline().addBefore("packet_handler", PacketEvents.get().getHandlerName(), playerChannelHandlerLegacy);
|
if (channel != null) {
|
||||||
|
channel.eventLoop().execute(() -> {
|
||||||
|
channel.pipeline().addBefore("packet_handler", PacketEvents.get().getHandlerName(), playerChannelHandlerLegacy);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -58,24 +63,39 @@ public class LateChannelInjectorLegacy implements LateInjector {
|
|||||||
@Override
|
@Override
|
||||||
public boolean hasInjected(Player player) {
|
public boolean hasInjected(Player player) {
|
||||||
Channel channel = (Channel) PacketEvents.get().getPlayerUtils().getChannel(player);
|
Channel channel = (Channel) PacketEvents.get().getPlayerUtils().getChannel(player);
|
||||||
return channel.pipeline().get(PacketEvents.get().getHandlerName()) != null;
|
return channel != null && channel.pipeline().get(PacketEvents.get().getHandlerName()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writePacket(Object ch, Object rawNMSPacket) {
|
public void writePacket(Object ch, Object rawNMSPacket) {
|
||||||
Channel channel = (Channel) ch;
|
Channel channel = (Channel) ch;
|
||||||
|
//Don't write packets to fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.write(rawNMSPacket);
|
channel.write(rawNMSPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flushPackets(Object ch) {
|
public void flushPackets(Object ch) {
|
||||||
Channel channel = (Channel) ch;
|
Channel channel = (Channel) ch;
|
||||||
|
//Don't flush packets for fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.flush();
|
channel.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPacket(Object rawChannel, Object packet) {
|
public void sendPacket(Object rawChannel, Object packet) {
|
||||||
Channel channel = (Channel) rawChannel;
|
Channel channel = (Channel) rawChannel;
|
||||||
|
//Don't send packets to fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.pipeline().writeAndFlush(packet);
|
channel.pipeline().writeAndFlush(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+8
@@ -20,11 +20,14 @@ package io.github.retrooper.packetevents.injector.modern;
|
|||||||
|
|
||||||
import io.github.retrooper.packetevents.PacketEvents;
|
import io.github.retrooper.packetevents.PacketEvents;
|
||||||
import io.github.retrooper.packetevents.processor.PacketProcessorInternal;
|
import io.github.retrooper.packetevents.processor.PacketProcessorInternal;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelDuplexHandler;
|
import io.netty.channel.ChannelDuplexHandler;
|
||||||
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelPromise;
|
import io.netty.channel.ChannelPromise;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ChannelHandler.Sharable
|
||||||
public class PlayerChannelHandlerModern extends ChannelDuplexHandler {
|
public class PlayerChannelHandlerModern extends ChannelDuplexHandler {
|
||||||
/**
|
/**
|
||||||
* Associated player.
|
* Associated player.
|
||||||
@@ -43,6 +46,11 @@ public class PlayerChannelHandlerModern extends ChannelDuplexHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(final ChannelHandlerContext ctx, Object packet, final ChannelPromise promise) throws Exception {
|
public void write(final ChannelHandlerContext ctx, Object packet, final ChannelPromise promise) throws Exception {
|
||||||
|
if (packet instanceof ByteBuf) {
|
||||||
|
//Ignore bytebufs!
|
||||||
|
super.write(ctx, packet, promise);
|
||||||
|
return;
|
||||||
|
}
|
||||||
PacketProcessorInternal.PacketData data = PacketEvents.get().getInternalPacketProcessor().write(player, ctx.channel(), packet);
|
PacketProcessorInternal.PacketData data = PacketEvents.get().getInternalPacketProcessor().write(player, ctx.channel(), packet);
|
||||||
if (data.postAction != null) {
|
if (data.postAction != null) {
|
||||||
promise.addListener(f -> {
|
promise.addListener(f -> {
|
||||||
|
|||||||
+26
-10
@@ -25,6 +25,7 @@ import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
|||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
import io.github.retrooper.packetevents.utils.list.ListWrapper;
|
import io.github.retrooper.packetevents.utils.list.ListWrapper;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.ClassUtil;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelFuture;
|
import io.netty.channel.ChannelFuture;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
@@ -73,10 +74,10 @@ public class EarlyChannelInjectorModern implements EarlyInjector {
|
|||||||
@Override
|
@Override
|
||||||
public void inject() {
|
public void inject() {
|
||||||
try {
|
try {
|
||||||
if (PaperChannelInjector.PAPER_INJECTION_METHOD) {
|
/* if (PaperChannelInjector.PAPER_INJECTION_METHOD) {
|
||||||
PaperChannelInjector.setPaperChannelInitializeListener();
|
PaperChannelInjector.setPaperChannelInitializeListener();
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
Object serverConnection = NMSUtils.getMinecraftServerConnection();
|
Object serverConnection = NMSUtils.getMinecraftServerConnection();
|
||||||
for (Field field : serverConnection.getClass().getDeclaredFields()) {
|
for (Field field : serverConnection.getClass().getDeclaredFields()) {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
@@ -128,9 +129,10 @@ public class EarlyChannelInjectorModern implements EarlyInjector {
|
|||||||
List<Object> networkManagers = NMSUtils.getNetworkManagers();
|
List<Object> networkManagers = NMSUtils.getNetworkManagers();
|
||||||
synchronized (networkManagers) {
|
synchronized (networkManagers) {
|
||||||
for (Object networkManager : networkManagers) {
|
for (Object networkManager : networkManagers) {
|
||||||
WrappedPacket networkManagerWrapper = new WrappedPacket(new NMSPacket(networkManager));
|
WrappedPacket networkManagerWrapper = new WrappedPacket(new NMSPacket(networkManager), NMSUtils.networkManagerClass);
|
||||||
Channel channel = (Channel) networkManagerWrapper.readObject(0, NMSUtils.nettyChannelClass);
|
Channel channel = (Channel) networkManagerWrapper.readObject(0, NMSUtils.nettyChannelClass);
|
||||||
if (channel == null) {
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,13 +197,13 @@ public class EarlyChannelInjectorModern implements EarlyInjector {
|
|||||||
@Override
|
@Override
|
||||||
public void eject() {
|
public void eject() {
|
||||||
// TODO: Uninject from players currently online to prevent protocol lib issues.
|
// TODO: Uninject from players currently online to prevent protocol lib issues.
|
||||||
if (PaperChannelInjector.PAPER_INJECTION_METHOD) {
|
/* if (PaperChannelInjector.PAPER_INJECTION_METHOD) {
|
||||||
try {
|
try {
|
||||||
PaperChannelInjector.removePaperChannelInitializeListener();
|
PaperChannelInjector.removePaperChannelInitializeListener();
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
Field childHandlerField = null;
|
Field childHandlerField = null;
|
||||||
for (ChannelFuture future : injectedFutures) {
|
for (ChannelFuture future : injectedFutures) {
|
||||||
List<String> names = future.channel().pipeline().names();
|
List<String> names = future.channel().pipeline().names();
|
||||||
@@ -235,7 +237,7 @@ public class EarlyChannelInjectorModern implements EarlyInjector {
|
|||||||
childHandlerField.set(bootstrapAcceptor, ((PEChannelInitializerModern) oldInit).getOldChannelInitializer());
|
childHandlerField.set(bootstrapAcceptor, ((PEChannelInitializerModern) oldInit).getOldChannelInitializer());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
PacketEvents.get().getPlugin().getLogger().severe("PacketEvents failed to eject the injection handler! Please reboot!");
|
//PacketEvents.get().getPlugin().getLogger().severe("PacketEvents failed to eject the injection handler! Please reboot!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
injectedFutures.clear();
|
injectedFutures.clear();
|
||||||
@@ -251,7 +253,7 @@ public class EarlyChannelInjectorModern implements EarlyInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
PacketEvents.get().getPlugin().getLogger().severe("PacketEvents failed to eject the injection handler! Please reboot!!");
|
//PacketEvents.get().getPlugin().getLogger().severe("PacketEvents failed to eject the injection handler! Please reboot!!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,9 +272,8 @@ public class EarlyChannelInjectorModern implements EarlyInjector {
|
|||||||
public void ejectPlayer(Player player) {
|
public void ejectPlayer(Player player) {
|
||||||
Object channel = PacketEvents.get().getPlayerUtils().getChannel(player);
|
Object channel = PacketEvents.get().getPlayerUtils().getChannel(player);
|
||||||
if (channel != null) {
|
if (channel != null) {
|
||||||
Channel chnl = (Channel) channel;
|
|
||||||
try {
|
try {
|
||||||
chnl.pipeline().remove(PacketEvents.get().getHandlerName());
|
((Channel)channel).pipeline().remove(PacketEvents.get().getHandlerName());
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,18 +292,33 @@ public class EarlyChannelInjectorModern implements EarlyInjector {
|
|||||||
@Override
|
@Override
|
||||||
public void writePacket(Object ch, Object rawNMSPacket) {
|
public void writePacket(Object ch, Object rawNMSPacket) {
|
||||||
Channel channel = (Channel) ch;
|
Channel channel = (Channel) ch;
|
||||||
|
//Don't write packets to fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.write(rawNMSPacket);
|
channel.write(rawNMSPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flushPackets(Object ch) {
|
public void flushPackets(Object ch) {
|
||||||
Channel channel = (Channel) ch;
|
Channel channel = (Channel) ch;
|
||||||
|
//Don't flush packets for fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.flush();
|
channel.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPacket(Object ch, Object rawNMSPacket) {
|
public void sendPacket(Object ch, Object rawNMSPacket) {
|
||||||
Channel channel = (Channel) ch;
|
Channel channel = (Channel) ch;
|
||||||
|
//Don't send packets to fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.writeAndFlush(rawNMSPacket);
|
channel.writeAndFlush(rawNMSPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -20,6 +20,7 @@ package io.github.retrooper.packetevents.injector.modern.early;
|
|||||||
|
|
||||||
import io.github.retrooper.packetevents.PacketEvents;
|
import io.github.retrooper.packetevents.PacketEvents;
|
||||||
import io.github.retrooper.packetevents.injector.modern.PlayerChannelHandlerModern;
|
import io.github.retrooper.packetevents.injector.modern.PlayerChannelHandlerModern;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.ClassUtil;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelInitializer;
|
import io.netty.channel.ChannelInitializer;
|
||||||
@@ -36,11 +37,16 @@ public class PEChannelInitializerModern extends ChannelInitializer<Channel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void postInitChannel(Channel channel) {
|
public static void postInitChannel(Channel channel) {
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
PlayerChannelHandlerModern channelHandler = new PlayerChannelHandlerModern();
|
PlayerChannelHandlerModern channelHandler = new PlayerChannelHandlerModern();
|
||||||
if (channel.pipeline().get("packet_handler") != null) {
|
if (channel.pipeline().get("packet_handler") != null) {
|
||||||
String handlerName = PacketEvents.get().getHandlerName();
|
String handlerName = PacketEvents.get().getHandlerName();
|
||||||
if (channel.pipeline().get(handlerName) != null) {
|
if (channel.pipeline().get(handlerName) != null) {
|
||||||
PacketEvents.get().getPlugin().getLogger().warning("[PacketEvents] Attempted to initialize a channel twice!");
|
//Just ignore this to support latest ProtocolLib snapshots.
|
||||||
|
//PacketEvents.get().getPlugin().getLogger().warning("[PacketEvents] Attempted to initialize a channel twice!");
|
||||||
} else {
|
} else {
|
||||||
channel.pipeline().addBefore("packet_handler", handlerName, channelHandler);
|
channel.pipeline().addBefore("packet_handler", handlerName, channelHandler);
|
||||||
}
|
}
|
||||||
|
|||||||
-67
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
|
||||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.github.retrooper.packetevents.injector.modern.early;
|
|
||||||
|
|
||||||
import io.github.retrooper.packetevents.PacketEvents;
|
|
||||||
import io.netty.channel.Channel;
|
|
||||||
import net.kyori.adventure.key.Key;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.lang.reflect.Proxy;
|
|
||||||
|
|
||||||
public class PaperChannelInjector {
|
|
||||||
public static final boolean PAPER_INJECTION_METHOD = hasPaperInjectionMethod();
|
|
||||||
|
|
||||||
private PaperChannelInjector() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPaperChannelInitializeListener() throws ReflectiveOperationException {
|
|
||||||
// Call io.papermc.paper.network.ChannelInitializeListenerHolder.addListener(net.kyori.adventure.key.Key, io.papermc.paper.network.ChannelInitializeListener)
|
|
||||||
// Create an interface proxy of ChannelInitializeListener
|
|
||||||
Class<?> listenerClass = Class.forName("io.papermc.paper.network.ChannelInitializeListener");
|
|
||||||
Object channelInitializeListener = Proxy.newProxyInstance(EarlyChannelInjectorModern.class.getClassLoader(), new Class[]{listenerClass}, (proxy, method, args) -> {
|
|
||||||
if (method.getName().equals("afterInitChannel")) {
|
|
||||||
PEChannelInitializerModern.postInitChannel((Channel) args[0]);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return method.invoke(proxy, args);
|
|
||||||
});
|
|
||||||
|
|
||||||
Class<?> holderClass = Class.forName("io.papermc.paper.network.ChannelInitializeListenerHolder");
|
|
||||||
Method addListenerMethod = holderClass.getDeclaredMethod("addListener", Key.class, listenerClass);
|
|
||||||
Key key = Key.key(PacketEvents.get().getHandlerName().toLowerCase(), "injector");
|
|
||||||
addListenerMethod.invoke(null, key, channelInitializeListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removePaperChannelInitializeListener() throws ReflectiveOperationException {
|
|
||||||
Class<?> holderClass = Class.forName("io.papermc.paper.network.ChannelInitializeListenerHolder");
|
|
||||||
Method addListenerMethod = holderClass.getDeclaredMethod("removeListener", Key.class);
|
|
||||||
Key key = Key.key(PacketEvents.get().getHandlerName().toLowerCase(), "injector");
|
|
||||||
addListenerMethod.invoke(null, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean hasPaperInjectionMethod() {
|
|
||||||
try {
|
|
||||||
Class.forName("io.papermc.paper.network.ChannelInitializeListener");
|
|
||||||
return true;
|
|
||||||
} catch (ReflectiveOperationException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+23
-4
@@ -21,6 +21,7 @@ package io.github.retrooper.packetevents.injector.modern.late;
|
|||||||
import io.github.retrooper.packetevents.PacketEvents;
|
import io.github.retrooper.packetevents.PacketEvents;
|
||||||
import io.github.retrooper.packetevents.injector.LateInjector;
|
import io.github.retrooper.packetevents.injector.LateInjector;
|
||||||
import io.github.retrooper.packetevents.injector.modern.PlayerChannelHandlerModern;
|
import io.github.retrooper.packetevents.injector.modern.PlayerChannelHandlerModern;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.ClassUtil;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -40,16 +41,19 @@ public class LateChannelInjectorModern implements LateInjector {
|
|||||||
PlayerChannelHandlerModern playerChannelHandlerModern = new PlayerChannelHandlerModern();
|
PlayerChannelHandlerModern playerChannelHandlerModern = new PlayerChannelHandlerModern();
|
||||||
playerChannelHandlerModern.player = player;
|
playerChannelHandlerModern.player = player;
|
||||||
Channel channel = (Channel) PacketEvents.get().getPlayerUtils().getChannel(player);
|
Channel channel = (Channel) PacketEvents.get().getPlayerUtils().getChannel(player);
|
||||||
channel.pipeline().addBefore("packet_handler", PacketEvents.get().getHandlerName(), playerChannelHandlerModern);
|
if (channel != null) {
|
||||||
|
channel.eventLoop().execute(() -> {
|
||||||
|
channel.pipeline().addBefore("packet_handler", PacketEvents.get().getHandlerName(), playerChannelHandlerModern);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ejectPlayer(Player player) {
|
public void ejectPlayer(Player player) {
|
||||||
Object channel = PacketEvents.get().getPlayerUtils().getChannel(player);
|
Object channel = PacketEvents.get().getPlayerUtils().getChannel(player);
|
||||||
if (channel != null) {
|
if (channel != null) {
|
||||||
Channel chnl = (Channel) channel;
|
|
||||||
try {
|
try {
|
||||||
chnl.pipeline().remove(PacketEvents.get().getHandlerName());
|
((Channel) channel).pipeline().remove(PacketEvents.get().getHandlerName());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -59,24 +63,39 @@ public class LateChannelInjectorModern implements LateInjector {
|
|||||||
@Override
|
@Override
|
||||||
public boolean hasInjected(Player player) {
|
public boolean hasInjected(Player player) {
|
||||||
Channel channel = (Channel) PacketEvents.get().getPlayerUtils().getChannel(player);
|
Channel channel = (Channel) PacketEvents.get().getPlayerUtils().getChannel(player);
|
||||||
return channel.pipeline().get(PacketEvents.get().getHandlerName()) != null;
|
return channel != null && channel.pipeline().get(PacketEvents.get().getHandlerName()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writePacket(Object ch, Object rawNMSPacket) {
|
public void writePacket(Object ch, Object rawNMSPacket) {
|
||||||
Channel channel = (Channel) ch;
|
Channel channel = (Channel) ch;
|
||||||
|
//Don't write packets to fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.write(rawNMSPacket);
|
channel.write(rawNMSPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flushPackets(Object ch) {
|
public void flushPackets(Object ch) {
|
||||||
Channel channel = (Channel) ch;
|
Channel channel = (Channel) ch;
|
||||||
|
//Don't flush packets for fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.flush();
|
channel.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPacket(Object rawChannel, Object packet) {
|
public void sendPacket(Object rawChannel, Object packet) {
|
||||||
Channel channel = (Channel) rawChannel;
|
Channel channel = (Channel) rawChannel;
|
||||||
|
//Don't send packets to fake channels
|
||||||
|
if (channel == null || ClassUtil.getClassSimpleName(channel.getClass()).equals("FakeChannel")
|
||||||
|
|| ClassUtil.getClassSimpleName(channel.getClass()).equals("SpoofedChannel")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
channel.pipeline().writeAndFlush(packet);
|
channel.pipeline().writeAndFlush(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,5 +23,5 @@ package io.github.retrooper.packetevents.packettype;
|
|||||||
* @since 1.8
|
* @since 1.8
|
||||||
*/
|
*/
|
||||||
public enum PacketState {
|
public enum PacketState {
|
||||||
STATUS, HANDSHAKING, LOGIN, PLAY
|
STATUS, HANDSHAKING, LOGIN, CONFIG, PLAY
|
||||||
}
|
}
|
||||||
@@ -39,6 +39,7 @@ public class PacketType {
|
|||||||
*/
|
*/
|
||||||
public static final byte INVALID = -128;
|
public static final byte INVALID = -128;
|
||||||
public static final Map<Class<?>, Byte> packetIDMap = new IdentityHashMap<>();
|
public static final Map<Class<?>, Byte> packetIDMap = new IdentityHashMap<>();
|
||||||
|
private static final boolean isNine = ServerVersion.getVersion().isNewerThanOrEquals(ServerVersion.v_1_9);
|
||||||
|
|
||||||
private static void insertPacketID(Class<?> cls, byte packetID) {
|
private static void insertPacketID(Class<?> cls, byte packetID) {
|
||||||
if (cls != null) {
|
if (cls != null) {
|
||||||
@@ -286,10 +287,7 @@ public class PacketType {
|
|||||||
* @return Has the client placed a block?
|
* @return Has the client placed a block?
|
||||||
*/
|
*/
|
||||||
public static boolean isBlockPlace(final byte packetID) {
|
public static boolean isBlockPlace(final byte packetID) {
|
||||||
final ServerVersion version = PacketEvents.get().getServerUtils().getVersion();
|
return isNine ? packetID == PacketType.Play.Client.USE_ITEM : packetID == PacketType.Play.Client.BLOCK_PLACE;
|
||||||
return version.isNewerThan(ServerVersion.v_1_8_8) ?
|
|
||||||
packetID == PacketType.Play.Client.USE_ITEM
|
|
||||||
: packetID == PacketType.Play.Client.BLOCK_PLACE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,7 +326,7 @@ public class PacketType {
|
|||||||
ADD_VIBRATION_SIGNAL = 30, CLEAR_TITLES = 31, INITIALIZE_BORDER = 32, PLAYER_COMBAT_END = 33,
|
ADD_VIBRATION_SIGNAL = 30, CLEAR_TITLES = 31, INITIALIZE_BORDER = 32, PLAYER_COMBAT_END = 33,
|
||||||
PLAYER_COMBAT_ENTER = 34, PLAYER_COMBAT_KILL = 35, SET_ACTIONBAR_TEXT = 36, SET_BORDER_CENTER = 37,
|
PLAYER_COMBAT_ENTER = 34, PLAYER_COMBAT_KILL = 35, SET_ACTIONBAR_TEXT = 36, SET_BORDER_CENTER = 37,
|
||||||
SET_BORDER_LERP_SIZE = 38, SET_BORDER_SIZE = 39, SET_BORDER_WARNING_DELAY = 40, SET_BORDER_WARNING_DISTANCE = 41,
|
SET_BORDER_LERP_SIZE = 38, SET_BORDER_SIZE = 39, SET_BORDER_WARNING_DELAY = 40, SET_BORDER_WARNING_DISTANCE = 41,
|
||||||
SET_SUBTITLE_TEXT = 42, SET_TITLES_ANIMATION = 43, SET_TITLE_TEXT = 44;
|
SET_SUBTITLE_TEXT = 42, SET_TITLES_ANIMATION = 43, SET_TITLE_TEXT = 44, SYSTEM_CHAT = 45;
|
||||||
|
|
||||||
private static void load() {
|
private static void load() {
|
||||||
insertPacketID(PacketTypeClasses.Play.Server.SPAWN_ENTITY, SPAWN_ENTITY);
|
insertPacketID(PacketTypeClasses.Play.Server.SPAWN_ENTITY, SPAWN_ENTITY);
|
||||||
@@ -442,6 +440,7 @@ public class PacketType {
|
|||||||
insertPacketID(PacketTypeClasses.Play.Server.SET_SUBTITLE_TEXT, SET_SUBTITLE_TEXT);
|
insertPacketID(PacketTypeClasses.Play.Server.SET_SUBTITLE_TEXT, SET_SUBTITLE_TEXT);
|
||||||
insertPacketID(PacketTypeClasses.Play.Server.SET_TITLES_ANIMATION, SET_TITLES_ANIMATION);
|
insertPacketID(PacketTypeClasses.Play.Server.SET_TITLES_ANIMATION, SET_TITLES_ANIMATION);
|
||||||
insertPacketID(PacketTypeClasses.Play.Server.SET_TITLE_TEXT, SET_TITLE_TEXT);
|
insertPacketID(PacketTypeClasses.Play.Server.SET_TITLE_TEXT, SET_TITLE_TEXT);
|
||||||
|
insertPacketID(PacketTypeClasses.Play.Server.SYSTEM_CHAT, SYSTEM_CHAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class PacketTypeClasses {
|
|||||||
PREFIX = "net.minecraft.network.protocol.status.";
|
PREFIX = "net.minecraft.network.protocol.status.";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PREFIX = ServerVersion.getNMSDirectory() + ".";
|
PREFIX = ServerVersion.getNMSDirectory();
|
||||||
}
|
}
|
||||||
Client.START = Reflection.getClassByNameWithoutException(PREFIX + "PacketStatusInStart");
|
Client.START = Reflection.getClassByNameWithoutException(PREFIX + "PacketStatusInStart");
|
||||||
Client.PING = Reflection.getClassByNameWithoutException(PREFIX + "PacketStatusInPing");
|
Client.PING = Reflection.getClassByNameWithoutException(PREFIX + "PacketStatusInPing");
|
||||||
@@ -64,7 +64,7 @@ public class PacketTypeClasses {
|
|||||||
PREFIX = "net.minecraft.network.protocol.status.";
|
PREFIX = "net.minecraft.network.protocol.status.";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PREFIX = ServerVersion.getNMSDirectory() + ".";
|
PREFIX = ServerVersion.getNMSDirectory();
|
||||||
}
|
}
|
||||||
Server.PONG = Reflection.getClassByNameWithoutException(PREFIX + "PacketStatusOutPong");
|
Server.PONG = Reflection.getClassByNameWithoutException(PREFIX + "PacketStatusOutPong");
|
||||||
Server.SERVER_INFO = Reflection.getClassByNameWithoutException(PREFIX + "PacketStatusOutServerInfo");
|
Server.SERVER_INFO = Reflection.getClassByNameWithoutException(PREFIX + "PacketStatusOutServerInfo");
|
||||||
@@ -82,7 +82,7 @@ public class PacketTypeClasses {
|
|||||||
PREFIX = "net.minecraft.network.protocol.handshake.";
|
PREFIX = "net.minecraft.network.protocol.handshake.";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PREFIX = ServerVersion.getNMSDirectory() + ".";
|
PREFIX = ServerVersion.getNMSDirectory();
|
||||||
}
|
}
|
||||||
Handshaking.Client.SET_PROTOCOL = Reflection.getClassByNameWithoutException(PREFIX + "PacketHandshakingInSetProtocol");
|
Handshaking.Client.SET_PROTOCOL = Reflection.getClassByNameWithoutException(PREFIX + "PacketHandshakingInSetProtocol");
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ public class PacketTypeClasses {
|
|||||||
PREFIX = "net.minecraft.network.protocol.login.";
|
PREFIX = "net.minecraft.network.protocol.login.";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PREFIX = ServerVersion.getNMSDirectory() + ".";
|
PREFIX = ServerVersion.getNMSDirectory();
|
||||||
}
|
}
|
||||||
//In and Out custom payload login packets have been here since 1.13
|
//In and Out custom payload login packets have been here since 1.13
|
||||||
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_13)) {
|
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_13)) {
|
||||||
@@ -119,7 +119,7 @@ public class PacketTypeClasses {
|
|||||||
PREFIX = "net.minecraft.network.protocol.login.";
|
PREFIX = "net.minecraft.network.protocol.login.";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PREFIX = ServerVersion.getNMSDirectory() + ".";
|
PREFIX = ServerVersion.getNMSDirectory();
|
||||||
}
|
}
|
||||||
//In and Out custom payload login packets have been here since 1.13
|
//In and Out custom payload login packets have been here since 1.13
|
||||||
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_13)) {
|
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_13)) {
|
||||||
@@ -137,8 +137,7 @@ public class PacketTypeClasses {
|
|||||||
|
|
||||||
public static class Play {
|
public static class Play {
|
||||||
public static class Client {
|
public static class Client {
|
||||||
private static String COMMON_PREFIX;
|
private static String COMMON_PREFIX, PREFIX, PREFIX_COMMON_STATES;
|
||||||
private static String PREFIX;
|
|
||||||
public static Class<?> FLYING, POSITION, POSITION_LOOK, LOOK, GROUND, CLIENT_COMMAND,
|
public static Class<?> FLYING, POSITION, POSITION_LOOK, LOOK, GROUND, CLIENT_COMMAND,
|
||||||
TRANSACTION, BLOCK_DIG, ENTITY_ACTION, USE_ENTITY,
|
TRANSACTION, BLOCK_DIG, ENTITY_ACTION, USE_ENTITY,
|
||||||
WINDOW_CLICK, STEER_VEHICLE, CUSTOM_PAYLOAD, ARM_ANIMATION,
|
WINDOW_CLICK, STEER_VEHICLE, CUSTOM_PAYLOAD, ARM_ANIMATION,
|
||||||
@@ -157,9 +156,12 @@ public class PacketTypeClasses {
|
|||||||
public static void load() {
|
public static void load() {
|
||||||
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_17)) {
|
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_17)) {
|
||||||
PREFIX = "net.minecraft.network.protocol.game.";
|
PREFIX = "net.minecraft.network.protocol.game.";
|
||||||
|
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_20_2)) {
|
||||||
|
PREFIX_COMMON_STATES = "net.minecraft.network.protocol.common.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PREFIX = ServerVersion.getNMSDirectory() + ".";
|
PREFIX = ServerVersion.getNMSDirectory();
|
||||||
}
|
}
|
||||||
COMMON_PREFIX = PREFIX + "PacketPlayIn";
|
COMMON_PREFIX = PREFIX + "PacketPlayIn";
|
||||||
FLYING = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Flying");
|
FLYING = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Flying");
|
||||||
@@ -174,6 +176,19 @@ public class PacketTypeClasses {
|
|||||||
}
|
}
|
||||||
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_17)) {
|
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_17)) {
|
||||||
GROUND = SubclassUtil.getSubClass(FLYING, "d");
|
GROUND = SubclassUtil.getSubClass(FLYING, "d");
|
||||||
|
if (GROUND == null) {
|
||||||
|
GROUND = SubclassUtil.getSubClass(FLYING, 0);
|
||||||
|
}
|
||||||
|
if (POSITION == null) {
|
||||||
|
POSITION = SubclassUtil.getSubClass(FLYING, 2);
|
||||||
|
}
|
||||||
|
if (POSITION_LOOK == null) {
|
||||||
|
POSITION_LOOK = SubclassUtil.getSubClass(FLYING, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LOOK == null) {
|
||||||
|
LOOK = SubclassUtil.getSubClass(FLYING, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GROUND = FLYING;
|
GROUND = FLYING;
|
||||||
@@ -182,17 +197,25 @@ public class PacketTypeClasses {
|
|||||||
TRANSACTION = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Transaction");
|
TRANSACTION = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Transaction");
|
||||||
//This packet was added in 1.17 protocol
|
//This packet was added in 1.17 protocol
|
||||||
PONG = Reflection.getClassByNameWithoutException(PREFIX + "ServerboundPongPacket");
|
PONG = Reflection.getClassByNameWithoutException(PREFIX + "ServerboundPongPacket");
|
||||||
|
if (PONG == null) {
|
||||||
|
PONG = Reflection.getClassByNameWithoutException(PREFIX_COMMON_STATES + "ServerboundPongPacket");
|
||||||
|
}
|
||||||
|
SETTINGS = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Settings");
|
||||||
|
if (SETTINGS == null) {
|
||||||
|
SETTINGS = Reflection.getClassByNameWithoutException(PREFIX_COMMON_STATES + "ServerboundClientInformationPacket");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
SETTINGS = Class.forName(COMMON_PREFIX + "Settings");
|
|
||||||
ENCHANT_ITEM = Class.forName(COMMON_PREFIX + "EnchantItem");
|
ENCHANT_ITEM = Class.forName(COMMON_PREFIX + "EnchantItem");
|
||||||
|
|
||||||
CLIENT_COMMAND = Class.forName(COMMON_PREFIX + "ClientCommand");
|
CLIENT_COMMAND = Class.forName(COMMON_PREFIX + "ClientCommand");
|
||||||
BLOCK_DIG = Class.forName(COMMON_PREFIX + "BlockDig");
|
BLOCK_DIG = Class.forName(COMMON_PREFIX + "BlockDig");
|
||||||
ENTITY_ACTION = Class.forName(COMMON_PREFIX + "EntityAction");
|
ENTITY_ACTION = Class.forName(COMMON_PREFIX + "EntityAction");
|
||||||
USE_ENTITY = Class.forName(COMMON_PREFIX + "UseEntity");
|
USE_ENTITY = Class.forName(COMMON_PREFIX + "UseEntity");
|
||||||
WINDOW_CLICK = Class.forName(COMMON_PREFIX + "WindowClick");
|
WINDOW_CLICK = Class.forName(COMMON_PREFIX + "WindowClick");
|
||||||
STEER_VEHICLE = Class.forName(COMMON_PREFIX + "SteerVehicle");
|
STEER_VEHICLE = Class.forName(COMMON_PREFIX + "SteerVehicle");
|
||||||
CUSTOM_PAYLOAD = Class.forName(COMMON_PREFIX + "CustomPayload");
|
CUSTOM_PAYLOAD = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "CustomPayload");
|
||||||
|
if (CUSTOM_PAYLOAD == null) {
|
||||||
|
CUSTOM_PAYLOAD = Reflection.getClassByNameWithoutException(PREFIX_COMMON_STATES + "ServerboundCustomPayloadPacket");
|
||||||
|
}
|
||||||
ARM_ANIMATION = Class.forName(COMMON_PREFIX + "ArmAnimation");
|
ARM_ANIMATION = Class.forName(COMMON_PREFIX + "ArmAnimation");
|
||||||
ABILITIES = Class.forName(COMMON_PREFIX + "Abilities");
|
ABILITIES = Class.forName(COMMON_PREFIX + "Abilities");
|
||||||
HELD_ITEM_SLOT = Class.forName(COMMON_PREFIX + "HeldItemSlot");
|
HELD_ITEM_SLOT = Class.forName(COMMON_PREFIX + "HeldItemSlot");
|
||||||
@@ -200,7 +223,10 @@ public class PacketTypeClasses {
|
|||||||
TAB_COMPLETE = Class.forName(COMMON_PREFIX + "TabComplete");
|
TAB_COMPLETE = Class.forName(COMMON_PREFIX + "TabComplete");
|
||||||
CHAT = Class.forName(COMMON_PREFIX + "Chat");
|
CHAT = Class.forName(COMMON_PREFIX + "Chat");
|
||||||
SET_CREATIVE_SLOT = Class.forName(COMMON_PREFIX + "SetCreativeSlot");
|
SET_CREATIVE_SLOT = Class.forName(COMMON_PREFIX + "SetCreativeSlot");
|
||||||
KEEP_ALIVE = Class.forName(COMMON_PREFIX + "KeepAlive");
|
KEEP_ALIVE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "KeepAlive");
|
||||||
|
if (KEEP_ALIVE == null) {
|
||||||
|
KEEP_ALIVE = Reflection.getClassByNameWithoutException(PREFIX_COMMON_STATES + "ServerboundKeepAlivePacket");
|
||||||
|
}
|
||||||
UPDATE_SIGN = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "UpdateSign");
|
UPDATE_SIGN = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "UpdateSign");
|
||||||
|
|
||||||
TELEPORT_ACCEPT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "TeleportAccept");
|
TELEPORT_ACCEPT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "TeleportAccept");
|
||||||
@@ -241,7 +267,7 @@ public class PacketTypeClasses {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Server {
|
public static class Server {
|
||||||
private static String COMMON_PREFIX, PREFIX;
|
private static String COMMON_PREFIX, PREFIX, PREFIX_COMMON_STATES;
|
||||||
public static Class<?> SPAWN_ENTITY, SPAWN_ENTITY_EXPERIENCE_ORB, SPAWN_ENTITY_WEATHER, SPAWN_ENTITY_LIVING,
|
public static Class<?> SPAWN_ENTITY, SPAWN_ENTITY_EXPERIENCE_ORB, SPAWN_ENTITY_WEATHER, SPAWN_ENTITY_LIVING,
|
||||||
SPAWN_ENTITY_PAINTING, SPAWN_ENTITY_SPAWN, ANIMATION, STATISTIC,
|
SPAWN_ENTITY_PAINTING, SPAWN_ENTITY_SPAWN, ANIMATION, STATISTIC,
|
||||||
BLOCK_BREAK, BLOCK_BREAK_ANIMATION, TILE_ENTITY_DATA, BLOCK_ACTION,
|
BLOCK_BREAK, BLOCK_BREAK_ANIMATION, TILE_ENTITY_DATA, BLOCK_ACTION,
|
||||||
@@ -267,7 +293,8 @@ public class PacketTypeClasses {
|
|||||||
ENTITY_EFFECT, RECIPE_UPDATE, TAGS, MAP_CHUNK_BULK, NAMED_ENTITY_SPAWN, PING, ADD_VIBRATION_SIGNAL,
|
ENTITY_EFFECT, RECIPE_UPDATE, TAGS, MAP_CHUNK_BULK, NAMED_ENTITY_SPAWN, PING, ADD_VIBRATION_SIGNAL,
|
||||||
CLEAR_TITLES, INITIALIZE_BORDER, PLAYER_COMBAT_END, PLAYER_COMBAT_ENTER, PLAYER_COMBAT_KILL,
|
CLEAR_TITLES, INITIALIZE_BORDER, PLAYER_COMBAT_END, PLAYER_COMBAT_ENTER, PLAYER_COMBAT_KILL,
|
||||||
SET_ACTIONBAR_TEXT, SET_BORDER_CENTER, SET_BORDER_LERP_SIZE, SET_BORDER_SIZE, SET_BORDER_WARNING_DELAY,
|
SET_ACTIONBAR_TEXT, SET_BORDER_CENTER, SET_BORDER_LERP_SIZE, SET_BORDER_SIZE, SET_BORDER_WARNING_DELAY,
|
||||||
SET_BORDER_WARNING_DISTANCE, SET_SUBTITLE_TEXT, SET_TITLES_ANIMATION, SET_TITLE_TEXT;
|
SET_BORDER_WARNING_DISTANCE, SET_SUBTITLE_TEXT, SET_TITLES_ANIMATION, SET_TITLE_TEXT,
|
||||||
|
SYSTEM_CHAT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiate all client-bound packet classes.
|
* Initiate all client-bound packet classes.
|
||||||
@@ -275,9 +302,12 @@ public class PacketTypeClasses {
|
|||||||
public static void load() {
|
public static void load() {
|
||||||
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_17)) {
|
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_17)) {
|
||||||
PREFIX = "net.minecraft.network.protocol.game.";
|
PREFIX = "net.minecraft.network.protocol.game.";
|
||||||
|
if (PacketEvents.get().getServerUtils().getVersion().isNewerThanOrEquals(ServerVersion.v_1_20_2)) {
|
||||||
|
PREFIX_COMMON_STATES = "net.minecraft.network.protocol.common.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PREFIX = ServerVersion.getNMSDirectory() + ".";
|
PREFIX = ServerVersion.getNMSDirectory();
|
||||||
}
|
}
|
||||||
COMMON_PREFIX = PREFIX + "PacketPlayOut";
|
COMMON_PREFIX = PREFIX + "PacketPlayOut";
|
||||||
SPAWN_ENTITY = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "SpawnEntity");
|
SPAWN_ENTITY = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "SpawnEntity");
|
||||||
@@ -296,6 +326,9 @@ public class PacketTypeClasses {
|
|||||||
BOSS = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Boss");
|
BOSS = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Boss");
|
||||||
SERVER_DIFFICULTY = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "ServerDifficulty");
|
SERVER_DIFFICULTY = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "ServerDifficulty");
|
||||||
CHAT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Chat");
|
CHAT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Chat");
|
||||||
|
if (CHAT == null) {
|
||||||
|
CHAT = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundPlayerChatPacket");
|
||||||
|
}
|
||||||
MULTI_BLOCK_CHANGE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "MultiBlockChange");
|
MULTI_BLOCK_CHANGE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "MultiBlockChange");
|
||||||
TAB_COMPLETE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "TabComplete");
|
TAB_COMPLETE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "TabComplete");
|
||||||
COMMANDS = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Commands");
|
COMMANDS = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Commands");
|
||||||
@@ -306,14 +339,23 @@ public class PacketTypeClasses {
|
|||||||
SET_SLOT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "SetSlot");
|
SET_SLOT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "SetSlot");
|
||||||
SET_COOLDOWN = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "SetCooldown");
|
SET_COOLDOWN = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "SetCooldown");
|
||||||
CUSTOM_PAYLOAD = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "CustomPayload");
|
CUSTOM_PAYLOAD = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "CustomPayload");
|
||||||
|
if (CUSTOM_PAYLOAD == null) {
|
||||||
|
CUSTOM_PAYLOAD = Reflection.getClassByNameWithoutException(PREFIX_COMMON_STATES + "ClientboundCustomPayloadPacket");
|
||||||
|
}
|
||||||
CUSTOM_SOUND_EFFECT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "CustomSoundEffect");
|
CUSTOM_SOUND_EFFECT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "CustomSoundEffect");
|
||||||
KICK_DISCONNECT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "KickDisconnect");
|
KICK_DISCONNECT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "KickDisconnect");
|
||||||
|
if (KICK_DISCONNECT == null) {
|
||||||
|
KICK_DISCONNECT = Reflection.getClassByNameWithoutException(PREFIX_COMMON_STATES + "ClientboundDisconnectPacket");
|
||||||
|
}
|
||||||
ENTITY_STATUS = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "EntityStatus");
|
ENTITY_STATUS = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "EntityStatus");
|
||||||
EXPLOSION = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Explosion");
|
EXPLOSION = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "Explosion");
|
||||||
UNLOAD_CHUNK = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "UnloadChunk");
|
UNLOAD_CHUNK = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "UnloadChunk");
|
||||||
GAME_STATE_CHANGE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "GameStateChange");
|
GAME_STATE_CHANGE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "GameStateChange");
|
||||||
OPEN_WINDOW_HORSE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "OpenWindowHorse");
|
OPEN_WINDOW_HORSE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "OpenWindowHorse");
|
||||||
KEEP_ALIVE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "KeepAlive");
|
KEEP_ALIVE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "KeepAlive");
|
||||||
|
if (KEEP_ALIVE == null) {
|
||||||
|
KEEP_ALIVE = Reflection.getClassByNameWithoutException(PREFIX_COMMON_STATES + "ClientboundKeepAlivePacket");
|
||||||
|
}
|
||||||
MAP_CHUNK = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "MapChunk");
|
MAP_CHUNK = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "MapChunk");
|
||||||
WORLD_EVENT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "WorldEvent");
|
WORLD_EVENT = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "WorldEvent");
|
||||||
WORLD_PARTICLES = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "WorldParticles");
|
WORLD_PARTICLES = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "WorldParticles");
|
||||||
@@ -330,6 +372,16 @@ public class PacketTypeClasses {
|
|||||||
REL_ENTITY_MOVE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "RelEntityMove");
|
REL_ENTITY_MOVE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "RelEntityMove");
|
||||||
REL_ENTITY_MOVE_LOOK = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "RelEntityMoveLook");
|
REL_ENTITY_MOVE_LOOK = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "RelEntityMoveLook");
|
||||||
ENTITY_LOOK = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "RelEntityLook");
|
ENTITY_LOOK = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "RelEntityLook");
|
||||||
|
|
||||||
|
if (REL_ENTITY_MOVE == null) {
|
||||||
|
REL_ENTITY_MOVE = SubclassUtil.getSubClass(ENTITY, 1);
|
||||||
|
}
|
||||||
|
if (REL_ENTITY_MOVE_LOOK == null) {
|
||||||
|
REL_ENTITY_MOVE_LOOK = SubclassUtil.getSubClass(ENTITY, 2);
|
||||||
|
}
|
||||||
|
if (ENTITY_LOOK == null) {
|
||||||
|
ENTITY_LOOK = SubclassUtil.getSubClass(ENTITY, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
VEHICLE_MOVE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "VehicleMove");
|
VEHICLE_MOVE = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "VehicleMove");
|
||||||
OPEN_BOOK = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "OpenBook");
|
OPEN_BOOK = Reflection.getClassByNameWithoutException(COMMON_PREFIX + "OpenBook");
|
||||||
@@ -384,6 +436,9 @@ public class PacketTypeClasses {
|
|||||||
|
|
||||||
//These packets were added in 1.17
|
//These packets were added in 1.17
|
||||||
PING = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundPingPacket");
|
PING = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundPingPacket");
|
||||||
|
if (PING == null) {
|
||||||
|
PING = Reflection.getClassByNameWithoutException(PREFIX_COMMON_STATES + "ClientboundPingPacket");
|
||||||
|
}
|
||||||
ADD_VIBRATION_SIGNAL = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundAddVibrationSignalPacket");
|
ADD_VIBRATION_SIGNAL = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundAddVibrationSignalPacket");
|
||||||
CLEAR_TITLES = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundClearTitlesPacket");
|
CLEAR_TITLES = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundClearTitlesPacket");
|
||||||
INITIALIZE_BORDER = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundInitializeBorderPacket");
|
INITIALIZE_BORDER = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundInitializeBorderPacket");
|
||||||
@@ -399,8 +454,13 @@ public class PacketTypeClasses {
|
|||||||
SET_SUBTITLE_TEXT = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundSetSubtitleTextPacket");
|
SET_SUBTITLE_TEXT = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundSetSubtitleTextPacket");
|
||||||
SET_TITLES_ANIMATION = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundSetTitlesAnimationPacket");
|
SET_TITLES_ANIMATION = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundSetTitlesAnimationPacket");
|
||||||
SET_TITLE_TEXT = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundSetTitleTextPacket");
|
SET_TITLE_TEXT = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundSetTitleTextPacket");
|
||||||
|
SYSTEM_CHAT = Reflection.getClassByNameWithoutException(PREFIX + "ClientboundSystemChatPacket");
|
||||||
|
|
||||||
|
// 1.18+ only, doesn't follow the naming convention
|
||||||
|
if (MAP_CHUNK == null) {
|
||||||
|
MAP_CHUNK = Reflection.getClassByNameWithoutException("net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,8 @@ import io.github.retrooper.packetevents.exceptions.WrapperUnsupportedUsageExcept
|
|||||||
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.api.WrapperPacketReader;
|
import io.github.retrooper.packetevents.packetwrappers.api.WrapperPacketReader;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.api.WrapperPacketWriter;
|
import io.github.retrooper.packetevents.packetwrappers.api.WrapperPacketWriter;
|
||||||
|
import io.github.retrooper.packetevents.utils.ConditionalValue;
|
||||||
|
import io.github.retrooper.packetevents.utils.MojangEitherUtil;
|
||||||
import io.github.retrooper.packetevents.utils.enums.EnumUtil;
|
import io.github.retrooper.packetevents.utils.enums.EnumUtil;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
import io.github.retrooper.packetevents.utils.player.GameMode;
|
import io.github.retrooper.packetevents.utils.player.GameMode;
|
||||||
@@ -34,6 +36,7 @@ import io.github.retrooper.packetevents.utils.vector.Vector3i;
|
|||||||
import io.github.retrooper.packetevents.utils.world.Difficulty;
|
import io.github.retrooper.packetevents.utils.world.Difficulty;
|
||||||
import io.github.retrooper.packetevents.utils.world.Dimension;
|
import io.github.retrooper.packetevents.utils.world.Dimension;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@@ -42,15 +45,12 @@ import java.lang.annotation.Target;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
|
public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
|
||||||
|
|
||||||
private static final Map<Class<? extends WrappedPacket>, Boolean> LOADED_WRAPPERS = new ConcurrentHashMap<>();
|
private static final Map<Class<? extends WrappedPacket>, Boolean> LOADED_WRAPPERS = new ConcurrentHashMap<>();
|
||||||
private static final Map<Class<?>, Map<Class<?>, Field[]>> FIELD_CACHE = new ConcurrentHashMap<>();
|
private static final Map<Class<?>, Map<Class<?>, Field[]>> FIELD_CACHE = new ConcurrentHashMap<>();
|
||||||
private static final Field[] EMPTY_FIELD_ARRAY = new Field[0];
|
private static final Field[] EMPTY_FIELD_ARRAY = new Field[0];
|
||||||
@@ -383,6 +383,9 @@ public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
|
|||||||
public void writeAnyObject(int index, Object value) {
|
public void writeAnyObject(int index, Object value) {
|
||||||
try {
|
try {
|
||||||
Field f = packetClass.getDeclaredFields()[index];
|
Field f = packetClass.getDeclaredFields()[index];
|
||||||
|
if (!f.isAccessible()) {
|
||||||
|
f.setAccessible(true);
|
||||||
|
}
|
||||||
f.set(packet.getRawNMSPacket(), value);
|
f.set(packet.getRawNMSPacket(), value);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new WrapperFieldNotFoundException("PacketEvents failed to find any field indexed " + index + " in the " + ClassUtil.getClassSimpleName(packetClass) + " class!");
|
throw new WrapperFieldNotFoundException("PacketEvents failed to find any field indexed " + index + " in the " + ClassUtil.getClassSimpleName(packetClass) + " class!");
|
||||||
@@ -393,8 +396,7 @@ public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
|
|||||||
public void writeEnumConstant(int index, Enum<?> enumConstant) {
|
public void writeEnumConstant(int index, Enum<?> enumConstant) {
|
||||||
try {
|
try {
|
||||||
write(enumConstant.getClass(), index, enumConstant);
|
write(enumConstant.getClass(), index, enumConstant);
|
||||||
}
|
} catch (WrapperFieldNotFoundException ex) {
|
||||||
catch (WrapperFieldNotFoundException ex) {
|
|
||||||
write(enumConstant.getDeclaringClass(), index, enumConstant);
|
write(enumConstant.getDeclaringClass(), index, enumConstant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,9 +416,30 @@ public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
|
|||||||
public Vector3i readBlockPosition(int index) {
|
public Vector3i readBlockPosition(int index) {
|
||||||
Object blockPosObj = readObject(index, NMSUtils.blockPosClass);
|
Object blockPosObj = readObject(index, NMSUtils.blockPosClass);
|
||||||
try {
|
try {
|
||||||
int x = (int) NMSUtils.getBlockPosX.invoke(blockPosObj);
|
int x, y, z;
|
||||||
int y = (int) NMSUtils.getBlockPosY.invoke(blockPosObj);
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_20_5)) {
|
||||||
int z = (int) NMSUtils.getBlockPosZ.invoke(blockPosObj);
|
x = (int) NMSUtils.getBaseBlockPosX.get(blockPosObj);
|
||||||
|
y = (int) NMSUtils.getBaseBlockPosY.get(blockPosObj);
|
||||||
|
z = (int) NMSUtils.getBaseBlockPosZ.get(blockPosObj);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x = (int) NMSUtils.getBlockPosX.invoke(blockPosObj);
|
||||||
|
y = (int) NMSUtils.getBlockPosY.invoke(blockPosObj);
|
||||||
|
z = (int) NMSUtils.getBlockPosZ.invoke(blockPosObj);
|
||||||
|
}
|
||||||
|
return new Vector3i(x, y, z);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3i readSectionPosition(int index) {
|
||||||
|
Object blockPosObj = readObject(index, NMSUtils.sectionPositionClass);
|
||||||
|
try {
|
||||||
|
int x = (Integer) NMSUtils.getBlockPosX.invoke(blockPosObj);
|
||||||
|
int y = (Integer) NMSUtils.getBlockPosY.invoke(blockPosObj);
|
||||||
|
int z = (Integer) NMSUtils.getBlockPosZ.invoke(blockPosObj);
|
||||||
return new Vector3i(x, y, z);
|
return new Vector3i(x, y, z);
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -439,13 +462,19 @@ public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
|
|||||||
write(NMSUtils.nmsItemStackClass, index, nmsItemStack);
|
write(NMSUtils.nmsItemStackClass, index, nmsItemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public GameMode readGameMode(int index) {
|
public GameMode readGameMode(int index) {
|
||||||
Enum<?> enumConst = readEnumConstant(index, NMSUtils.enumGameModeClass);
|
Enum<?> enumConst = readEnumConstant(index, NMSUtils.enumGameModeClass);
|
||||||
return GameMode.values()[enumConst.ordinal() - 1];
|
int targetIndex = enumConst.ordinal() - 1;
|
||||||
|
if (targetIndex == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return GameMode.values()[targetIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeGameMode(int index, GameMode gameMode) {
|
public void writeGameMode(int index, @Nullable GameMode gameMode) {
|
||||||
Enum<?> enumConst = EnumUtil.valueByIndex(NMSUtils.enumGameModeClass, gameMode.ordinal() + 1);
|
int i = gameMode != null ? (gameMode.ordinal() + 1) : (0);
|
||||||
|
Enum<?> enumConst = EnumUtil.valueByIndex(NMSUtils.enumGameModeClass, i);
|
||||||
writeEnumConstant(index, enumConst);
|
writeEnumConstant(index, enumConst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,12 +533,7 @@ public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeMinecraftKey(int index, String content) {
|
public void writeMinecraftKey(int index, String content) {
|
||||||
Object minecraftKey = null;
|
Object minecraftKey = NMSUtils.generateMinecraftKeyNew(content);
|
||||||
try {
|
|
||||||
minecraftKey = NMSUtils.minecraftKeyConstructor.newInstance(content);
|
|
||||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
write(NMSUtils.minecraftKeyClass, index, minecraftKey);
|
write(NMSUtils.minecraftKeyClass, index, minecraftKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,6 +545,34 @@ public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
|
|||||||
write(List.class, index, list);
|
write(List.class, index, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T, K> ConditionalValue<T, K> readEither(int index) {
|
||||||
|
Object either = readObject(index, NMSUtils.mojangEitherClass);
|
||||||
|
Optional<T> left = MojangEitherUtil.getLeft(either);
|
||||||
|
if (left.isPresent()) {
|
||||||
|
return ConditionalValue.makeLeft(left.get());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Optional<K> right = MojangEitherUtil.getRight(either);
|
||||||
|
try {
|
||||||
|
return ConditionalValue.makeRight(right.orElseThrow((Supplier<Throwable>) () -> new IllegalStateException("Conditional value has no values. Atleast one side must have a value!")));
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T, K> void writeEither(int index, ConditionalValue<T, K> conditionalValue) {
|
||||||
|
Object either;
|
||||||
|
if (conditionalValue.left().isPresent()) {
|
||||||
|
either = MojangEitherUtil.makeLeft(conditionalValue.left().get());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
either = MojangEitherUtil.makeRight(conditionalValue.right().get());
|
||||||
|
}
|
||||||
|
write(NMSUtils.mojangEitherClass, index, either);
|
||||||
|
}
|
||||||
|
|
||||||
private Field getField(Class<?> type, int index) {
|
private Field getField(Class<?> type, int index) {
|
||||||
Map<Class<?>, Field[]> cached = FIELD_CACHE.computeIfAbsent(packetClass, k -> new ConcurrentHashMap<>());
|
Map<Class<?>, Field[]> cached = FIELD_CACHE.computeIfAbsent(packetClass, k -> new ConcurrentHashMap<>());
|
||||||
Field[] fields = cached.computeIfAbsent(type, typeClass -> getFields(typeClass, packetClass.getDeclaredFields()));
|
Field[] fields = cached.computeIfAbsent(type, typeClass -> getFields(typeClass, packetClass.getDeclaredFields()));
|
||||||
|
|||||||
+6
-6
@@ -23,30 +23,30 @@ import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
|||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
|
|
||||||
public class WrappedPacketHandshakingInSetProtocol extends WrappedPacket {
|
public class WrappedPacketHandshakingInSetProtocol extends WrappedPacket {
|
||||||
private static boolean v_1_17;
|
private static boolean between_V_1_17_And_1_20_1;
|
||||||
public WrappedPacketHandshakingInSetProtocol(NMSPacket packet) {
|
public WrappedPacketHandshakingInSetProtocol(NMSPacket packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
between_V_1_17_And_1_20_1 = version.isNewerThanOrEquals(ServerVersion.v_1_17) && version.isOlderThan(ServerVersion.v_1_20_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProtocolVersion() {
|
public int getProtocolVersion() {
|
||||||
return readInt(v_1_17 ? 1 : 0);
|
return readInt(between_V_1_17_And_1_20_1 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProtocolVersion(int protocolVersion) {
|
public void setProtocolVersion(int protocolVersion) {
|
||||||
writeInt(v_1_17 ? 1 : 0, protocolVersion);
|
writeInt(between_V_1_17_And_1_20_1 ? 1 : 0, protocolVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
return readInt(v_1_17 ? 2 : 1);
|
return readInt(between_V_1_17_And_1_20_1 ? 2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPort(int port) {
|
public void setPort(int port) {
|
||||||
writeInt(v_1_17 ? 2 : 1, port);
|
writeInt(between_V_1_17_And_1_20_1 ? 2 : 1, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHostName() {
|
public String getHostName() {
|
||||||
|
|||||||
+64
-4
@@ -21,12 +21,38 @@ package io.github.retrooper.packetevents.packetwrappers.login.in.encryptionbegin
|
|||||||
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
|
import io.github.retrooper.packetevents.utils.ConditionalValue;
|
||||||
|
import io.github.retrooper.packetevents.utils.MojangEitherUtil;
|
||||||
|
import io.github.retrooper.packetevents.utils.SaltSignature;
|
||||||
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.ClassUtil;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.SubclassUtil;
|
||||||
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
public class WrappedPacketLoginInEncryptionBegin extends WrappedPacket {
|
public class WrappedPacketLoginInEncryptionBegin extends WrappedPacket {
|
||||||
|
private static Class<?> VANILLA_SALT_SIGNATURE_CLASS;
|
||||||
|
private static Constructor<?> VANILLA_SALT_SIGNATURE_CONSTRUCTOR;
|
||||||
public WrappedPacketLoginInEncryptionBegin(NMSPacket packet) {
|
public WrappedPacketLoginInEncryptionBegin(NMSPacket packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void load() {
|
||||||
|
Class<?> minecraftEncryptionClass = Reflection.getClassByNameWithoutException("net.minecraft.util.MinecraftEncryption");
|
||||||
|
if (minecraftEncryptionClass != null) {
|
||||||
|
VANILLA_SALT_SIGNATURE_CLASS = SubclassUtil.getSubClass(minecraftEncryptionClass, "b");
|
||||||
|
try {
|
||||||
|
VANILLA_SALT_SIGNATURE_CONSTRUCTOR = VANILLA_SALT_SIGNATURE_CLASS.getConstructor(long.class, byte[].class);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] getPublicKey() {
|
public byte[] getPublicKey() {
|
||||||
return readByteArray(0);
|
return readByteArray(0);
|
||||||
}
|
}
|
||||||
@@ -35,12 +61,46 @@ public class WrappedPacketLoginInEncryptionBegin extends WrappedPacket {
|
|||||||
writeByteArray(0, key);
|
writeByteArray(0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getVerifyToken() {
|
|
||||||
return readByteArray(1);
|
public ConditionalValue<byte[], SaltSignature> getVerifyTokenOrSaltSignature() {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
ConditionalValue<byte[], Object> rawEither = readEither(0);
|
||||||
|
if (rawEither.left().isPresent()) {
|
||||||
|
return ConditionalValue.makeLeft(rawEither.left().get());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Object rawRight = rawEither.right().get();
|
||||||
|
WrappedPacket rawRightWrapper = new WrappedPacket(new NMSPacket(rawRight));
|
||||||
|
SaltSignature ss = new SaltSignature(rawRightWrapper.readLong(0), rawRightWrapper.readByteArray(0));
|
||||||
|
return ConditionalValue.makeRight(ss);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ConditionalValue.makeLeft(readByteArray(1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVerifyToken(byte[] token) {
|
public void setVerifyTokenOrSaltSignature(ConditionalValue<byte[], SaltSignature> value) {
|
||||||
writeByteArray(1, token);
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
Object either;
|
||||||
|
if (value.left().isPresent()) {
|
||||||
|
either = MojangEitherUtil.makeLeft(value.left().get());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SaltSignature ss = value.right().get();
|
||||||
|
Object rawSS = null;
|
||||||
|
try {
|
||||||
|
rawSS = VANILLA_SALT_SIGNATURE_CONSTRUCTOR.newInstance(ss.getSalt(), ss.getSignature());
|
||||||
|
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
either = MojangEitherUtil.makeRight(rawSS);
|
||||||
|
}
|
||||||
|
write(NMSUtils.mojangEitherClass, 0, either);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
writeByteArray(1, value.left().get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+54
-4
@@ -24,21 +24,71 @@ import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
|||||||
import io.github.retrooper.packetevents.utils.gameprofile.GameProfileUtil;
|
import io.github.retrooper.packetevents.utils.gameprofile.GameProfileUtil;
|
||||||
import io.github.retrooper.packetevents.utils.gameprofile.WrappedGameProfile;
|
import io.github.retrooper.packetevents.utils.gameprofile.WrappedGameProfile;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
// TODO: This wrapper needs Signature data @retrooper
|
||||||
public class WrappedPacketLoginInStart extends WrappedPacket {
|
public class WrappedPacketLoginInStart extends WrappedPacket {
|
||||||
public WrappedPacketLoginInStart(NMSPacket packet) {
|
public WrappedPacketLoginInStart(NMSPacket packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Allow accessing game profile property
|
//TODO Allow accessing game profile property
|
||||||
public WrappedGameProfile getGameProfile() {
|
public Optional<WrappedGameProfile> getGameProfile() {
|
||||||
return GameProfileUtil.getWrappedGameProfile(readObject(0, NMSUtils.gameProfileClass));
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return Optional.of(GameProfileUtil.getWrappedGameProfile(readObject(0, NMSUtils.gameProfileClass)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Add support for game profile property
|
//TODO Add support for game profile property
|
||||||
public void setGameProfile(WrappedGameProfile wrappedGameProfile) {
|
public void setGameProfile(WrappedGameProfile wrappedGameProfile) {
|
||||||
Object gameProfile = GameProfileUtil.getGameProfile(wrappedGameProfile.getId(), wrappedGameProfile.getName());
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
write(NMSUtils.gameProfileClass, 0, gameProfile);
|
writeString(0, wrappedGameProfile.getName());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Object gameProfile = GameProfileUtil.getGameProfile(wrappedGameProfile.getId(), wrappedGameProfile.getName());
|
||||||
|
write(NMSUtils.gameProfileClass, 0, gameProfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
return readString(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return GameProfileUtil.getWrappedGameProfile(readObject(0, NMSUtils.gameProfileClass)).getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) throws IllegalAccessException {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
writeString(0, username);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IllegalAccessException("Please use the setGameProfile method in the WrappedPacketLoginInStart wrapper to change the username!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable UUID getPlayerUUID() {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
return readObject(0, UUID.class);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return GameProfileUtil.getWrappedGameProfile(readObject(0, NMSUtils.gameProfileClass)).getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerUUID(UUID playerUUID) throws IllegalAccessException {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
writeObject(0, playerUUID);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IllegalAccessException("Please use the setGameProfile method in the WrappedPacketLoginInStart wrapper to change the uuid!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+6
@@ -40,6 +40,12 @@ public class WrappedPacketLoginOutCustomPayload extends WrappedPacket implements
|
|||||||
super(packet);
|
super(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WrappedPacketLoginOutCustomPayload(int messageID, String channelName, byte[] data) {
|
||||||
|
this.messageID = messageID;
|
||||||
|
this.channelName = channelName;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
||||||
|
|||||||
+3
-24
@@ -28,28 +28,14 @@ import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
|||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
public class WrappedPacketLoginOutSuccess extends WrappedPacket implements SendableWrapper {
|
public class WrappedPacketLoginOutSuccess extends WrappedPacket {
|
||||||
private static Constructor<?> packetConstructor;
|
|
||||||
private WrappedGameProfile wrappedGameProfile;
|
private WrappedGameProfile wrappedGameProfile;
|
||||||
|
|
||||||
public WrappedPacketLoginOutSuccess(final NMSPacket packet) {
|
public WrappedPacketLoginOutSuccess(final NMSPacket packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketLoginOutSuccess(final WrappedGameProfile wrappedGameProfile) {
|
//TODO Support property reading in wrapped game profile(NECESSARY IN 1.19!, PLEASE UPDATE TO 2.0 PACKETEVENTS)
|
||||||
this.wrappedGameProfile = wrappedGameProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void load() {
|
|
||||||
try {
|
|
||||||
packetConstructor = PacketTypeClasses.Login.Server.SUCCESS.getConstructors()[1];
|
|
||||||
} catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO Support property reading in wrapped game profile
|
|
||||||
public WrappedGameProfile getGameProfile() {
|
public WrappedGameProfile getGameProfile() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
return GameProfileUtil.getWrappedGameProfile(readObject(0, NMSUtils.gameProfileClass));
|
return GameProfileUtil.getWrappedGameProfile(readObject(0, NMSUtils.gameProfileClass));
|
||||||
@@ -58,7 +44,7 @@ public class WrappedPacketLoginOutSuccess extends WrappedPacket implements Senda
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Support writing property in wrapped game profile
|
//TODO Support writing property in wrapped game profile(NECESSARY IN 1.19!, PLEASE UPDATE TO 2.0 PACKETEVENTS)
|
||||||
public void setGameProfile(final WrappedGameProfile wrappedGameProfile) {
|
public void setGameProfile(final WrappedGameProfile wrappedGameProfile) {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
final Object gameProfile = GameProfileUtil.getGameProfile(wrappedGameProfile.getId(), wrappedGameProfile.getName());
|
final Object gameProfile = GameProfileUtil.getGameProfile(wrappedGameProfile.getId(), wrappedGameProfile.getName());
|
||||||
@@ -68,13 +54,6 @@ public class WrappedPacketLoginOutSuccess extends WrappedPacket implements Senda
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object asNMSPacket() throws Exception {
|
|
||||||
WrappedGameProfile gp = getGameProfile();
|
|
||||||
//TODO Support writing property in wrapped game profile
|
|
||||||
return packetConstructor.newInstance(GameProfileUtil.getGameProfile(gp.getId(), gp.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSupported() {
|
public boolean isSupported() {
|
||||||
return PacketTypeClasses.Login.Server.SUCCESS != null;
|
return PacketTypeClasses.Login.Server.SUCCESS != null;
|
||||||
|
|||||||
+3
@@ -47,6 +47,9 @@ public final class WrappedPacketInBlockDig extends WrappedPacket {
|
|||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
//It is probably a subclass
|
//It is probably a subclass
|
||||||
digTypeClass = SubclassUtil.getEnumSubClass(blockDigClass, "EnumPlayerDigType");
|
digTypeClass = SubclassUtil.getEnumSubClass(blockDigClass, "EnumPlayerDigType");
|
||||||
|
if (digTypeClass == null) {
|
||||||
|
digTypeClass = SubclassUtil.getEnumSubClass(blockDigClass, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+75
@@ -20,12 +20,38 @@ package io.github.retrooper.packetevents.packetwrappers.play.in.chat;
|
|||||||
|
|
||||||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
|
import io.github.retrooper.packetevents.utils.SaltSignature;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.SubclassUtil;
|
||||||
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public final class WrappedPacketInChat extends WrappedPacket {
|
public final class WrappedPacketInChat extends WrappedPacket {
|
||||||
|
private static Class<?> VANILLA_SALT_SIGNATURE_CLASS;
|
||||||
|
private static Constructor<?> VANILLA_SALT_SIGNATURE_CONSTRUCTOR;
|
||||||
public WrappedPacketInChat(NMSPacket packet) {
|
public WrappedPacketInChat(NMSPacket packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void load() {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
Class<?> minecraftEncryptionClass = Reflection.getClassByNameWithoutException("net.minecraft.util.MinecraftEncryption");
|
||||||
|
if (minecraftEncryptionClass != null) {
|
||||||
|
VANILLA_SALT_SIGNATURE_CLASS = SubclassUtil.getSubClass(minecraftEncryptionClass, "b");
|
||||||
|
try {
|
||||||
|
VANILLA_SALT_SIGNATURE_CONSTRUCTOR = VANILLA_SALT_SIGNATURE_CLASS.getConstructor(long.class, byte[].class);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return readString(0);
|
return readString(0);
|
||||||
}
|
}
|
||||||
@@ -33,4 +59,53 @@ public final class WrappedPacketInChat extends WrappedPacket {
|
|||||||
public void setMessage(String message) {
|
public void setMessage(String message) {
|
||||||
writeString(0, message);
|
writeString(0, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<Instant> getInstant() {
|
||||||
|
return version.isNewerThanOrEquals(ServerVersion.v_1_19) ? Optional.of(readObject(0, Instant.class)) : Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstant(Instant instant) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
writeObject(0, instant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<SaltSignature> getSaltSignature() {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
Object rawSS = readObject(0, VANILLA_SALT_SIGNATURE_CLASS);
|
||||||
|
WrappedPacket rawSSWrapper = new WrappedPacket(new NMSPacket(rawSS));
|
||||||
|
SaltSignature ss = new SaltSignature(rawSSWrapper.readLong(0), rawSSWrapper.readByteArray(0));
|
||||||
|
return Optional.of(ss);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSaltSignature(SaltSignature saltSignature) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
Object rawSS = null;
|
||||||
|
try {
|
||||||
|
rawSS = VANILLA_SALT_SIGNATURE_CONSTRUCTOR.newInstance(saltSignature.getSalt(), saltSignature.getSignature());
|
||||||
|
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
write(VANILLA_SALT_SIGNATURE_CLASS, 0, rawSS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSignedPreview() {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
return readBoolean(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignedPreview(boolean signedPreview) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
writeBoolean(0, signedPreview);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+5
-3
@@ -37,11 +37,13 @@ public final class WrappedPacketInClientCommand extends WrappedPacket {
|
|||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
v_1_16 = version.isNewerThanOrEquals(ServerVersion.v_1_16);
|
v_1_16 = version.isNewerThanOrEquals(ServerVersion.v_1_16);
|
||||||
try {
|
enumClientCommandClass = NMSUtils.getNMSEnumClassWithoutException("EnumClientCommand");
|
||||||
enumClientCommandClass = NMSUtils.getNMSEnumClass("EnumClientCommand");
|
if (enumClientCommandClass == null) {
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
//Probably a subclass
|
//Probably a subclass
|
||||||
enumClientCommandClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.CLIENT_COMMAND, "EnumClientCommand");
|
enumClientCommandClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.CLIENT_COMMAND, "EnumClientCommand");
|
||||||
|
if (enumClientCommandClass == null) {
|
||||||
|
enumClientCommandClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.CLIENT_COMMAND, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+92
-5
@@ -22,13 +22,21 @@ import io.github.retrooper.packetevents.PacketEvents;
|
|||||||
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
|
import io.github.retrooper.packetevents.utils.netty.bytebuf.ByteBufUtil;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public final class WrappedPacketInCustomPayload extends WrappedPacket {
|
public final class WrappedPacketInCustomPayload extends WrappedPacket {
|
||||||
private static boolean strPresent, byteArrayPresent;
|
private static boolean strPresent, byteArrayPresent, customPacketPayloadPresent;
|
||||||
|
private static Class<?> CUSTOM_PACKET_PAYLOAD, BRAND_PAYLOAD, DISCARDED_PAYLOAD;
|
||||||
|
private static Method CUSTOM_PACKET_PAYLOAD_MINECRAFT_KEY, CUSTOM_PACKET_PAYLOAD_PACKETDATASERIALIZER;
|
||||||
|
private static byte isVersion_1_17 = -1;
|
||||||
|
private static boolean isVersion_1_20_5;
|
||||||
|
private static boolean isVersion_1_20_6;
|
||||||
|
|
||||||
public WrappedPacketInCustomPayload(NMSPacket packet) {
|
public WrappedPacketInCustomPayload(NMSPacket packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
@@ -38,10 +46,61 @@ public final class WrappedPacketInCustomPayload extends WrappedPacket {
|
|||||||
protected void load() {
|
protected void load() {
|
||||||
strPresent = Reflection.getField(PacketTypeClasses.Play.Client.CUSTOM_PAYLOAD, String.class, 0) != null;
|
strPresent = Reflection.getField(PacketTypeClasses.Play.Client.CUSTOM_PAYLOAD, String.class, 0) != null;
|
||||||
byteArrayPresent = Reflection.getField(PacketTypeClasses.Play.Client.CUSTOM_PAYLOAD, byte[].class, 0) != null;
|
byteArrayPresent = Reflection.getField(PacketTypeClasses.Play.Client.CUSTOM_PAYLOAD, byte[].class, 0) != null;
|
||||||
|
CUSTOM_PACKET_PAYLOAD = Reflection.getClassByNameWithoutException("net.minecraft.network.protocol.common.custom.CustomPacketPayload");
|
||||||
|
customPacketPayloadPresent = Reflection.getField(PacketTypeClasses.Play.Client.CUSTOM_PAYLOAD, CUSTOM_PACKET_PAYLOAD, 0) != null;
|
||||||
|
if (customPacketPayloadPresent) {
|
||||||
|
CUSTOM_PACKET_PAYLOAD_MINECRAFT_KEY = Reflection.getMethod(CUSTOM_PACKET_PAYLOAD, NMSUtils.minecraftKeyClass, 0);
|
||||||
|
CUSTOM_PACKET_PAYLOAD_PACKETDATASERIALIZER = Reflection.getMethod(CUSTOM_PACKET_PAYLOAD, 0, NMSUtils.packetDataSerializerClass);
|
||||||
|
}
|
||||||
|
isVersion_1_20_5 = version.isNewerThanOrEquals(ServerVersion.v_1_20_5);
|
||||||
|
isVersion_1_20_6 = version.isNewerThanOrEquals(ServerVersion.v_1_20_6);
|
||||||
|
if (isVersion_1_20_5) {
|
||||||
|
BRAND_PAYLOAD = NMSUtils.getNMClassWithoutException("network.protocol.common.custom.BrandPayload");
|
||||||
|
DISCARDED_PAYLOAD = NMSUtils.getNMClassWithoutException("network.protocol.common.custom.DiscardedPayload");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getModernPayloadObject() {
|
||||||
|
return readObject(0, CUSTOM_PACKET_PAYLOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChannelName() {
|
public String getChannelName() {
|
||||||
if (strPresent) {
|
if (customPacketPayloadPresent) {
|
||||||
|
Object payload = getModernPayloadObject();
|
||||||
|
if (isVersion_1_20_5) {
|
||||||
|
if (BRAND_PAYLOAD.isInstance(payload)) {
|
||||||
|
WrappedPacket reflectBrandPayload = new WrappedPacket(new NMSPacket(payload));
|
||||||
|
return reflectBrandPayload.readString(0);
|
||||||
|
}
|
||||||
|
else if (DISCARDED_PAYLOAD.isInstance(payload)) {
|
||||||
|
WrappedPacket reflectBrandPayload = new WrappedPacket(new NMSPacket(payload));
|
||||||
|
if (isVersion_1_20_6) {
|
||||||
|
return reflectBrandPayload.readMinecraftKey(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return reflectBrandPayload.readString(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
if (isVersion_1_17 == -1) {
|
||||||
|
isVersion_1_17 = (byte) (version.isNewerThanOrEquals(ServerVersion.v_1_17) ? 1 : 0);
|
||||||
|
}
|
||||||
|
int namespaceIndex = isVersion_1_17 == 1 ? 2 : 0;
|
||||||
|
int keyIndex = isVersion_1_17 == 1 ? 3 : 1;
|
||||||
|
Object minecraftKey = CUSTOM_PACKET_PAYLOAD_MINECRAFT_KEY.invoke(payload);
|
||||||
|
WrappedPacket minecraftKeyWrapper = new WrappedPacket(new NMSPacket(minecraftKey));
|
||||||
|
return minecraftKeyWrapper.readString(namespaceIndex) + ":" + minecraftKeyWrapper.readString(keyIndex);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} else if (strPresent) {
|
||||||
return readString(0);
|
return readString(0);
|
||||||
} else {
|
} else {
|
||||||
return readMinecraftKey(1);
|
return readMinecraftKey(1);
|
||||||
@@ -49,7 +108,10 @@ public final class WrappedPacketInCustomPayload extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setChannelName(String channelName) {
|
public void setChannelName(String channelName) {
|
||||||
if (strPresent) {
|
if (customPacketPayloadPresent) {
|
||||||
|
throw new UnsupportedOperationException("PacketEvents v1.8 is a dying version, setting the channel name is not supported!");
|
||||||
|
}
|
||||||
|
else if (strPresent) {
|
||||||
writeString(0, channelName);
|
writeString(0, channelName);
|
||||||
} else {
|
} else {
|
||||||
writeMinecraftKey(1, channelName);
|
writeMinecraftKey(1, channelName);
|
||||||
@@ -57,7 +119,32 @@ public final class WrappedPacketInCustomPayload extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getData() {
|
public byte[] getData() {
|
||||||
if (byteArrayPresent) {
|
if (customPacketPayloadPresent) {
|
||||||
|
Object payload = getModernPayloadObject();
|
||||||
|
if (isVersion_1_20_6) {
|
||||||
|
if (DISCARDED_PAYLOAD.isInstance(payload)) {
|
||||||
|
WrappedPacket reflectDiscardedPayload = new WrappedPacket(new NMSPacket(payload));
|
||||||
|
Object buffer = reflectDiscardedPayload.readObject(0, NMSUtils.byteBufClass);
|
||||||
|
return PacketEvents.get().getByteBufUtil().getBytes(buffer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Object buffer = PacketEvents.get().getByteBufUtil().buffer();
|
||||||
|
Object packetDataSerializer = NMSUtils.generatePacketDataSerializer(buffer);
|
||||||
|
try {
|
||||||
|
CUSTOM_PACKET_PAYLOAD_PACKETDATASERIALIZER.invoke(payload, packetDataSerializer);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
byte[] data = PacketEvents.get().getByteBufUtil().getBytes(buffer);
|
||||||
|
PacketEvents.get().getByteBufUtil().release(buffer);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (byteArrayPresent) {
|
||||||
return readByteArray(0);
|
return readByteArray(0);
|
||||||
} else {
|
} else {
|
||||||
return PacketEvents.get().getByteBufUtil().getBytes(getBuffer());
|
return PacketEvents.get().getByteBufUtil().getBytes(getBuffer());
|
||||||
|
|||||||
+3
@@ -43,6 +43,9 @@ public final class WrappedPacketInEntityAction extends WrappedPacketEntityAbstra
|
|||||||
if (enumPlayerActionClass == null) {
|
if (enumPlayerActionClass == null) {
|
||||||
enumPlayerActionClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.ENTITY_ACTION, "EnumPlayerAction");
|
enumPlayerActionClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.ENTITY_ACTION, "EnumPlayerAction");
|
||||||
}
|
}
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_20_6)) {
|
||||||
|
enumPlayerActionClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.ENTITY_ACTION, 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-1
@@ -26,7 +26,6 @@ import io.github.retrooper.packetevents.utils.vector.Vector3i;
|
|||||||
* Sent when Generate is pressed on the Jigsaw Block interface.
|
* Sent when Generate is pressed on the Jigsaw Block interface.
|
||||||
*
|
*
|
||||||
* @author Tecnio
|
* @author Tecnio
|
||||||
* @see <a href="https://wiki.vg/Protocol#Generate_Structure"</a>
|
|
||||||
*/
|
*/
|
||||||
public class WrappedPacketInJigsawGenerate extends WrappedPacket {
|
public class WrappedPacketInJigsawGenerate extends WrappedPacket {
|
||||||
|
|
||||||
|
|||||||
+30
-11
@@ -32,7 +32,7 @@ import java.util.Set;
|
|||||||
public class WrappedPacketInSettings extends WrappedPacket {
|
public class WrappedPacketInSettings extends WrappedPacket {
|
||||||
private static Class<? extends Enum<?>> chatVisibilityEnumClass;
|
private static Class<? extends Enum<?>> chatVisibilityEnumClass;
|
||||||
|
|
||||||
private static boolean isLowerThan_v_1_8, v_1_17;
|
private static boolean isLowerThan_v_1_8, v_1_17, v_1_18;
|
||||||
|
|
||||||
public WrappedPacketInSettings(final NMSPacket packet) {
|
public WrappedPacketInSettings(final NMSPacket packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
@@ -42,6 +42,7 @@ public class WrappedPacketInSettings extends WrappedPacket {
|
|||||||
protected void load() {
|
protected void load() {
|
||||||
isLowerThan_v_1_8 = version.isOlderThan(ServerVersion.v_1_8);
|
isLowerThan_v_1_8 = version.isOlderThan(ServerVersion.v_1_8);
|
||||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
||||||
|
v_1_18 = version.isNewerThanOrEquals(ServerVersion.v_1_18);
|
||||||
chatVisibilityEnumClass = NMSUtils.getNMSEnumClassWithoutException("EnumChatVisibility");
|
chatVisibilityEnumClass = NMSUtils.getNMSEnumClassWithoutException("EnumChatVisibility");
|
||||||
if (chatVisibilityEnumClass == null) {
|
if (chatVisibilityEnumClass == null) {
|
||||||
//They are on 1.17+
|
//They are on 1.17+
|
||||||
@@ -62,11 +63,11 @@ public class WrappedPacketInSettings extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getViewDistance() {
|
public int getViewDistance() {
|
||||||
return readInt(v_1_17 ? 1 : 0);
|
return readInt((v_1_17 && !v_1_18) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setViewDistance(int viewDistance) {
|
public void setViewDistance(int viewDistance) {
|
||||||
writeInt(v_1_17 ? 1 : 0, viewDistance);
|
writeInt((v_1_17 && !v_1_18) ? 1 : 0, viewDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatVisibility getChatVisibility() {
|
public ChatVisibility getChatVisibility() {
|
||||||
@@ -87,19 +88,37 @@ public class WrappedPacketInSettings extends WrappedPacket {
|
|||||||
writeBoolean(0, chatColors);
|
writeBoolean(0, chatColors);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Boolean> isTextFilteringEnabled() {
|
//Added in 1.17
|
||||||
if (!v_1_17) {
|
public boolean isTextFilteringEnabled() {
|
||||||
return Optional.empty();
|
if (v_1_17) {
|
||||||
|
return readBoolean(1);
|
||||||
}
|
}
|
||||||
return Optional.of(!readBoolean(1));
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextFilteringEnabled(boolean textFilteringEnabled) {
|
//Added in 1.17
|
||||||
|
public void setTextFilteringEnabled(boolean enabled) {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
writeBoolean(1, !textFilteringEnabled);
|
writeBoolean(1, enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Added in 1.18
|
||||||
|
public boolean isServerListingsAllowed() {
|
||||||
|
if (v_1_18) {
|
||||||
|
return readBoolean(2);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Added in 1.18
|
||||||
|
public void setServerListingsAllowed(boolean allowed) {
|
||||||
|
if (v_1_18) {
|
||||||
|
writeBoolean(2, allowed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public byte getDisplaySkinPartsMask() {
|
public byte getDisplaySkinPartsMask() {
|
||||||
byte mask = 0;
|
byte mask = 0;
|
||||||
if (isLowerThan_v_1_8) {
|
if (isLowerThan_v_1_8) {
|
||||||
@@ -108,7 +127,7 @@ public class WrappedPacketInSettings extends WrappedPacket {
|
|||||||
mask |= 0x01;
|
mask |= 0x01;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mask = (byte) readInt(v_1_17 ? 2 : 1);
|
mask = (byte) readInt((v_1_17 && !v_1_18) ? 2 : 1);
|
||||||
}
|
}
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
@@ -118,7 +137,7 @@ public class WrappedPacketInSettings extends WrappedPacket {
|
|||||||
boolean capeEnabled = (mask & 0x01) == 0x01;
|
boolean capeEnabled = (mask & 0x01) == 0x01;
|
||||||
writeBoolean(1, capeEnabled);
|
writeBoolean(1, capeEnabled);
|
||||||
} else {
|
} else {
|
||||||
writeInt(v_1_17 ? 2 : 1, mask);
|
writeInt((v_1_17 && !v_1_18) ? 2 : 1, mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
@@ -23,6 +23,7 @@ import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
|||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
import io.github.retrooper.packetevents.utils.vector.Vector3i;
|
import io.github.retrooper.packetevents.utils.vector.Vector3i;
|
||||||
|
|
||||||
public class WrappedPacketInUpdateSign extends WrappedPacket {
|
public class WrappedPacketInUpdateSign extends WrappedPacket {
|
||||||
@@ -78,4 +79,19 @@ public class WrappedPacketInUpdateSign extends WrappedPacket {
|
|||||||
writeAnyObject(1, iChatComponents);
|
writeAnyObject(1, iChatComponents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFrontText() {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_20)) {
|
||||||
|
return readBoolean(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrontText(boolean frontText) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_20)) {
|
||||||
|
writeBoolean(0,frontText);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+15
-2
@@ -38,7 +38,7 @@ public final class WrappedPacketInUseEntity extends WrappedPacketEntityAbstracti
|
|||||||
private static Class<? extends Enum<?>> enumEntityUseActionClass;
|
private static Class<? extends Enum<?>> enumEntityUseActionClass;
|
||||||
private static Class<?> obfuscatedDataInterface, obfuscatedHandContainerClass, obfuscatedTargetAndHandContainerClass;
|
private static Class<?> obfuscatedDataInterface, obfuscatedHandContainerClass, obfuscatedTargetAndHandContainerClass;
|
||||||
private static Method getObfuscatedEntityUseActionMethod;
|
private static Method getObfuscatedEntityUseActionMethod;
|
||||||
private static boolean v_1_7_10, v_1_9, v_1_17;
|
private static boolean v_1_7_10, v_1_9, v_1_17, v_1_20_5;
|
||||||
private EntityUseAction action;
|
private EntityUseAction action;
|
||||||
private Object obfuscatedDataObj;
|
private Object obfuscatedDataObj;
|
||||||
|
|
||||||
@@ -51,15 +51,27 @@ public final class WrappedPacketInUseEntity extends WrappedPacketEntityAbstracti
|
|||||||
v_1_7_10 = version.isOlderThan(ServerVersion.v_1_8);
|
v_1_7_10 = version.isOlderThan(ServerVersion.v_1_8);
|
||||||
v_1_9 = version.isNewerThanOrEquals(ServerVersion.v_1_9);
|
v_1_9 = version.isNewerThanOrEquals(ServerVersion.v_1_9);
|
||||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
||||||
|
v_1_20_5 = version.isNewerThanOrEquals(ServerVersion.v_1_20_5);
|
||||||
try {
|
try {
|
||||||
enumEntityUseActionClass = NMSUtils.getNMSEnumClass("EnumEntityUseAction");
|
enumEntityUseActionClass = NMSUtils.getNMSEnumClass("EnumEntityUseAction");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
//That is fine, it is probably a subclass
|
//That is fine, it is probably a subclass
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
enumEntityUseActionClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, "b");
|
enumEntityUseActionClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, "b");
|
||||||
|
if (v_1_20_5) {
|
||||||
|
if (enumEntityUseActionClass == null) {
|
||||||
|
enumEntityUseActionClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
obfuscatedDataInterface = SubclassUtil.getSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, "EnumEntityUseAction");
|
obfuscatedDataInterface = SubclassUtil.getSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, "EnumEntityUseAction");
|
||||||
|
if (v_1_20_5) {
|
||||||
|
obfuscatedDataInterface = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, 0);
|
||||||
|
}
|
||||||
obfuscatedHandContainerClass = SubclassUtil.getSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, "d");
|
obfuscatedHandContainerClass = SubclassUtil.getSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, "d");
|
||||||
obfuscatedTargetAndHandContainerClass = SubclassUtil.getSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, "e");
|
obfuscatedTargetAndHandContainerClass = SubclassUtil.getSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, "e");
|
||||||
|
if (obfuscatedTargetAndHandContainerClass == null) {
|
||||||
|
obfuscatedTargetAndHandContainerClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, 2);
|
||||||
|
}
|
||||||
getObfuscatedEntityUseActionMethod = Reflection.getMethod(obfuscatedDataInterface, enumEntityUseActionClass, 0);
|
getObfuscatedEntityUseActionMethod = Reflection.getMethod(obfuscatedDataInterface, enumEntityUseActionClass, 0);
|
||||||
} else {
|
} else {
|
||||||
enumEntityUseActionClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, "EnumEntityUseAction");
|
enumEntityUseActionClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.USE_ENTITY, "EnumEntityUseAction");
|
||||||
@@ -133,11 +145,12 @@ public final class WrappedPacketInUseEntity extends WrappedPacketEntityAbstracti
|
|||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO Finish this
|
||||||
protected void setAction(EntityUseAction action) {
|
protected void setAction(EntityUseAction action) {
|
||||||
this.action = action;
|
this.action = action;
|
||||||
Enum<?> enumConst = EnumUtil.valueByIndex((Class<? extends Enum<?>>) enumEntityUseActionClass, action.ordinal());
|
Enum<?> enumConst = EnumUtil.valueByIndex((Class<? extends Enum<?>>) enumEntityUseActionClass, action.ordinal());
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
//TODO Add 1.17 support
|
//TODO Add 1.17+ support
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
writeEnumConstant(0, enumConst);
|
writeEnumConstant(0, enumConst);
|
||||||
|
|||||||
-1
@@ -37,7 +37,6 @@ public class WrappedPacketInVehicleMove extends WrappedPacket {
|
|||||||
writeDouble(2, position.z);
|
writeDouble(2, position.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Cut off at 1.8.1
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getX() {
|
public double getX() {
|
||||||
return readDouble(0);
|
return readDouble(0);
|
||||||
|
|||||||
+24
-26
@@ -18,25 +18,16 @@
|
|||||||
|
|
||||||
package io.github.retrooper.packetevents.packetwrappers.play.in.windowclick;
|
package io.github.retrooper.packetevents.packetwrappers.play.in.windowclick;
|
||||||
|
|
||||||
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
|
||||||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
import io.github.retrooper.packetevents.utils.enums.EnumUtil;
|
import io.github.retrooper.packetevents.utils.enums.EnumUtil;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class WrappedPacketInWindowClick extends WrappedPacket {
|
public class WrappedPacketInWindowClick extends WrappedPacket {
|
||||||
private static boolean v_1_17;
|
private static boolean legacy, v_1_17;
|
||||||
private static Class<? extends Enum<?>> invClickTypeClass;
|
private static Class<? extends Enum<?>> invClickTypeClass;
|
||||||
private static boolean isClickModePrimitive;
|
|
||||||
|
|
||||||
|
|
||||||
public WrappedPacketInWindowClick(NMSPacket packet) {
|
public WrappedPacketInWindowClick(NMSPacket packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
@@ -44,53 +35,60 @@ public class WrappedPacketInWindowClick extends WrappedPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
|
legacy = version.isOlderThanOrEquals(ServerVersion.v_1_8_8);
|
||||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
||||||
invClickTypeClass = NMSUtils.getNMSEnumClassWithoutException("InventoryClickType");
|
invClickTypeClass = NMSUtils.getNMSEnumClassWithoutException("InventoryClickType");
|
||||||
if (invClickTypeClass == null) {
|
if (invClickTypeClass == null) {
|
||||||
invClickTypeClass = NMSUtils.getNMEnumClassWithoutException("world.inventory.InventoryClickType");
|
invClickTypeClass = NMSUtils.getNMEnumClassWithoutException("world.inventory.InventoryClickType");
|
||||||
}
|
}
|
||||||
isClickModePrimitive = Reflection.getField(PacketTypeClasses.Play.Client.WINDOW_CLICK, int.class, 3) != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unique ID for the inventory, 0 for player's inventory
|
||||||
public int getWindowId() {
|
public int getWindowId() {
|
||||||
return readInt(0);
|
return readInt(v_1_17 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWindowId(int windowID) {
|
public void setWindowId(int windowID) {
|
||||||
writeInt(0, windowID);
|
writeInt(v_1_17 ? 1 : 0, windowID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Id of clicked slot
|
||||||
public int getWindowSlot() {
|
public int getWindowSlot() {
|
||||||
return readInt(1);
|
return readInt(v_1_17 ? 3 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWindowSlot(int slot) {
|
public void setWindowSlot(int slot) {
|
||||||
writeInt(1, slot);
|
writeInt(v_1_17 ? 3 : 1, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Left or right click
|
||||||
public int getWindowButton() {
|
public int getWindowButton() {
|
||||||
return readInt(2);
|
return readInt(v_1_17 ? 4 : 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWindowButton(int button) {
|
public void setWindowButton(int button) {
|
||||||
writeInt(2, button);
|
writeInt(v_1_17 ? 4 : 2, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Short> getActionNumber() {
|
// Used to sync together client and server
|
||||||
|
public int getActionNumber() {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
return Optional.empty();
|
return readInt(2);
|
||||||
}
|
}
|
||||||
return Optional.of(readShort(0));
|
return readShort(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActionNumber(short actionNumber) {
|
public void setActionNumber(int actionNumber) {
|
||||||
if (!v_1_17) {
|
if (v_1_17) {
|
||||||
writeShort(0, actionNumber);
|
writeInt(2, actionNumber);
|
||||||
|
} else {
|
||||||
|
writeShort(0, (short) actionNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Type of click - shift clicking, hotbar, drag, pickup...
|
||||||
public int getMode() {
|
public int getMode() {
|
||||||
if (isClickModePrimitive) {
|
if(legacy) {
|
||||||
return readInt(3);
|
return readInt(3);
|
||||||
} else {
|
} else {
|
||||||
Enum<?> enumConst = readEnumConstant(0, invClickTypeClass);
|
Enum<?> enumConst = readEnumConstant(0, invClickTypeClass);
|
||||||
@@ -99,7 +97,7 @@ public class WrappedPacketInWindowClick extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMode(int mode) {
|
public void setMode(int mode) {
|
||||||
if (isClickModePrimitive) {
|
if(legacy) {
|
||||||
writeInt(3, mode);
|
writeInt(3, mode);
|
||||||
} else {
|
} else {
|
||||||
Enum<?> enumConst = EnumUtil.valueByIndex(invClickTypeClass, mode);
|
Enum<?> enumConst = EnumUtil.valueByIndex(invClickTypeClass, mode);
|
||||||
@@ -117,6 +115,6 @@ public class WrappedPacketInWindowClick extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setClickedItemStack(ItemStack stack) {
|
public void setClickedItemStack(ItemStack stack) {
|
||||||
writeItemStack(0, stack);
|
writeItemStack(0, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-1
@@ -30,7 +30,6 @@ import java.util.Optional;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Tecnio
|
* @author Tecnio
|
||||||
* @see <a href="https://wiki.vg/Protocol#Edit_Book"</a>
|
|
||||||
*/
|
*/
|
||||||
public class WrappedPacketInBEdit extends WrappedPacket {
|
public class WrappedPacketInBEdit extends WrappedPacket {
|
||||||
private static boolean v_1_13, v_1_17;
|
private static boolean v_1_13, v_1_17;
|
||||||
|
|||||||
-1
@@ -32,7 +32,6 @@ import java.lang.reflect.Constructor;
|
|||||||
* This packet is used for a number of actions and animations performed by blocks, usually non-persistent.
|
* This packet is used for a number of actions and animations performed by blocks, usually non-persistent.
|
||||||
*
|
*
|
||||||
* @author Tecnio
|
* @author Tecnio
|
||||||
* @see <a href="https://wiki.vg/Protocol#Block_Action"</a>
|
|
||||||
*/
|
*/
|
||||||
public class WrappedPacketOutBlockAction extends WrappedPacket implements SendableWrapper {
|
public class WrappedPacketOutBlockAction extends WrappedPacket implements SendableWrapper {
|
||||||
|
|
||||||
|
|||||||
+8
@@ -71,7 +71,15 @@ public class WrappedPacketOutBlockChange extends WrappedPacket implements Sendab
|
|||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
getNMSBlockMethodCache = Reflection.getMethod(NMSUtils.iBlockDataClass, "getBlock", 0);
|
getNMSBlockMethodCache = Reflection.getMethod(NMSUtils.iBlockDataClass, "getBlock", 0);
|
||||||
|
if (getNMSBlockMethodCache == null) {
|
||||||
|
Class<?> blockDataClass = NMSUtils.iBlockDataClass.getSuperclass();
|
||||||
|
getNMSBlockMethodCache = Reflection.getMethod(blockDataClass, NMSUtils.blockClass, 0);
|
||||||
|
}
|
||||||
getNMSWorldTypeMethodCache = Reflection.getMethod(NMSUtils.nmsWorldClass, "getType", 0);
|
getNMSWorldTypeMethodCache = Reflection.getMethod(NMSUtils.nmsWorldClass, "getType", 0);
|
||||||
|
if (getNMSWorldTypeMethodCache == null) {
|
||||||
|
getNMSWorldTypeMethodCache = Reflection.getMethod(NMSUtils.nmsWorldClass,
|
||||||
|
"getBlockStateIfLoaded", 0);
|
||||||
|
}
|
||||||
v_1_7_10 = version.isOlderThan(ServerVersion.v_1_8);
|
v_1_7_10 = version.isOlderThan(ServerVersion.v_1_8);
|
||||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
|
|||||||
+182
-42
@@ -25,16 +25,21 @@ import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
|||||||
import io.github.retrooper.packetevents.utils.enums.EnumUtil;
|
import io.github.retrooper.packetevents.utils.enums.EnumUtil;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.SubclassUtil;
|
||||||
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.UUID;
|
import java.util.*;
|
||||||
|
|
||||||
public final class WrappedPacketOutChat extends WrappedPacket implements SendableWrapper {
|
public final class WrappedPacketOutChat extends WrappedPacket implements SendableWrapper {
|
||||||
private static Constructor<?> chatClassConstructor;
|
private static Constructor<?> chatClassConstructor;
|
||||||
private static Class<? extends Enum<?>> chatMessageTypeEnum;
|
private static Class<? extends Enum<?>> chatMessageTypeEnum;
|
||||||
|
private static Class<?> PLAYER_CHAT_MESSAGE_CLASS, SIGNED_MESSAGE_BODY_CLASS,
|
||||||
|
CHAT_MESSAGE_CONTENT_CLASS, CHAT_MESSAGE_TYPE_CLASS, NETWORK_BOUND_CHAT_TYPE_CLASS;
|
||||||
//0 = IChatBaseComponent, Byte
|
//0 = IChatBaseComponent, Byte
|
||||||
//1 = IChatBaseComponent, Int
|
//1 = IChatBaseComponent, Int
|
||||||
//2 = IChatBaseComponent, ChatMessageType
|
//2 = IChatBaseComponent, ChatMessageType
|
||||||
@@ -69,50 +74,66 @@ public final class WrappedPacketOutChat extends WrappedPacket implements Sendabl
|
|||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
Class<?> packetClass = PacketTypeClasses.Play.Server.CHAT;
|
Class<?> packetClass = PacketTypeClasses.Play.Server.CHAT;
|
||||||
chatMessageTypeEnum = NMSUtils.getNMSEnumClassWithoutException("ChatMessageType");
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
if (chatMessageTypeEnum == null) {
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
chatMessageTypeEnum = NMSUtils.getNMEnumClassWithoutException("network.chat.ChatMessageType");
|
PLAYER_CHAT_MESSAGE_CLASS = NMSUtils.getNMClassWithoutException("network.chat.PlayerChatMessage");
|
||||||
}
|
SIGNED_MESSAGE_BODY_CLASS = NMSUtils.getNMClassWithoutException("network.chat.SignedMessageBody");
|
||||||
if (chatMessageTypeEnum != null) {
|
CHAT_MESSAGE_CONTENT_CLASS = NMSUtils.getNMClassWithoutException("network.chat.ChatMessageContent");
|
||||||
try {
|
CHAT_MESSAGE_TYPE_CLASS = NMSUtils.getNMClassWithoutException("network.chat.ChatMessageType");
|
||||||
chatClassConstructor = packetClass.getConstructor(NMSUtils.iChatBaseComponentClass, chatMessageTypeEnum);
|
NETWORK_BOUND_CHAT_TYPE_CLASS = SubclassUtil.getSubClass(CHAT_MESSAGE_TYPE_CLASS, 1);
|
||||||
constructorMode = 2;
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
//Just a much newer version(1.16.x and above right now)
|
|
||||||
try {
|
|
||||||
chatClassConstructor = packetClass.getConstructor(NMSUtils.iChatBaseComponentClass, chatMessageTypeEnum, UUID.class);
|
|
||||||
constructorMode = 3;
|
|
||||||
} catch (NoSuchMethodException e2) {
|
|
||||||
//Failed to resolve the constructor
|
|
||||||
e2.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
//Cause we read getChatPosition using constructor mode
|
||||||
try {
|
constructorMode = 4;
|
||||||
chatClassConstructor = packetClass.getConstructor(NMSUtils.iChatBaseComponentClass, byte.class);
|
}
|
||||||
constructorMode = 0;
|
else {
|
||||||
} catch (NoSuchMethodException e) {
|
chatMessageTypeEnum = NMSUtils.getNMSEnumClassWithoutException("ChatMessageType");
|
||||||
//That is fine, they are most likely on an older version.
|
if (chatMessageTypeEnum == null) {
|
||||||
|
chatMessageTypeEnum = NMSUtils.getNMEnumClassWithoutException("network.chat.ChatMessageType");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chatMessageTypeEnum != null) {
|
||||||
try {
|
try {
|
||||||
chatClassConstructor = packetClass.getConstructor(NMSUtils.iChatBaseComponentClass, int.class);
|
chatClassConstructor = packetClass.getConstructor(NMSUtils.iChatBaseComponentClass, chatMessageTypeEnum);
|
||||||
constructorMode = 1;
|
constructorMode = 2;
|
||||||
} catch (NoSuchMethodException e2) {
|
} catch (NoSuchMethodException e) {
|
||||||
|
//Just a much newer version(1.16.x and above right now)
|
||||||
try {
|
try {
|
||||||
//Some weird 1.7.10 spigots remove that int parameter for no reason, I won't keep adding support for any more spigots and might stop
|
chatClassConstructor = packetClass.getConstructor(NMSUtils.iChatBaseComponentClass, chatMessageTypeEnum, UUID.class);
|
||||||
//accepting pull requests for support for spigots breaking things that normal spigot has.
|
constructorMode = 3;
|
||||||
chatClassConstructor = packetClass.getConstructor(NMSUtils.iChatBaseComponentClass);
|
} catch (NoSuchMethodException e2) {
|
||||||
constructorMode = -1;
|
//Failed to resolve the constructor
|
||||||
} catch (NoSuchMethodException e3) {
|
e2.printStackTrace();
|
||||||
e3.printStackTrace();
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
chatClassConstructor = packetClass.getConstructor(NMSUtils.iChatBaseComponentClass, byte.class);
|
||||||
|
constructorMode = 0;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
//That is fine, they are most likely on an older version.
|
||||||
|
try {
|
||||||
|
chatClassConstructor = packetClass.getConstructor(NMSUtils.iChatBaseComponentClass, int.class);
|
||||||
|
constructorMode = 1;
|
||||||
|
} catch (NoSuchMethodException e2) {
|
||||||
|
try {
|
||||||
|
//Some weird 1.7.10 spigots remove that int parameter for no reason, I won't keep adding support for any more spigots and might stop
|
||||||
|
//accepting pull requests for support for spigots breaking things that normal spigot has.
|
||||||
|
chatClassConstructor = packetClass.getConstructor(NMSUtils.iChatBaseComponentClass);
|
||||||
|
constructorMode = -1;
|
||||||
|
} catch (NoSuchMethodException e3) {
|
||||||
|
e3.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object asNMSPacket() throws Exception {
|
public Object asNMSPacket() throws Exception {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
throw new IllegalStateException("You are trying to send the WrappedPacketOutChat packet on 1.19 or above. Please update to packetevents 2.0, this is not supported.");
|
||||||
|
}
|
||||||
byte chatPos = (byte) getChatPosition().ordinal();
|
byte chatPos = (byte) getChatPosition().ordinal();
|
||||||
Enum<?> chatMessageTypeInstance = null;
|
Enum<?> chatMessageTypeInstance = null;
|
||||||
if (chatMessageTypeEnum != null) {
|
if (chatMessageTypeEnum != null) {
|
||||||
@@ -141,6 +162,15 @@ public final class WrappedPacketOutChat extends WrappedPacket implements Sendabl
|
|||||||
*/
|
*/
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
Object playerChatMessage = readObject(0, PLAYER_CHAT_MESSAGE_CLASS);
|
||||||
|
WrappedPacket playerChatMessageWrapper = new WrappedPacket(new NMSPacket(playerChatMessage));
|
||||||
|
Object signedMessageBody = playerChatMessageWrapper.readObject(0, SIGNED_MESSAGE_BODY_CLASS);
|
||||||
|
WrappedPacket wrappedSignedMessageBody = new WrappedPacket(new NMSPacket(signedMessageBody));
|
||||||
|
Object chatMessageContent = wrappedSignedMessageBody.readObject(0, CHAT_MESSAGE_CONTENT_CLASS);
|
||||||
|
WrappedPacket wrappedChatMessage = new WrappedPacket(new NMSPacket(chatMessageContent));
|
||||||
|
return wrappedChatMessage.readIChatBaseComponent(0);
|
||||||
|
}
|
||||||
return readIChatBaseComponent(0);
|
return readIChatBaseComponent(0);
|
||||||
} else {
|
} else {
|
||||||
return message;
|
return message;
|
||||||
@@ -149,12 +179,55 @@ public final class WrappedPacketOutChat extends WrappedPacket implements Sendabl
|
|||||||
|
|
||||||
public void setMessage(String message) {
|
public void setMessage(String message) {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
Object playerChatMessage = readObject(0, PLAYER_CHAT_MESSAGE_CLASS);
|
||||||
|
WrappedPacket playerChatMessageWrapper = new WrappedPacket(new NMSPacket(playerChatMessage));
|
||||||
|
Object signedMessageBody = playerChatMessageWrapper.readObject(0, SIGNED_MESSAGE_BODY_CLASS);
|
||||||
|
WrappedPacket wrappedSignedMessageBody = new WrappedPacket(new NMSPacket(signedMessageBody));
|
||||||
|
Object chatMessageContent = wrappedSignedMessageBody.readObject(0, CHAT_MESSAGE_CONTENT_CLASS);
|
||||||
|
WrappedPacket wrappedChatMessage = new WrappedPacket(new NMSPacket(chatMessageContent));
|
||||||
|
wrappedChatMessage.writeIChatBaseComponent(0, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
writeIChatBaseComponent(0, message);
|
writeIChatBaseComponent(0, message);
|
||||||
} else {
|
} else {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<String> getUnsignedMessage() {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
Object playerChatMessage = readObject(0, PLAYER_CHAT_MESSAGE_CLASS);
|
||||||
|
WrappedPacket playerChatMessageWrapper = new WrappedPacket(new NMSPacket(playerChatMessage));
|
||||||
|
Optional<?> opt = playerChatMessageWrapper.readObject(0, Optional.class);
|
||||||
|
if (opt.isPresent()) {
|
||||||
|
Object iChatBaseComponent = opt.get();
|
||||||
|
return Optional.ofNullable(NMSUtils.readIChatBaseComponent(iChatBaseComponent));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
Optional<?> opt = readObject(0, Optional.class);
|
||||||
|
if (opt.isPresent()) {
|
||||||
|
Object iChatBaseComponent = opt.get();
|
||||||
|
return Optional.ofNullable(NMSUtils.readIChatBaseComponent(iChatBaseComponent));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnsignedMessage(String unsignedMessage) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
Object playerChatMessage = readObject(0, PLAYER_CHAT_MESSAGE_CLASS);
|
||||||
|
WrappedPacket playerChatMessageWrapper = new WrappedPacket(new NMSPacket(playerChatMessage));
|
||||||
|
Object iChatBaseComponent = NMSUtils.generateIChatBaseComponent(unsignedMessage);
|
||||||
|
playerChatMessageWrapper.write(Optional.class, 0, Optional.ofNullable(iChatBaseComponent));
|
||||||
|
}
|
||||||
|
else if (version.isNewerThanOrEquals(ServerVersion.v_1_19)) {
|
||||||
|
Object iChatBaseComponent = NMSUtils.generateIChatBaseComponent(unsignedMessage);
|
||||||
|
write(Optional.class, 0, Optional.ofNullable(iChatBaseComponent));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the chat position.
|
* Get the chat position.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -168,7 +241,7 @@ public final class WrappedPacketOutChat extends WrappedPacket implements Sendabl
|
|||||||
byte chatPositionValue;
|
byte chatPositionValue;
|
||||||
switch (constructorMode) {
|
switch (constructorMode) {
|
||||||
case -1:
|
case -1:
|
||||||
chatPositionValue = (byte) ChatPosition.CHAT.ordinal();
|
chatPositionValue = (byte) ChatPosition.CHAT.getId(version);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
chatPositionValue = readByte(0);
|
chatPositionValue = readByte(0);
|
||||||
@@ -180,11 +253,16 @@ public final class WrappedPacketOutChat extends WrappedPacket implements Sendabl
|
|||||||
case 3:
|
case 3:
|
||||||
Enum<?> chatTypeEnumInstance = readEnumConstant(0, chatMessageTypeEnum);
|
Enum<?> chatTypeEnumInstance = readEnumConstant(0, chatMessageTypeEnum);
|
||||||
return ChatPosition.values()[chatTypeEnumInstance.ordinal()];
|
return ChatPosition.values()[chatTypeEnumInstance.ordinal()];
|
||||||
|
case 4:
|
||||||
|
Object chatMsgType = readObject(0, NETWORK_BOUND_CHAT_TYPE_CLASS);
|
||||||
|
WrappedPacket chatMsgTypeWrapper = new WrappedPacket(new NMSPacket(chatMsgType));
|
||||||
|
chatPositionValue = (byte) chatMsgTypeWrapper.readInt(0);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
chatPositionValue = 0;
|
chatPositionValue = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ChatPosition.values()[chatPositionValue];
|
return ChatPosition.getById(version, chatPositionValue);
|
||||||
} else {
|
} else {
|
||||||
return chatPosition;
|
return chatPosition;
|
||||||
}
|
}
|
||||||
@@ -194,25 +272,87 @@ public final class WrappedPacketOutChat extends WrappedPacket implements Sendabl
|
|||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
switch (constructorMode) {
|
switch (constructorMode) {
|
||||||
case 0:
|
case 0:
|
||||||
writeByte(0, (byte) chatPosition.ordinal());
|
writeByte(0, (byte) chatPosition.getId(version));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
writeInt(0, chatPosition.ordinal());
|
writeInt(0, chatPosition.getId(version));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
Enum<?> chatTypeEnumInstance = EnumUtil.valueByIndex(chatMessageTypeEnum, chatPosition.ordinal());
|
Enum<?> chatTypeEnumInstance = EnumUtil.valueByIndex(chatMessageTypeEnum,
|
||||||
|
chatPosition.getId(version));
|
||||||
writeEnumConstant(0, chatTypeEnumInstance);
|
writeEnumConstant(0, chatTypeEnumInstance);
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
Object chatMsgType = readObject(0, NETWORK_BOUND_CHAT_TYPE_CLASS);
|
||||||
|
WrappedPacket chatMsgTypeWrapper = new WrappedPacket(new NMSPacket(chatMsgType));
|
||||||
|
chatMsgTypeWrapper.writeInt(0, chatPosition.getId(version));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.chatPosition = chatPosition;
|
this.chatPosition = chatPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Add support to every single Wrapper usage
|
||||||
public enum ChatPosition {
|
public enum ChatPosition {
|
||||||
CHAT,
|
CHAT(0),
|
||||||
SYSTEM_MESSAGE,
|
|
||||||
GAME_INFO;
|
@Deprecated
|
||||||
|
SYSTEM(-1),
|
||||||
|
@Deprecated
|
||||||
|
GAME_INFO(-1),
|
||||||
|
|
||||||
|
SAY_COMMAND(1),
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
MSG_COMMAND(-1),
|
||||||
|
|
||||||
|
MSG_COMMAND_INCOMING(2),
|
||||||
|
MSG_COMMAND_OUTGOING(3),
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
TEAM_MSG_COMMAND(-1),
|
||||||
|
|
||||||
|
TEAM_MSG_COMMAND_INCOMING(4),
|
||||||
|
TEAM_MSG_COMMAND_OUTGOING(5),
|
||||||
|
EMOTE_COMMAND(6),
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
TELLRAW_COMMAND(-1);
|
||||||
|
|
||||||
|
private final byte modernId;
|
||||||
|
|
||||||
|
ChatPosition(int modernId) {
|
||||||
|
this.modernId = (byte) modernId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final ChatPosition[] VALUES;
|
||||||
|
private static final Map<Byte, ChatPosition> MODERN_CHAT_TYPE_MAP;
|
||||||
|
|
||||||
|
static {
|
||||||
|
VALUES = values();
|
||||||
|
MODERN_CHAT_TYPE_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
Arrays.stream(VALUES)
|
||||||
|
.filter(chatType -> chatType.modernId != -1)
|
||||||
|
.forEach(chatType -> MODERN_CHAT_TYPE_MAP.put(chatType.modernId, chatType));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId(ServerVersion version) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
return modernId;
|
||||||
|
}
|
||||||
|
return ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static ChatPosition getById(ServerVersion version, int id) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
return MODERN_CHAT_TYPE_MAP.get((byte) id);
|
||||||
|
} else {
|
||||||
|
return VALUES[id];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+31
-21
@@ -35,11 +35,12 @@ public class WrappedPacketOutEntity extends WrappedPacketEntityAbstraction imple
|
|||||||
//Byte = 1.7.10->1.8.8, Int = 1.9->1.15.x, Short = 1.16.x
|
//Byte = 1.7.10->1.8.8, Int = 1.9->1.15.x, Short = 1.16.x
|
||||||
private static byte mode; //byte = 0, int = 1, short = 2
|
private static byte mode; //byte = 0, int = 1, short = 2
|
||||||
private static double dXYZDivisor;
|
private static double dXYZDivisor;
|
||||||
|
private static final float ROTATION_FACTOR = 256.0F / 360.0F;
|
||||||
private static int yawByteIndex = 0;
|
private static int yawByteIndex = 0;
|
||||||
private static int pitchByteIndex = 1;
|
private static int pitchByteIndex = 1;
|
||||||
private static Constructor<?> entityPacketConstructor, entityRelMovePacketConstructor, entityLookConstructor, entityRelMoveLookConstructor;
|
private static Constructor<?> entityPacketConstructor, entityRelMovePacketConstructor, entityLookConstructor, entityRelMoveLookConstructor;
|
||||||
private double deltaX, deltaY, deltaZ;
|
private double deltaX, deltaY, deltaZ;
|
||||||
private byte pitch, yaw;
|
private float pitch, yaw;
|
||||||
private boolean onGround, rotating, moving;
|
private boolean onGround, rotating, moving;
|
||||||
|
|
||||||
public WrappedPacketOutEntity(NMSPacket packet) {
|
public WrappedPacketOutEntity(NMSPacket packet) {
|
||||||
@@ -48,7 +49,7 @@ public class WrappedPacketOutEntity extends WrappedPacketEntityAbstraction imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketOutEntity(int entityID, double deltaX, double deltaY, double deltaZ,
|
public WrappedPacketOutEntity(int entityID, double deltaX, double deltaY, double deltaZ,
|
||||||
byte yaw, byte pitch, boolean onGround, boolean rotating, boolean moving) {
|
float yaw, float pitch, boolean onGround, boolean rotating, boolean moving) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
this.deltaX = deltaX;
|
this.deltaX = deltaX;
|
||||||
this.deltaY = deltaY;
|
this.deltaY = deltaY;
|
||||||
@@ -61,22 +62,22 @@ public class WrappedPacketOutEntity extends WrappedPacketEntityAbstraction imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketOutEntity(int entityID, double deltaX, double deltaY, double deltaZ,
|
public WrappedPacketOutEntity(int entityID, double deltaX, double deltaY, double deltaZ,
|
||||||
byte yaw, byte pitch, boolean onGround, boolean rotating) {
|
float yaw, float pitch, boolean onGround, boolean rotating) {
|
||||||
this(entityID, deltaX, deltaY, deltaZ, yaw, pitch, onGround, rotating, false);
|
this(entityID, deltaX, deltaY, deltaZ, yaw, pitch, onGround, rotating, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketOutEntity(int entityID, double deltaX, double deltaY, double deltaZ,
|
public WrappedPacketOutEntity(int entityID, double deltaX, double deltaY, double deltaZ,
|
||||||
byte yaw, byte pitch, boolean onGround) {
|
float yaw, float pitch, boolean onGround) {
|
||||||
this(entityID, deltaX, deltaY, deltaZ, yaw, pitch, onGround, false, false);
|
this(entityID, deltaX, deltaY, deltaZ, yaw, pitch, onGround, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketOutEntity(Entity entity, double deltaX, double deltaY, double deltaZ,
|
public WrappedPacketOutEntity(Entity entity, double deltaX, double deltaY, double deltaZ,
|
||||||
byte yaw, byte pitch, boolean onGround, boolean isLook) {
|
float yaw, float pitch, boolean onGround, boolean isLook) {
|
||||||
this(entity.getEntityId(), deltaX, deltaY, deltaZ, yaw, pitch, onGround, isLook);
|
this(entity.getEntityId(), deltaX, deltaY, deltaZ, yaw, pitch, onGround, isLook);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketOutEntity(Entity entity, double deltaX, double deltaY, double deltaZ,
|
public WrappedPacketOutEntity(Entity entity, double deltaX, double deltaY, double deltaZ,
|
||||||
byte yaw, byte pitch, boolean onGround) {
|
float yaw, float pitch, boolean onGround) {
|
||||||
this(entity.getEntityId(), deltaX, deltaY, deltaZ, yaw, pitch, onGround, false);
|
this(entity.getEntityId(), deltaX, deltaY, deltaZ, yaw, pitch, onGround, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +95,9 @@ public class WrappedPacketOutEntity extends WrappedPacketEntityAbstraction imple
|
|||||||
pitchByteIndex = 4;
|
pitchByteIndex = 4;
|
||||||
} else if (dxField.equals(Reflection.getField(packetClass, int.class, 1))) {
|
} else if (dxField.equals(Reflection.getField(packetClass, int.class, 1))) {
|
||||||
mode = 1;
|
mode = 1;
|
||||||
} else if (dxField.equals(Reflection.getField(packetClass, short.class, 0))) {
|
} else if (dxField.equals(Reflection.getField(packetClass, short.class, 0))
|
||||||
|
//1.19 support
|
||||||
|
|| dxField.equals(Reflection.getField(packetClass, short.class, 1))) {
|
||||||
mode = 2;
|
mode = 2;
|
||||||
}
|
}
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
@@ -116,33 +119,33 @@ public class WrappedPacketOutEntity extends WrappedPacketEntityAbstraction imple
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getPitch() {
|
public float getPitch() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
return readByte(pitchByteIndex);
|
return readByte(pitchByteIndex) / ROTATION_FACTOR;
|
||||||
} else {
|
} else {
|
||||||
return pitch;
|
return pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPitch(byte pitch) {
|
public void setPitch(float pitch) {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
writeByte(pitchByteIndex, pitch);
|
writeByte(pitchByteIndex, (byte) (pitch * ROTATION_FACTOR));
|
||||||
} else {
|
} else {
|
||||||
this.pitch = pitch;
|
this.pitch = pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getYaw() {
|
public float getYaw() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
return readByte(yawByteIndex);
|
return readByte(yawByteIndex) / ROTATION_FACTOR;
|
||||||
} else {
|
} else {
|
||||||
return yaw;
|
return yaw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setYaw(byte yaw) {
|
public void setYaw(float yaw) {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
writeByte(yawByteIndex, yaw);
|
writeByte(yawByteIndex, (byte) (yaw * ROTATION_FACTOR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,10 +318,12 @@ public class WrappedPacketOutEntity extends WrappedPacketEntityAbstraction imple
|
|||||||
@Override
|
@Override
|
||||||
public Object asNMSPacket() throws Exception {
|
public Object asNMSPacket() throws Exception {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
|
byte angleYaw = (byte) (getYaw() * ROTATION_FACTOR);
|
||||||
|
byte anglePitch = (byte) (getPitch() * ROTATION_FACTOR);
|
||||||
return entityPacketConstructor.newInstance(getEntityId(),
|
return entityPacketConstructor.newInstance(getEntityId(),
|
||||||
(short) (getDeltaX() * dXYZDivisor), (short) (getDeltaY() * dXYZDivisor),
|
(short) (getDeltaX() * dXYZDivisor), (short) (getDeltaY() * dXYZDivisor),
|
||||||
(short) (getDeltaZ() * dXYZDivisor),
|
(short) (getDeltaZ() * dXYZDivisor),
|
||||||
getYaw(), getPitch(), isOnGround(), isRotating().get(), isMoving().get());
|
angleYaw, anglePitch, isOnGround(), isRotating().get(), isMoving().get());
|
||||||
} else {
|
} else {
|
||||||
Object packetInstance = entityPacketConstructor.newInstance(getEntityId());
|
Object packetInstance = entityPacketConstructor.newInstance(getEntityId());
|
||||||
WrappedPacketOutEntity wrapper = new WrappedPacketOutEntity(new NMSPacket(packetInstance));
|
WrappedPacketOutEntity wrapper = new WrappedPacketOutEntity(new NMSPacket(packetInstance));
|
||||||
@@ -343,7 +348,7 @@ public class WrappedPacketOutEntity extends WrappedPacketEntityAbstraction imple
|
|||||||
super(packet);
|
super(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketOutEntityLook(int entityID, byte yaw, byte pitch, boolean onGround) {
|
public WrappedPacketOutEntityLook(int entityID, float yaw, float pitch, boolean onGround) {
|
||||||
super(entityID, 0, 0, 0, yaw, pitch, onGround, true);
|
super(entityID, 0, 0, 0, yaw, pitch, onGround, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,7 +371,9 @@ public class WrappedPacketOutEntity extends WrappedPacketEntityAbstraction imple
|
|||||||
public Object asNMSPacket() throws Exception {
|
public Object asNMSPacket() throws Exception {
|
||||||
Object packetInstance;
|
Object packetInstance;
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
packetInstance = entityLookConstructor.newInstance(getEntityId(), getYaw(), getPitch(), isOnGround());
|
byte angleYaw = (byte) (getYaw() * ROTATION_FACTOR);
|
||||||
|
byte anglePitch = (byte) (getPitch() * ROTATION_FACTOR);
|
||||||
|
packetInstance = entityLookConstructor.newInstance(getEntityId(), angleYaw, anglePitch, isOnGround());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
packetInstance = entityLookConstructor.newInstance();
|
packetInstance = entityLookConstructor.newInstance();
|
||||||
@@ -389,7 +396,7 @@ public class WrappedPacketOutEntity extends WrappedPacketEntityAbstraction imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketOutRelEntityMove(int entityID, double deltaX, double deltaY, double deltaZ, boolean onGround) {
|
public WrappedPacketOutRelEntityMove(int entityID, double deltaX, double deltaY, double deltaZ, boolean onGround) {
|
||||||
super(entityID, deltaX, deltaY, deltaZ, (byte) 0, (byte) 0, onGround, false);
|
super(entityID, deltaX, deltaY, deltaZ, 0, 0, onGround, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -438,7 +445,8 @@ public class WrappedPacketOutEntity extends WrappedPacketEntityAbstraction imple
|
|||||||
super(packet);
|
super(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketOutRelEntityMoveLook(int entityID, double deltaX, double deltaY, double deltaZ, byte yaw, byte pitch, boolean onGround) {
|
public WrappedPacketOutRelEntityMoveLook(int entityID, double deltaX, double deltaY, double deltaZ,
|
||||||
|
float yaw, float pitch, boolean onGround) {
|
||||||
super(entityID, deltaX, deltaY, deltaZ, yaw, pitch, onGround, false);
|
super(entityID, deltaX, deltaY, deltaZ, yaw, pitch, onGround, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,7 +472,9 @@ public class WrappedPacketOutEntity extends WrappedPacketEntityAbstraction imple
|
|||||||
short dx = (short) (getDeltaX() * dXYZDivisor);
|
short dx = (short) (getDeltaX() * dXYZDivisor);
|
||||||
short dy = (short) (getDeltaY() * dXYZDivisor);
|
short dy = (short) (getDeltaY() * dXYZDivisor);
|
||||||
short dz = (short) (getDeltaZ() * dXYZDivisor);
|
short dz = (short) (getDeltaZ() * dXYZDivisor);
|
||||||
packetInstance = entityRelMoveLookConstructor.newInstance(getEntityId(), dx, dy, dz, getYaw(), getPitch(), isOnGround());
|
byte angleYaw = (byte) (getYaw() * ROTATION_FACTOR);
|
||||||
|
byte anglePitch = (byte) (getPitch() * ROTATION_FACTOR);
|
||||||
|
packetInstance = entityRelMoveLookConstructor.newInstance(getEntityId(), dx, dy, dz, angleYaw, anglePitch, isOnGround());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
packetInstance = entityRelMoveLookConstructor.newInstance();
|
packetInstance = entityRelMoveLookConstructor.newInstance();
|
||||||
|
|||||||
+74
-42
@@ -22,18 +22,24 @@ import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
|||||||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.api.helper.WrappedPacketEntityAbstraction;
|
import io.github.retrooper.packetevents.packetwrappers.api.helper.WrappedPacketEntityAbstraction;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
|
||||||
import it.unimi.dsi.fastutil.ints.IntList;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanjulang, MWHunter
|
* @author yanjulang, MWHunter
|
||||||
* @since 1.8
|
* @since 1.8
|
||||||
*/
|
*/
|
||||||
public class WrappedPacketOutEntityDestroy extends WrappedPacketEntityAbstraction implements SendableWrapper {
|
public class WrappedPacketOutEntityDestroy extends WrappedPacketEntityAbstraction implements SendableWrapper {
|
||||||
|
private static Class<?> INT_COLLECTION_CLASS;
|
||||||
|
private static Class<?> INT_LIST_CLASS;
|
||||||
|
private static Class<?> INT_ARRAY_LIST_CLASS;
|
||||||
|
private static Constructor<?> INT_ARRAY_LIST_CONSTRUCTOR;
|
||||||
|
private static Method TO_INT_ARRAY_METHOD;
|
||||||
private static boolean v_1_17;
|
private static boolean v_1_17;
|
||||||
private static boolean v_1_17_1;
|
private static boolean v_1_17_1;
|
||||||
private static Constructor<?> packetConstructor;
|
private static Constructor<?> packetConstructor;
|
||||||
@@ -61,12 +67,31 @@ public class WrappedPacketOutEntityDestroy extends WrappedPacketEntityAbstractio
|
|||||||
v_1_17_1 = version.isNewerThanOrEquals(ServerVersion.v_1_17_1);
|
v_1_17_1 = version.isNewerThanOrEquals(ServerVersion.v_1_17_1);
|
||||||
v_1_17 = version.equals(ServerVersion.v_1_17);
|
v_1_17 = version.equals(ServerVersion.v_1_17);
|
||||||
|
|
||||||
|
if (v_1_17_1) {
|
||||||
|
if (INT_COLLECTION_CLASS == null) {
|
||||||
|
INT_COLLECTION_CLASS = Reflection.getClassByNameWithoutException("it.unimi.dsi.fastutil.ints.IntCollection");
|
||||||
|
INT_LIST_CLASS = Reflection.getClassByNameWithoutException("it.unimi.dsi.fastutil.ints.IntList");
|
||||||
|
INT_ARRAY_LIST_CLASS = Reflection.getClassByNameWithoutException("it.unimi.dsi.fastutil.ints.IntArrayList");
|
||||||
|
try {
|
||||||
|
INT_ARRAY_LIST_CONSTRUCTOR = INT_ARRAY_LIST_CLASS.getConstructor(int[].class);
|
||||||
|
INT_ARRAY_LIST_CONSTRUCTOR.setAccessible(true);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
TO_INT_ARRAY_METHOD = INT_COLLECTION_CLASS.getDeclaredMethod("toIntArray");
|
||||||
|
TO_INT_ARRAY_METHOD.setAccessible(true);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
packetConstructor =
|
packetConstructor =
|
||||||
PacketTypeClasses.Play.Server.ENTITY_DESTROY.getConstructor(int.class);
|
PacketTypeClasses.Play.Server.ENTITY_DESTROY.getConstructor(int.class);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
packetConstructor =
|
packetConstructor =
|
||||||
PacketTypeClasses.Play.Server.ENTITY_DESTROY.getConstructor(int[].class);
|
PacketTypeClasses.Play.Server.ENTITY_DESTROY.getConstructor(int[].class);
|
||||||
}
|
}
|
||||||
@@ -80,15 +105,17 @@ public class WrappedPacketOutEntityDestroy extends WrappedPacketEntityAbstractio
|
|||||||
if (entityID != -1 || entityIds.length > 0 || packet == null) {
|
if (entityID != -1 || entityIds.length > 0 || packet == null) {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
return entityID;
|
return entityID;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return entityIds[0];
|
return entityIds[0];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (v_1_17_1) {
|
if (v_1_17_1) {
|
||||||
IntList list = readObject(0, IntList.class);
|
Object list = readObject(0, INT_LIST_CLASS);
|
||||||
entityIds = list.toIntArray();
|
try {
|
||||||
|
entityIds = (int[]) TO_INT_ARRAY_METHOD.invoke(list);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return entityIds[0];
|
return entityIds[0];
|
||||||
} else if (v_1_17) {
|
} else if (v_1_17) {
|
||||||
return entityID = readInt(0);
|
return entityID = readInt(0);
|
||||||
@@ -105,23 +132,25 @@ public class WrappedPacketOutEntityDestroy extends WrappedPacketEntityAbstractio
|
|||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
writeInt(0, this.entityID = entityID);
|
writeInt(0, this.entityID = entityID);
|
||||||
}
|
} else {
|
||||||
else {
|
this.entityIds = new int[]{entityID};
|
||||||
this.entityIds = new int[] {entityID};
|
|
||||||
if (v_1_17_1) {
|
if (v_1_17_1) {
|
||||||
IntList intArrayList = new IntArrayList(this.entityIds);
|
Object intArrayList = null;
|
||||||
write(IntList.class, 0, intArrayList);
|
try {
|
||||||
}
|
intArrayList = INT_ARRAY_LIST_CONSTRUCTOR.newInstance(this.entityIds);
|
||||||
else {
|
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
write(INT_LIST_CLASS, 0, intArrayList);
|
||||||
|
} else {
|
||||||
writeIntArray(0, new int[]{this.entityIds[0]});
|
writeIntArray(0, new int[]{this.entityIds[0]});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
}
|
} else {
|
||||||
else {
|
this.entityIds = new int[]{entityID};
|
||||||
this.entityIds = new int[] {entityID};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.entity = null;
|
this.entity = null;
|
||||||
@@ -130,19 +159,22 @@ public class WrappedPacketOutEntityDestroy extends WrappedPacketEntityAbstractio
|
|||||||
public int[] getEntityIds() {
|
public int[] getEntityIds() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
return new int[] {getEntityId()};
|
return new int[]{getEntityId()};
|
||||||
}
|
} else if (v_1_17_1) {
|
||||||
else if (v_1_17_1) {
|
Object list = readObject(0, INT_LIST_CLASS);
|
||||||
return readObject(0, IntList.class).toIntArray();
|
try {
|
||||||
}
|
return (int[]) TO_INT_ARRAY_METHOD.invoke(list);
|
||||||
else {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
return readIntArray(0);
|
return readIntArray(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
return new int[] {entityID};
|
return new int[]{entityID};
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return entityIds;
|
return entityIds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,20 +184,21 @@ public class WrappedPacketOutEntityDestroy extends WrappedPacketEntityAbstractio
|
|||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
setEntityId(entityIds[0]);
|
setEntityId(entityIds[0]);
|
||||||
}
|
} else if (v_1_17_1) {
|
||||||
else if (v_1_17_1) {
|
Object intArrayList = null;
|
||||||
IntList intList = new IntArrayList(entityIds);
|
try {
|
||||||
write(IntList.class, 0, intList);
|
intArrayList = INT_ARRAY_LIST_CONSTRUCTOR.newInstance(entityIds);
|
||||||
}
|
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||||
else {
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
write(INT_LIST_CLASS, 0, intArrayList);
|
||||||
|
} else {
|
||||||
writeIntArray(0, entityIds);
|
writeIntArray(0, entityIds);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
this.entityID = entityIds[0];
|
this.entityID = entityIds[0];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.entityIds = entityIds;
|
this.entityIds = entityIds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,8 +209,7 @@ public class WrappedPacketOutEntityDestroy extends WrappedPacketEntityAbstractio
|
|||||||
public Object asNMSPacket() throws Exception {
|
public Object asNMSPacket() throws Exception {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
return packetConstructor.newInstance(getEntityId());
|
return packetConstructor.newInstance(getEntityId());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return packetConstructor.newInstance(getEntityIds());
|
return packetConstructor.newInstance(getEntityIds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+96
-13
@@ -24,17 +24,23 @@ import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
|||||||
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.api.helper.WrappedPacketEntityAbstraction;
|
import io.github.retrooper.packetevents.packetwrappers.api.helper.WrappedPacketEntityAbstraction;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class WrappedPacketOutEntityEffect extends WrappedPacketEntityAbstraction implements SendableWrapper {
|
public class WrappedPacketOutEntityEffect extends WrappedPacketEntityAbstraction implements SendableWrapper {
|
||||||
private static boolean v_1_7_10, v_1_17;
|
private static boolean v_1_7_10, v_1_17, v_1_18_2, v_1_19, v_1_20_5;
|
||||||
private static Constructor<?> packetConstructor;
|
private static Constructor<?> packetConstructor;
|
||||||
|
private static Class<?> holderClass;
|
||||||
|
private static Method accessHolderValueMethod;
|
||||||
|
private static boolean hasHolder = false;
|
||||||
private int effectID;
|
private int effectID;
|
||||||
private int amplifier;
|
private int amplifier;
|
||||||
private int duration;
|
private int duration;
|
||||||
@@ -104,12 +110,26 @@ public class WrappedPacketOutEntityEffect extends WrappedPacketEntityAbstraction
|
|||||||
protected void load() {
|
protected void load() {
|
||||||
v_1_7_10 = version.isOlderThan(ServerVersion.v_1_8);
|
v_1_7_10 = version.isOlderThan(ServerVersion.v_1_8);
|
||||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
||||||
|
v_1_18_2 = version.isNewerThanOrEquals(ServerVersion.v_1_18_2);
|
||||||
|
v_1_19 = version.isNewerThanOrEquals(ServerVersion.v_1_19);
|
||||||
|
v_1_20_5 = version.isNewerThanOrEquals(ServerVersion.v_1_20_5);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
packetConstructor = PacketTypeClasses.Play.Server.ENTITY_EFFECT.getConstructor(NMSUtils.packetDataSerializerClass);
|
/*packetConstructor = PacketTypeClasses.Play.Server.ENTITY_EFFECT.getDeclaredConstructor(NMSUtils.packetDataSerializerClass);
|
||||||
|
packetConstructor.setAccessible(true);
|
||||||
|
if (packetConstructor == null) {
|
||||||
|
Class<?> registryFriendlyByteBuf = NMSUtils.getNMClassWithoutException("network.RegistryFriendlyByteBuf");
|
||||||
|
packetConstructor = PacketTypeClasses.Play.Server.ENTITY_EFFECT.getDeclaredConstructor(registryFriendlyByteBuf);
|
||||||
|
}*/
|
||||||
} else {
|
} else {
|
||||||
packetConstructor = PacketTypeClasses.Play.Server.ENTITY_EFFECT.getConstructor();
|
packetConstructor = PacketTypeClasses.Play.Server.ENTITY_EFFECT.getConstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
holderClass = NMSUtils.getNMClassWithoutException("core.Holder");
|
||||||
|
if (holderClass != null) {
|
||||||
|
hasHolder = Reflection.getField(PacketTypeClasses.Play.Server.ENTITY_EFFECT, holderClass, 0) != null;
|
||||||
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -117,7 +137,28 @@ public class WrappedPacketOutEntityEffect extends WrappedPacketEntityAbstraction
|
|||||||
|
|
||||||
public int getEffectId() {
|
public int getEffectId() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
return readByte(0);
|
if (v_1_19) {
|
||||||
|
Object mobEffectList = null;
|
||||||
|
if (hasHolder) {
|
||||||
|
Object holder = readObject(0, holderClass);
|
||||||
|
if (accessHolderValueMethod == null) {
|
||||||
|
accessHolderValueMethod = Reflection.getMethod(holderClass, 0);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
mobEffectList = accessHolderValueMethod.invoke(holder);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mobEffectList = readObject(0, NMSUtils.mobEffectListClass);
|
||||||
|
}
|
||||||
|
return NMSUtils.getEffectId(mobEffectList);
|
||||||
|
} else if (v_1_18_2) {
|
||||||
|
return readInt(4);
|
||||||
|
} else {
|
||||||
|
return readByte(0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return effectID;
|
return effectID;
|
||||||
}
|
}
|
||||||
@@ -125,7 +166,14 @@ public class WrappedPacketOutEntityEffect extends WrappedPacketEntityAbstraction
|
|||||||
|
|
||||||
public void setEffectId(int effectID) {
|
public void setEffectId(int effectID) {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
writeByte(0, (byte) effectID);
|
if (v_1_19) {
|
||||||
|
Object mobEffectList = NMSUtils.getMobEffectListById(effectID);
|
||||||
|
write(NMSUtils.mobEffectListClass, 0, mobEffectList);
|
||||||
|
} else if (v_1_18_2) {
|
||||||
|
writeInt(4, effectID);
|
||||||
|
} else {
|
||||||
|
writeByte(0, (byte) effectID);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.effectID = effectID;
|
this.effectID = effectID;
|
||||||
}
|
}
|
||||||
@@ -133,7 +181,10 @@ public class WrappedPacketOutEntityEffect extends WrappedPacketEntityAbstraction
|
|||||||
|
|
||||||
public int getAmplifier() {
|
public int getAmplifier() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
return readByte(1);
|
if (v_1_20_5) {
|
||||||
|
return readInt(5);
|
||||||
|
}
|
||||||
|
return readByte(v_1_18_2 ? 0 : 1);
|
||||||
} else {
|
} else {
|
||||||
return amplifier;
|
return amplifier;
|
||||||
}
|
}
|
||||||
@@ -141,7 +192,10 @@ public class WrappedPacketOutEntityEffect extends WrappedPacketEntityAbstraction
|
|||||||
|
|
||||||
public void setAmplifier(int amplifier) {
|
public void setAmplifier(int amplifier) {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
writeByte(1, (byte) amplifier);
|
if (v_1_20_5) {
|
||||||
|
writeInt(5, amplifier);
|
||||||
|
}
|
||||||
|
writeByte(v_1_18_2 ? 0 : 1, (byte) amplifier);
|
||||||
} else {
|
} else {
|
||||||
this.amplifier = amplifier;
|
this.amplifier = amplifier;
|
||||||
}
|
}
|
||||||
@@ -149,9 +203,22 @@ public class WrappedPacketOutEntityEffect extends WrappedPacketEntityAbstraction
|
|||||||
|
|
||||||
public int getDuration() {
|
public int getDuration() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
|
//1.7 and only 1.7(below 1.8)
|
||||||
if (v_1_7_10) {
|
if (v_1_7_10) {
|
||||||
return readShort(1);
|
return readShort(1);
|
||||||
} else {
|
}
|
||||||
|
else if (v_1_20_5) {
|
||||||
|
return readInt(6);
|
||||||
|
}
|
||||||
|
else if (v_1_19) {
|
||||||
|
return readInt(4);
|
||||||
|
}
|
||||||
|
//1.18.2+
|
||||||
|
else if (v_1_18_2) {
|
||||||
|
return readInt(5);
|
||||||
|
}
|
||||||
|
//1.17 - 1.8
|
||||||
|
else {
|
||||||
return readInt(v_1_17 ? 4 : 1);
|
return readInt(v_1_17 ? 4 : 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -169,6 +236,14 @@ public class WrappedPacketOutEntityEffect extends WrappedPacketEntityAbstraction
|
|||||||
duration = Short.MIN_VALUE;
|
duration = Short.MIN_VALUE;
|
||||||
}
|
}
|
||||||
writeShort(0, (short) duration);
|
writeShort(0, (short) duration);
|
||||||
|
}
|
||||||
|
else if (v_1_20_5) {
|
||||||
|
writeInt(6, duration);
|
||||||
|
}
|
||||||
|
else if (v_1_19) {
|
||||||
|
writeInt(4, duration);
|
||||||
|
} else if (v_1_18_2) {
|
||||||
|
writeInt(5, duration);
|
||||||
} else {
|
} else {
|
||||||
writeInt(v_1_17 ? 4 : 1, duration);
|
writeInt(v_1_17 ? 4 : 1, duration);
|
||||||
}
|
}
|
||||||
@@ -178,21 +253,27 @@ public class WrappedPacketOutEntityEffect extends WrappedPacketEntityAbstraction
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Optional<Byte> getByteMask() {
|
private Optional<Byte> getByteMask() {
|
||||||
if (version.isOlderThan(ServerVersion.v_1_8)) {
|
if (v_1_7_10) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
if (packet != null && !byteMaskInitialized) {
|
if (packet != null && !byteMaskInitialized) {
|
||||||
return Optional.of(byteMask = readByte(2));
|
if (v_1_20_5) {
|
||||||
|
return Optional.of(readByte(0));
|
||||||
|
}
|
||||||
|
return Optional.of(byteMask = readByte(v_1_18_2 ? 1 : 2));
|
||||||
} else {
|
} else {
|
||||||
return Optional.of(byteMask);
|
return Optional.of(byteMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setByteMask(byte byteMask) {
|
private void setByteMask(byte byteMask) {
|
||||||
if (version.isNewerThan(ServerVersion.v_1_7_10)) {
|
if (!v_1_7_10) {
|
||||||
this.byteMask = byteMask;
|
this.byteMask = byteMask;
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
writeByte(2, byteMask);
|
if (v_1_20_5) {
|
||||||
|
writeByte(0, byteMask);
|
||||||
|
}
|
||||||
|
writeByte(v_1_18_2 ? 1 : 2, byteMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,8 +374,10 @@ public class WrappedPacketOutEntityEffect extends WrappedPacketEntityAbstraction
|
|||||||
public Object asNMSPacket() throws Exception {
|
public Object asNMSPacket() throws Exception {
|
||||||
Object packetInstance;
|
Object packetInstance;
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
//Lazy, but smart way :)
|
//Lazy and stupid way
|
||||||
Object packetDataSerializer = NMSUtils.generatePacketDataSerializer(PacketEvents.get().getByteBufUtil().newByteBuf(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}));
|
//was size 12
|
||||||
|
byte[] buffer = new byte[30];
|
||||||
|
Object packetDataSerializer = NMSUtils.generatePacketDataSerializer(PacketEvents.get().getByteBufUtil().newByteBuf(buffer));
|
||||||
packetInstance = packetConstructor.newInstance(packetDataSerializer);
|
packetInstance = packetConstructor.newInstance(packetDataSerializer);
|
||||||
} else {
|
} else {
|
||||||
packetInstance = packetConstructor.newInstance();
|
packetInstance = packetConstructor.newInstance();
|
||||||
|
|||||||
+8
-7
@@ -32,18 +32,19 @@ import java.lang.reflect.Constructor;
|
|||||||
public class WrappedPacketOutEntityHeadRotation extends WrappedPacketEntityAbstraction implements SendableWrapper {
|
public class WrappedPacketOutEntityHeadRotation extends WrappedPacketEntityAbstraction implements SendableWrapper {
|
||||||
private static boolean v_1_17;
|
private static boolean v_1_17;
|
||||||
private static Constructor<?> packetConstructor;
|
private static Constructor<?> packetConstructor;
|
||||||
private byte yaw;
|
private static final float ROTATION_FACTOR = 256.0F / 360.0F;
|
||||||
|
private float yaw;
|
||||||
|
|
||||||
public WrappedPacketOutEntityHeadRotation(NMSPacket packet) {
|
public WrappedPacketOutEntityHeadRotation(NMSPacket packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketOutEntityHeadRotation(int entityID, byte yaw) {
|
public WrappedPacketOutEntityHeadRotation(int entityID, float yaw) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
this.yaw = yaw;
|
this.yaw = yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketOutEntityHeadRotation(Entity entity, byte yaw) {
|
public WrappedPacketOutEntityHeadRotation(Entity entity, float yaw) {
|
||||||
this.entityID = entity.getEntityId();
|
this.entityID = entity.getEntityId();
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.yaw = yaw;
|
this.yaw = yaw;
|
||||||
@@ -64,17 +65,17 @@ public class WrappedPacketOutEntityHeadRotation extends WrappedPacketEntityAbstr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getYaw() {
|
public float getYaw() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
return readByte(0);
|
return readByte(0) / ROTATION_FACTOR;
|
||||||
} else {
|
} else {
|
||||||
return yaw;
|
return yaw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setYaw(byte yaw) {
|
public void setYaw(float yaw) {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
writeByte(0, yaw);
|
writeByte(0, (byte) (yaw * ROTATION_FACTOR));
|
||||||
} else {
|
} else {
|
||||||
this.yaw = yaw;
|
this.yaw = yaw;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ public class WrappedPacketOutEntityMetadata extends WrappedPacketEntityAbstracti
|
|||||||
|
|
||||||
public List<WrappedWatchableObject> getWatchableObjects() {
|
public List<WrappedWatchableObject> getWatchableObjects() {
|
||||||
List<Object> nmsWatchableObjectList = readList(0);
|
List<Object> nmsWatchableObjectList = readList(0);
|
||||||
//Its annotated as nullable on 1.17 NMS, so lets just handle it being null
|
//It's annotated as nullable on 1.17 NMS, so lets just handle it being null
|
||||||
if (nmsWatchableObjectList == null) {
|
if (nmsWatchableObjectList == null) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-5
@@ -38,7 +38,15 @@ public class WrappedWatchableObject extends WrappedPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
if (version.isNewerThan(ServerVersion.v_1_8_8)) {
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_3)) {
|
||||||
|
valueIndex = 2;
|
||||||
|
try {
|
||||||
|
googleOptionalClass = Class.forName("com.google.common.base.Optional");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (version.isNewerThan(ServerVersion.v_1_8_8)) {
|
||||||
valueIndex = 1;
|
valueIndex = 1;
|
||||||
try {
|
try {
|
||||||
googleOptionalClass = Class.forName("com.google.common.base.Optional");
|
googleOptionalClass = Class.forName("com.google.common.base.Optional");
|
||||||
@@ -49,17 +57,19 @@ public class WrappedWatchableObject extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
if (version.isNewerThan(ServerVersion.v_1_8_8)) {
|
if (version.isNewerThan(ServerVersion.v_1_8_8) && version.isOlderThan(ServerVersion.v_1_19_3)) {
|
||||||
Object dataWatcherObject = readAnyObject(0);
|
Object dataWatcherObject = readAnyObject(0);
|
||||||
WrappedPacket wrappedDataWatcher = new WrappedPacket(new NMSPacket(dataWatcherObject));
|
WrappedPacket wrappedDataWatcher = new WrappedPacket(new NMSPacket(dataWatcherObject));
|
||||||
return wrappedDataWatcher.readInt(0);
|
return wrappedDataWatcher.readInt(0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
//1.19.3 changed back to this
|
||||||
return readInt(0);
|
return readInt(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndex(int index) {
|
public void setIndex(int index) {
|
||||||
if (version.isNewerThan(ServerVersion.v_1_8_8)) {
|
if (version.isNewerThan(ServerVersion.v_1_8_8) && version.isOlderThan(ServerVersion.v_1_19_3)) {
|
||||||
Object dataWatcherObject = readAnyObject(0);
|
Object dataWatcherObject = readAnyObject(0);
|
||||||
WrappedPacket wrappedDataWatcher = new WrappedPacket(new NMSPacket(dataWatcherObject));
|
WrappedPacket wrappedDataWatcher = new WrappedPacket(new NMSPacket(dataWatcherObject));
|
||||||
wrappedDataWatcher.writeInt(0, index);
|
wrappedDataWatcher.writeInt(0, index);
|
||||||
@@ -69,11 +79,13 @@ public class WrappedWatchableObject extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDirty() {
|
public boolean isDirty() {
|
||||||
return readBoolean(0);
|
return !version.isOlderThan(ServerVersion.v_1_19_3) || readBoolean(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDirty(boolean dirty) {
|
public void setDirty(boolean dirty) {
|
||||||
writeBoolean(0, dirty);
|
if (version.isOlderThan(ServerVersion.v_1_19_3)) {
|
||||||
|
writeBoolean(0, dirty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getRawValue() {
|
public Object getRawValue() {
|
||||||
|
|||||||
+3
-4
@@ -84,9 +84,9 @@ public final class WrappedPacketOutEntityVelocity extends WrappedPacketEntityAbs
|
|||||||
|
|
||||||
public void setVelocity(Vector3d velocity) {
|
public void setVelocity(Vector3d velocity) {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
writeInt(1, (int) (velocity.x));
|
writeInt(1, (int) (velocity.x * 8000.0));
|
||||||
writeInt(2, (int) (velocity.y));
|
writeInt(2, (int) (velocity.y * 8000.0));
|
||||||
writeInt(3, (int) (velocity.z));
|
writeInt(3, (int) (velocity.z * 8000.0));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.velocityX = velocity.x;
|
this.velocityX = velocity.x;
|
||||||
@@ -95,7 +95,6 @@ public final class WrappedPacketOutEntityVelocity extends WrappedPacketEntityAbs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Cut off at 1.8.1 and optimize the methods above.
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getVelocityX() {
|
public double getVelocityX() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
|
|||||||
+1
-2
@@ -81,7 +81,7 @@ public class WrappedPacketOutExplosion extends WrappedPacket implements Sendable
|
|||||||
chunkPosConstructor = chunkPosClass.getConstructor(int.class, int.class, int.class);
|
chunkPosConstructor = chunkPosClass.getConstructor(int.class, int.class, int.class);
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
//1.20.4 or newer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +238,6 @@ public class WrappedPacketOutExplosion extends WrappedPacket implements Sendable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Cut off at 1.8.1, and once you cut off, you can optimize the methods above. Also optimize the position part.
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public float getPlayerMotionX() {
|
public float getPlayerMotionX() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
|
|||||||
+2
-1
@@ -54,6 +54,7 @@ public class WrappedPacketOutGameStateChange extends WrappedPacket implements Se
|
|||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
reasonClassType = SubclassUtil.getSubClass(PacketTypeClasses.Play.Server.GAME_STATE_CHANGE, 0);
|
reasonClassType = SubclassUtil.getSubClass(PacketTypeClasses.Play.Server.GAME_STATE_CHANGE, 0);
|
||||||
|
net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange gsc;
|
||||||
if (reasonClassType != null) {
|
if (reasonClassType != null) {
|
||||||
try {
|
try {
|
||||||
reasonClassConstructor = reasonClassType.getConstructor(int.class);
|
reasonClassConstructor = reasonClassType.getConstructor(int.class);
|
||||||
@@ -140,7 +141,7 @@ public class WrappedPacketOutGameStateChange extends WrappedPacket implements Se
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object asNMSPacket() throws Exception {
|
public Object asNMSPacket() throws Exception {
|
||||||
if (reasonClassType == null) {
|
if (reasonIntMode) {
|
||||||
if (valueFloatMode) {
|
if (valueFloatMode) {
|
||||||
return packetConstructor.newInstance(getReason(), (float) getValue());
|
return packetConstructor.newInstance(getReason(), (float) getValue());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+23
@@ -80,4 +80,27 @@ public class WrappedPacketOutLogin extends WrappedPacketEntityAbstraction {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPortalCooldown() {
|
||||||
|
if (packet != null) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_20)) {
|
||||||
|
return readInt(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//TODO unfinished
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPortalCooldown(int portalCooldown) {
|
||||||
|
if (packet != null) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_20)) {
|
||||||
|
writeInt(4, portalCooldown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//TODO unfinished
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+48
-39
@@ -21,6 +21,7 @@ package io.github.retrooper.packetevents.packetwrappers.play.out.mapchunk;
|
|||||||
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.SubclassUtil;
|
import io.github.retrooper.packetevents.utils.reflection.SubclassUtil;
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
|
|
||||||
@@ -31,8 +32,8 @@ import java.util.Optional;
|
|||||||
|
|
||||||
//TODO finish wrapper
|
//TODO finish wrapper
|
||||||
public class WrappedPacketOutMapChunk extends WrappedPacket {
|
public class WrappedPacketOutMapChunk extends WrappedPacket {
|
||||||
private static boolean v_1_8_x, v_1_17;
|
private static boolean v_1_8_x, v_1_17, v_1_18;
|
||||||
private static Class<?> chunkMapClass;
|
private static Class<?> chunkMapClass, chunkPacketDataClass;
|
||||||
private Constructor<?> chunkMapConstructor;
|
private Constructor<?> chunkMapConstructor;
|
||||||
private Object nmsChunkMap;
|
private Object nmsChunkMap;
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ public class WrappedPacketOutMapChunk extends WrappedPacket {
|
|||||||
protected void load() {
|
protected void load() {
|
||||||
v_1_8_x = version.isNewerThan(ServerVersion.v_1_7_10) && version.isOlderThan(ServerVersion.v_1_9);
|
v_1_8_x = version.isNewerThan(ServerVersion.v_1_7_10) && version.isOlderThan(ServerVersion.v_1_9);
|
||||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
||||||
|
v_1_18 = version.isNewerThanOrEquals(ServerVersion.v_1_18);
|
||||||
if (v_1_8_x) {
|
if (v_1_8_x) {
|
||||||
chunkMapClass = SubclassUtil.getSubClass(PacketTypeClasses.Play.Server.MAP_CHUNK, 0);
|
chunkMapClass = SubclassUtil.getSubClass(PacketTypeClasses.Play.Server.MAP_CHUNK, 0);
|
||||||
try {
|
try {
|
||||||
@@ -52,69 +54,68 @@ public class WrappedPacketOutMapChunk extends WrappedPacket {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
chunkPacketDataClass = Reflection.getClassByNameWithoutException("net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getChunkX() {
|
public int getChunkX() {
|
||||||
return readInt(v_1_17 ? 1 : 0);
|
return readInt(v_1_17 && !v_1_18 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChunkX(int chunkX) {
|
public void setChunkX(int chunkX) {
|
||||||
writeInt(v_1_17 ? 1: 0, chunkX);
|
writeInt(v_1_17 && !v_1_18 ? 1 : 0, chunkX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getChunkZ() {
|
public int getChunkZ() {
|
||||||
return readInt(v_1_17 ? 2: 1);
|
return readInt(v_1_17 && !v_1_18 ? 2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChunkZ(int chunkZ) {
|
public void setChunkZ(int chunkZ) {
|
||||||
writeInt(v_1_17 ? 2: 1, chunkZ);
|
writeInt(v_1_17 && !v_1_18 ? 2 : 1, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<BitSet> getPrimaryBitMaskBitSet() {
|
public Optional<BitSet> getBitSet() {
|
||||||
|
if (v_1_18) { // Bitsets were removed in 1.18
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
return Optional.of(readObject(0, BitSet.class));
|
return Optional.of(readObject(0, BitSet.class));
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrimaryBitMaskBitSet(BitSet bitMaskBitSet) {
|
|
||||||
if (v_1_17) {
|
|
||||||
writeObject(0, bitMaskBitSet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Optional<Integer> getPrimaryBitMap() {
|
|
||||||
return getPrimaryBitMask();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setPrimaryBitMap(int primaryBitMask) {
|
|
||||||
setPrimaryBitMask(primaryBitMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<Integer> getPrimaryBitMask() {
|
|
||||||
if (v_1_17) {
|
|
||||||
long[] bitset = readObject(0, BitSet.class).toLongArray();
|
|
||||||
return Optional.of(bitset.length == 0 ? 0 : (int) bitset[0]);
|
|
||||||
}
|
|
||||||
if (v_1_8_x) {
|
if (v_1_8_x) {
|
||||||
if (nmsChunkMap == null) {
|
if (nmsChunkMap == null) {
|
||||||
nmsChunkMap = readObject(0, chunkMapClass);
|
nmsChunkMap = readObject(0, chunkMapClass);
|
||||||
}
|
}
|
||||||
WrappedPacket nmsChunkMapWrapper = new WrappedPacket(new NMSPacket(nmsChunkMap));
|
WrappedPacket nmsChunkMapWrapper = new WrappedPacket(new NMSPacket(nmsChunkMap));
|
||||||
return Optional.of(nmsChunkMapWrapper.readInt(0));
|
return Optional.of(BitSet.valueOf(new long[]{nmsChunkMapWrapper.readInt(0)}));
|
||||||
} else {
|
} else {
|
||||||
return Optional.of(readInt(2));
|
return Optional.of(BitSet.valueOf(new long[]{readInt(2)}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrimaryBitMask(int primaryBitMask) {
|
/**
|
||||||
|
* @param bitSet Bitset that can hold multiple integer values to support the expanded world height on
|
||||||
|
* 1.17 and newer servers. This is due to 1.17 needing to support up to 127 chunk sections
|
||||||
|
* (2032 blocks) and an integer only being able to hold 32 bits to represent 32 chunk sections
|
||||||
|
*/
|
||||||
|
public void setPrimaryBitMask(BitSet bitSet) {
|
||||||
|
if (v_1_18) return; // Bitsets were removed in 1.18
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
writeObject(0, BitSet.valueOf(new long[] {primaryBitMask}));
|
writeObject(0, bitSet);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setPrimaryBitMask((int) bitSet.toLongArray()[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param primaryBitMask Integer that determines which chunk sections the server is sending
|
||||||
|
* @deprecated Possible lossy conversion on 1.17 servers that could result in the client only reading 32
|
||||||
|
* out of the total possible 127 chunk sections. Safe to use on 1.16 and below servers
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void setPrimaryBitMask(int primaryBitMask) {
|
||||||
|
if (v_1_18) return; // Bitsets were removed in 1.18
|
||||||
|
if (v_1_17) {
|
||||||
|
writeObject(0, BitSet.valueOf(new long[]{primaryBitMask}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (v_1_8_x) {
|
if (v_1_8_x) {
|
||||||
@@ -134,7 +135,9 @@ public class WrappedPacketOutMapChunk extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Confirm if 1.17 support is possible
|
/**
|
||||||
|
* @return Whether the packet overwrites the entire chunk column or just the sections being sent
|
||||||
|
*/
|
||||||
public Optional<Boolean> isGroundUpContinuous() {
|
public Optional<Boolean> isGroundUpContinuous() {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@@ -142,7 +145,9 @@ public class WrappedPacketOutMapChunk extends WrappedPacket {
|
|||||||
return Optional.of(readBoolean(0));
|
return Optional.of(readBoolean(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Confirm if 1.17 support is possible
|
/**
|
||||||
|
* @param groundUpContinuous Whether the packet overwrites the entire chunk column or just the sections being sent
|
||||||
|
*/
|
||||||
public void setGroundUpContinuous(boolean groundUpContinuous) {
|
public void setGroundUpContinuous(boolean groundUpContinuous) {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
return;
|
return;
|
||||||
@@ -157,6 +162,8 @@ public class WrappedPacketOutMapChunk extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
WrappedPacket nmsChunkMapWrapper = new WrappedPacket(new NMSPacket(nmsChunkMap));
|
WrappedPacket nmsChunkMapWrapper = new WrappedPacket(new NMSPacket(nmsChunkMap));
|
||||||
return nmsChunkMapWrapper.readByteArray(0);
|
return nmsChunkMapWrapper.readByteArray(0);
|
||||||
|
} else if (v_1_18) {
|
||||||
|
return new WrappedPacket(new NMSPacket(readObject(0, chunkPacketDataClass))).readByteArray(0);
|
||||||
} else {
|
} else {
|
||||||
return readByteArray(0);
|
return readByteArray(0);
|
||||||
}
|
}
|
||||||
@@ -174,6 +181,8 @@ public class WrappedPacketOutMapChunk extends WrappedPacket {
|
|||||||
WrappedPacket nmsChunkMapWrapper = new WrappedPacket(new NMSPacket(nmsChunkMap));
|
WrappedPacket nmsChunkMapWrapper = new WrappedPacket(new NMSPacket(nmsChunkMap));
|
||||||
nmsChunkMapWrapper.writeByteArray(0, data);
|
nmsChunkMapWrapper.writeByteArray(0, data);
|
||||||
write(chunkMapClass, 0, nmsChunkMap);
|
write(chunkMapClass, 0, nmsChunkMap);
|
||||||
|
} else if (v_1_18) {
|
||||||
|
new WrappedPacket(new NMSPacket(readObject(0, chunkPacketDataClass))).writeByteArray(0, data);
|
||||||
} else {
|
} else {
|
||||||
writeByteArray(0, data);
|
writeByteArray(0, data);
|
||||||
}
|
}
|
||||||
|
|||||||
-43
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
|
||||||
* Copyright (C) 2021 retrooper and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.github.retrooper.packetevents.packetwrappers.play.out.multiblockchange;
|
|
||||||
|
|
||||||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
|
||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
|
||||||
|
|
||||||
//TODO finish this wrapper
|
|
||||||
class WrappedPacketOutMultiBlockChange extends WrappedPacket {
|
|
||||||
|
|
||||||
public WrappedPacketOutMultiBlockChange(NMSPacket packet) {
|
|
||||||
super(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void load() {
|
|
||||||
net.minecraft.server.v1_7_R4.PacketPlayOutMultiBlockChange a0;
|
|
||||||
net.minecraft.server.v1_8_R3.PacketPlayOutMultiBlockChange a1;
|
|
||||||
net.minecraft.server.v1_9_R1.PacketPlayOutMultiBlockChange a2;
|
|
||||||
net.minecraft.server.v1_9_R2.PacketPlayOutMultiBlockChange a3;
|
|
||||||
net.minecraft.server.v1_12_R1.PacketPlayOutMultiBlockChange a4;
|
|
||||||
net.minecraft.server.v1_13_R1.PacketPlayOutMultiBlockChange a5;
|
|
||||||
net.minecraft.server.v1_13_R2.PacketPlayOutMultiBlockChange a6;
|
|
||||||
net.minecraft.server.v1_16_R2.PacketPlayOutMultiBlockChange a7;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+10
@@ -114,6 +114,7 @@ public class WrappedPacketOutPlayerInfo extends WrappedPacket implements Sendabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO Technically we would need to support profile signiture data for complete 1.19.1 support.
|
||||||
public PlayerInfo[] getPlayerInfo() {
|
public PlayerInfo[] getPlayerInfo() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
PlayerInfo[] playerInfoArray = new PlayerInfo[1];
|
PlayerInfo[] playerInfoArray = new PlayerInfo[1];
|
||||||
@@ -126,6 +127,7 @@ public class WrappedPacketOutPlayerInfo extends WrappedPacket implements Sendabl
|
|||||||
playerInfoArray[0] = new PlayerInfo(username, gameProfile, gameMode, ping);
|
playerInfoArray[0] = new PlayerInfo(username, gameProfile, gameMode, ping);
|
||||||
} else {
|
} else {
|
||||||
List<Object> nmsPlayerInfoDataList = readList(0);
|
List<Object> nmsPlayerInfoDataList = readList(0);
|
||||||
|
playerInfoArray = new PlayerInfo[nmsPlayerInfoDataList.size()];
|
||||||
for (int i = 0; i < nmsPlayerInfoDataList.size(); i++) {
|
for (int i = 0; i < nmsPlayerInfoDataList.size(); i++) {
|
||||||
Object nmsPlayerInfoData = nmsPlayerInfoDataList.get(i);
|
Object nmsPlayerInfoData = nmsPlayerInfoDataList.get(i);
|
||||||
WrappedPacket nmsPlayerInfoDataWrapper = new WrappedPacket(new NMSPacket(nmsPlayerInfoData));
|
WrappedPacket nmsPlayerInfoDataWrapper = new WrappedPacket(new NMSPacket(nmsPlayerInfoData));
|
||||||
@@ -200,6 +202,14 @@ public class WrappedPacketOutPlayerInfo extends WrappedPacket implements Sendabl
|
|||||||
return packetInstance;
|
return packetInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSupported() {
|
||||||
|
//1.19.3 removed this packet and replaced it with PlayerInfoRemove & PlayerInfoUpdate
|
||||||
|
//TODO Since this is a minimal update, we won't add those. v1.8 will eventually be discontinued
|
||||||
|
//so please consider updating to 2.0
|
||||||
|
return version.isOlderThanOrEquals(ServerVersion.v_1_19_2);
|
||||||
|
}
|
||||||
|
|
||||||
public enum PlayerInfoAction {
|
public enum PlayerInfoAction {
|
||||||
ADD_PLAYER,
|
ADD_PLAYER,
|
||||||
UPDATE_GAME_MODE,
|
UPDATE_GAME_MODE,
|
||||||
|
|||||||
+37
-5
@@ -23,14 +23,20 @@ import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
|||||||
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.api.helper.WrappedPacketEntityAbstraction;
|
import io.github.retrooper.packetevents.packetwrappers.api.helper.WrappedPacketEntityAbstraction;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class WrappedPacketOutRemoveEntityEffect extends WrappedPacketEntityAbstraction implements SendableWrapper {
|
public class WrappedPacketOutRemoveEntityEffect extends WrappedPacketEntityAbstraction implements SendableWrapper {
|
||||||
private static boolean v_1_8_x, v_1_17;
|
private static boolean v_1_8_x, v_1_17;
|
||||||
private static Constructor<?> packetConstructor;
|
private static Constructor<?> packetConstructor;
|
||||||
|
private static Class<?> holderClass;
|
||||||
|
private static Method accessHolderValueMethod;
|
||||||
|
private static boolean hasHolder = false;
|
||||||
private int effectID;
|
private int effectID;
|
||||||
|
|
||||||
public WrappedPacketOutRemoveEntityEffect(NMSPacket packet) {
|
public WrappedPacketOutRemoveEntityEffect(NMSPacket packet) {
|
||||||
@@ -54,11 +60,17 @@ public class WrappedPacketOutRemoveEntityEffect extends WrappedPacketEntityAbstr
|
|||||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
||||||
try {
|
try {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
packetConstructor = PacketTypeClasses.Play.Server.REMOVE_ENTITY_EFFECT.getConstructor(int.class, NMSUtils.mobEffectListClass);
|
//packetConstructor = PacketTypeClasses.Play.Server.REMOVE_ENTITY_EFFECT.getConstructor(int.class, NMSUtils.mobEffectListClass);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
packetConstructor = PacketTypeClasses.Play.Server.REMOVE_ENTITY_EFFECT.getConstructor();
|
packetConstructor = PacketTypeClasses.Play.Server.REMOVE_ENTITY_EFFECT.getConstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
holderClass = NMSUtils.getNMClassWithoutException("core.Holder");
|
||||||
|
if (holderClass != null) {
|
||||||
|
hasHolder = Reflection.getField(PacketTypeClasses.Play.Server.ENTITY_EFFECT, holderClass, 0) != null;
|
||||||
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -66,11 +78,28 @@ public class WrappedPacketOutRemoveEntityEffect extends WrappedPacketEntityAbstr
|
|||||||
|
|
||||||
public int getEffectId() {
|
public int getEffectId() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
|
//1.7 and 1.8
|
||||||
if (v_1_8_x) {
|
if (v_1_8_x) {
|
||||||
return readInt(1);
|
return readInt(1);
|
||||||
} else {
|
}
|
||||||
Object nmsMobEffectList = readObject(0, NMSUtils.mobEffectListClass);
|
//1.9+
|
||||||
return NMSUtils.getEffectId(nmsMobEffectList);
|
else {
|
||||||
|
Object mobEffectList = null;
|
||||||
|
if (hasHolder) {
|
||||||
|
Object holder = readObject(0, holderClass);
|
||||||
|
if (accessHolderValueMethod == null) {
|
||||||
|
accessHolderValueMethod = Reflection.getMethod(holderClass, 0);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
mobEffectList = accessHolderValueMethod.invoke(holder);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mobEffectList = readObject(0, NMSUtils.mobEffectListClass);
|
||||||
|
}
|
||||||
|
return NMSUtils.getEffectId(mobEffectList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -80,9 +109,12 @@ public class WrappedPacketOutRemoveEntityEffect extends WrappedPacketEntityAbstr
|
|||||||
|
|
||||||
public void setEffectId(int effectID) {
|
public void setEffectId(int effectID) {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
|
//1.7 and 1.8
|
||||||
if (v_1_8_x) {
|
if (v_1_8_x) {
|
||||||
writeInt(1, effectID);
|
writeInt(1, effectID);
|
||||||
} else {
|
}
|
||||||
|
//1.9+
|
||||||
|
else {
|
||||||
Object nmsMobEffectList = NMSUtils.getMobEffectListById(effectID);
|
Object nmsMobEffectList = NMSUtils.getMobEffectListById(effectID);
|
||||||
write(NMSUtils.mobEffectListClass, 0, nmsMobEffectList);
|
write(NMSUtils.mobEffectListClass, 0, nmsMobEffectList);
|
||||||
}
|
}
|
||||||
|
|||||||
+19
@@ -33,6 +33,7 @@ class WrappedPacketOutRespawn extends WrappedPacket {
|
|||||||
private Difficulty difficulty;
|
private Difficulty difficulty;
|
||||||
private GameMode gameMode;
|
private GameMode gameMode;
|
||||||
private WorldType levelType;
|
private WorldType levelType;
|
||||||
|
private int portalCooldown;
|
||||||
|
|
||||||
public WrappedPacketOutRespawn(NMSPacket packet) {
|
public WrappedPacketOutRespawn(NMSPacket packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
@@ -76,6 +77,24 @@ class WrappedPacketOutRespawn extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPortalCooldown() {
|
||||||
|
if (packet != null) {
|
||||||
|
return readInt(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return portalCooldown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPortalCooldown(int portalCooldown) {
|
||||||
|
if (packet != null) {
|
||||||
|
writeInt(0, portalCooldown);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.portalCooldown = portalCooldown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*public WorldType getLevelType() {
|
/*public WorldType getLevelType() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
//TODO finish
|
//TODO finish
|
||||||
|
|||||||
-107
@@ -1,107 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
|
||||||
* Copyright (C) 2021 retrooper and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.github.retrooper.packetevents.packetwrappers.play.out.scoreboardteam;
|
|
||||||
|
|
||||||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
|
||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
|
||||||
import io.github.retrooper.packetevents.utils.enums.EnumUtil;
|
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
//TODO FINISH WRAPPER
|
|
||||||
class WrappedPacketOutScoreboardTeam extends WrappedPacket {
|
|
||||||
private static Class<? extends Enum<?>> enumChatFormat;
|
|
||||||
public WrappedPacketOutScoreboardTeam(NMSPacket packet) {
|
|
||||||
super(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void load() {
|
|
||||||
enumChatFormat = NMSUtils.getNMSEnumClassWithoutException("EnumChatFormat");
|
|
||||||
if (enumChatFormat == null) {
|
|
||||||
enumChatFormat= NMSUtils.getNMEnumClassWithoutException("EnumChatFormat");
|
|
||||||
}
|
|
||||||
net.minecraft.server.v1_7_R4.PacketPlayOutScoreboardTeam a0;
|
|
||||||
net.minecraft.server.v1_8_R3.PacketPlayOutScoreboardTeam a1;
|
|
||||||
net.minecraft.server.v1_9_R1.PacketPlayOutScoreboardTeam a2;
|
|
||||||
net.minecraft.server.v1_9_R2.PacketPlayOutScoreboardTeam a3;
|
|
||||||
net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardTeam a4;
|
|
||||||
net.minecraft.server.v1_13_R1.PacketPlayOutScoreboardTeam a5;
|
|
||||||
net.minecraft.server.v1_13_R2.PacketPlayOutScoreboardTeam a6;
|
|
||||||
net.minecraft.server.v1_16_R2.PacketPlayOutScoreboardTeam a7;
|
|
||||||
//Add 1.17 support, its very diff
|
|
||||||
//net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam a8;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTeamName() {
|
|
||||||
return readString(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTeamName(String name) {
|
|
||||||
writeString(0, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTeamPrefix() {
|
|
||||||
if (version.isNewerThanOrEquals(ServerVersion.v_1_13)) {
|
|
||||||
return readIChatBaseComponent(0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return readString(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTeamPrefix(String teamPrefix) {
|
|
||||||
if (version.isNewerThanOrEquals(ServerVersion.v_1_13)) {
|
|
||||||
writeIChatBaseComponent(0, teamPrefix);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
writeString(1, teamPrefix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTeamSuffix() {
|
|
||||||
if (version.isNewerThanOrEquals(ServerVersion.v_1_13)) {
|
|
||||||
return readIChatBaseComponent(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return readString(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTeamSuffix(String teamSuffix) {
|
|
||||||
if (version.isNewerThanOrEquals(ServerVersion.v_1_13)) {
|
|
||||||
writeIChatBaseComponent(1, teamSuffix);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
writeString(2, teamSuffix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatColor getTeamColor() {
|
|
||||||
Enum<?> enumChatFormatConstant = readEnumConstant(0, enumChatFormat);
|
|
||||||
return ChatColor.values()[enumChatFormatConstant.ordinal()];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTeamColor(ChatColor color) {
|
|
||||||
Enum<?> enumChatFormatConstant = EnumUtil.valueByIndex(enumChatFormat, color.ordinal());
|
|
||||||
writeEnumConstant(0, enumChatFormatConstant);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+38
-34
@@ -19,33 +19,33 @@
|
|||||||
package io.github.retrooper.packetevents.packetwrappers.play.out.setcooldown;
|
package io.github.retrooper.packetevents.packetwrappers.play.out.setcooldown;
|
||||||
|
|
||||||
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.IdentityHashMap;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
//TODO TEST
|
|
||||||
public class WrappedPacketOutSetCooldown extends WrappedPacket implements SendableWrapper {
|
public class WrappedPacketOutSetCooldown extends WrappedPacket implements SendableWrapper {
|
||||||
private static final Map<Short, EntityType> ID_MAP = new IdentityHashMap<>();
|
|
||||||
private static Constructor<?> packetConstructor;
|
private static Constructor<?> packetConstructor;
|
||||||
private EntityType type;
|
private Object nmsItem;
|
||||||
private int cooldownTicks;
|
private int cooldownTicks;
|
||||||
|
|
||||||
public WrappedPacketOutSetCooldown(EntityType type, int cooldownTicks) {
|
public WrappedPacketOutSetCooldown(NMSPacket packet) {
|
||||||
this.type = type;
|
super(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WrappedPacketOutSetCooldown(Object nmsItem, int cooldownTicks) {
|
||||||
|
this.nmsItem = nmsItem;
|
||||||
this.cooldownTicks = cooldownTicks;
|
this.cooldownTicks = cooldownTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
for (EntityType type : EntityType.values()) {
|
|
||||||
ID_MAP.put(type.getTypeId(), type);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
packetConstructor = PacketTypeClasses.Play.Server.SET_COOLDOWN.getConstructor(NMSUtils.nmsItemClass, int.class);
|
packetConstructor = PacketTypeClasses.Play.Server.SET_COOLDOWN.getConstructor(NMSUtils.nmsItemClass, int.class);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
@@ -53,23 +53,38 @@ public class WrappedPacketOutSetCooldown extends WrappedPacket implements Sendab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityType getType() {
|
@Override
|
||||||
if (packet != null) {
|
public boolean isSupported() {
|
||||||
|
return version.isNewerThan(ServerVersion.v_1_8_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getItemStack() {
|
||||||
|
try {
|
||||||
Object nmsItem = readObject(0, NMSUtils.nmsItemClass);
|
Object nmsItem = readObject(0, NMSUtils.nmsItemClass);
|
||||||
short nmsItemID = (short) NMSUtils.getNMSItemId(nmsItem);
|
Object nmsItemStack = NMSUtils.itemStackConstructor.newInstance(nmsItem);
|
||||||
return ID_MAP.get(nmsItemID);
|
return NMSUtils.toBukkitItemStack(nmsItemStack);
|
||||||
|
} catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ItemStack(Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getNmsItem() {
|
||||||
|
return nmsItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNMSItemStack(Object type) {
|
||||||
|
if (packet != null) {
|
||||||
|
write(NMSUtils.nmsItemClass, 0, type);
|
||||||
} else {
|
} else {
|
||||||
return type;
|
this.nmsItem = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(EntityType type) {
|
@Override
|
||||||
if (packet != null) {
|
public Object asNMSPacket() throws Exception {
|
||||||
Object nmsItem = NMSUtils.getNMSItemById(type.getTypeId());
|
return packetConstructor.newInstance(nmsItem, getCooldownTicks());
|
||||||
write(NMSUtils.nmsItemClass, 0, nmsItem);
|
|
||||||
} else {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCooldownTicks() {
|
public int getCooldownTicks() {
|
||||||
@@ -87,15 +102,4 @@ public class WrappedPacketOutSetCooldown extends WrappedPacket implements Sendab
|
|||||||
this.cooldownTicks = cooldownTicks;
|
this.cooldownTicks = cooldownTicks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSupported() {
|
|
||||||
return version.isNewerThan(ServerVersion.v_1_8_8);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object asNMSPacket() throws Exception {
|
|
||||||
Object nmsItem = NMSUtils.getNMSItemById(getType().getTypeId());
|
|
||||||
return packetConstructor.newInstance(nmsItem, getCooldownTicks());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+3
-3
@@ -80,7 +80,7 @@ public class WrappedPacketOutSetSlot extends WrappedPacket implements SendableWr
|
|||||||
|
|
||||||
public int getWindowId() {
|
public int getWindowId() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
int index = v_1_17_1 ? 3 : v_1_17 ? 2 : 0;
|
int index = v_1_17 ? 2 : 0;
|
||||||
return readInt(index);
|
return readInt(index);
|
||||||
} else {
|
} else {
|
||||||
return windowID;
|
return windowID;
|
||||||
@@ -89,7 +89,7 @@ public class WrappedPacketOutSetSlot extends WrappedPacket implements SendableWr
|
|||||||
|
|
||||||
public void setWindowId(int windowID) {
|
public void setWindowId(int windowID) {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
int index = v_1_17_1 ? 3 : v_1_17 ? 2 : 0;
|
int index = v_1_17 ? 2 : 0;
|
||||||
writeInt(index, windowID);
|
writeInt(index, windowID);
|
||||||
} else {
|
} else {
|
||||||
this.windowID = windowID;
|
this.windowID = windowID;
|
||||||
@@ -155,7 +155,7 @@ public class WrappedPacketOutSetSlot extends WrappedPacket implements SendableWr
|
|||||||
@Override
|
@Override
|
||||||
public Object asNMSPacket() throws Exception {
|
public Object asNMSPacket() throws Exception {
|
||||||
if (v_1_17_1) {
|
if (v_1_17_1) {
|
||||||
return packetConstructor.newInstance(getWindowId(), getStateId(), getSlot(), NMSUtils.toNMSItemStack(getItemStack()));
|
return packetConstructor.newInstance(getWindowId(), getStateId().get(), getSlot(), NMSUtils.toNMSItemStack(getItemStack()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return packetConstructor.newInstance(getWindowId(), getSlot(), NMSUtils.toNMSItemStack(getItemStack()));
|
return packetConstructor.newInstance(getWindowId(), getSlot(), NMSUtils.toNMSItemStack(getItemStack()));
|
||||||
|
|||||||
+92
@@ -0,0 +1,92 @@
|
|||||||
|
package io.github.retrooper.packetevents.packetwrappers.play.out.systemchat;
|
||||||
|
|
||||||
|
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
||||||
|
import io.github.retrooper.packetevents.packetwrappers.play.out.chat.WrappedPacketOutChat;
|
||||||
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
|
public class WrappedPacketOutSystemChat extends WrappedPacket implements SendableWrapper {
|
||||||
|
private static Constructor<?> packetConstructor;
|
||||||
|
private String message;
|
||||||
|
private WrappedPacketOutChat.ChatPosition position;
|
||||||
|
|
||||||
|
public WrappedPacketOutSystemChat(final NMSPacket packet) {
|
||||||
|
super(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WrappedPacketOutSystemChat(String messageJSON, WrappedPacketOutChat.ChatPosition position) {
|
||||||
|
this.message = messageJSON;
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void load() {
|
||||||
|
try {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
packetConstructor = PacketTypeClasses.Play.Server.SYSTEM_CHAT.getConstructor(String.class, boolean.class);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
packetConstructor = PacketTypeClasses.Play.Server.SYSTEM_CHAT.getConstructor(String.class, int.class);
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessageJSON() {
|
||||||
|
if (packet != null) {
|
||||||
|
return readString(0);
|
||||||
|
} else {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageJSON(String message) {
|
||||||
|
if (packet != null) {
|
||||||
|
writeString(0, message);
|
||||||
|
} else {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public WrappedPacketOutChat.ChatPosition getPosition() {
|
||||||
|
if (packet != null) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
return readBoolean(1) ? WrappedPacketOutChat.ChatPosition.GAME_INFO : WrappedPacketOutChat.ChatPosition.SYSTEM;
|
||||||
|
}
|
||||||
|
return WrappedPacketOutChat.ChatPosition.getById(version, readInt(0));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(WrappedPacketOutChat.ChatPosition position) {
|
||||||
|
if (packet != null) {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
writeBoolean(1, position == WrappedPacketOutChat.ChatPosition.GAME_INFO);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
writeInt(0, position.ordinal());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object asNMSPacket() throws Exception {
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_19_1)) {
|
||||||
|
return packetConstructor.newInstance(getMessageJSON(), getPosition() == WrappedPacketOutChat.ChatPosition.GAME_INFO);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return packetConstructor.newInstance(getMessageJSON(), getPosition().ordinal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+72
-16
@@ -23,7 +23,6 @@ import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
|||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@@ -31,36 +30,49 @@ import java.lang.reflect.Constructor;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
//TODO Test wrapper
|
//TODO Test wrapper
|
||||||
public class WrappedPacketOutWindowItems extends WrappedPacket implements SendableWrapper {
|
public class WrappedPacketOutWindowItems extends WrappedPacket implements SendableWrapper {
|
||||||
private static boolean v_1_17;
|
private static boolean v_1_17, v_1_17_1;
|
||||||
private static Object nonNullListInstance;
|
private static Object nonNullListInstance;
|
||||||
private static Class<?> nonNullListClass;
|
private static Class<?> nonNullListClass;
|
||||||
private static Constructor<?> packetConstructor;
|
private static Constructor<?> packetConstructor;
|
||||||
private int windowID;
|
private int windowID;
|
||||||
|
private int stateID;
|
||||||
private List<ItemStack> slotData;
|
private List<ItemStack> slotData;
|
||||||
|
private ItemStack heldItem;
|
||||||
|
|
||||||
public WrappedPacketOutWindowItems(NMSPacket packet) {
|
public WrappedPacketOutWindowItems(NMSPacket packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WrappedPacketOutWindowItems(int windowID, List<ItemStack> slots) {
|
public WrappedPacketOutWindowItems(int windowID, int stateID, List<ItemStack> slots, ItemStack heldItem) {
|
||||||
this.windowID = windowID;
|
this.windowID = windowID;
|
||||||
|
this.stateID = stateID;
|
||||||
this.slotData = slots;
|
this.slotData = slots;
|
||||||
|
this.heldItem = heldItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load() {
|
protected void load() {
|
||||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
||||||
|
v_1_17_1 = version.isNewerThanOrEquals(ServerVersion.v_1_17_1);
|
||||||
try {
|
try {
|
||||||
if (v_1_17) {
|
if (v_1_17) {
|
||||||
nonNullListClass = NMSUtils.getNMClassWithoutException("core.NonNullList");
|
nonNullListClass = NMSUtils.getNMClassWithoutException("core.NonNullList");
|
||||||
Constructor<?> nonNullListConstructor = nonNullListClass.getConstructor();
|
if (v_1_17_1) {
|
||||||
nonNullListConstructor.setAccessible(true);
|
Constructor<?> nonNullListConstructor = nonNullListClass.getDeclaredConstructors()[0];
|
||||||
nonNullListInstance = nonNullListConstructor.newInstance();
|
nonNullListConstructor.setAccessible(true);
|
||||||
packetConstructor = PacketTypeClasses.Play.Server.WINDOW_ITEMS.getConstructor(int.class, nonNullListClass);
|
nonNullListInstance = nonNullListConstructor.newInstance(new ArrayList<>(), null);
|
||||||
}
|
packetConstructor = PacketTypeClasses.Play.Server.WINDOW_ITEMS.getConstructor(int.class, int.class, nonNullListClass, NMSUtils.nmsItemStackClass);
|
||||||
else {
|
} else {
|
||||||
|
Constructor<?> nonNullListConstructor = nonNullListClass.getDeclaredConstructor();
|
||||||
|
nonNullListConstructor.setAccessible(true);
|
||||||
|
nonNullListInstance = nonNullListConstructor.newInstance();
|
||||||
|
packetConstructor = PacketTypeClasses.Play.Server.WINDOW_ITEMS.getConstructor(int.class, nonNullListClass);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
packetConstructor = PacketTypeClasses.Play.Server.WINDOW_ITEMS.getConstructor();
|
packetConstructor = PacketTypeClasses.Play.Server.WINDOW_ITEMS.getConstructor();
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
|
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
|
||||||
@@ -84,6 +96,22 @@ public class WrappedPacketOutWindowItems extends WrappedPacket implements Sendab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStateId() {
|
||||||
|
if (packet != null) {
|
||||||
|
return readInt(1);
|
||||||
|
} else {
|
||||||
|
return stateID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStateId(int stateID) {
|
||||||
|
if (packet != null) {
|
||||||
|
writeInt(1, stateID);
|
||||||
|
} else {
|
||||||
|
this.stateID = stateID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<ItemStack> getSlots() {
|
public List<ItemStack> getSlots() {
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
List<ItemStack> slots = new ArrayList<>();
|
List<ItemStack> slots = new ArrayList<>();
|
||||||
@@ -99,8 +127,7 @@ public class WrappedPacketOutWindowItems extends WrappedPacket implements Sendab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return slots;
|
return slots;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return slotData;
|
return slotData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,21 +147,50 @@ public class WrappedPacketOutWindowItems extends WrappedPacket implements Sendab
|
|||||||
}
|
}
|
||||||
writeAnyObject(1, nmsItemStacks);
|
writeAnyObject(1, nmsItemStacks);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.slotData = slots;
|
this.slotData = slots;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<ItemStack> getHeldItem() {
|
||||||
|
if (!v_1_17_1) return Optional.empty();
|
||||||
|
|
||||||
|
if (packet != null) {
|
||||||
|
return Optional.ofNullable(NMSUtils.toBukkitItemStack(readObject(0, NMSUtils.nmsItemStackClass)));
|
||||||
|
} else {
|
||||||
|
return Optional.of(heldItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeldItem(ItemStack heldItem) {
|
||||||
|
if (packet != null) {
|
||||||
|
writeObject(0, NMSUtils.toNMSItemStack(heldItem));
|
||||||
|
} else {
|
||||||
|
this.heldItem = heldItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getNMSItemHeld() {
|
||||||
|
if (packet != null) {
|
||||||
|
return readObject(0, NMSUtils.nmsItemStackClass);
|
||||||
|
} else {
|
||||||
|
return NMSUtils.toNMSItemStack(heldItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object asNMSPacket() throws Exception {
|
public Object asNMSPacket() throws Exception {
|
||||||
Object packetInstance;
|
Object packetInstance;
|
||||||
if (v_1_17) {
|
|
||||||
|
if (v_1_17_1) {
|
||||||
|
packetInstance = packetConstructor.newInstance(getWindowId(), stateID, nonNullListInstance, getNMSItemHeld());
|
||||||
|
WrappedPacketOutWindowItems wrappedPacketOutWindowItems = new WrappedPacketOutWindowItems(new NMSPacket(packetInstance));
|
||||||
|
wrappedPacketOutWindowItems.setSlots(getSlots());
|
||||||
|
} else if (v_1_17) {
|
||||||
packetInstance = packetConstructor.newInstance(getWindowId(), nonNullListInstance);
|
packetInstance = packetConstructor.newInstance(getWindowId(), nonNullListInstance);
|
||||||
WrappedPacketOutWindowItems wrappedPacketOutWindowItems = new WrappedPacketOutWindowItems(new NMSPacket(packetInstance));
|
WrappedPacketOutWindowItems wrappedPacketOutWindowItems = new WrappedPacketOutWindowItems(new NMSPacket(packetInstance));
|
||||||
wrappedPacketOutWindowItems.setSlots(getSlots());
|
wrappedPacketOutWindowItems.setSlots(getSlots());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
packetInstance = packetConstructor.newInstance();
|
packetInstance = packetConstructor.newInstance();
|
||||||
WrappedPacketOutWindowItems wrappedPacketOutWindowItems = new WrappedPacketOutWindowItems(new NMSPacket(packetInstance));
|
WrappedPacketOutWindowItems wrappedPacketOutWindowItems = new WrappedPacketOutWindowItems(new NMSPacket(packetInstance));
|
||||||
wrappedPacketOutWindowItems.setWindowId(getWindowId());
|
wrappedPacketOutWindowItems.setWindowId(getWindowId());
|
||||||
|
|||||||
-1
@@ -35,7 +35,6 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.spigotmc.AsyncCatcher;
|
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|||||||
+31
-9
@@ -24,8 +24,7 @@ import io.github.retrooper.packetevents.packettype.PacketState;
|
|||||||
import io.github.retrooper.packetevents.packettype.PacketType;
|
import io.github.retrooper.packetevents.packettype.PacketType;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.handshaking.setprotocol.WrappedPacketHandshakingInSetProtocol;
|
import io.github.retrooper.packetevents.packetwrappers.handshaking.setprotocol.WrappedPacketHandshakingInSetProtocol;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.login.in.start.WrappedPacketLoginInStart;
|
import io.github.retrooper.packetevents.packetwrappers.login.out.success.WrappedPacketLoginOutSuccess;
|
||||||
import io.github.retrooper.packetevents.utils.gameprofile.WrappedGameProfile;
|
|
||||||
import io.github.retrooper.packetevents.utils.player.ClientVersion;
|
import io.github.retrooper.packetevents.utils.player.ClientVersion;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.ClassUtil;
|
import io.github.retrooper.packetevents.utils.reflection.ClassUtil;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -90,12 +89,7 @@ public class PacketProcessorInternal {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LOGIN:
|
case LOGIN:
|
||||||
PacketLoginReceiveEvent loginEvent = new PacketLoginReceiveEvent(channel, new NMSPacket(packet));//Cache the channel
|
PacketLoginReceiveEvent loginEvent = new PacketLoginReceiveEvent(channel, new NMSPacket(packet));
|
||||||
if (loginEvent.getPacketId() == PacketType.Login.Client.START) {
|
|
||||||
WrappedPacketLoginInStart startWrapper = new WrappedPacketLoginInStart(loginEvent.getNMSPacket());
|
|
||||||
WrappedGameProfile gameProfile = startWrapper.getGameProfile();
|
|
||||||
PacketEvents.get().getPlayerUtils().channels.put(gameProfile.getName(), channel);
|
|
||||||
}
|
|
||||||
PacketEvents.get().getEventManager().callEvent(loginEvent);
|
PacketEvents.get().getEventManager().callEvent(loginEvent);
|
||||||
packet = loginEvent.getNMSPacket().getRawNMSPacket();
|
packet = loginEvent.getNMSPacket().getRawNMSPacket();
|
||||||
interceptLoginReceive(loginEvent);
|
interceptLoginReceive(loginEvent);
|
||||||
@@ -103,6 +97,14 @@ public class PacketProcessorInternal {
|
|||||||
packet = null;
|
packet = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CONFIG:
|
||||||
|
PacketConfigReceiveEvent configEvent = new PacketConfigReceiveEvent(channel, new NMSPacket(packet));
|
||||||
|
PacketEvents.get().getEventManager().callEvent(configEvent);
|
||||||
|
packet = configEvent.getNMSPacket().getRawNMSPacket();
|
||||||
|
if (configEvent.isCancelled()) {
|
||||||
|
packet = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case PLAY:
|
case PLAY:
|
||||||
PacketPlayReceiveEvent event = new PacketPlayReceiveEvent(player, channel, new NMSPacket(packet));
|
PacketPlayReceiveEvent event = new PacketPlayReceiveEvent(player, channel, new NMSPacket(packet));
|
||||||
PacketEvents.get().getEventManager().callEvent(event);
|
PacketEvents.get().getEventManager().callEvent(event);
|
||||||
@@ -148,6 +150,11 @@ public class PacketProcessorInternal {
|
|||||||
break;
|
break;
|
||||||
case LOGIN:
|
case LOGIN:
|
||||||
PacketLoginSendEvent loginEvent = new PacketLoginSendEvent(channel, new NMSPacket(packet));
|
PacketLoginSendEvent loginEvent = new PacketLoginSendEvent(channel, new NMSPacket(packet));
|
||||||
|
if (loginEvent.getPacketId() == PacketType.Login.Server.SUCCESS) {
|
||||||
|
WrappedPacketLoginOutSuccess success = new WrappedPacketLoginOutSuccess(loginEvent.getNMSPacket());
|
||||||
|
String username = success.getGameProfile().getName();
|
||||||
|
PacketEvents.get().getPlayerUtils().channels.put(username, channel); //Cache channel
|
||||||
|
}
|
||||||
PacketEvents.get().getEventManager().callEvent(loginEvent);
|
PacketEvents.get().getEventManager().callEvent(loginEvent);
|
||||||
if (loginEvent.isPostTaskAvailable()) {
|
if (loginEvent.isPostTaskAvailable()) {
|
||||||
data.postAction = loginEvent.getPostTask();
|
data.postAction = loginEvent.getPostTask();
|
||||||
@@ -158,6 +165,17 @@ public class PacketProcessorInternal {
|
|||||||
packet = null;
|
packet = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CONFIG:
|
||||||
|
PacketConfigSendEvent configEvent = new PacketConfigSendEvent(channel, new NMSPacket(packet));
|
||||||
|
PacketEvents.get().getEventManager().callEvent(configEvent);
|
||||||
|
if (configEvent.isPostTaskAvailable()) {
|
||||||
|
data.postAction = configEvent.getPostTask();
|
||||||
|
}
|
||||||
|
packet = configEvent.getNMSPacket().getRawNMSPacket();
|
||||||
|
if (configEvent.isCancelled()) {
|
||||||
|
packet = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case PLAY:
|
case PLAY:
|
||||||
PacketPlaySendEvent playEvent = new PacketPlaySendEvent(player, channel, new NMSPacket(packet));
|
PacketPlaySendEvent playEvent = new PacketPlaySendEvent(player, channel, new NMSPacket(packet));
|
||||||
PacketEvents.get().getEventManager().callEvent(playEvent);
|
PacketEvents.get().getEventManager().callEvent(playEvent);
|
||||||
@@ -324,7 +342,11 @@ public class PacketProcessorInternal {
|
|||||||
return PacketState.LOGIN;
|
return PacketState.LOGIN;
|
||||||
} else if (packetName.startsWith("PacketS")) {
|
} else if (packetName.startsWith("PacketS")) {
|
||||||
return PacketState.STATUS;
|
return PacketState.STATUS;
|
||||||
} else {
|
}
|
||||||
|
else if (packet.getClass().getName().contains("protocol.common")) {
|
||||||
|
return PacketState.CONFIG;
|
||||||
|
}
|
||||||
|
else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ public class PacketEventsSettings {
|
|||||||
* @param compatInjector Value
|
* @param compatInjector Value
|
||||||
* @return Settings instance.
|
* @return Settings instance.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public PacketEventsSettings compatInjector(boolean compatInjector) {
|
public PacketEventsSettings compatInjector(boolean compatInjector) {
|
||||||
if (!locked) {
|
if (!locked) {
|
||||||
this.compatInjector = compatInjector;
|
this.compatInjector = compatInjector;
|
||||||
@@ -175,6 +176,7 @@ public class PacketEventsSettings {
|
|||||||
*
|
*
|
||||||
* @return Getter for {@link #compatInjector}
|
* @return Getter for {@link #compatInjector}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean shouldUseCompatibilityInjector() {
|
public boolean shouldUseCompatibilityInjector() {
|
||||||
return compatInjector;
|
return compatInjector;
|
||||||
}
|
}
|
||||||
|
|||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
|
||||||
* Copyright (C) 2021 retrooper and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.github.retrooper.packetevents.updatechecker;
|
|
||||||
|
|
||||||
import net.minecraft.util.com.google.gson.JsonObject;
|
|
||||||
import net.minecraft.util.com.google.gson.JsonParser;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class LowLevelUpdateCheckerLegacy implements LowLevelUpdateChecker {
|
|
||||||
@Override
|
|
||||||
public String getLatestRelease() {
|
|
||||||
String jsonResponse;
|
|
||||||
try {
|
|
||||||
jsonResponse = getLatestReleaseJson();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new IllegalStateException("Failed to parse packetevents version!");
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonParser parser = new JsonParser();
|
|
||||||
JsonObject jsonObject = parser.parse(jsonResponse).getAsJsonObject();
|
|
||||||
String versionName = null;
|
|
||||||
if (jsonObject != null) {
|
|
||||||
versionName = jsonObject.get("tag_name").getAsString();
|
|
||||||
}
|
|
||||||
return versionName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
|
||||||
* Copyright (C) 2021 retrooper and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.github.retrooper.packetevents.updatechecker;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class LowLevelUpdateCheckerModern implements LowLevelUpdateChecker {
|
|
||||||
@Override
|
|
||||||
public String getLatestRelease() {
|
|
||||||
String jsonResponse;
|
|
||||||
try {
|
|
||||||
jsonResponse = getLatestReleaseJson();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new IllegalStateException("Failed to parse packetevents version!");
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonParser parser = new JsonParser();
|
|
||||||
JsonObject jsonObject = parser.parse(jsonResponse).getAsJsonObject();
|
|
||||||
String versionName = null;
|
|
||||||
if (jsonObject != null) {
|
|
||||||
versionName = jsonObject.get("tag_name").getAsString();
|
|
||||||
}
|
|
||||||
return versionName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
package io.github.retrooper.packetevents.updatechecker;
|
package io.github.retrooper.packetevents.updatechecker;
|
||||||
|
|
||||||
import io.github.retrooper.packetevents.PacketEvents;
|
import io.github.retrooper.packetevents.PacketEvents;
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
|
||||||
import io.github.retrooper.packetevents.utils.version.PEVersion;
|
import io.github.retrooper.packetevents.utils.version.PEVersion;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@@ -31,14 +30,10 @@ import org.bukkit.ChatColor;
|
|||||||
* @since 1.6.9
|
* @since 1.6.9
|
||||||
*/
|
*/
|
||||||
public class UpdateChecker {
|
public class UpdateChecker {
|
||||||
private final LowLevelUpdateChecker lowLevelUpdateChecker;
|
private final UpdaterCheck lowLevelUpdateChecker;
|
||||||
|
|
||||||
public UpdateChecker() {
|
public UpdateChecker() {
|
||||||
if (PacketEvents.get().getServerUtils().getVersion().isOlderThan(ServerVersion.v_1_8)) {
|
lowLevelUpdateChecker = new UpdaterCheck();
|
||||||
lowLevelUpdateChecker = new LowLevelUpdateCheckerLegacy();
|
|
||||||
} else {
|
|
||||||
lowLevelUpdateChecker = new LowLevelUpdateCheckerModern();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String checkLatestReleasedVersion() {
|
public String checkLatestReleasedVersion() {
|
||||||
@@ -50,23 +45,26 @@ public class UpdateChecker {
|
|||||||
*/
|
*/
|
||||||
public UpdateCheckerStatus checkForUpdate() {
|
public UpdateCheckerStatus checkForUpdate() {
|
||||||
PEVersion localVersion = PacketEvents.get().getVersion();
|
PEVersion localVersion = PacketEvents.get().getVersion();
|
||||||
PEVersion newVersion;
|
|
||||||
try {
|
String version = checkLatestReleasedVersion();
|
||||||
newVersion = new PEVersion(checkLatestReleasedVersion());
|
|
||||||
} catch (Exception ex) {
|
if (version == null) {
|
||||||
newVersion = null;
|
return UpdateCheckerStatus.FAILED;
|
||||||
}
|
}
|
||||||
if (newVersion != null && localVersion.isOlderThan(newVersion)) {
|
|
||||||
inform("There is an update available for the PacketEvents API! Your build: (" + localVersion.toString() + ") | Latest released build: (" + newVersion.toString() + ")");
|
PEVersion newVersion = new PEVersion(checkLatestReleasedVersion());
|
||||||
|
|
||||||
|
if (localVersion.isOlderThan(newVersion)) {
|
||||||
|
inform("There is an update available for the PacketEvents API! Your build: (" + localVersion + ") | Latest released build: (" + newVersion + ")");
|
||||||
return UpdateCheckerStatus.OUTDATED;
|
return UpdateCheckerStatus.OUTDATED;
|
||||||
} else if (newVersion != null && localVersion.isNewerThan(newVersion)) {
|
} else if (localVersion.isNewerThan(newVersion)) {
|
||||||
inform("You are on a dev or pre released build of PacketEvents. Your build: (" + localVersion.toString() + ") | Latest released build: (" + newVersion.toString() + ")");
|
inform("You are on a dev or pre released build of PacketEvents. Your build: (" + localVersion + ") | Latest released build: (" + newVersion + ")");
|
||||||
return UpdateCheckerStatus.PRE_RELEASE;
|
return UpdateCheckerStatus.PRE_RELEASE;
|
||||||
} else if (localVersion.equals(newVersion)) {
|
} else if (localVersion.equals(newVersion)) {
|
||||||
inform("You are on the latest released version of PacketEvents. (" + newVersion.toString() + ")");
|
inform("You are on the latest released version of PacketEvents. (" + newVersion + ")");
|
||||||
return UpdateCheckerStatus.UP_TO_DATE;
|
return UpdateCheckerStatus.UP_TO_DATE;
|
||||||
} else {
|
} else {
|
||||||
report("Something went wrong while checking for an update. Your build: (" + localVersion.toString() + ") | Latest released build: (" + newVersion.toString() + ")");
|
report("Something went wrong while checking for an update. Your build: (" + localVersion + ") | Latest released build: (" + newVersion + ")");
|
||||||
return UpdateCheckerStatus.FAILED;
|
return UpdateCheckerStatus.FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-3
@@ -24,10 +24,23 @@ import java.io.InputStreamReader;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
public interface LowLevelUpdateChecker {
|
public class UpdaterCheck {
|
||||||
String getLatestRelease();
|
public String getLatestRelease() {
|
||||||
|
try {
|
||||||
|
String jsonResponse = getLatestReleaseJson();
|
||||||
|
|
||||||
default String getLatestReleaseJson() throws IOException {
|
String targetPart = "\"name\":";
|
||||||
|
int nameIndex = jsonResponse.indexOf(targetPart);
|
||||||
|
|
||||||
|
int stringStart = nameIndex + targetPart.length();
|
||||||
|
int stringEnd = jsonResponse.indexOf(",", stringStart);
|
||||||
|
return jsonResponse.substring(stringStart + 1, stringEnd - 1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLatestReleaseJson() throws IOException {
|
||||||
URLConnection connection = new URL("https://api.github.com/repos/retrooper/packetevents/releases/latest").openConnection();
|
URLConnection connection = new URL("https://api.github.com/repos/retrooper/packetevents/releases/latest").openConnection();
|
||||||
connection.addRequestProperty("User-Agent", "Mozilla/4.0");
|
connection.addRequestProperty("User-Agent", "Mozilla/4.0");
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package io.github.retrooper.packetevents.utils;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class ConditionalValue<T, K> {
|
||||||
|
private final Optional<T> left;
|
||||||
|
private final Optional<K> right;
|
||||||
|
private ConditionalValue(Optional<T> left, Optional<K> right) {
|
||||||
|
this.left = left;
|
||||||
|
this.right = right;
|
||||||
|
}
|
||||||
|
public Optional<T> left() {
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
public Optional<K> right() {
|
||||||
|
return right;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return left.map(t -> "ConditionalValue {left: " + t.toString() + "}")
|
||||||
|
.orElseGet(() -> "ConditionalValue {right: " + right.get().toString() + "}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <L, R> ConditionalValue<L, R> makeLeft(L left) {
|
||||||
|
return new ConditionalValue<>(Optional.of(left), Optional.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <L, R> ConditionalValue<L, R> makeRight(R right) {
|
||||||
|
return new ConditionalValue<>(Optional.empty(), Optional.of(right));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package io.github.retrooper.packetevents.utils;
|
||||||
|
|
||||||
|
import com.mojang.datafixers.util.Either;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class MojangEitherUtil {
|
||||||
|
public static <L, R> Either<L, R> makeLeft(L left) {
|
||||||
|
return Either.left(left);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <L, R> Either<L, R> makeRight(R right) {
|
||||||
|
return Either.right(right);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <L> Optional<L> getLeft(Object either) {
|
||||||
|
return ((Either)either).left();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <R> Optional<R> getRight(Object either) {
|
||||||
|
return ((Either)either).right();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||||
|
* Copyright (C) 2021 retrooper and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.retrooper.packetevents.utils;
|
||||||
|
|
||||||
|
public class SaltSignature {
|
||||||
|
private final long salt;
|
||||||
|
private final byte[] signature;
|
||||||
|
|
||||||
|
public SaltSignature(long salt, byte[] signature) {
|
||||||
|
this.salt = salt;
|
||||||
|
this.signature = signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSalt() {
|
||||||
|
return salt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getSignature() {
|
||||||
|
return signature;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -101,6 +101,7 @@ public class AttributeModifierWrapper extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO Might cause issues since now a resourcelocation
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (supplierPresent) {
|
if (supplierPresent) {
|
||||||
//About 1.13 and above
|
//About 1.13 and above
|
||||||
|
|||||||
+43
-3
@@ -24,6 +24,7 @@ import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
|||||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.SubclassUtil;
|
import io.github.retrooper.packetevents.utils.reflection.SubclassUtil;
|
||||||
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -40,6 +41,11 @@ public class AttributeSnapshotWrapper extends WrappedPacket {
|
|||||||
private static Class<?> attributeSnapshotClass, attributeBaseClass;
|
private static Class<?> attributeSnapshotClass, attributeBaseClass;
|
||||||
private static Field iRegistryAttributeBaseField;
|
private static Field iRegistryAttributeBaseField;
|
||||||
private static Method getiRegistryByMinecraftKeyMethod;
|
private static Method getiRegistryByMinecraftKeyMethod;
|
||||||
|
private static Method readStringMethod;
|
||||||
|
|
||||||
|
private static Class<?> holderClass;
|
||||||
|
private static Method accessHolderValueMethod;
|
||||||
|
private static boolean hasHolder = false;
|
||||||
private static boolean stringKeyPresent;
|
private static boolean stringKeyPresent;
|
||||||
|
|
||||||
public AttributeSnapshotWrapper(NMSPacket packet) {
|
public AttributeSnapshotWrapper(NMSPacket packet) {
|
||||||
@@ -58,6 +64,11 @@ public class AttributeSnapshotWrapper extends WrappedPacket {
|
|||||||
attributeSnapshotClass = SubclassUtil.getSubClass(PacketTypeClasses.Play.Server.UPDATE_ATTRIBUTES, "AttributeSnapshot");
|
attributeSnapshotClass = SubclassUtil.getSubClass(PacketTypeClasses.Play.Server.UPDATE_ATTRIBUTES, "AttributeSnapshot");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
holderClass = NMSUtils.getNMClassWithoutException("core.Holder");
|
||||||
|
if (holderClass != null) {
|
||||||
|
hasHolder = Reflection.getField(attributeSnapshotClass, holderClass, 0) != null;
|
||||||
|
}
|
||||||
if (attributeSnapshotConstructor == null) {
|
if (attributeSnapshotConstructor == null) {
|
||||||
try {
|
try {
|
||||||
attributeSnapshotConstructor = attributeSnapshotClass.getConstructor(PacketTypeClasses.Play.Server.UPDATE_ATTRIBUTES, String.class, double.class, Collection.class);
|
attributeSnapshotConstructor = attributeSnapshotClass.getConstructor(PacketTypeClasses.Play.Server.UPDATE_ATTRIBUTES, String.class, double.class, Collection.class);
|
||||||
@@ -135,6 +146,11 @@ public class AttributeSnapshotWrapper extends WrappedPacket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
holderClass = NMSUtils.getNMClassWithoutException("core.Holder");
|
||||||
|
if (holderClass != null) {
|
||||||
|
hasHolder = Reflection.getField(attributeSnapshotClass, holderClass, 0) != null;
|
||||||
|
}
|
||||||
|
|
||||||
if (attributeSnapshotConstructor == null) {
|
if (attributeSnapshotConstructor == null) {
|
||||||
try {
|
try {
|
||||||
attributeSnapshotConstructor = attributeSnapshotClass.getConstructor(attributeBaseClass, double.class, Collection.class);
|
attributeSnapshotConstructor = attributeSnapshotClass.getConstructor(attributeBaseClass, double.class, Collection.class);
|
||||||
@@ -160,9 +176,33 @@ public class AttributeSnapshotWrapper extends WrappedPacket {
|
|||||||
if (stringKeyPresent) {
|
if (stringKeyPresent) {
|
||||||
return readString(0);
|
return readString(0);
|
||||||
} else {
|
} else {
|
||||||
Object attributeBase = readObject(0, attributeBaseClass);
|
Object attributeBase = null;
|
||||||
WrappedPacket attributeBaseWrapper = new WrappedPacket(new NMSPacket(attributeBase), attributeBaseClass);
|
if (hasHolder) {
|
||||||
return attributeBaseWrapper.readString(0);
|
Object holder = readObject(0, holderClass);
|
||||||
|
if (accessHolderValueMethod == null) {
|
||||||
|
accessHolderValueMethod = Reflection.getMethod(holderClass, 0);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
attributeBase = accessHolderValueMethod.invoke(holder);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
attributeBase = readObject(0, attributeBaseClass);
|
||||||
|
}
|
||||||
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_21)) {
|
||||||
|
if (readStringMethod== null) {
|
||||||
|
readStringMethod = Reflection.getMethod(attributeBaseClass, String.class, 0);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return (String) readStringMethod.invoke(attributeBase);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WrappedPacket attributeBaseWrapper = new WrappedPacket(new NMSPacket(attributeBase), attributeBaseClass);
|
||||||
|
return attributeBaseWrapper.readString(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -50,9 +50,7 @@ public final class EntityFinderUtils {
|
|||||||
try {
|
try {
|
||||||
craftWorldGetHandle = NMSUtils.craftWorldClass.getMethod("getHandle");
|
craftWorldGetHandle = NMSUtils.craftWorldClass.getMethod("getHandle");
|
||||||
|
|
||||||
String getEntityByIdMethodName = (version.getProtocolVersion() == (short) 47)
|
getEntityByIdMethod = worldServerClass.getMethod("a", int.class);
|
||||||
? "a" : "getEntity";
|
|
||||||
getEntityByIdMethod = worldServerClass.getMethod(getEntityByIdMethodName, int.class);
|
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
try {
|
try {
|
||||||
getEntityByIdMethod = worldServerClass.getMethod("getEntity", int.class);
|
getEntityByIdMethod = worldServerClass.getMethod("getEntity", int.class);
|
||||||
|
|||||||
@@ -18,12 +18,50 @@
|
|||||||
|
|
||||||
package io.github.retrooper.packetevents.utils.geyser;
|
package io.github.retrooper.packetevents.utils.geyser;
|
||||||
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
|
||||||
|
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class GeyserUtils {
|
public class GeyserUtils {
|
||||||
|
private static Class<?> GEYSER_CLASS;
|
||||||
|
private static Class<?> GEYSER_API_CLASS;
|
||||||
|
private static Method GEYSER_API_METHOD;
|
||||||
|
private static Method CONNECTION_BY_UUID_METHOD;
|
||||||
|
|
||||||
public static boolean isGeyserPlayer(UUID uuid) {
|
public static boolean isGeyserPlayer(UUID uuid) {
|
||||||
return GeyserConnector.getInstance().getPlayerByUuid(uuid) != null;
|
if (GEYSER_CLASS == null) {
|
||||||
|
GEYSER_CLASS = Reflection.getClassByNameWithoutException("org.geysermc.api.Geyser");
|
||||||
|
}
|
||||||
|
if (GEYSER_CLASS == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GEYSER_API_CLASS == null) {
|
||||||
|
GEYSER_API_CLASS = Reflection.getClassByNameWithoutException("org.geysermc.api.GeyserApiBase");
|
||||||
|
}
|
||||||
|
if (GEYSER_API_METHOD == null) {
|
||||||
|
GEYSER_API_METHOD = Reflection.getMethod(GEYSER_CLASS, "api", null, new Class<?>[]{});
|
||||||
|
}
|
||||||
|
if (CONNECTION_BY_UUID_METHOD == null) {
|
||||||
|
CONNECTION_BY_UUID_METHOD = Reflection.getMethod(GEYSER_API_CLASS, "connectionByUuid", 0);
|
||||||
|
}
|
||||||
|
Object apiInstance = null;
|
||||||
|
try {
|
||||||
|
apiInstance = GEYSER_API_METHOD.invoke(null);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
Object connection = null;
|
||||||
|
try {
|
||||||
|
if (apiInstance != null) {
|
||||||
|
connection = CONNECTION_BY_UUID_METHOD.invoke(apiInstance, uuid);
|
||||||
|
}
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return connection != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,8 @@ package io.github.retrooper.packetevents.utils.netty.bytebuf;
|
|||||||
|
|
||||||
public interface ByteBufUtil {
|
public interface ByteBufUtil {
|
||||||
|
|
||||||
|
Object buffer();
|
||||||
|
|
||||||
Object newByteBuf(byte[] data);
|
Object newByteBuf(byte[] data);
|
||||||
|
|
||||||
void retain(Object byteBuf);
|
void retain(Object byteBuf);
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ import net.minecraft.util.io.netty.util.internal.EmptyArrays;
|
|||||||
|
|
||||||
public final class ByteBufUtil_7 implements ByteBufUtil {
|
public final class ByteBufUtil_7 implements ByteBufUtil {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object buffer() {
|
||||||
|
return Unpooled.buffer();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object newByteBuf(byte[] data) {
|
public Object newByteBuf(byte[] data) {
|
||||||
return Unpooled.wrappedBuffer(data);
|
return Unpooled.wrappedBuffer(data);
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ import io.netty.util.internal.EmptyArrays;
|
|||||||
|
|
||||||
public final class ByteBufUtil_8 implements ByteBufUtil {
|
public final class ByteBufUtil_8 implements ByteBufUtil {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object buffer() {
|
||||||
|
return Unpooled.buffer();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object newByteBuf(byte[] data) {
|
public Object newByteBuf(byte[] data) {
|
||||||
return Unpooled.wrappedBuffer(data);
|
return Unpooled.wrappedBuffer(data);
|
||||||
|
|||||||
@@ -21,50 +21,46 @@ package io.github.retrooper.packetevents.utils.nms;
|
|||||||
import io.github.retrooper.packetevents.PacketEvents;
|
import io.github.retrooper.packetevents.PacketEvents;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||||
|
import io.github.retrooper.packetevents.utils.reflection.ClassUtil;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||||
import io.github.retrooper.packetevents.utils.reflection.SubclassUtil;
|
import io.github.retrooper.packetevents.utils.reflection.SubclassUtil;
|
||||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||||
import io.github.retrooper.packetevents.utils.vector.Vector3d;
|
import io.github.retrooper.packetevents.utils.vector.Vector3d;
|
||||||
import io.github.retrooper.packetevents.utils.vector.Vector3f;
|
import io.github.retrooper.packetevents.utils.vector.Vector3f;
|
||||||
import io.github.retrooper.packetevents.utils.vector.Vector3i;
|
import io.github.retrooper.packetevents.utils.vector.Vector3i;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.*;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public final class NMSUtils {
|
public final class NMSUtils {
|
||||||
public static final String NMS_DIR = ServerVersion.getNMSDirectory() + ".";
|
|
||||||
public static final String OBC_DIR = ServerVersion.getOBCDirectory() + ".";
|
|
||||||
private static final ThreadLocal<Random> randomThreadLocal = ThreadLocal.withInitial(Random::new);
|
private static final ThreadLocal<Random> randomThreadLocal = ThreadLocal.withInitial(Random::new);
|
||||||
public static boolean legacyNettyImportMode;
|
public static boolean legacyNettyImportMode;
|
||||||
public static ServerVersion version;
|
public static ServerVersion version;
|
||||||
public static Constructor<?> blockPosConstructor, minecraftKeyConstructor, vec3DConstructor, dataWatcherConstructor, packetDataSerializerConstructor;
|
public static Executable minecraftKeyConstructorOrMethod;
|
||||||
public static Class<?> mobEffectListClass, nmsEntityClass, minecraftServerClass, craftWorldClass, playerInteractManagerClass, entityPlayerClass, playerConnectionClass, craftServerClass,
|
public static Constructor<?> blockPosConstructor, vec3DConstructor, dataWatcherConstructor, packetDataSerializerConstructor, itemStackConstructor;
|
||||||
|
public static Class<?> mobEffectListClass, nmsEntityClass, minecraftServerClass, craftWorldClass, playerInteractManagerClass, entityPlayerClass, playerConnectionClass, SERVER_COMMON_PACKETLISTENER_IMPL_CLASS, craftServerClass,
|
||||||
craftPlayerClass, serverConnectionClass, craftEntityClass, nmsItemStackClass, networkManagerClass, nettyChannelClass, gameProfileClass, iChatBaseComponentClass,
|
craftPlayerClass, serverConnectionClass, craftEntityClass, nmsItemStackClass, networkManagerClass, nettyChannelClass, gameProfileClass, iChatBaseComponentClass,
|
||||||
blockPosClass, vec3DClass, channelFutureClass, blockClass, iBlockDataClass, nmsWorldClass, craftItemStackClass,
|
blockPosClass, sectionPositionClass, vec3DClass, channelFutureClass, blockClass, iBlockDataClass, nmsWorldClass, craftItemStackClass,
|
||||||
soundEffectClass, minecraftKeyClass, chatSerializerClass, craftMagicNumbersClass, worldSettingsClass, worldServerClass, dataWatcherClass,
|
soundEffectClass, minecraftKeyClass, chatSerializerClass, craftMagicNumbersClass, worldSettingsClass, worldServerClass, dataWatcherClass,
|
||||||
dedicatedServerClass, entityHumanClass, packetDataSerializerClass, byteBufClass, dimensionManagerClass, nmsItemClass, movingObjectPositionBlockClass, boundingBoxClass,
|
dedicatedServerClass, entityHumanClass, packetDataSerializerClass, byteBufClass, dimensionManagerClass, nmsItemClass, iMaterialClass, movingObjectPositionBlockClass, boundingBoxClass,
|
||||||
tileEntityCommandClass;
|
tileEntityCommandClass, mojangEitherClass, registryMaterials, builtInRegistriesClass;
|
||||||
public static Class<? extends Enum<?>> enumDirectionClass, enumHandClass, enumGameModeClass, enumDifficultyClass, tileEntityCommandTypeClass;
|
public static Class<? extends Enum<?>> enumDirectionClass, enumHandClass, enumGameModeClass, enumDifficultyClass, tileEntityCommandTypeClass;
|
||||||
public static Method getBlockPosX, getBlockPosY, getBlockPosZ;
|
public static Method getBlockPosX, getBlockPosY, getBlockPosZ, mojangEitherLeft, mojangEitherRight, getRegistryId, getRegistryById;
|
||||||
private static String nettyPrefix;
|
private static String nettyPrefix;
|
||||||
private static Method getCraftPlayerHandle, getCraftEntityHandle, getCraftWorldHandle, asBukkitCopy,
|
private static Method getCraftPlayerHandle, getCraftEntityHandle, getCraftWorldHandle, asBukkitCopy,
|
||||||
asNMSCopy, getMessageMethod, chatFromStringMethod, getMaterialFromNMSBlock, getNMSBlockFromMaterial,
|
asNMSCopy, getMessageMethod, chatFromStringMethod, getMaterialFromNMSBlock, getNMSBlockFromMaterial,
|
||||||
getMobEffectListId, getMobEffectListById, getItemId, getItemById, getBukkitEntity;
|
getMobEffectListId, getMobEffectListById, getItemId, getItemById, getBukkitEntity;
|
||||||
private static Field entityPlayerPingField, entityBoundingBoxField;
|
private static Field entityPlayerPingField, entityBoundingBoxField, mobEffectsRegistryField;
|
||||||
|
public static Field getBaseBlockPosX, getBaseBlockPosY, getBaseBlockPosZ;
|
||||||
private static Object minecraftServer;
|
private static Object minecraftServer;
|
||||||
private static Object minecraftServerConnection;
|
private static Object minecraftServerConnection;
|
||||||
|
|
||||||
@@ -82,7 +78,7 @@ public final class NMSUtils {
|
|||||||
//Test if the selected netty location is valid
|
//Test if the selected netty location is valid
|
||||||
getNettyClass("channel.Channel");
|
getNettyClass("channel.Channel");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.err.println("[packetevents] Failed to locate the netty package location for your server version. Searching...");
|
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "[packetevents] Failed to locate the netty package location for your server version. Searching...");
|
||||||
//Time to correct the netty location
|
//Time to correct the netty location
|
||||||
if (legacyNettyImportMode) {
|
if (legacyNettyImportMode) {
|
||||||
legacyNettyImportMode = false;
|
legacyNettyImportMode = false;
|
||||||
@@ -136,6 +132,8 @@ public final class NMSUtils {
|
|||||||
playerConnectionClass = getNMSClassWithoutException("PlayerConnection");
|
playerConnectionClass = getNMSClassWithoutException("PlayerConnection");
|
||||||
if (playerConnectionClass == null) {
|
if (playerConnectionClass == null) {
|
||||||
playerConnectionClass = getNMClassWithoutException("server.network.PlayerConnection");
|
playerConnectionClass = getNMClassWithoutException("server.network.PlayerConnection");
|
||||||
|
//Only for 1.20.2
|
||||||
|
SERVER_COMMON_PACKETLISTENER_IMPL_CLASS = getNMClassWithoutException("server.network.ServerCommonPacketListenerImpl");
|
||||||
}
|
}
|
||||||
serverConnectionClass = getNMSClassWithoutException("ServerConnection");
|
serverConnectionClass = getNMSClassWithoutException("ServerConnection");
|
||||||
if (serverConnectionClass == null) {
|
if (serverConnectionClass == null) {
|
||||||
@@ -185,11 +183,18 @@ public final class NMSUtils {
|
|||||||
dataWatcherClass = getNMSClassWithoutException("DataWatcher");
|
dataWatcherClass = getNMSClassWithoutException("DataWatcher");
|
||||||
if (dataWatcherClass == null) {
|
if (dataWatcherClass == null) {
|
||||||
dataWatcherClass = getNMClassWithoutException("network.syncher.DataWatcher");
|
dataWatcherClass = getNMClassWithoutException("network.syncher.DataWatcher");
|
||||||
|
if (dataWatcherClass == null) {
|
||||||
|
dataWatcherClass = getNMClassWithoutException("network.syncher.SynchedEntityData");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
nmsItemClass = getNMSClassWithoutException("Item");
|
nmsItemClass = getNMSClassWithoutException("Item");
|
||||||
if (nmsItemClass == null) {
|
if (nmsItemClass == null) {
|
||||||
nmsItemClass = getNMClassWithoutException("world.item.Item");
|
nmsItemClass = getNMClassWithoutException("world.item.Item");
|
||||||
}
|
}
|
||||||
|
iMaterialClass = getNMSClassWithoutException("IMaterial");
|
||||||
|
if (iMaterialClass == null) {
|
||||||
|
iMaterialClass = getNMClassWithoutException("world.level.IMaterial");
|
||||||
|
}
|
||||||
dedicatedServerClass = getNMSClassWithoutException("DedicatedServer");
|
dedicatedServerClass = getNMSClassWithoutException("DedicatedServer");
|
||||||
if (dedicatedServerClass == null) {
|
if (dedicatedServerClass == null) {
|
||||||
dedicatedServerClass = getNMClassWithoutException("server.dedicated.DedicatedServer");
|
dedicatedServerClass = getNMClassWithoutException("server.dedicated.DedicatedServer");
|
||||||
@@ -221,6 +226,9 @@ public final class NMSUtils {
|
|||||||
iChatBaseComponentClass = NMSUtils.getNMSClassWithoutException("IChatBaseComponent");
|
iChatBaseComponentClass = NMSUtils.getNMSClassWithoutException("IChatBaseComponent");
|
||||||
if (iChatBaseComponentClass == null) {
|
if (iChatBaseComponentClass == null) {
|
||||||
iChatBaseComponentClass = getNMClassWithoutException("network.chat.IChatBaseComponent");
|
iChatBaseComponentClass = getNMClassWithoutException("network.chat.IChatBaseComponent");
|
||||||
|
if (iChatBaseComponentClass == null) {
|
||||||
|
iChatBaseComponentClass = getNMClassWithoutException("network.chat.Component");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tileEntityCommandClass = NMSUtils.getNMSClassWithoutException("TileEntityCommand");
|
tileEntityCommandClass = NMSUtils.getNMSClassWithoutException("TileEntityCommand");
|
||||||
@@ -230,6 +238,37 @@ public final class NMSUtils {
|
|||||||
|
|
||||||
tileEntityCommandTypeClass = SubclassUtil.getEnumSubClass(tileEntityCommandClass, 0);
|
tileEntityCommandTypeClass = SubclassUtil.getEnumSubClass(tileEntityCommandClass, 0);
|
||||||
|
|
||||||
|
//Isn't present on every version
|
||||||
|
mojangEitherClass = Reflection.getClassByNameWithoutException("com.mojang.datafixers.util.Either");
|
||||||
|
|
||||||
|
registryMaterials = Reflection.getClassByNameWithoutException("net.minecraft.core.RegistryMaterials");
|
||||||
|
|
||||||
|
builtInRegistriesClass = Reflection.getClassByNameWithoutException("net.minecraft.core.registries.BuiltInRegistries");
|
||||||
|
|
||||||
|
if (builtInRegistriesClass != null) {
|
||||||
|
mobEffectsRegistryField = Reflection.getField(builtInRegistriesClass, "e");
|
||||||
|
|
||||||
|
for (Field f : Reflection.getFields(builtInRegistriesClass)) {
|
||||||
|
Type type = f.getGenericType();
|
||||||
|
if (type instanceof ParameterizedType) {
|
||||||
|
ParameterizedType pType = (ParameterizedType) type;
|
||||||
|
if (pType.getActualTypeArguments()[0].equals(mobEffectListClass)) {
|
||||||
|
mobEffectsRegistryField = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Class<?> baseBlockPosClass = NMSUtils.getNMSClassWithoutException("BaseBlockPosition");
|
||||||
|
if (baseBlockPosClass == null) {
|
||||||
|
baseBlockPosClass = getNMClassWithoutException("core.BaseBlockPosition");
|
||||||
|
}
|
||||||
|
if (baseBlockPosClass != null) {
|
||||||
|
getBaseBlockPosX = Reflection.getField(baseBlockPosClass, int.class, 0);
|
||||||
|
getBaseBlockPosY = Reflection.getField(baseBlockPosClass, int.class, 1);
|
||||||
|
getBaseBlockPosZ = Reflection.getField(baseBlockPosClass, int.class, 2);
|
||||||
|
}
|
||||||
vec3DClass = NMSUtils.getNMSClassWithoutException("Vec3D");
|
vec3DClass = NMSUtils.getNMSClassWithoutException("Vec3D");
|
||||||
if (vec3DClass == null) {
|
if (vec3DClass == null) {
|
||||||
vec3DClass = getNMClassWithoutException("world.phys.Vec3D");
|
vec3DClass = getNMClassWithoutException("world.phys.Vec3D");
|
||||||
@@ -242,6 +281,11 @@ public final class NMSUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sectionPositionClass = getNMSClassWithoutException("SectionPosition");
|
||||||
|
if (sectionPositionClass == null) {
|
||||||
|
sectionPositionClass = getNMClassWithoutException("core.SectionPosition");
|
||||||
|
}
|
||||||
|
|
||||||
if (version.isNewerThanOrEquals(ServerVersion.v_1_14)) {
|
if (version.isNewerThanOrEquals(ServerVersion.v_1_14)) {
|
||||||
movingObjectPositionBlockClass = NMSUtils.getNMSClassWithoutException("MovingObjectPositionBlock");
|
movingObjectPositionBlockClass = NMSUtils.getNMSClassWithoutException("MovingObjectPositionBlock");
|
||||||
|
|
||||||
@@ -260,7 +304,15 @@ public final class NMSUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dataWatcherClass != null) {
|
if (dataWatcherClass != null) {
|
||||||
dataWatcherConstructor = dataWatcherClass.getConstructor(nmsEntityClass);
|
try {
|
||||||
|
dataWatcherConstructor = dataWatcherClass.getConstructor(nmsEntityClass);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
dataWatcherConstructor = dataWatcherClass.getDeclaredConstructors()[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nmsItemStackClass != null && iMaterialClass != null) {
|
||||||
|
itemStackConstructor = nmsItemStackClass.getDeclaredConstructor(iMaterialClass);
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -299,6 +351,9 @@ public final class NMSUtils {
|
|||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
//That is fine, it is probably a subclass
|
//That is fine, it is probably a subclass
|
||||||
chatSerializerClass = SubclassUtil.getSubClass(iChatBaseComponentClass, "ChatSerializer");
|
chatSerializerClass = SubclassUtil.getSubClass(iChatBaseComponentClass, "ChatSerializer");
|
||||||
|
if (chatSerializerClass == null) {
|
||||||
|
chatSerializerClass = SubclassUtil.getSubClass(iChatBaseComponentClass, "Serializer");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
craftMagicNumbersClass = NMSUtils.getOBCClass("util.CraftMagicNumbers");
|
craftMagicNumbersClass = NMSUtils.getOBCClass("util.CraftMagicNumbers");
|
||||||
|
|
||||||
@@ -308,7 +363,12 @@ public final class NMSUtils {
|
|||||||
getNMSBlockFromMaterial = Reflection.getMethod(craftMagicNumbersClass, "getBlock", NMSUtils.blockClass, Material.class);
|
getNMSBlockFromMaterial = Reflection.getMethod(craftMagicNumbersClass, "getBlock", NMSUtils.blockClass, Material.class);
|
||||||
|
|
||||||
if (minecraftKeyClass != null) {
|
if (minecraftKeyClass != null) {
|
||||||
minecraftKeyConstructor = minecraftKeyClass.getConstructor(String.class);
|
try {
|
||||||
|
minecraftKeyConstructorOrMethod = minecraftKeyClass.getConstructor(String.class);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
minecraftKeyConstructorOrMethod = Reflection.getMethod(minecraftKeyClass, 0, String.class, char.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -316,11 +376,11 @@ public final class NMSUtils {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (mobEffectListClass != null) {
|
if (mobEffectListClass != null) {
|
||||||
getMobEffectListId = mobEffectListClass.getMethod("getId", mobEffectListClass);
|
getMobEffectListId = Reflection.getMethod(mobEffectListClass, 0, mobEffectListClass);
|
||||||
getMobEffectListById = mobEffectListClass.getMethod("fromId", int.class);
|
getMobEffectListById = Reflection.getMethod(mobEffectListClass, 0, int.class);
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
entityPlayerPingField = entityPlayerClass.getField("ping");
|
entityPlayerPingField = entityPlayerClass.getField("ping");
|
||||||
@@ -329,10 +389,34 @@ public final class NMSUtils {
|
|||||||
}
|
}
|
||||||
//In case its null, these methods are not needed and would cause errors
|
//In case its null, these methods are not needed and would cause errors
|
||||||
if (blockPosClass != null) {
|
if (blockPosClass != null) {
|
||||||
getBlockPosX = Reflection.getMethod(NMSUtils.blockPosClass.getSuperclass(), "getX", 0);
|
getBlockPosX = Reflection.getMethod(NMSUtils.blockPosClass, "getX", int.class);
|
||||||
getBlockPosY = Reflection.getMethod(NMSUtils.blockPosClass.getSuperclass(), "getY", 0);
|
getBlockPosY = Reflection.getMethod(NMSUtils.blockPosClass, "getY", int.class);
|
||||||
getBlockPosZ = Reflection.getMethod(NMSUtils.blockPosClass.getSuperclass(), "getZ", 0);
|
getBlockPosZ = Reflection.getMethod(NMSUtils.blockPosClass, "getZ", int.class);
|
||||||
|
// Mappings changed with 1.18
|
||||||
|
if (getBlockPosX == null) {
|
||||||
|
getBlockPosX = Reflection.getMethod(NMSUtils.blockPosClass, "u", int.class);
|
||||||
|
if (getBlockPosX == null) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getBlockPosY == null) {
|
||||||
|
getBlockPosY = Reflection.getMethod(NMSUtils.blockPosClass, "v", int.class);
|
||||||
|
}
|
||||||
|
if (getBlockPosZ == null) {
|
||||||
|
getBlockPosZ = Reflection.getMethod(NMSUtils.blockPosClass, "w", int.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mojangEitherClass != null) {
|
||||||
|
mojangEitherLeft = Reflection.getMethod(mojangEitherClass, "left", Optional.class);
|
||||||
|
mojangEitherRight = Reflection.getMethod(mojangEitherClass, "right", Optional.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (registryMaterials != null) {
|
||||||
|
getRegistryId = Reflection.getMethod(registryMaterials, int.class, 0, 1);
|
||||||
|
getRegistryById = Reflection.getMethod(registryMaterials, Optional.class, true, 0, int.class);
|
||||||
|
}
|
||||||
|
|
||||||
worldSettingsClass = NMSUtils.getNMSClassWithoutException("WorldSettings");
|
worldSettingsClass = NMSUtils.getNMSClassWithoutException("WorldSettings");
|
||||||
if (worldServerClass == null) {
|
if (worldServerClass == null) {
|
||||||
worldServerClass = getNMClassWithoutException("world.level.WorldSettings");
|
worldServerClass = getNMClassWithoutException("world.level.WorldSettings");
|
||||||
@@ -359,8 +443,13 @@ public final class NMSUtils {
|
|||||||
public static Object getMinecraftServerInstance(Server server) {
|
public static Object getMinecraftServerInstance(Server server) {
|
||||||
if (minecraftServer == null) {
|
if (minecraftServer == null) {
|
||||||
try {
|
try {
|
||||||
minecraftServer = Reflection.getField(craftServerClass, minecraftServerClass, 0)
|
Field f = Reflection.getField(craftServerClass, minecraftServerClass, 0);
|
||||||
.get(server);
|
if (f == null) {
|
||||||
|
//1.20.5 way
|
||||||
|
minecraftServer = Reflection.getField(minecraftServerClass, minecraftServerClass, 0).get(null);
|
||||||
|
} else {
|
||||||
|
minecraftServer = f.get(server);
|
||||||
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -380,11 +469,14 @@ public final class NMSUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double[] recentTPS() {
|
public static double[] recentTPS() {
|
||||||
return new WrappedPacket(new NMSPacket(getMinecraftServerInstance(Bukkit.getServer())), minecraftServerClass).readDoubleArray(0);
|
WrappedPacket minecraftServerInstanceReader = new WrappedPacket(
|
||||||
|
new NMSPacket(getMinecraftServerInstance(Bukkit.getServer())),
|
||||||
|
minecraftServerClass);
|
||||||
|
return minecraftServerInstanceReader.readDoubleArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getNMSClass(String name) throws ClassNotFoundException {
|
public static Class<?> getNMSClass(String name) throws ClassNotFoundException {
|
||||||
return Class.forName(NMS_DIR + name);
|
return Class.forName(ServerVersion.getNMSDirectory() + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getNMClass(String name) throws ClassNotFoundException {
|
public static Class<?> getNMClass(String name) throws ClassNotFoundException {
|
||||||
@@ -408,7 +500,7 @@ public final class NMSUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Class<? extends Enum<?>> getNMSEnumClass(String name) throws ClassNotFoundException {
|
public static Class<? extends Enum<?>> getNMSEnumClass(String name) throws ClassNotFoundException {
|
||||||
return (Class<? extends Enum<?>>) Class.forName(NMS_DIR + name);
|
return (Class<? extends Enum<?>>) Class.forName(ServerVersion.getNMSDirectory() + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<? extends Enum<?>> getNMSEnumClassWithoutException(String name) {
|
public static Class<? extends Enum<?>> getNMSEnumClassWithoutException(String name) {
|
||||||
@@ -429,7 +521,7 @@ public final class NMSUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getOBCClass(String name) throws ClassNotFoundException {
|
public static Class<?> getOBCClass(String name) throws ClassNotFoundException {
|
||||||
return Class.forName(OBC_DIR + name);
|
return Class.forName(ServerVersion.getOBCDirectory() + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getNettyClass(String name) throws ClassNotFoundException {
|
public static Class<?> getNettyClass(String name) throws ClassNotFoundException {
|
||||||
@@ -439,7 +531,7 @@ public final class NMSUtils {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Entity getEntityById(@Nullable World world, int id) {
|
public static Entity getEntityById(@Nullable World world, int id) {
|
||||||
return PacketEvents.get().getServerUtils().getEntityById(world, id);
|
return PacketEvents.get().getServerUtils().getEntityById(world, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entity getBukkitEntity(Object nmsEntity) {
|
public static Entity getBukkitEntity(Object nmsEntity) {
|
||||||
@@ -487,10 +579,18 @@ public final class NMSUtils {
|
|||||||
|
|
||||||
public static Object getPlayerConnection(final Player player) {
|
public static Object getPlayerConnection(final Player player) {
|
||||||
Object entityPlayer = getEntityPlayer(player);
|
Object entityPlayer = getEntityPlayer(player);
|
||||||
if (entityPlayer == null) {
|
Class<?> entityPlayerClass = entityPlayer != null ? entityPlayer.getClass() : null;
|
||||||
|
String className = entityPlayer != null ? ClassUtil.getClassSimpleName(entityPlayerClass) : "";
|
||||||
|
if (entityPlayer == null
|
||||||
|
|| className.contains("Fake")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
WrappedPacket wrappedEntityPlayer = new WrappedPacket(new NMSPacket(entityPlayer));
|
//If we need to get the superclass, we get it
|
||||||
|
if (!className.equals("EntityPlayer")
|
||||||
|
&& ClassUtil.getClassSimpleName(entityPlayerClass.getSuperclass()).equals("EntityPlayer")) {
|
||||||
|
entityPlayerClass = entityPlayerClass.getSuperclass();
|
||||||
|
}
|
||||||
|
WrappedPacket wrappedEntityPlayer = new WrappedPacket(new NMSPacket(entityPlayer), entityPlayerClass);
|
||||||
return wrappedEntityPlayer.readObject(0, NMSUtils.playerConnectionClass);
|
return wrappedEntityPlayer.readObject(0, NMSUtils.playerConnectionClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,7 +605,8 @@ public final class NMSUtils {
|
|||||||
if (playerConnection == null) {
|
if (playerConnection == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
WrappedPacket wrapper = new WrappedPacket(new NMSPacket(playerConnection), playerConnectionClass);
|
Class<?> playerConClass = SERVER_COMMON_PACKETLISTENER_IMPL_CLASS != null ? SERVER_COMMON_PACKETLISTENER_IMPL_CLASS : playerConnectionClass;
|
||||||
|
WrappedPacket wrapper = new WrappedPacket(new NMSPacket(playerConnection), playerConClass);
|
||||||
try {
|
try {
|
||||||
return wrapper.readObject(0, networkManagerClass);
|
return wrapper.readObject(0, networkManagerClass);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -514,11 +615,17 @@ public final class NMSUtils {
|
|||||||
return wrapper.readObject(0, networkManagerClass);
|
return wrapper.readObject(0, networkManagerClass);
|
||||||
} catch (Exception ex2) {
|
} catch (Exception ex2) {
|
||||||
//Support for some custom plugins.
|
//Support for some custom plugins.
|
||||||
playerConnection = wrapper.read(0, playerConnectionClass);
|
try {
|
||||||
wrapper = new WrappedPacket(new NMSPacket(playerConnection), playerConnectionClass);
|
playerConnection = wrapper.read(0, playerConnectionClass);
|
||||||
return wrapper.readObject(0, networkManagerClass);
|
wrapper = new WrappedPacket(new NMSPacket(playerConnection), playerConnectionClass);
|
||||||
|
return wrapper.readObject(0, networkManagerClass);
|
||||||
|
} catch (Exception ex3) {
|
||||||
|
//Print the original exception!
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getChannel(final Player player) {
|
public static Object getChannel(final Player player) {
|
||||||
@@ -526,7 +633,7 @@ public final class NMSUtils {
|
|||||||
if (networkManager == null) {
|
if (networkManager == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
WrappedPacket wrapper = new WrappedPacket(new NMSPacket(networkManager));
|
WrappedPacket wrapper = new WrappedPacket(new NMSPacket(networkManager), networkManagerClass);
|
||||||
return wrapper.readObject(0, nettyChannelClass);
|
return wrapper.readObject(0, nettyChannelClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,7 +784,12 @@ public final class NMSUtils {
|
|||||||
|
|
||||||
public static Object generateMinecraftKeyNew(String text) {
|
public static Object generateMinecraftKeyNew(String text) {
|
||||||
try {
|
try {
|
||||||
return minecraftKeyConstructor.newInstance(text);
|
if (minecraftKeyConstructorOrMethod instanceof Constructor<?>) {
|
||||||
|
return ((Constructor<?>)minecraftKeyConstructorOrMethod).newInstance(text);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ((Method)minecraftKeyConstructorOrMethod).invoke(text, ':');
|
||||||
|
}
|
||||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -719,9 +831,13 @@ public final class NMSUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object generateDataWatcher(Entity entity) {
|
public static Object generateDataWatcher(Object nmsEntity) {
|
||||||
try {
|
try {
|
||||||
return dataWatcherConstructor.newInstance(entity);
|
if (dataWatcherConstructor.getParameterCount() == 2) {
|
||||||
|
return dataWatcherConstructor.newInstance(nmsEntity, null);
|
||||||
|
} else {
|
||||||
|
return dataWatcherConstructor.newInstance(nmsEntity);
|
||||||
|
}
|
||||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -757,6 +873,11 @@ public final class NMSUtils {
|
|||||||
|
|
||||||
public static int getEffectId(Object nmsMobEffectList) {
|
public static int getEffectId(Object nmsMobEffectList) {
|
||||||
try {
|
try {
|
||||||
|
//1.20.2+
|
||||||
|
if (getMobEffectListId == null) {
|
||||||
|
Object registry = mobEffectsRegistryField.get(null);
|
||||||
|
return (int) getRegistryId.invoke(registry, nmsMobEffectList);
|
||||||
|
}
|
||||||
return (int) getMobEffectListId.invoke(null, nmsMobEffectList);
|
return (int) getMobEffectListId.invoke(null, nmsMobEffectList);
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -766,6 +887,10 @@ public final class NMSUtils {
|
|||||||
|
|
||||||
public static Object getMobEffectListById(int effectID) {
|
public static Object getMobEffectListById(int effectID) {
|
||||||
try {
|
try {
|
||||||
|
if (getMobEffectListById == null) {
|
||||||
|
Object registry = mobEffectsRegistryField.get(null);
|
||||||
|
return getRegistryById.invoke(registry, effectID);
|
||||||
|
}
|
||||||
return getMobEffectListById.invoke(null, effectID);
|
return getMobEffectListById.invoke(null, effectID);
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -799,4 +924,22 @@ public final class NMSUtils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Optional<Object> getEitherLeft(Object either) {
|
||||||
|
try {
|
||||||
|
return (Optional<Object>) mojangEitherLeft.invoke(either);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<Object> getEitherRight(Object either) {
|
||||||
|
try {
|
||||||
|
return (Optional<Object>) mojangEitherRight.invoke(either);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loaded 100 of 111 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user