mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2026-11-04 17:00:19 -05:00
Compare commits
27
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aca303b228 | ||
|
|
8eeb82f89d | ||
|
|
b0b9b666a7 | ||
|
|
b723ff3351 | ||
|
|
72fd0709b6 | ||
|
|
5a9afed462 | ||
|
|
9404ce32db | ||
|
|
6c6bde522e | ||
|
|
f911ee904c | ||
|
|
22012d3dc9 | ||
|
|
c52b4bb10c | ||
|
|
b9f96469f5 | ||
|
|
e5413ccc5b | ||
|
|
b37a3bcb13 | ||
|
|
19cb81b6ab | ||
|
|
f606cc954d | ||
|
|
774e679571 | ||
|
|
1257506929 | ||
|
|
5773bcbc16 | ||
|
|
468082c9f9 | ||
|
|
a11b403c4b | ||
|
|
aa4fab1632 | ||
|
|
771a530fe2 | ||
|
|
ca9b5bbb80 | ||
|
|
d790ded81f | ||
|
|
f357ac85d0 | ||
|
|
66cdb5b69d |
No files matched your search
@@ -0,0 +1,43 @@
|
||||
name: ProtocolLib development build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
cache: 'gradle'
|
||||
|
||||
- name: Run gradle build lifecycle
|
||||
run: |
|
||||
COMMIT_SHA=${{ github.sha }} ./gradlew build shadowJar --no-daemon
|
||||
|
||||
- name: Upload plugin file
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ProtocolLib
|
||||
path: build/libs/ProtocolLib.jar
|
||||
|
||||
- name: Create or update GitHub pre-release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
COMMIT_MSG=$(git log -1 --pretty=%B)
|
||||
SHORT_HASH=$(echo "${{ github.sha }}" | cut -c1-7)
|
||||
RELEASE_NOTES=$(gh release view dev-build --repo ${{ github.repository }} --json body -q ".body" 2>/dev/null || echo "")
|
||||
gh release view dev-build --repo ${{ github.repository }} || \
|
||||
gh release create dev-build --prerelease --title "Development Build" --notes "## Changelog" --repo ${{ github.repository }}
|
||||
NEW_NOTES="$RELEASE_NOTES"$'\n'"* [$SHORT_HASH] $COMMIT_MSG"
|
||||
gh release edit dev-build --notes "$NEW_NOTES" --repo ${{ github.repository }}
|
||||
gh release upload dev-build build/libs/ProtocolLib.jar#ProtocolLib.jar --clobber --repo ${{ github.repository }}
|
||||
@@ -14,6 +14,7 @@ lead to more subtle bugs.
|
||||
|
||||
* [Spigot Page](https://spigotmc.org/resources/protocollib.1997/)
|
||||
* [Releases](https://github.com/dmulloy2/ProtocolLib/releases)
|
||||
* [Dev Build](https://github.com/dmulloy2/ProtocolLib/releases/tag/dev-build)
|
||||
* [JavaDoc](https://dmulloy2.net/ProtocolLib/javadoc/)
|
||||
* [Protocol Wiki](https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Protocol)
|
||||
|
||||
|
||||
+34
-34
@@ -1,26 +1,25 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import io.github.patrick.gradle.remapper.RemapTask
|
||||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
`signing`
|
||||
id("com.gradleup.shadow") version "9.0.0-beta13"
|
||||
id("io.github.patrick.remapper") version "1.4.2"
|
||||
id("com.vanniktech.maven.publish") version "0.34.0"
|
||||
signing
|
||||
id("com.gradleup.shadow") version "9.4.0"
|
||||
id("io.github.patrick.remapper") version "1.4.3"
|
||||
id("com.vanniktech.maven.publish") version "0.36.0"
|
||||
}
|
||||
|
||||
group = "net.dmulloy2"
|
||||
description = "Provides access to the Minecraft protocol"
|
||||
|
||||
val mcVersion = "1.21.8"
|
||||
val mcVersion = "26.2"
|
||||
val isSnapshot = version.toString().endsWith("-SNAPSHOT")
|
||||
val buildNumber = System.getenv("BUILD_NUMBER") ?: ""
|
||||
val isJenkins = buildNumber.isNotEmpty()
|
||||
val isJitPack = System.getenv("JITPACK")?.equals("true", ignoreCase = true) ?: false
|
||||
val commitHash = System.getenv("COMMIT_SHA") ?: ""
|
||||
val isCI = commitHash.isNotEmpty()
|
||||
|
||||
repositories {
|
||||
if (!isJenkins) {
|
||||
if (!isCI) {
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
@@ -45,37 +44,36 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("net.bytebuddy:byte-buddy:1.17.5")
|
||||
implementation("net.bytebuddy:byte-buddy:1.18.2")
|
||||
compileOnly("org.spigotmc:spigot-api:${mcVersion}-R0.1-SNAPSHOT")
|
||||
compileOnly("org.spigotmc:spigot:${mcVersion}-R0.1-SNAPSHOT:remapped-mojang")
|
||||
compileOnly("io.netty:netty-all:4.0.23.Final")
|
||||
/*
|
||||
* TODO(fix): once you update kyori:adventure-text-serializer-gson please uncomment the TODO in
|
||||
* com.comphenix.protocol.wrappers.WrappedComponentStyleTest if the following issue got fixed:
|
||||
* https://github.com/KyoriPowered/adventure/issues/1194
|
||||
*/
|
||||
compileOnly("net.kyori:adventure-text-serializer-gson:4.21.0")
|
||||
compileOnly("org.spigotmc:spigot:${mcVersion}-R0.1-SNAPSHOT")//:remapped-mojang")
|
||||
compileOnly("io.netty:netty-all:4.2.8.Final")
|
||||
compileOnly("net.kyori:adventure-text-serializer-gson:4.25.0")
|
||||
compileOnly("com.googlecode.json-simple:json-simple:1.1.1")
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.10.0")
|
||||
testImplementation("org.mockito:mockito-core:5.6.0")
|
||||
testImplementation("io.netty:netty-common:4.1.97.Final")
|
||||
testImplementation("io.netty:netty-transport:4.1.97.Final")
|
||||
testImplementation("org.spigotmc:spigot:${mcVersion}-R0.1-SNAPSHOT:remapped-mojang")
|
||||
testImplementation("net.kyori:adventure-text-serializer-gson:4.14.0")
|
||||
testImplementation("net.kyori:adventure-text-serializer-plain:4.14.0")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-engine:6.0.1")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:6.0.1")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher:6.0.1")
|
||||
testImplementation("org.mockito:mockito-core:5.21.0")
|
||||
testImplementation("io.netty:netty-common:4.2.8.Final")
|
||||
testImplementation("io.netty:netty-transport:4.2.8.Final")
|
||||
testImplementation("org.spigotmc:spigot:${mcVersion}-R0.1-SNAPSHOT")//:remapped-mojang")
|
||||
testImplementation("net.kyori:adventure-text-serializer-gson:4.25.0")
|
||||
testImplementation("net.kyori:adventure-text-serializer-plain:4.25.0")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
// sourceCompatibility = JavaVersion.VERSION_25
|
||||
// targetCompatibility = JavaVersion.VERSION_25
|
||||
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(25))
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
processResources {
|
||||
val fullVersion = if (isSnapshot && isJenkins) "${version}-${buildNumber}" else version
|
||||
val fullVersion = if (isSnapshot && isCI) "${version}-${commitHash.take(7)}" else version
|
||||
|
||||
eachFile {
|
||||
expand("version" to fullVersion)
|
||||
@@ -104,7 +102,7 @@ tasks {
|
||||
archiveFileName = "ProtocolLib.jar"
|
||||
}
|
||||
|
||||
remap {
|
||||
/*remap {
|
||||
dependsOn("shadowJar")
|
||||
|
||||
inputTask.set(getByName<ShadowJar>("shadowJar"))
|
||||
@@ -114,7 +112,7 @@ tasks {
|
||||
|
||||
assemble {
|
||||
dependsOn("remap")
|
||||
}
|
||||
}*/
|
||||
|
||||
javadoc {
|
||||
options.encoding = "UTF-8"
|
||||
@@ -127,7 +125,9 @@ tasks {
|
||||
|
||||
mavenPublishing {
|
||||
publishToMavenCentral()
|
||||
signAllPublications()
|
||||
if (!isSnapshot && !isJitPack) {
|
||||
signAllPublications()
|
||||
}
|
||||
|
||||
coordinates("$group", project.name, "$version")
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
version=5.4.0
|
||||
version=5.5.0-SNAPSHOT
|
||||
mavenCentralUsername=
|
||||
mavenCentralPassword=
|
||||
signing.keyId=
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -84,7 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -112,7 +114,6 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -170,7 +171,6 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -203,15 +203,14 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+13
-12
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -57,22 +59,21 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
@@ -133,114 +133,121 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
||||
public static final PacketType CUSTOM_CHAT_COMPLETIONS = new PacketType(PROTOCOL, SENDER, 0x17, "CustomChatCompletions");
|
||||
public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x18, "CustomPayload", "SPacketCustomPayload");
|
||||
public static final PacketType DAMAGE_EVENT = new PacketType(PROTOCOL, SENDER, 0x19, "DamageEvent", "ClientboundDamageEventPacket");
|
||||
public static final PacketType DEBUG_SAMPLE = new PacketType(PROTOCOL, SENDER, 0x1A, "DebugSample");
|
||||
public static final PacketType DELETE_CHAT_MESSAGE = new PacketType(PROTOCOL, SENDER, 0x1B, "DeleteChat");
|
||||
public static final PacketType KICK_DISCONNECT = new PacketType(PROTOCOL, SENDER, 0x1C, "Disconnect", "KickDisconnect", "SPacketDisconnect");
|
||||
public static final PacketType DISGUISED_CHAT = new PacketType(PROTOCOL, SENDER, 0x1D, "DisguisedChat");
|
||||
public static final PacketType ENTITY_STATUS = new PacketType(PROTOCOL, SENDER, 0x1E, "EntityEvent", "EntityStatus", "SPacketEntityStatus");
|
||||
public static final PacketType ENTITY_POSITION_SYNC = new PacketType(PROTOCOL, SENDER, 0x1F, "EntityPositionSync");
|
||||
public static final PacketType EXPLOSION = new PacketType(PROTOCOL, SENDER, 0x20, "Explode", "Explosion", "SPacketExplosion");
|
||||
public static final PacketType UNLOAD_CHUNK = new PacketType(PROTOCOL, SENDER, 0x21, "ForgetLevelChunk", "UnloadChunk", "SPacketUnloadChunk");
|
||||
public static final PacketType GAME_STATE_CHANGE = new PacketType(PROTOCOL, SENDER, 0x22, "GameEvent", "GameStateChange", "SPacketChangeGameState");
|
||||
public static final PacketType OPEN_WINDOW_HORSE = new PacketType(PROTOCOL, SENDER, 0x23, "HorseScreenOpen", "OpenWindowHorse");
|
||||
public static final PacketType HURT_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x24, "HurtAnimation", "ClientboundHurtAnimationPacket");
|
||||
public static final PacketType INITIALIZE_BORDER = new PacketType(PROTOCOL, SENDER, 0x25, "InitializeBorder");
|
||||
public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x26, "KeepAlive", "SPacketKeepAlive");
|
||||
public static final PacketType MAP_CHUNK = new PacketType(PROTOCOL, SENDER, 0x27, "LevelChunkWithLight", "MapChunk", "SPacketChunkData");
|
||||
public static final PacketType WORLD_EVENT = new PacketType(PROTOCOL, SENDER, 0x28, "LevelEvent", "WorldEvent", "SPacketEffect");
|
||||
public static final PacketType WORLD_PARTICLES = new PacketType(PROTOCOL, SENDER, 0x29, "LevelParticles", "WorldParticles", "SPacketParticles");
|
||||
public static final PacketType LIGHT_UPDATE = new PacketType(PROTOCOL, SENDER, 0x2A, "LightUpdate");
|
||||
public static final PacketType LOGIN = new PacketType(PROTOCOL, SENDER, 0x2B, "Login", "SPacketJoinGame");
|
||||
public static final PacketType MAP = new PacketType(PROTOCOL, SENDER, 0x2C, "MapItemData", "Map", "SPacketMaps");
|
||||
public static final PacketType OPEN_WINDOW_MERCHANT = new PacketType(PROTOCOL, SENDER, 0x2D, "MerchantOffers", "OpenWindowMerchant");
|
||||
public static final PacketType REL_ENTITY_MOVE = new PacketType(PROTOCOL, SENDER, 0x2E, "net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Pos", "Entity$RelEntityMove", "Entity$PacketPlayOutRelEntityMove");
|
||||
public static final PacketType REL_ENTITY_MOVE_LOOK = new PacketType(PROTOCOL, SENDER, 0x2F, "net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$PosRot", "Entity$RelEntityMoveLook", "Entity$PacketPlayOutRelEntityMoveLook");
|
||||
public static final PacketType MOVE_MINECART = new PacketType(PROTOCOL, SENDER, 0x30, "MoveMinecart");
|
||||
public static final PacketType ENTITY_LOOK = new PacketType(PROTOCOL, SENDER, 0x31, "net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Rot", "Entity$EntityLook", "Entity$PacketPlayOutEntityLook");
|
||||
public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x32, "MoveVehicle", "VehicleMove", "SPacketMoveVehicle");
|
||||
public static final PacketType OPEN_BOOK = new PacketType(PROTOCOL, SENDER, 0x33, "OpenBook");
|
||||
public static final PacketType OPEN_WINDOW = new PacketType(PROTOCOL, SENDER, 0x34, "OpenScreen", "OpenWindow", "SPacketOpenWindow");
|
||||
public static final PacketType OPEN_SIGN_EDITOR = new PacketType(PROTOCOL, SENDER, 0x35, "OpenSignEditor", "SPacketSignEditorOpen");
|
||||
public static final PacketType PING = new PacketType(PROTOCOL, SENDER, 0x36, "Ping");
|
||||
public static final PacketType PONG_RESPONSE = new PacketType(PROTOCOL, SENDER, 0x37, "PongResponse");
|
||||
public static final PacketType AUTO_RECIPE = new PacketType(PROTOCOL, SENDER, 0x38, "PlaceGhostRecipe", "AutoRecipe", "SPacketPlaceGhostRecipe");
|
||||
public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x39, "PlayerAbilities", "Abilities", "SPacketPlayerAbilities");
|
||||
public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x3A, "PlayerChat", "Chat", "SPacketChat");
|
||||
public static final PacketType PLAYER_COMBAT_END = new PacketType(PROTOCOL, SENDER, 0x3B, "PlayerCombatEnd");
|
||||
public static final PacketType PLAYER_COMBAT_ENTER = new PacketType(PROTOCOL, SENDER, 0x3C, "PlayerCombatEnter");
|
||||
public static final PacketType PLAYER_COMBAT_KILL = new PacketType(PROTOCOL, SENDER, 0x3D, "PlayerCombatKill");
|
||||
public static final PacketType PLAYER_INFO_REMOVE = new PacketType(PROTOCOL, SENDER, 0x3E, "PlayerInfoRemove");
|
||||
public static final PacketType PLAYER_INFO = new PacketType(PROTOCOL, SENDER, 0x3F, "PlayerInfoUpdate", "PlayerInfo");
|
||||
public static final PacketType LOOK_AT = new PacketType(PROTOCOL, SENDER, 0x40, "PlayerLookAt", "LookAt", "SPacketPlayerPosLook");
|
||||
public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x41, "PlayerPosition", "Position");
|
||||
public static final PacketType PLAYER_ROTATION = new PacketType(PROTOCOL, SENDER, 0x42, "PlayerRotation");
|
||||
public static final PacketType RECIPE_BOOK_ADD = new PacketType(PROTOCOL, SENDER, 0x43, "RecipeBookAdd");
|
||||
public static final PacketType RECIPE_BOOK_REMOVE = new PacketType(PROTOCOL, SENDER, 0x44, "RecipeBookRemove");
|
||||
public static final PacketType RECIPE_BOOK_SETTINGS = new PacketType(PROTOCOL, SENDER, 0x45, "RecipeBookSettings");
|
||||
public static final PacketType ENTITY_DESTROY = new PacketType(PROTOCOL, SENDER, 0x46, "RemoveEntities", "EntityDestroy", "SPacketDestroyEntities");
|
||||
public static final PacketType REMOVE_ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x47, "RemoveMobEffect", "RemoveEntityEffect", "SPacketRemoveEntityEffect");
|
||||
public static final PacketType RESET_SCORE = new PacketType(PROTOCOL, SENDER, 0x48, "ResetScore", "ResetScorePacket");
|
||||
public static final PacketType REMOVE_RESOURCE_PACK = new PacketType(PROTOCOL, SENDER, 0x49, "ResourcePackPop", "ResourcePackPopPacket");
|
||||
public static final PacketType ADD_RESOURCE_PACK = new PacketType(PROTOCOL, SENDER, 0x4A, "ResourcePackPush", "ResourcePackPushPacket");
|
||||
public static final PacketType RESPAWN = new PacketType(PROTOCOL, SENDER, 0x4B, "Respawn", "SPacketRespawn");
|
||||
public static final PacketType ENTITY_HEAD_ROTATION = new PacketType(PROTOCOL, SENDER, 0x4C, "RotateHead", "EntityHeadRotation", "SPacketEntityHeadLook");
|
||||
public static final PacketType MULTI_BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x4D, "SectionBlocksUpdate", "MultiBlockChange", "SPacketMultiBlockChange");
|
||||
public static final PacketType SELECT_ADVANCEMENT_TAB = new PacketType(PROTOCOL, SENDER, 0x4E, "SelectAdvancementsTab", "SelectAdvancementTab", "SPacketSelectAdvancementsTab");
|
||||
public static final PacketType SERVER_DATA = new PacketType(PROTOCOL, SENDER, 0x4F, "ServerData");
|
||||
public static final PacketType SET_ACTION_BAR_TEXT = new PacketType(PROTOCOL, SENDER, 0x50, "SetActionBarText");
|
||||
public static final PacketType SET_BORDER_CENTER = new PacketType(PROTOCOL, SENDER, 0x51, "SetBorderCenter");
|
||||
public static final PacketType SET_BORDER_LERP_SIZE = new PacketType(PROTOCOL, SENDER, 0x52, "SetBorderLerpSize");
|
||||
public static final PacketType SET_BORDER_SIZE = new PacketType(PROTOCOL, SENDER, 0x53, "SetBorderSize");
|
||||
public static final PacketType SET_BORDER_WARNING_DELAY = new PacketType(PROTOCOL, SENDER, 0x54, "SetBorderWarningDelay");
|
||||
public static final PacketType SET_BORDER_WARNING_DISTANCE = new PacketType(PROTOCOL, SENDER, 0x55, "SetBorderWarningDistance");
|
||||
public static final PacketType CAMERA = new PacketType(PROTOCOL, SENDER, 0x56, "SetCamera", "Camera", "SPacketCamera");
|
||||
public static final PacketType VIEW_CENTRE = new PacketType(PROTOCOL, SENDER, 0x57, "SetChunkCacheCenter", "ViewCentre");
|
||||
public static final PacketType VIEW_DISTANCE = new PacketType(PROTOCOL, SENDER, 0x58, "SetChunkCacheRadius", "ViewDistance");
|
||||
public static final PacketType SET_CURSOR_ITEM = new PacketType(PROTOCOL, SENDER, 0x59, "SetCursorItem");
|
||||
public static final PacketType SPAWN_POSITION = new PacketType(PROTOCOL, SENDER, 0x5A, "SetDefaultSpawnPosition", "SpawnPosition", "SPacketSpawnPosition");
|
||||
public static final PacketType SCOREBOARD_DISPLAY_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x5B, "SetDisplayObjective", "ScoreboardDisplayObjective", "SPacketDisplayObjective");
|
||||
public static final PacketType ENTITY_METADATA = new PacketType(PROTOCOL, SENDER, 0x5C, "SetEntityData", "EntityMetadata", "SPacketEntityMetadata");
|
||||
public static final PacketType ATTACH_ENTITY = new PacketType(PROTOCOL, SENDER, 0x5D, "SetEntityLink", "AttachEntity", "SPacketEntityAttach");
|
||||
public static final PacketType ENTITY_VELOCITY = new PacketType(PROTOCOL, SENDER, 0x5E, "SetEntityMotion", "EntityVelocity", "SPacketEntityVelocity");
|
||||
public static final PacketType ENTITY_EQUIPMENT = new PacketType(PROTOCOL, SENDER, 0x5F, "SetEquipment", "EntityEquipment", "SPacketEntityEquipment");
|
||||
public static final PacketType EXPERIENCE = new PacketType(PROTOCOL, SENDER, 0x60, "SetExperience", "Experience", "SPacketSetExperience");
|
||||
public static final PacketType UPDATE_HEALTH = new PacketType(PROTOCOL, SENDER, 0x61, "SetHealth", "UpdateHealth", "SPacketUpdateHealth");
|
||||
public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x62, "SetHeldSlot", "SetCarriedItem", "HeldItemSlot", "SPacketHeldItemChange");
|
||||
public static final PacketType SCOREBOARD_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x63, "SetObjective", "ScoreboardObjective", "SPacketScoreboardObjective");
|
||||
public static final PacketType MOUNT = new PacketType(PROTOCOL, SENDER, 0x64, "SetPassengers", "Mount", "SPacketSetPassengers");
|
||||
public static final PacketType SET_PLAYER_INVENTORY = new PacketType(PROTOCOL, SENDER, 0x65, "SetPlayerInventory");
|
||||
public static final PacketType SCOREBOARD_TEAM = new PacketType(PROTOCOL, SENDER, 0x66, "SetPlayerTeam", "ScoreboardTeam", "SPacketTeams");
|
||||
public static final PacketType SCOREBOARD_SCORE = new PacketType(PROTOCOL, SENDER, 0x67, "SetScore", "ScoreboardScore", "SPacketUpdateScore");
|
||||
public static final PacketType UPDATE_SIMULATION_DISTANCE = new PacketType(PROTOCOL, SENDER, 0x68, "SetSimulationDistance");
|
||||
public static final PacketType SET_SUBTITLE_TEXT = new PacketType(PROTOCOL, SENDER, 0x69, "SetSubtitleText");
|
||||
public static final PacketType UPDATE_TIME = new PacketType(PROTOCOL, SENDER, 0x6A, "SetTime", "UpdateTime", "SPacketTimeUpdate");
|
||||
public static final PacketType SET_TITLE_TEXT = new PacketType(PROTOCOL, SENDER, 0x6B, "SetTitleText");
|
||||
public static final PacketType SET_TITLES_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x6C, "SetTitlesAnimation");
|
||||
public static final PacketType ENTITY_SOUND = new PacketType(PROTOCOL, SENDER, 0x6D, "SoundEntity", "EntitySound", "SPacketSoundEffect");
|
||||
public static final PacketType NAMED_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x6E, "Sound", "NamedSoundEffect");
|
||||
public static final PacketType START_CONFIGURATION = new PacketType(PROTOCOL, SENDER, 0x6F, "StartConfiguration");
|
||||
public static final PacketType STOP_SOUND = new PacketType(PROTOCOL, SENDER, 0x70, "StopSound");
|
||||
public static final PacketType STORE_COOKIE = new PacketType(PROTOCOL, SENDER, 0x71, "StoreCookie");
|
||||
public static final PacketType SYSTEM_CHAT = new PacketType(PROTOCOL, SENDER, 0x72, "SystemChat");
|
||||
public static final PacketType PLAYER_LIST_HEADER_FOOTER = new PacketType(PROTOCOL, SENDER, 0x73, "TabList", "PlayerListHeaderFooter", "SPacketPlayerListHeaderFooter");
|
||||
public static final PacketType NBT_QUERY = new PacketType(PROTOCOL, SENDER, 0x74, "TagQuery", "NBTQuery");
|
||||
public static final PacketType COLLECT = new PacketType(PROTOCOL, SENDER, 0x75, "TakeItemEntity", "Collect", "SPacketCollectItem");
|
||||
public static final PacketType ENTITY_TELEPORT = new PacketType(PROTOCOL, SENDER, 0x76, "TeleportEntity", "EntityTeleport", "SPacketEntityTeleport");
|
||||
public static final PacketType TEST_INSTANCE_BLOCK_STATUS = new PacketType(PROTOCOL, SENDER, 0x77, "ClientboundTestInstanceBlockStatus");
|
||||
public static final PacketType TICKING_STATE = new PacketType(PROTOCOL, SENDER, 0x78, "TickingState", "TickingStatePacket");
|
||||
public static final PacketType TICKING_STEP_STATE = new PacketType(PROTOCOL, SENDER, 0x79, "TickingStep", "TickingStepPacket");
|
||||
public static final PacketType TRANSFER = new PacketType(PROTOCOL, SENDER, 0x7A, "Transfer");
|
||||
public static final PacketType ADVANCEMENTS = new PacketType(PROTOCOL, SENDER, 0x7B, "UpdateAdvancements", "Advancements", "SPacketAdvancementInfo");
|
||||
public static final PacketType UPDATE_ATTRIBUTES = new PacketType(PROTOCOL, SENDER, 0x7C, "UpdateAttributes", "SPacketEntityProperties");
|
||||
public static final PacketType ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x7D, "UpdateMobEffect", "EntityEffect", "SPacketEntityEffect");
|
||||
public static final PacketType RECIPE_UPDATE = new PacketType(PROTOCOL, SENDER, 0x7E, "UpdateRecipes", "RecipeUpdate");
|
||||
public static final PacketType TAGS = new PacketType(PROTOCOL, SENDER, 0x7F, "UpdateTags", "Tags");
|
||||
public static final PacketType PROJECTILE_POWER = new PacketType(PROTOCOL, SENDER, 0x80, "ProjectilePower");
|
||||
public static final PacketType REPORT_DETAILS = new PacketType(PROTOCOL, SENDER, 0x81, "CustomReportDetails");
|
||||
public static final PacketType SERVER_LINKS = new PacketType(PROTOCOL, SENDER, 0x82, "ServerLinks");
|
||||
public static final PacketType TRACKED_WAYPOINT = new PacketType(PROTOCOL, SENDER, 0x83, "TrackedWaypoint");
|
||||
public static final PacketType CLEAR_DIALOG = new PacketType(PROTOCOL, SENDER, 0x84, "ClearDialog");
|
||||
public static final PacketType SHOW_DIALOG = new PacketType(PROTOCOL, SENDER, 0x85, "ShowDialog");
|
||||
public static final PacketType DEBUG_BLOCK_VALUE = new PacketType(PROTOCOL, SENDER, 0x1A, "DebugBlockValue");
|
||||
public static final PacketType DEBUG_CHUNK_VALUE = new PacketType(PROTOCOL, SENDER, 0x1B, "DebugChunkValue");
|
||||
public static final PacketType DEBUG_ENTITY_VALUE = new PacketType(PROTOCOL, SENDER, 0x1C, "DebugEntityValue");
|
||||
public static final PacketType DEBUG_EVENT = new PacketType(PROTOCOL, SENDER, 0x1D, "DebugEvent");
|
||||
public static final PacketType DEBUG_SAMPLE = new PacketType(PROTOCOL, SENDER, 0x1E, "DebugSample");
|
||||
public static final PacketType DELETE_CHAT_MESSAGE = new PacketType(PROTOCOL, SENDER, 0x1F, "DeleteChat");
|
||||
public static final PacketType KICK_DISCONNECT = new PacketType(PROTOCOL, SENDER, 0x20, "Disconnect", "KickDisconnect", "SPacketDisconnect");
|
||||
public static final PacketType DISGUISED_CHAT = new PacketType(PROTOCOL, SENDER, 0x21, "DisguisedChat");
|
||||
public static final PacketType ENTITY_STATUS = new PacketType(PROTOCOL, SENDER, 0x22, "EntityEvent", "EntityStatus", "SPacketEntityStatus");
|
||||
public static final PacketType ENTITY_POSITION_SYNC = new PacketType(PROTOCOL, SENDER, 0x23, "EntityPositionSync");
|
||||
public static final PacketType EXPLOSION = new PacketType(PROTOCOL, SENDER, 0x24, "Explode", "Explosion", "SPacketExplosion");
|
||||
public static final PacketType UNLOAD_CHUNK = new PacketType(PROTOCOL, SENDER, 0x25, "ForgetLevelChunk", "UnloadChunk", "SPacketUnloadChunk");
|
||||
public static final PacketType GAME_STATE_CHANGE = new PacketType(PROTOCOL, SENDER, 0x26, "GameEvent", "GameStateChange", "SPacketChangeGameState");
|
||||
public static final PacketType GAME_RULE_VALUES = new PacketType(PROTOCOL, SENDER, 0x27, "GameRuleValues");
|
||||
public static final PacketType GAME_TEST_HIGHLIGHT_POS = new PacketType(PROTOCOL, SENDER, 0x28, "GameTestHighlightPos");
|
||||
public static final PacketType OPEN_WINDOW_HORSE = new PacketType(PROTOCOL, SENDER, 0x29, "MountScreenOpen", "HorseScreenOpen", "OpenWindowHorse");
|
||||
public static final PacketType HURT_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x2A, "HurtAnimation", "ClientboundHurtAnimationPacket");
|
||||
public static final PacketType INITIALIZE_BORDER = new PacketType(PROTOCOL, SENDER, 0x2B, "InitializeBorder");
|
||||
public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x2C, "KeepAlive", "SPacketKeepAlive");
|
||||
public static final PacketType MAP_CHUNK = new PacketType(PROTOCOL, SENDER, 0x2D, "LevelChunkWithLight", "MapChunk", "SPacketChunkData");
|
||||
public static final PacketType WORLD_EVENT = new PacketType(PROTOCOL, SENDER, 0x2E, "LevelEvent", "WorldEvent", "SPacketEffect");
|
||||
public static final PacketType WORLD_PARTICLES = new PacketType(PROTOCOL, SENDER, 0x2F, "LevelParticles", "WorldParticles", "SPacketParticles");
|
||||
public static final PacketType LIGHT_UPDATE = new PacketType(PROTOCOL, SENDER, 0x30, "LightUpdate");
|
||||
public static final PacketType LOGIN = new PacketType(PROTOCOL, SENDER, 0x31, "Login", "SPacketJoinGame");
|
||||
public static final PacketType LOW_DISK_SPACE_WARNING = new PacketType(PROTOCOL, SENDER, 0x32, "LowDiskSpaceWarning");
|
||||
public static final PacketType MAP = new PacketType(PROTOCOL, SENDER, 0x33, "MapItemData", "Map", "SPacketMaps");
|
||||
public static final PacketType OPEN_WINDOW_MERCHANT = new PacketType(PROTOCOL, SENDER, 0x34, "MerchantOffers", "OpenWindowMerchant");
|
||||
public static final PacketType REL_ENTITY_MOVE = new PacketType(PROTOCOL, SENDER, 0x35, "net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Pos", "Entity$RelEntityMove", "Entity$PacketPlayOutRelEntityMove");
|
||||
public static final PacketType REL_ENTITY_MOVE_LOOK = new PacketType(PROTOCOL, SENDER, 0x36, "net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$PosRot", "Entity$RelEntityMoveLook", "Entity$PacketPlayOutRelEntityMoveLook");
|
||||
public static final PacketType MOVE_MINECART = new PacketType(PROTOCOL, SENDER, 0x37, "MoveMinecart");
|
||||
public static final PacketType ENTITY_LOOK = new PacketType(PROTOCOL, SENDER, 0x38, "net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Rot", "Entity$EntityLook", "Entity$PacketPlayOutEntityLook");
|
||||
public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x39, "MoveVehicle", "VehicleMove", "SPacketMoveVehicle");
|
||||
public static final PacketType OPEN_BOOK = new PacketType(PROTOCOL, SENDER, 0x3A, "OpenBook");
|
||||
public static final PacketType OPEN_WINDOW = new PacketType(PROTOCOL, SENDER, 0x3B, "OpenScreen", "OpenWindow", "SPacketOpenWindow");
|
||||
public static final PacketType OPEN_SIGN_EDITOR = new PacketType(PROTOCOL, SENDER, 0x3C, "OpenSignEditor", "SPacketSignEditorOpen");
|
||||
public static final PacketType PING = new PacketType(PROTOCOL, SENDER, 0x3D, "Ping");
|
||||
public static final PacketType PONG_RESPONSE = new PacketType(PROTOCOL, SENDER, 0x3E, "PongResponse");
|
||||
public static final PacketType AUTO_RECIPE = new PacketType(PROTOCOL, SENDER, 0x3F, "PlaceGhostRecipe", "AutoRecipe", "SPacketPlaceGhostRecipe");
|
||||
public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x40, "PlayerAbilities", "Abilities", "SPacketPlayerAbilities");
|
||||
public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x41, "PlayerChat", "Chat", "SPacketChat");
|
||||
public static final PacketType PLAYER_COMBAT_END = new PacketType(PROTOCOL, SENDER, 0x42, "PlayerCombatEnd");
|
||||
public static final PacketType PLAYER_COMBAT_ENTER = new PacketType(PROTOCOL, SENDER, 0x43, "PlayerCombatEnter");
|
||||
public static final PacketType PLAYER_COMBAT_KILL = new PacketType(PROTOCOL, SENDER, 0x44, "PlayerCombatKill");
|
||||
public static final PacketType PLAYER_INFO_REMOVE = new PacketType(PROTOCOL, SENDER, 0x45, "PlayerInfoRemove");
|
||||
public static final PacketType PLAYER_INFO = new PacketType(PROTOCOL, SENDER, 0x46, "PlayerInfoUpdate", "PlayerInfo");
|
||||
public static final PacketType LOOK_AT = new PacketType(PROTOCOL, SENDER, 0x47, "PlayerLookAt", "LookAt", "SPacketPlayerPosLook");
|
||||
public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x48, "PlayerPosition", "Position");
|
||||
public static final PacketType PLAYER_ROTATION = new PacketType(PROTOCOL, SENDER, 0x49, "PlayerRotation");
|
||||
public static final PacketType RECIPE_BOOK_ADD = new PacketType(PROTOCOL, SENDER, 0x4A, "RecipeBookAdd");
|
||||
public static final PacketType RECIPE_BOOK_REMOVE = new PacketType(PROTOCOL, SENDER, 0x4B, "RecipeBookRemove");
|
||||
public static final PacketType RECIPE_BOOK_SETTINGS = new PacketType(PROTOCOL, SENDER, 0x4C, "RecipeBookSettings");
|
||||
public static final PacketType ENTITY_DESTROY = new PacketType(PROTOCOL, SENDER, 0x4D, "RemoveEntities", "EntityDestroy", "SPacketDestroyEntities");
|
||||
public static final PacketType REMOVE_ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x4E, "RemoveMobEffect", "RemoveEntityEffect", "SPacketRemoveEntityEffect");
|
||||
public static final PacketType RESET_SCORE = new PacketType(PROTOCOL, SENDER, 0x4F, "ResetScore", "ResetScorePacket");
|
||||
public static final PacketType REMOVE_RESOURCE_PACK = new PacketType(PROTOCOL, SENDER, 0x50, "ResourcePackPop", "ResourcePackPopPacket");
|
||||
public static final PacketType ADD_RESOURCE_PACK = new PacketType(PROTOCOL, SENDER, 0x51, "ResourcePackPush", "ResourcePackPushPacket");
|
||||
public static final PacketType RESPAWN = new PacketType(PROTOCOL, SENDER, 0x52, "Respawn", "SPacketRespawn");
|
||||
public static final PacketType ENTITY_HEAD_ROTATION = new PacketType(PROTOCOL, SENDER, 0x53, "RotateHead", "EntityHeadRotation", "SPacketEntityHeadLook");
|
||||
public static final PacketType MULTI_BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x54, "SectionBlocksUpdate", "MultiBlockChange", "SPacketMultiBlockChange");
|
||||
public static final PacketType SELECT_ADVANCEMENT_TAB = new PacketType(PROTOCOL, SENDER, 0x55, "SelectAdvancementsTab", "SelectAdvancementTab", "SPacketSelectAdvancementsTab");
|
||||
public static final PacketType SERVER_DATA = new PacketType(PROTOCOL, SENDER, 0x56, "ServerData");
|
||||
public static final PacketType SET_ACTION_BAR_TEXT = new PacketType(PROTOCOL, SENDER, 0x57, "SetActionBarText");
|
||||
public static final PacketType SET_BORDER_CENTER = new PacketType(PROTOCOL, SENDER, 0x58, "SetBorderCenter");
|
||||
public static final PacketType SET_BORDER_LERP_SIZE = new PacketType(PROTOCOL, SENDER, 0x59, "SetBorderLerpSize");
|
||||
public static final PacketType SET_BORDER_SIZE = new PacketType(PROTOCOL, SENDER, 0x5A, "SetBorderSize");
|
||||
public static final PacketType SET_BORDER_WARNING_DELAY = new PacketType(PROTOCOL, SENDER, 0x5B, "SetBorderWarningDelay");
|
||||
public static final PacketType SET_BORDER_WARNING_DISTANCE = new PacketType(PROTOCOL, SENDER, 0x5C, "SetBorderWarningDistance");
|
||||
public static final PacketType CAMERA = new PacketType(PROTOCOL, SENDER, 0x5D, "SetCamera", "Camera", "SPacketCamera");
|
||||
public static final PacketType VIEW_CENTRE = new PacketType(PROTOCOL, SENDER, 0x5E, "SetChunkCacheCenter", "ViewCentre");
|
||||
public static final PacketType VIEW_DISTANCE = new PacketType(PROTOCOL, SENDER, 0x5F, "SetChunkCacheRadius", "ViewDistance");
|
||||
public static final PacketType SET_CURSOR_ITEM = new PacketType(PROTOCOL, SENDER, 0x60, "SetCursorItem");
|
||||
public static final PacketType SPAWN_POSITION = new PacketType(PROTOCOL, SENDER, 0x61, "SetDefaultSpawnPosition", "SpawnPosition", "SPacketSpawnPosition");
|
||||
public static final PacketType SCOREBOARD_DISPLAY_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x62, "SetDisplayObjective", "ScoreboardDisplayObjective", "SPacketDisplayObjective");
|
||||
public static final PacketType ENTITY_METADATA = new PacketType(PROTOCOL, SENDER, 0x63, "SetEntityData", "EntityMetadata", "SPacketEntityMetadata");
|
||||
public static final PacketType ATTACH_ENTITY = new PacketType(PROTOCOL, SENDER, 0x64, "SetEntityLink", "AttachEntity", "SPacketEntityAttach");
|
||||
public static final PacketType ENTITY_VELOCITY = new PacketType(PROTOCOL, SENDER, 0x65, "SetEntityMotion", "EntityVelocity", "SPacketEntityVelocity");
|
||||
public static final PacketType ENTITY_EQUIPMENT = new PacketType(PROTOCOL, SENDER, 0x66, "SetEquipment", "EntityEquipment", "SPacketEntityEquipment");
|
||||
public static final PacketType EXPERIENCE = new PacketType(PROTOCOL, SENDER, 0x67, "SetExperience", "Experience", "SPacketSetExperience");
|
||||
public static final PacketType UPDATE_HEALTH = new PacketType(PROTOCOL, SENDER, 0x68, "SetHealth", "UpdateHealth", "SPacketUpdateHealth");
|
||||
public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x69, "SetHeldSlot", "SetCarriedItem", "HeldItemSlot", "SPacketHeldItemChange");
|
||||
public static final PacketType SCOREBOARD_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x6A, "SetObjective", "ScoreboardObjective", "SPacketScoreboardObjective");
|
||||
public static final PacketType MOUNT = new PacketType(PROTOCOL, SENDER, 0x6B, "SetPassengers", "Mount", "SPacketSetPassengers");
|
||||
public static final PacketType SET_PLAYER_INVENTORY = new PacketType(PROTOCOL, SENDER, 0x6C, "SetPlayerInventory");
|
||||
public static final PacketType SCOREBOARD_TEAM = new PacketType(PROTOCOL, SENDER, 0x6D, "SetPlayerTeam", "ScoreboardTeam", "SPacketTeams");
|
||||
public static final PacketType SCOREBOARD_SCORE = new PacketType(PROTOCOL, SENDER, 0x6E, "SetScore", "ScoreboardScore", "SPacketUpdateScore");
|
||||
public static final PacketType UPDATE_SIMULATION_DISTANCE = new PacketType(PROTOCOL, SENDER, 0x6F, "SetSimulationDistance");
|
||||
public static final PacketType SET_SUBTITLE_TEXT = new PacketType(PROTOCOL, SENDER, 0x70, "SetSubtitleText");
|
||||
public static final PacketType UPDATE_TIME = new PacketType(PROTOCOL, SENDER, 0x71, "SetTime", "UpdateTime", "SPacketTimeUpdate");
|
||||
public static final PacketType SET_TITLE_TEXT = new PacketType(PROTOCOL, SENDER, 0x72, "SetTitleText");
|
||||
public static final PacketType SET_TITLES_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x73, "SetTitlesAnimation");
|
||||
public static final PacketType ENTITY_SOUND = new PacketType(PROTOCOL, SENDER, 0x74, "SoundEntity", "EntitySound", "SPacketSoundEffect");
|
||||
public static final PacketType NAMED_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x75, "Sound", "NamedSoundEffect");
|
||||
public static final PacketType START_CONFIGURATION = new PacketType(PROTOCOL, SENDER, 0x76, "StartConfiguration");
|
||||
public static final PacketType STOP_SOUND = new PacketType(PROTOCOL, SENDER, 0x77, "StopSound");
|
||||
public static final PacketType STORE_COOKIE = new PacketType(PROTOCOL, SENDER, 0x78, "StoreCookie");
|
||||
public static final PacketType SYSTEM_CHAT = new PacketType(PROTOCOL, SENDER, 0x79, "SystemChat");
|
||||
public static final PacketType PLAYER_LIST_HEADER_FOOTER = new PacketType(PROTOCOL, SENDER, 0x7A, "TabList", "PlayerListHeaderFooter", "SPacketPlayerListHeaderFooter");
|
||||
public static final PacketType NBT_QUERY = new PacketType(PROTOCOL, SENDER, 0x7B, "TagQuery", "NBTQuery");
|
||||
public static final PacketType COLLECT = new PacketType(PROTOCOL, SENDER, 0x7C, "TakeItemEntity", "Collect", "SPacketCollectItem");
|
||||
public static final PacketType ENTITY_TELEPORT = new PacketType(PROTOCOL, SENDER, 0x7D, "TeleportEntity", "EntityTeleport", "SPacketEntityTeleport");
|
||||
public static final PacketType TEST_INSTANCE_BLOCK_STATUS = new PacketType(PROTOCOL, SENDER, 0x7E, "ClientboundTestInstanceBlockStatus");
|
||||
public static final PacketType TICKING_STATE = new PacketType(PROTOCOL, SENDER, 0x7F, "TickingState", "TickingStatePacket");
|
||||
public static final PacketType TICKING_STEP_STATE = new PacketType(PROTOCOL, SENDER, 0x80, "TickingStep", "TickingStepPacket");
|
||||
public static final PacketType TRANSFER = new PacketType(PROTOCOL, SENDER, 0x81, "Transfer");
|
||||
public static final PacketType ADVANCEMENTS = new PacketType(PROTOCOL, SENDER, 0x82, "UpdateAdvancements", "Advancements", "SPacketAdvancementInfo");
|
||||
public static final PacketType UPDATE_ATTRIBUTES = new PacketType(PROTOCOL, SENDER, 0x83, "UpdateAttributes", "SPacketEntityProperties");
|
||||
public static final PacketType ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x84, "UpdateMobEffect", "EntityEffect", "SPacketEntityEffect");
|
||||
public static final PacketType RECIPE_UPDATE = new PacketType(PROTOCOL, SENDER, 0x85, "UpdateRecipes", "RecipeUpdate");
|
||||
public static final PacketType TAGS = new PacketType(PROTOCOL, SENDER, 0x86, "UpdateTags", "Tags");
|
||||
public static final PacketType PROJECTILE_POWER = new PacketType(PROTOCOL, SENDER, 0x87, "ProjectilePower");
|
||||
public static final PacketType REPORT_DETAILS = new PacketType(PROTOCOL, SENDER, 0x88, "CustomReportDetails");
|
||||
public static final PacketType SERVER_LINKS = new PacketType(PROTOCOL, SENDER, 0x89, "ServerLinks");
|
||||
public static final PacketType TRACKED_WAYPOINT = new PacketType(PROTOCOL, SENDER, 0x8A, "TrackedWaypoint");
|
||||
public static final PacketType CLEAR_DIALOG = new PacketType(PROTOCOL, SENDER, 0x8B, "ClearDialog");
|
||||
public static final PacketType SHOW_DIALOG = new PacketType(PROTOCOL, SENDER, 0x8C, "ShowDialog");
|
||||
|
||||
/**
|
||||
* @deprecated Removed in 1.9
|
||||
@@ -416,7 +423,6 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
||||
*/
|
||||
@Deprecated
|
||||
public static final PacketType SPAWN_ENTITY_EXPERIENCE_ORB = new PacketType(PROTOCOL, SENDER, 232, "AddExperienceOrb", "SpawnEntityExperienceOrb", "SPacketSpawnExperienceOrb");
|
||||
|
||||
|
||||
private static final Server INSTANCE = new Server();
|
||||
|
||||
@@ -439,71 +445,74 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
||||
private static final Sender SENDER = Sender.CLIENT;
|
||||
|
||||
public static final PacketType TELEPORT_ACCEPT = new PacketType(PROTOCOL, SENDER, 0x00, "AcceptTeleportation", "TeleportAccept", "CPacketConfirmTeleport");
|
||||
public static final PacketType TILE_NBT_QUERY = new PacketType(PROTOCOL, SENDER, 0x01, "BlockEntityTagQuery", "TileNBTQuery");
|
||||
public static final PacketType SELECT_BUNDLE_ITEM = new PacketType(PROTOCOL, SENDER, 0x02, "SelectBundleItem");
|
||||
public static final PacketType DIFFICULTY_CHANGE = new PacketType(PROTOCOL, SENDER, 0x03, "ChangeDifficulty", "DifficultyChange");
|
||||
public static final PacketType CHANGE_GAME_MODE = new PacketType(PROTOCOL, SENDER, 0x04, "ChangeGameMode");
|
||||
public static final PacketType CHAT_ACK = new PacketType(PROTOCOL, SENDER, 0x05, "ChatAck");
|
||||
public static final PacketType CHAT_COMMAND = new PacketType(PROTOCOL, SENDER, 0x06, "ChatCommand");
|
||||
public static final PacketType CHAT_COMMAND_SIGNED = new PacketType(PROTOCOL, SENDER, 0x07, "ChatCommandSigned");
|
||||
public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x08, "Chat", "CPacketChatMessage");
|
||||
public static final PacketType CHAT_SESSION_UPDATE = new PacketType(PROTOCOL, SENDER, 0x09, "ChatSessionUpdate");
|
||||
public static final PacketType CHUNK_BATCH_RECEIVED = new PacketType(PROTOCOL, SENDER, 0x0A, "ChunkBatchReceived");
|
||||
public static final PacketType CLIENT_COMMAND = new PacketType(PROTOCOL, SENDER, 0x0B, "ClientCommand", "CPacketClientStatus");
|
||||
public static final PacketType CLIENT_TICK_END = new PacketType(PROTOCOL, SENDER, 0x0C, "ClientTickEnd");
|
||||
public static final PacketType SETTINGS = new PacketType(PROTOCOL, SENDER, 0x0D, "ClientInformation", "Settings", "CPacketClientSettings");
|
||||
public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x0E, "CommandSuggestion", "TabComplete", "CPacketTabComplete");
|
||||
public static final PacketType CONFIGURATION_ACK = new PacketType(PROTOCOL, SENDER, 0x0F, "ConfigurationAcknowledged");
|
||||
public static final PacketType ENCHANT_ITEM = new PacketType(PROTOCOL, SENDER, 0x10, "ContainerButtonClick", "EnchantItem", "CPacketEnchantItem");
|
||||
public static final PacketType WINDOW_CLICK = new PacketType(PROTOCOL, SENDER, 0x11, "ContainerClick", "WindowClick", "CPacketClickWindow");
|
||||
public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x12, "ContainerClose", "CloseWindow", "CPacketCloseWindow");
|
||||
public static final PacketType CONTAINER_SLOT_STATE_CHANGED = new PacketType(PROTOCOL, SENDER, 0x13, "ContainerSlotStateChanged", "ContainerSlotStateChangedPacket");
|
||||
public static final PacketType COOKIE_RESPONSE = new PacketType(PROTOCOL, SENDER, 0x14, "CookieResponse");
|
||||
public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x15, "CustomPayload", "CPacketCustomPayload");
|
||||
public static final PacketType DEBUG_SAMPLE_SUBSCRIPTION = new PacketType(PROTOCOL, SENDER, 0x16, "DebugSampleSubscription");
|
||||
public static final PacketType B_EDIT = new PacketType(PROTOCOL, SENDER, 0x17, "EditBook", "BEdit");
|
||||
public static final PacketType ENTITY_NBT_QUERY = new PacketType(PROTOCOL, SENDER, 0x18, "EntityTagQuery", "EntityNBTQuery");
|
||||
public static final PacketType USE_ENTITY = new PacketType(PROTOCOL, SENDER, 0x19, "Interact", "UseEntity", "CPacketUseEntity");
|
||||
public static final PacketType JIGSAW_GENERATE = new PacketType(PROTOCOL, SENDER, 0x1A, "JigsawGenerate");
|
||||
public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x1B, "KeepAlive", "CPacketKeepAlive");
|
||||
public static final PacketType DIFFICULTY_LOCK = new PacketType(PROTOCOL, SENDER, 0x1C, "LockDifficulty", "DifficultyLock");
|
||||
public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x1D, "net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos", "Flying$Position", "Flying$PacketPlayInPosition", "CPacketPlayer$Position");
|
||||
public static final PacketType POSITION_LOOK = new PacketType(PROTOCOL, SENDER, 0x1E, "net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot", "Flying$PositionLook", "Flying$PacketPlayInPositionLook", "CPacketPlayer$PositionRotation");
|
||||
public static final PacketType LOOK = new PacketType(PROTOCOL, SENDER, 0x1F, "net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot", "Flying$Look", "Flying$PacketPlayInLook", "CPacketPlayer$Rotation");
|
||||
public static final PacketType GROUND = new PacketType(PROTOCOL, SENDER, 0x20, "net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$StatusOnly", "Flying$d");
|
||||
public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x21, "MoveVehicle", "VehicleMove", "CPacketVehicleMove");
|
||||
public static final PacketType BOAT_MOVE = new PacketType(PROTOCOL, SENDER, 0x22, "PaddleBoat", "BoatMove", "CPacketSteerBoat");
|
||||
public static final PacketType PICK_ITEM_FROM_BLOCK = new PacketType(PROTOCOL, SENDER, 0x23, "PickItemFromBlock");
|
||||
public static final PacketType PICK_ITEM = new PacketType(PROTOCOL, SENDER, 0x24, "PickItemFromEntity", "PickItem");
|
||||
public static final PacketType PING_REQUEST = new PacketType(PROTOCOL, SENDER, 0x25, "PingRequest");
|
||||
public static final PacketType AUTO_RECIPE = new PacketType(PROTOCOL, SENDER, 0x26, "PlaceRecipe", "AutoRecipe", "CPacketPlaceRecipe");
|
||||
public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x27, "PlayerAbilities", "Abilities", "CPacketPlayerAbilities");
|
||||
public static final PacketType BLOCK_DIG = new PacketType(PROTOCOL, SENDER, 0x28, "PlayerAction", "BlockDig", "CPacketPlayerDigging");
|
||||
public static final PacketType ENTITY_ACTION = new PacketType(PROTOCOL, SENDER, 0x29, "PlayerCommand", "EntityAction", "CPacketEntityAction");
|
||||
public static final PacketType STEER_VEHICLE = new PacketType(PROTOCOL, SENDER, 0x2A, "PlayerInput", "SteerVehicle", "CPacketInput");
|
||||
public static final PacketType PLAYER_LOADED = new PacketType(PROTOCOL, SENDER, 0x2B, "PlayerLoaded");
|
||||
public static final PacketType PONG = new PacketType(PROTOCOL, SENDER, 0x2C, "Pong");
|
||||
public static final PacketType RECIPE_SETTINGS = new PacketType(PROTOCOL, SENDER, 0x2D, "RecipeBookChangeSettings", "RecipeSettings");
|
||||
public static final PacketType RECIPE_DISPLAYED = new PacketType(PROTOCOL, SENDER, 0x2E, "RecipeBookSeenRecipe", "RecipeDisplayed", "CPacketRecipeInfo");
|
||||
public static final PacketType ITEM_NAME = new PacketType(PROTOCOL, SENDER, 0x2F, "RenameItem", "ItemName");
|
||||
public static final PacketType RESOURCE_PACK_STATUS = new PacketType(PROTOCOL, SENDER, 0x30, "ResourcePack", "ResourcePackStatus", "CPacketResourcePackStatus");
|
||||
public static final PacketType ADVANCEMENTS = new PacketType(PROTOCOL, SENDER, 0x31, "SeenAdvancements", "Advancements", "CPacketSeenAdvancements");
|
||||
public static final PacketType TR_SEL = new PacketType(PROTOCOL, SENDER, 0x32, "SelectTrade", "TrSel");
|
||||
public static final PacketType BEACON = new PacketType(PROTOCOL, SENDER, 0x33, "SetBeacon", "Beacon");
|
||||
public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x34, "SetCarriedItem", "HeldItemSlot", "CPacketHeldItemChange");
|
||||
public static final PacketType SET_COMMAND_BLOCK = new PacketType(PROTOCOL, SENDER, 0x35, "SetCommandBlock");
|
||||
public static final PacketType SET_COMMAND_MINECART = new PacketType(PROTOCOL, SENDER, 0x36, "SetCommandMinecart");
|
||||
public static final PacketType SET_CREATIVE_SLOT = new PacketType(PROTOCOL, SENDER, 0x37, "SetCreativeModeSlot", "SetCreativeSlot", "CPacketCreativeInventoryAction");
|
||||
public static final PacketType SET_JIGSAW = new PacketType(PROTOCOL, SENDER, 0x38, "SetJigsawBlock", "SetJigsaw");
|
||||
public static final PacketType STRUCT = new PacketType(PROTOCOL, SENDER, 0x39, "SetStructureBlock", "Struct");
|
||||
public static final PacketType SET_TEST_BLOCK = new PacketType(PROTOCOL, SENDER, 0x3A, "SetTestBlock");
|
||||
public static final PacketType UPDATE_SIGN = new PacketType(PROTOCOL, SENDER, 0x3B, "SignUpdate", "UpdateSign", "CPacketUpdateSign");
|
||||
public static final PacketType ARM_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x3C, "Swing", "ArmAnimation", "CPacketAnimation");
|
||||
public static final PacketType SPECTATE = new PacketType(PROTOCOL, SENDER, 0x3D, "TeleportToEntity", "Spectate", "CPacketSpectate");
|
||||
public static final PacketType TEST_INSTANCE_BLOCK_ACTION = new PacketType(PROTOCOL, SENDER, 0x3E, "TestInstanceBlockAction");
|
||||
public static final PacketType USE_ITEM_ON = new PacketType(PROTOCOL, SENDER, 0x3F, "UseItemOn", "BlockPlace", "CPacketPlayerTryUseItemOnBlock");
|
||||
public static final PacketType USE_ITEM = new PacketType(PROTOCOL, SENDER, 0x40, "UseItem", "CPacketPlayerTryUseItem");
|
||||
public static final PacketType CUSTOM_CLICK_ACTION = new PacketType(PROTOCOL, SENDER, 0x41, "CustomClickAction");
|
||||
public static final PacketType ATTACK = new PacketType(PROTOCOL, SENDER, 0x01, "Attack");
|
||||
public static final PacketType TILE_NBT_QUERY = new PacketType(PROTOCOL, SENDER, 0x02, "BlockEntityTagQuery", "TileNBTQuery");
|
||||
public static final PacketType SELECT_BUNDLE_ITEM = new PacketType(PROTOCOL, SENDER, 0x03, "SelectBundleItem");
|
||||
public static final PacketType DIFFICULTY_CHANGE = new PacketType(PROTOCOL, SENDER, 0x04, "ChangeDifficulty", "DifficultyChange");
|
||||
public static final PacketType CHANGE_GAME_MODE = new PacketType(PROTOCOL, SENDER, 0x05, "ChangeGameMode");
|
||||
public static final PacketType CHAT_ACK = new PacketType(PROTOCOL, SENDER, 0x06, "ChatAck");
|
||||
public static final PacketType CHAT_COMMAND = new PacketType(PROTOCOL, SENDER, 0x07, "ChatCommand");
|
||||
public static final PacketType CHAT_COMMAND_SIGNED = new PacketType(PROTOCOL, SENDER, 0x08, "ChatCommandSigned");
|
||||
public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x09, "Chat", "CPacketChatMessage");
|
||||
public static final PacketType CHAT_SESSION_UPDATE = new PacketType(PROTOCOL, SENDER, 0x0A, "ChatSessionUpdate");
|
||||
public static final PacketType CHUNK_BATCH_RECEIVED = new PacketType(PROTOCOL, SENDER, 0x0B, "ChunkBatchReceived");
|
||||
public static final PacketType CLIENT_COMMAND = new PacketType(PROTOCOL, SENDER, 0x0C, "ClientCommand", "CPacketClientStatus");
|
||||
public static final PacketType CLIENT_TICK_END = new PacketType(PROTOCOL, SENDER, 0x0D, "ClientTickEnd");
|
||||
public static final PacketType SETTINGS = new PacketType(PROTOCOL, SENDER, 0x0E, "ClientInformation", "Settings", "CPacketClientSettings");
|
||||
public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x0F, "CommandSuggestion", "TabComplete", "CPacketTabComplete");
|
||||
public static final PacketType CONFIGURATION_ACK = new PacketType(PROTOCOL, SENDER, 0x10, "ConfigurationAcknowledged");
|
||||
public static final PacketType ENCHANT_ITEM = new PacketType(PROTOCOL, SENDER, 0x11, "ContainerButtonClick", "EnchantItem", "CPacketEnchantItem");
|
||||
public static final PacketType WINDOW_CLICK = new PacketType(PROTOCOL, SENDER, 0x12, "ContainerClick", "WindowClick", "CPacketClickWindow");
|
||||
public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x13, "ContainerClose", "CloseWindow", "CPacketCloseWindow");
|
||||
public static final PacketType CONTAINER_SLOT_STATE_CHANGED = new PacketType(PROTOCOL, SENDER, 0x14, "ContainerSlotStateChanged", "ContainerSlotStateChangedPacket");
|
||||
public static final PacketType COOKIE_RESPONSE = new PacketType(PROTOCOL, SENDER, 0x15, "CookieResponse");
|
||||
public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x16, "CustomPayload", "CPacketCustomPayload");
|
||||
public static final PacketType DEBUG_SUBSCRIPTION_REQUEST = new PacketType(PROTOCOL, SENDER, 0x17, "DebugSubscriptionRequest");
|
||||
public static final PacketType B_EDIT = new PacketType(PROTOCOL, SENDER, 0x18, "EditBook", "BEdit");
|
||||
public static final PacketType ENTITY_NBT_QUERY = new PacketType(PROTOCOL, SENDER, 0x19, "EntityTagQuery", "EntityNBTQuery");
|
||||
public static final PacketType USE_ENTITY = new PacketType(PROTOCOL, SENDER, 0x1A, "Interact", "UseEntity", "CPacketUseEntity");
|
||||
public static final PacketType JIGSAW_GENERATE = new PacketType(PROTOCOL, SENDER, 0x1B, "JigsawGenerate");
|
||||
public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x1C, "KeepAlive", "CPacketKeepAlive");
|
||||
public static final PacketType DIFFICULTY_LOCK = new PacketType(PROTOCOL, SENDER, 0x1D, "LockDifficulty", "DifficultyLock");
|
||||
public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x1E, "net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos", "Flying$Position", "Flying$PacketPlayInPosition", "CPacketPlayer$Position");
|
||||
public static final PacketType POSITION_LOOK = new PacketType(PROTOCOL, SENDER, 0x1F, "net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot", "Flying$PositionLook", "Flying$PacketPlayInPositionLook", "CPacketPlayer$PositionRotation");
|
||||
public static final PacketType LOOK = new PacketType(PROTOCOL, SENDER, 0x20, "net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot", "Flying$Look", "Flying$PacketPlayInLook", "CPacketPlayer$Rotation");
|
||||
public static final PacketType GROUND = new PacketType(PROTOCOL, SENDER, 0x21, "net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$StatusOnly", "Flying$d");
|
||||
public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x22, "MoveVehicle", "VehicleMove", "CPacketVehicleMove");
|
||||
public static final PacketType BOAT_MOVE = new PacketType(PROTOCOL, SENDER, 0x23, "PaddleBoat", "BoatMove", "CPacketSteerBoat");
|
||||
public static final PacketType PICK_ITEM_FROM_BLOCK = new PacketType(PROTOCOL, SENDER, 0x24, "PickItemFromBlock");
|
||||
public static final PacketType PICK_ITEM = new PacketType(PROTOCOL, SENDER, 0x25, "PickItemFromEntity", "PickItem");
|
||||
public static final PacketType PING_REQUEST = new PacketType(PROTOCOL, SENDER, 0x26, "PingRequest");
|
||||
public static final PacketType AUTO_RECIPE = new PacketType(PROTOCOL, SENDER, 0x27, "PlaceRecipe", "AutoRecipe", "CPacketPlaceRecipe");
|
||||
public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x28, "PlayerAbilities", "Abilities", "CPacketPlayerAbilities");
|
||||
public static final PacketType BLOCK_DIG = new PacketType(PROTOCOL, SENDER, 0x29, "PlayerAction", "BlockDig", "CPacketPlayerDigging");
|
||||
public static final PacketType ENTITY_ACTION = new PacketType(PROTOCOL, SENDER, 0x2A, "PlayerCommand", "EntityAction", "CPacketEntityAction");
|
||||
public static final PacketType STEER_VEHICLE = new PacketType(PROTOCOL, SENDER, 0x2B, "PlayerInput", "SteerVehicle", "CPacketInput");
|
||||
public static final PacketType PLAYER_LOADED = new PacketType(PROTOCOL, SENDER, 0x2C, "PlayerLoaded");
|
||||
public static final PacketType PONG = new PacketType(PROTOCOL, SENDER, 0x2D, "Pong");
|
||||
public static final PacketType RECIPE_SETTINGS = new PacketType(PROTOCOL, SENDER, 0x2E, "RecipeBookChangeSettings", "RecipeSettings");
|
||||
public static final PacketType RECIPE_DISPLAYED = new PacketType(PROTOCOL, SENDER, 0x2F, "RecipeBookSeenRecipe", "RecipeDisplayed", "CPacketRecipeInfo");
|
||||
public static final PacketType ITEM_NAME = new PacketType(PROTOCOL, SENDER, 0x30, "RenameItem", "ItemName");
|
||||
public static final PacketType RESOURCE_PACK_STATUS = new PacketType(PROTOCOL, SENDER, 0x31, "ResourcePack", "ResourcePackStatus", "CPacketResourcePackStatus");
|
||||
public static final PacketType ADVANCEMENTS = new PacketType(PROTOCOL, SENDER, 0x32, "SeenAdvancements", "Advancements", "CPacketSeenAdvancements");
|
||||
public static final PacketType TR_SEL = new PacketType(PROTOCOL, SENDER, 0x33, "SelectTrade", "TrSel");
|
||||
public static final PacketType BEACON = new PacketType(PROTOCOL, SENDER, 0x34, "SetBeacon", "Beacon");
|
||||
public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x35, "SetCarriedItem", "HeldItemSlot", "CPacketHeldItemChange");
|
||||
public static final PacketType SET_COMMAND_BLOCK = new PacketType(PROTOCOL, SENDER, 0x36, "SetCommandBlock");
|
||||
public static final PacketType SET_COMMAND_MINECART = new PacketType(PROTOCOL, SENDER, 0x37, "SetCommandMinecart");
|
||||
public static final PacketType SET_CREATIVE_SLOT = new PacketType(PROTOCOL, SENDER, 0x38, "SetCreativeModeSlot", "SetCreativeSlot", "CPacketCreativeInventoryAction");
|
||||
public static final PacketType SET_GAME_RULE = new PacketType(PROTOCOL, SENDER, 0x39, "SetGameRule");
|
||||
public static final PacketType SET_JIGSAW = new PacketType(PROTOCOL, SENDER, 0x3A, "SetJigsawBlock", "SetJigsaw");
|
||||
public static final PacketType STRUCT = new PacketType(PROTOCOL, SENDER, 0x3B, "SetStructureBlock", "Struct");
|
||||
public static final PacketType SET_TEST_BLOCK = new PacketType(PROTOCOL, SENDER, 0x3C, "SetTestBlock");
|
||||
public static final PacketType UPDATE_SIGN = new PacketType(PROTOCOL, SENDER, 0x3D, "SignUpdate", "UpdateSign", "CPacketUpdateSign");
|
||||
public static final PacketType SPECTATE_ENTITY = new PacketType(PROTOCOL, SENDER, 0x3E, "SpectatorAction", "SpectateEntity");
|
||||
public static final PacketType ARM_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x3F, "Swing", "ArmAnimation", "CPacketAnimation");
|
||||
public static final PacketType SPECTATE = new PacketType(PROTOCOL, SENDER, 0x40, "TeleportToEntity", "Spectate", "CPacketSpectate");
|
||||
public static final PacketType TEST_INSTANCE_BLOCK_ACTION = new PacketType(PROTOCOL, SENDER, 0x41, "TestInstanceBlockAction");
|
||||
public static final PacketType USE_ITEM_ON = new PacketType(PROTOCOL, SENDER, 0x42, "UseItemOn", "BlockPlace", "CPacketPlayerTryUseItemOnBlock");
|
||||
public static final PacketType USE_ITEM = new PacketType(PROTOCOL, SENDER, 0x43, "UseItem", "CPacketPlayerTryUseItem");
|
||||
public static final PacketType CUSTOM_CLICK_ACTION = new PacketType(PROTOCOL, SENDER, 0x44, "CustomClickAction");
|
||||
|
||||
/**
|
||||
* @deprecated Removed in 1.17
|
||||
@@ -523,6 +532,12 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
||||
@Deprecated
|
||||
public static final PacketType CHAT_PREVIEW = new PacketType(PROTOCOL, SENDER, 253, "ChatPreview");
|
||||
|
||||
/**
|
||||
* deprecated Removed in 1.21.9
|
||||
*/
|
||||
@Deprecated
|
||||
public static final PacketType DEBUG_SAMPLE_SUBSCRIPTION = new PacketType(PROTOCOL, SENDER, 0x16, "DebugSampleSubscription");
|
||||
|
||||
/**
|
||||
* @deprecated Renamed to USE_ITEM_ON
|
||||
*/
|
||||
@@ -713,6 +728,7 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
||||
public static final PacketType SERVER_LINKS = new PacketType(PROTOCOL, SENDER, 0x10, "ServerLinks");
|
||||
public static final PacketType CLEAR_DIALOG = new PacketType(PROTOCOL, SENDER, 0x11, "ClearDialog");
|
||||
public static final PacketType SHOW_DIALOG = new PacketType(PROTOCOL, SENDER, 0x12, "ShowDialog");
|
||||
public static final PacketType CODE_OF_CONDUCT = new PacketType(PROTOCOL, SENDER, 0x13, "CodeOfConduct");
|
||||
|
||||
/**
|
||||
* @deprecated Removed in 1.20.4: replaced with new packets for removing and sending resource packs
|
||||
@@ -745,6 +761,7 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
||||
public static final PacketType RESOURCE_PACK_ACK = new PacketType(PROTOCOL, SENDER, 0x06, "ResourcePack");
|
||||
public static final PacketType SELECT_KNOWN_PACKS = new PacketType(PROTOCOL, SENDER, 0x07, "ServerboundSelectKnownPacks");
|
||||
public static final PacketType CUSTOM_CLICK_ACTION = new PacketType(PROTOCOL, SENDER, 0x08, "CustomClickAction");
|
||||
public static final PacketType ACCEPT_CODE_OF_CONDUCT = new PacketType(PROTOCOL, SENDER, 0x09, "AcceptCodeOfConduct");
|
||||
|
||||
private static final Client INSTANCE = new Client();
|
||||
|
||||
|
||||
@@ -35,12 +35,12 @@ public class ProtocolLibrary {
|
||||
/**
|
||||
* The maximum version ProtocolLib has been tested with.
|
||||
*/
|
||||
public static final String MAXIMUM_MINECRAFT_VERSION = "1.21.8";
|
||||
public static final String MAXIMUM_MINECRAFT_VERSION = "26.2";
|
||||
|
||||
/**
|
||||
* The date (with ISO 8601 or YYYY-MM-DD) when the most recent version (1.21.8) was released.
|
||||
* The date (with ISO 8601 or YYYY-MM-DD) when the most recent version (26.2) was released.
|
||||
*/
|
||||
public static final String MINECRAFT_LAST_RELEASE_DATE = "2025-07-17";
|
||||
public static final String MINECRAFT_LAST_RELEASE_DATE = "2026-06-16";
|
||||
|
||||
private static Plugin plugin;
|
||||
private static ProtocolConfig config;
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import com.comphenix.protocol.injector.collection.InboundPacketListenerSet;
|
||||
import com.comphenix.protocol.injector.collection.OutboundPacketListenerSet;
|
||||
import com.comphenix.protocol.injector.netty.Injector;
|
||||
import com.comphenix.protocol.scheduler.ProtocolScheduler;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -274,7 +275,7 @@ public class AsyncFilterManager implements AsynchronousManager {
|
||||
* @return TRUE if we are, FALSE otherwise.
|
||||
*/
|
||||
private boolean onMainThread() {
|
||||
return Thread.currentThread().getId() == mainThread.getId();
|
||||
return Thread.currentThread() == mainThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -347,8 +348,8 @@ public class AsyncFilterManager implements AsynchronousManager {
|
||||
* Construct a asynchronous marker with all the default values.
|
||||
* @return Asynchronous marker.
|
||||
*/
|
||||
public AsyncMarker createAsyncMarker() {
|
||||
return createAsyncMarker(AsyncMarker.DEFAULT_TIMEOUT_DELTA);
|
||||
public AsyncMarker createAsyncMarker(Injector injector) {
|
||||
return createAsyncMarker(injector, AsyncMarker.DEFAULT_TIMEOUT_DELTA);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,13 +357,13 @@ public class AsyncFilterManager implements AsynchronousManager {
|
||||
* @param timeoutDelta - how long (in ms) until the packet expire.
|
||||
* @return An async marker.
|
||||
*/
|
||||
public AsyncMarker createAsyncMarker(long timeoutDelta) {
|
||||
return createAsyncMarker(timeoutDelta, currentSendingIndex.incrementAndGet());
|
||||
public AsyncMarker createAsyncMarker(Injector injector, long timeoutDelta) {
|
||||
return createAsyncMarker(injector, timeoutDelta, currentSendingIndex.incrementAndGet());
|
||||
}
|
||||
|
||||
// Helper method
|
||||
private AsyncMarker createAsyncMarker(long timeoutDelta, long sendingIndex) {
|
||||
return new AsyncMarker(manager, sendingIndex, System.currentTimeMillis(), timeoutDelta);
|
||||
private AsyncMarker createAsyncMarker(Injector injector, long timeoutDelta, long sendingIndex) {
|
||||
return new AsyncMarker(injector, sendingIndex, System.currentTimeMillis(), timeoutDelta);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -538,7 +538,7 @@ public class AsyncListenerHandler {
|
||||
*/
|
||||
private void listenerLoop(int workerID) {
|
||||
// Danger, danger!
|
||||
if (Thread.currentThread().getId() == mainThread.getId())
|
||||
if (Thread.currentThread() == mainThread)
|
||||
throw new IllegalStateException("Do not call this method from the main thread.");
|
||||
if (cancelled)
|
||||
throw new IllegalStateException("Listener has been cancelled. Create a new listener instead.");
|
||||
|
||||
@@ -23,14 +23,18 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.comphenix.protocol.PacketStream;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolLogger;
|
||||
import com.comphenix.protocol.events.NetworkMarker;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.injector.netty.Injector;
|
||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||
import com.comphenix.protocol.reflect.FuzzyReflection;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
@@ -64,7 +68,7 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
|
||||
/**
|
||||
* The packet stream responsible for transmitting the packet when it's done processing.
|
||||
*/
|
||||
private transient PacketStream packetStream;
|
||||
private final Injector injector;
|
||||
|
||||
/**
|
||||
* Current list of async packet listeners.
|
||||
@@ -86,7 +90,7 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
|
||||
private volatile boolean processed;
|
||||
|
||||
// Whether or not the packet has been sent
|
||||
private volatile boolean transmitted;
|
||||
private final AtomicBoolean transmitted = new AtomicBoolean(false);
|
||||
|
||||
// Whether or not the asynchronous processing itself should be cancelled
|
||||
private volatile boolean asyncCancelled;
|
||||
@@ -109,11 +113,8 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
|
||||
* Create a container for asyncronous packets.
|
||||
* @param initialTime - the current time in milliseconds since 01.01.1970 00:00.
|
||||
*/
|
||||
AsyncMarker(PacketStream packetStream, long sendingIndex, long initialTime, long timeoutDelta) {
|
||||
if (packetStream == null)
|
||||
throw new IllegalArgumentException("packetStream cannot be NULL");
|
||||
|
||||
this.packetStream = packetStream;
|
||||
AsyncMarker(Injector injector, long sendingIndex, long initialTime, long timeoutDelta) {
|
||||
this.injector = Objects.requireNonNull(injector, "injector is nul");
|
||||
|
||||
// Timeout
|
||||
this.initialTime = initialTime;
|
||||
@@ -180,16 +181,18 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
|
||||
* Retrieve the packet stream responsible for transmitting this packet.
|
||||
* @return The packet stream.
|
||||
*/
|
||||
@Deprecated
|
||||
public PacketStream getPacketStream() {
|
||||
return packetStream;
|
||||
return ProtocolLibrary.getProtocolManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the output packet stream responsible for transmitting this packet.
|
||||
* @param packetStream - new output packet stream.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPacketStream(PacketStream packetStream) {
|
||||
this.packetStream = packetStream;
|
||||
// NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,7 +288,7 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
|
||||
* @return TRUE if it has been sent before, FALSE otherwise.
|
||||
*/
|
||||
public boolean isTransmitted() {
|
||||
return transmitted;
|
||||
return transmitted.get();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -383,13 +386,18 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
|
||||
* @throws IOException If the packet couldn't be sent.
|
||||
*/
|
||||
void sendPacket(PacketEvent event) throws IOException {
|
||||
if (event.isServerPacket()) {
|
||||
packetStream.sendServerPacket(event.getPlayer(), event.getPacket(), NetworkMarker.getNetworkMarker(event), false);
|
||||
} else {
|
||||
packetStream.receiveClientPacket(event.getPlayer(), event.getPacket(), NetworkMarker.getNetworkMarker(event),
|
||||
false);
|
||||
if (!this.transmitted.compareAndSet(false, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object handle = event.getPacket().getHandle();
|
||||
|
||||
if (event.isServerPacket()) {
|
||||
NetworkMarker marker = NetworkMarker.getNetworkMarker(event);
|
||||
this.injector.sendClientboundPacket(handle, marker, false);
|
||||
} else {
|
||||
this.injector.readServerboundPacket(handle);
|
||||
}
|
||||
transmitted = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,8 @@ import com.comphenix.protocol.error.Report;
|
||||
import com.comphenix.protocol.error.ReportType;
|
||||
import com.comphenix.protocol.events.ListeningWhitelist;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.MinMaxPriorityQueue;
|
||||
|
||||
@@ -209,7 +211,7 @@ class PacketProcessingQueue {
|
||||
|
||||
public void cleanupAll() {
|
||||
// Cancel all the threads and every listener
|
||||
for (AsyncListenerHandler handler : map.values()) {
|
||||
for (AsyncListenerHandler handler : ImmutableList.copyOf(map.values())) {
|
||||
handler.cancel();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ import com.comphenix.protocol.wrappers.WrappedLevelChunkData;
|
||||
import com.comphenix.protocol.wrappers.WrappedMessageSignature;
|
||||
import com.comphenix.protocol.wrappers.WrappedNumberFormat;
|
||||
import com.comphenix.protocol.wrappers.WrappedParticle;
|
||||
import com.comphenix.protocol.wrappers.WrappedPositionMoveRotation;
|
||||
import com.comphenix.protocol.wrappers.WrappedProfilePublicKey;
|
||||
import com.comphenix.protocol.wrappers.WrappedProfilePublicKey.WrappedProfileKeyData;
|
||||
import com.comphenix.protocol.wrappers.WrappedRegistrable;
|
||||
@@ -1297,6 +1298,20 @@ public abstract class AbstractStructure {
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a read/write structure for {@link WrappedPositionMoveRotation} (available since Minecraft 1.21.2).
|
||||
* <p>
|
||||
* This is used in packets such as {@code ENTITY_TELEPORT} and {@code ENTITY_POSITION_SYNC}.
|
||||
*
|
||||
* @return A modifier for PositionMoveRotation fields.
|
||||
*/
|
||||
public StructureModifier<WrappedPositionMoveRotation> getPositionMoveRotation() {
|
||||
return structureModifier.withType(
|
||||
MinecraftReflection.getPositionMoveRotationClass(),
|
||||
WrappedPositionMoveRotation.getConverter()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an equivalent converter for ItemStack arrays.
|
||||
* @author Kristian
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.comphenix.protocol.injector.PluginVerifier.VerificationResult;
|
||||
import com.comphenix.protocol.injector.collection.InboundPacketListenerSet;
|
||||
import com.comphenix.protocol.injector.collection.OutboundPacketListenerSet;
|
||||
import com.comphenix.protocol.injector.collection.PacketListenerSet;
|
||||
import com.comphenix.protocol.injector.netty.Injector;
|
||||
import com.comphenix.protocol.injector.netty.WirePacket;
|
||||
import com.comphenix.protocol.injector.netty.manager.NetworkManagerInjector;
|
||||
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
||||
@@ -151,29 +152,20 @@ public class PacketFilterManager implements ListenerManager, InternalManager {
|
||||
|
||||
@Override
|
||||
public void sendServerPacket(Player receiver, PacketContainer packet, NetworkMarker marker, boolean filters) {
|
||||
if (!this.closed) {
|
||||
// if we skip the packet events later when actually writing into the pipeline we at least notify all
|
||||
// monitor listeners before doing so - they will not be able to change the event tho
|
||||
if (!filters) {
|
||||
// ensure we are on the main thread if any listener requires that
|
||||
if (this.hasMainThreadListener(packet.getType()) && !this.server.isPrimaryThread()) {
|
||||
NetworkMarker copy = marker; // okay fine
|
||||
ProtocolLibrary.getScheduler().scheduleSyncDelayedTask(
|
||||
() -> this.sendServerPacket(receiver, packet, copy, false), 1L);
|
||||
return;
|
||||
}
|
||||
|
||||
// construct the event and post to all monitor listeners
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
|
||||
// A monitor listener should never modify a packet/event so we can simply invoke monitor listeners
|
||||
// independently of our injector pipeline
|
||||
if (!filters) {
|
||||
this.runMonitorListeners(packet, () -> {
|
||||
PacketEvent event = PacketEvent.fromServer(this, packet, marker, receiver, false);
|
||||
this.outboundListeners.invoke(event, ListenerPriority.MONITOR);
|
||||
|
||||
// update the marker of the event without accidentally constructing it
|
||||
marker = NetworkMarker.getNetworkMarker(event);
|
||||
}
|
||||
|
||||
// process outbound
|
||||
this.networkManagerInjector.getInjector(receiver).sendClientboundPacket(packet.getHandle(), marker, filters);
|
||||
});
|
||||
}
|
||||
|
||||
this.networkManagerInjector.getInjector(receiver).sendClientboundPacket(packet.getHandle(), marker, filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,34 +192,40 @@ public class PacketFilterManager implements ListenerManager, InternalManager {
|
||||
|
||||
@Override
|
||||
public void receiveClientPacket(Player sender, PacketContainer packet, NetworkMarker marker, boolean filters) {
|
||||
if (!this.closed) {
|
||||
// make sure we are on the main thread if any listener of the packet needs it
|
||||
if (this.hasMainThreadListener(packet.getType()) && !this.server.isPrimaryThread()) {
|
||||
ProtocolLibrary.getScheduler().runTask(
|
||||
() -> this.receiveClientPacket(sender, packet, marker, filters));
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure we are on the main thread if any listener of the packet needs it
|
||||
if (filters && this.requiresMainThread(packet)) {
|
||||
ProtocolLibrary.getScheduler().runTask(
|
||||
() -> this.receiveClientPacket(sender, packet, marker, filters));
|
||||
return;
|
||||
}
|
||||
|
||||
Object nmsPacket = packet.getHandle();
|
||||
|
||||
if (filters) {
|
||||
PacketEvent event = PacketEvent.fromClient(this, packet, marker, sender, false);
|
||||
this.invokeInboundPacketListeners(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object nmsPacket = packet.getHandle();
|
||||
// check to which listeners we need to post the packet
|
||||
if (filters) {
|
||||
// post to all listeners
|
||||
PacketEvent event = PacketEvent.fromClient(this.networkManagerInjector, packet, null, sender);
|
||||
this.invokeInboundPacketListeners(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// prevent possible de-sync
|
||||
nmsPacket = event.getPacket().getHandle();
|
||||
} else {
|
||||
// Prevent possible de-sync if the packet was replaced by a listener.
|
||||
nmsPacket = event.getPacket().getHandle();
|
||||
} else {
|
||||
// A monitor listener should never modify a packet/event so we can simply invoke monitor listeners
|
||||
// independently of our injector pipeline
|
||||
this.runMonitorListeners(packet, () -> {
|
||||
PacketEvent event = PacketEvent.fromClient(this, packet, marker, sender, false);
|
||||
this.inboundListeners.invoke(event, ListenerPriority.MONITOR);
|
||||
}
|
||||
|
||||
// post to the player inject, reset our cancel state change
|
||||
this.networkManagerInjector.getInjector(sender).readServerboundPacket(nmsPacket);
|
||||
});
|
||||
}
|
||||
|
||||
// post to the player inject, reset our cancel state change
|
||||
this.networkManagerInjector.getInjector(sender).readServerboundPacket(nmsPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -516,12 +514,25 @@ public class PacketFilterManager implements ListenerManager, InternalManager {
|
||||
this.postPacketToListeners(this.outboundListeners, event, true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean requiresMainThread(PacketContainer packet) {
|
||||
return this.hasMainThreadListener(packet.getType()) && !this.server.isPrimaryThread();
|
||||
}
|
||||
|
||||
private void runMonitorListeners(PacketContainer packet, Runnable notifyMonitor) {
|
||||
if (this.requiresMainThread(packet)) {
|
||||
ProtocolLibrary.getScheduler().runTask(notifyMonitor);
|
||||
} else {
|
||||
notifyMonitor.run();
|
||||
}
|
||||
}
|
||||
|
||||
private void postPacketToListeners(PacketListenerSet listeners, PacketEvent event, boolean outbound) {
|
||||
try {
|
||||
// append async marker if any async listener for the packet was registered
|
||||
if (this.asyncFilterManager.hasAsynchronousListeners(event)) {
|
||||
event.setAsyncMarker(this.asyncFilterManager.createAsyncMarker());
|
||||
Injector injector = this.networkManagerInjector.getInjector(event.getPlayer());
|
||||
event.setAsyncMarker(this.asyncFilterManager.createAsyncMarker(injector));
|
||||
}
|
||||
|
||||
// post to sync listeners
|
||||
|
||||
@@ -287,8 +287,8 @@ public class StructureCache {
|
||||
|
||||
if (registryByteBuf.isPresent()) {
|
||||
ConstructorAccessor accessor = Accessors.getConstructorAccessor(FuzzyReflection.fromClass(serializerBase, true).getConstructor(FuzzyMethodContract.newBuilder()
|
||||
.parameterDerivedOf(ByteBuf.class)
|
||||
.parameterDerivedOf(MinecraftReflection.getRegistryAccessClass())
|
||||
.parameterExactType(ByteBuf.class)
|
||||
.parameterExactType(MinecraftReflection.getRegistryAccessClass())
|
||||
.build()));
|
||||
TRICKED_DATA_SERIALIZER_BASE = (buf) -> accessor.invoke(buf, MinecraftRegistryAccess.get());
|
||||
} else {
|
||||
|
||||
+7
-5
@@ -58,11 +58,13 @@ public class OutboundPacketListenerSet extends PacketListenerSet {
|
||||
}
|
||||
}
|
||||
|
||||
if (packets.iterator().hasNext()) {
|
||||
event.getPacket().getPacketBundles().write(0, outPackets);
|
||||
} else {
|
||||
// cancel entire packet if each individual packet has been cancelled
|
||||
event.setCancelled(true);
|
||||
if (!event.isReadOnly()) {
|
||||
if (packets.iterator().hasNext()) {
|
||||
event.getPacket().getPacketBundles().write(0, outPackets);
|
||||
} else {
|
||||
// cancel entire packet if each individual packet has been cancelled
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-6
@@ -29,6 +29,7 @@ import com.comphenix.protocol.injector.NetworkProcessor;
|
||||
import com.comphenix.protocol.injector.netty.Injector;
|
||||
import com.comphenix.protocol.injector.netty.WirePacket;
|
||||
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
||||
import com.comphenix.protocol.injector.temporary.TemporaryPlayer;
|
||||
import com.comphenix.protocol.reflect.FuzzyReflection;
|
||||
import com.comphenix.protocol.reflect.accessors.Accessors;
|
||||
import com.comphenix.protocol.reflect.accessors.FieldAccessor;
|
||||
@@ -242,7 +243,7 @@ public class NettyChannelInjector implements Injector {
|
||||
this.uninject();
|
||||
|
||||
// remove any outgoing references
|
||||
this.channel.attr(INJECTOR).remove();
|
||||
this.channel.attr(INJECTOR).set(null);
|
||||
|
||||
// cleanup
|
||||
this.savedMarkers.clear();
|
||||
@@ -289,8 +290,7 @@ public class NettyChannelInjector implements Injector {
|
||||
|
||||
this.ensureInEventLoop(() -> {
|
||||
try {
|
||||
// try to invoke the method, this should normally not fail
|
||||
this.listenerInvoker.read(packet);
|
||||
this.channel.pipeline().context(INBOUND_INTERCEPTOR_NAME).fireChannelRead(packet);
|
||||
} catch (Exception exception) {
|
||||
this.errorReporter.reportWarning(this, Report.newBuilder(REPORT_CANNOT_READ_PACKET)
|
||||
.messageParam(packet, this.playerName)
|
||||
@@ -344,14 +344,15 @@ public class NettyChannelInjector implements Injector {
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
// if the player was already resolved there is no need to do further lookups
|
||||
if (this.player != null) {
|
||||
if (this.player != null && !(this.player instanceof TemporaryPlayer)) {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
// check if the name of the player is already known to the injector
|
||||
if (this.playerName != null) {
|
||||
this.player = Bukkit.getPlayerExact(this.playerName);
|
||||
if (this.player != null) {
|
||||
Player bukkitPlayer = Bukkit.getPlayerExact(this.playerName);
|
||||
if (bukkitPlayer != null) {
|
||||
this.player = bukkitPlayer;
|
||||
this.injectionFactory.cacheInjector(this.player, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelId;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelProgressivePromise;
|
||||
@@ -33,6 +34,11 @@ final class NettyChannelProxy implements Channel {
|
||||
this.injector = injector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelId id() {
|
||||
return this.delegate.id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventLoop eventLoop() {
|
||||
return this.eventLoop;
|
||||
@@ -238,6 +244,11 @@ final class NettyChannelProxy implements Channel {
|
||||
return this.delegate.attr(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> boolean hasAttr(AttributeKey<T> attributeKey) {
|
||||
return this.delegate.hasAttr(attributeKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull Channel o) {
|
||||
return this.delegate.compareTo(o);
|
||||
|
||||
+18
-1
@@ -10,11 +10,13 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import io.netty.channel.AbstractEventLoop;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.EventLoop;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.util.concurrent.AbstractEventExecutor;
|
||||
import io.netty.util.concurrent.EventExecutor;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.ProgressivePromise;
|
||||
@@ -25,7 +27,7 @@ import io.netty.util.concurrent.ScheduledFuture;
|
||||
* An abstract event loop implementation which delegates all calls to a given event loop, but proxies all calls which
|
||||
* schedule something on the event loop to methods which decide what should happen to the scheduled task.
|
||||
*/
|
||||
final class NettyEventLoopProxy implements EventLoop {
|
||||
final class NettyEventLoopProxy extends AbstractEventLoop {
|
||||
|
||||
private static final Callable<?> EMPTY_CALLABLE = () -> null;
|
||||
private static final Runnable EMPTY_RUNNABLE = () -> {
|
||||
@@ -236,6 +238,15 @@ final class NettyEventLoopProxy implements EventLoop {
|
||||
}
|
||||
}
|
||||
|
||||
// ShreddedPaper uses this method
|
||||
@Override
|
||||
public void lazyExecute(Runnable command) {
|
||||
Runnable proxied = this.proxyRunnable(command);
|
||||
if (proxied != null) {
|
||||
((AbstractEventExecutor)this.delegate).lazyExecute(proxied);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(Consumer<? super EventExecutor> action) {
|
||||
this.delegate.forEach(action);
|
||||
@@ -251,6 +262,12 @@ final class NettyEventLoopProxy implements EventLoop {
|
||||
return this.delegate.register(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture register(ChannelPromise channelPromise) {
|
||||
return this.delegate.register(channelPromise);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public ChannelFuture register(Channel channel, ChannelPromise promise) {
|
||||
return this.delegate.register(channel, promise);
|
||||
|
||||
+4
-25
@@ -14,13 +14,11 @@ import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
/**
|
||||
* This class facilitates the invocation of methods on the current packet listener.
|
||||
* It attempts to execute the <code>send</code>, <code>read</code>, and <code>disconnect</code>
|
||||
* methods and, upon failure (either due to the absence of the method or the packet
|
||||
* listener being of an incorrect type), it delegates the call to the network manager.
|
||||
* It attempts to execute the <code>send</code>, and <code>disconnect</code> methods, upon failure
|
||||
* (either due to the absence of the method or the packet listener being of an incorrect type),
|
||||
* it delegates the call to the network manager.
|
||||
*
|
||||
* <p>Supported packet listener types include CONFIGURATION and PLAY. If the packet
|
||||
* listener does not match these types, or if the required method is missing, the
|
||||
@@ -43,7 +41,6 @@ public class PacketListenerInvoker {
|
||||
private static final boolean DOES_PACKET_LISTENER_DISCONNECT_USE_COMPONENT = doesPacketListenerDisconnectUseComponent();
|
||||
|
||||
private static final MethodAccessor NETWORK_MANAGER_SEND = getNetworkManagerSend();
|
||||
private static final MethodAccessor NETWORK_MANAGER_READ = getNetworkManagerRead();
|
||||
private static final MethodAccessor NETWORK_MANAGER_DISCONNECT = getNetworkManagerDisconnect();
|
||||
private static final MethodAccessor NETWORK_MANAGER_PACKET_LISTENER = getNetworkManagerPacketListener();
|
||||
|
||||
@@ -117,15 +114,6 @@ public class PacketListenerInvoker {
|
||||
return Accessors.getMethodAccessor(send);
|
||||
}
|
||||
|
||||
private static MethodAccessor getNetworkManagerRead() {
|
||||
FuzzyReflection networkManager = FuzzyReflection.fromClass(MinecraftReflection.getNetworkManagerClass(), true);
|
||||
|
||||
Method read = networkManager
|
||||
.getMethodByParameters("read", ChannelHandlerContext.class, MinecraftReflection.getPacketClass());
|
||||
|
||||
return Accessors.getMethodAccessor(read);
|
||||
}
|
||||
|
||||
private static MethodAccessor getNetworkManagerDisconnect() {
|
||||
FuzzyReflection networkManager = FuzzyReflection.fromClass(MinecraftReflection.getNetworkManagerClass());
|
||||
|
||||
@@ -190,7 +178,7 @@ public class PacketListenerInvoker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a packet using the current packet listener if available and valid; otherwise,
|
||||
* Sends a packet using the current packet listener if available and valid; otherwise,
|
||||
* falls back to the network manager.
|
||||
*
|
||||
* @param packet The packet to be sent.
|
||||
@@ -204,15 +192,6 @@ public class PacketListenerInvoker {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a packet directly using the network manager.
|
||||
*
|
||||
* @param packet The packet to be read.
|
||||
*/
|
||||
public void read(Object packet) {
|
||||
NETWORK_MANAGER_READ.invoke(this.networkManager, null, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects the player using the current packet listener if available and valid; otherwise,
|
||||
* falls back to the network manager.
|
||||
|
||||
@@ -412,8 +412,8 @@ public class PacketRegistry {
|
||||
private static Class<?> searchForPacket(List<String> classNames) {
|
||||
for (String name : classNames) {
|
||||
try {
|
||||
Class<?> clazz = MinecraftReflection.getMinecraftClass(name);
|
||||
if (MinecraftReflection.getPacketClass().isAssignableFrom(clazz)
|
||||
Class<?> clazz = resolvePacketClassName(name);
|
||||
if (clazz != null && MinecraftReflection.getPacketClass().isAssignableFrom(clazz)
|
||||
&& !Modifier.isAbstract(clazz.getModifiers())) {
|
||||
return clazz;
|
||||
}
|
||||
@@ -424,6 +424,22 @@ public class PacketRegistry {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a single packet class name. Fully-qualified names (those already containing their
|
||||
* package, e.g. {@code net.minecraft.network.protocol.game.XPacket}) are loaded directly, since
|
||||
* {@link MinecraftReflection#getMinecraftClass(String)} would otherwise prepend the Minecraft
|
||||
* package and fail to find them. Relative names continue to be resolved against the Minecraft
|
||||
* package.
|
||||
*/
|
||||
private static Class<?> resolvePacketClassName(String name) {
|
||||
Optional<Class<?>> direct = MinecraftReflection.getOptionalClass(name);
|
||||
if (direct.isPresent()) {
|
||||
return direct.get();
|
||||
}
|
||||
|
||||
return MinecraftReflection.getMinecraftClass(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the correct packet class from a given type.
|
||||
*
|
||||
|
||||
@@ -96,6 +96,11 @@ public final class MinecraftProtocolVersion {
|
||||
map.put(new MinecraftVersion(1, 21, 2), 768);
|
||||
map.put(new MinecraftVersion(1, 21, 6), 771);
|
||||
map.put(new MinecraftVersion(1, 21, 8), 772);
|
||||
map.put(new MinecraftVersion(1, 21, 9), 773);
|
||||
map.put(new MinecraftVersion(1, 21, 11), 774);
|
||||
|
||||
map.put(new MinecraftVersion(26, 1, 0), 775);
|
||||
map.put(new MinecraftVersion(26, 2, 0), 776);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@@ -553,6 +553,10 @@ public final class MinecraftReflection {
|
||||
return getClass("com.mojang.authlib.GameProfile");
|
||||
}
|
||||
|
||||
public static Class<?> getGameProfilePropertyMapClass() {
|
||||
return getClass("com.mojang.authlib.properties.PropertyMap");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the entity (NMS) class.
|
||||
*
|
||||
@@ -917,15 +921,15 @@ public final class MinecraftReflection {
|
||||
}
|
||||
|
||||
public static Class<?> getMinecraftKeyClass() {
|
||||
return getMinecraftClass("resources.MinecraftKey", "resources.ResourceLocation", "MinecraftKey");
|
||||
return getMinecraftClass("resources.MinecraftKey", "resources.Identifier", "resources.ResourceLocation", "MinecraftKey");
|
||||
}
|
||||
|
||||
public static Class<?> getMobEffectListClass() {
|
||||
return getMinecraftClass("world.effect.MobEffectList", "MobEffectList", "world.effect.MobEffect");
|
||||
return getMinecraftClass("world.effect.MobEffectList", "MobEffectList", "world.effect.MobEffect", "world.effect.MobEffects");
|
||||
}
|
||||
|
||||
public static Class<?> getSoundEffectClass() {
|
||||
return getNullableNMS("sounds.SoundEffect", "sounds.SoundEvent", "SoundEffect");
|
||||
return getNullableNMS("sounds.SoundEffect", "sounds.SoundEvent", "SoundEffect", "sounds.SoundEvents");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1114,6 +1118,15 @@ public final class MinecraftReflection {
|
||||
return getOptionalNMS("network.chat.numbers.StyledFormat");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the NMS TeamColor class, added in 26.2.
|
||||
*
|
||||
* @return The TeamColor class.
|
||||
*/
|
||||
public static Optional<Class<?>> getTeamColorClass() {
|
||||
return getOptionalNMS("world.scores.TeamColor");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Gson class used by Minecraft.
|
||||
*
|
||||
@@ -1476,6 +1489,18 @@ public final class MinecraftReflection {
|
||||
.orElseThrow(() -> new RuntimeException("Cannot find class " + className));
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to load a class by its fully-qualified canonical name, without prepending the
|
||||
* Minecraft package. Unlike {@link #getMinecraftClass(String)}, this can resolve names that
|
||||
* already include their package (e.g. {@code net.minecraft.network.protocol.game.XPacket}).
|
||||
*
|
||||
* @param className - the fully-qualified class name.
|
||||
* @return Optional that may contain the class.
|
||||
*/
|
||||
public static Optional<Class<?>> getOptionalClass(String className) {
|
||||
return getClassSource().loadClass(className);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the class object of a specific CraftBukkit class.
|
||||
*
|
||||
@@ -1680,7 +1705,7 @@ public final class MinecraftReflection {
|
||||
}
|
||||
|
||||
public static Class<?> getEntityTypes() {
|
||||
return getMinecraftClass("world.entity.EntityTypes", "world.entity.EntityType", "EntityTypes");
|
||||
return getMinecraftClass("world.entity.EntityType", "world.entity.EntityTypes", "EntityTypes");
|
||||
}
|
||||
|
||||
public static Class<?> getParticleParam() {
|
||||
@@ -1899,4 +1924,13 @@ public final class MinecraftReflection {
|
||||
|
||||
return isMojangMapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the PositionMoveRotation class (introduced in 1.21.2).
|
||||
*
|
||||
* @return The PositionMoveRotation class.
|
||||
*/
|
||||
public static Class<?> getPositionMoveRotationClass() {
|
||||
return getMinecraftClass("world.entity.PositionMoveRotation");
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.comphenix.protocol.utility;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import com.comphenix.protocol.wrappers.codecs.WrappedDynamicOps;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.comphenix.protocol.reflect.FuzzyReflection;
|
||||
@@ -17,6 +18,7 @@ public class MinecraftRegistryAccess {
|
||||
|
||||
private static MethodAccessor GET_SERVER = null;
|
||||
private static MethodAccessor REGISTRY_ACCESS = null;
|
||||
private static MethodAccessor CREATE_SERIALIZATION_CONTEXT = null;
|
||||
|
||||
// lazy initialized
|
||||
private static Object registryAccess = null;
|
||||
@@ -36,6 +38,14 @@ public class MinecraftRegistryAccess {
|
||||
.banModifier(Modifier.STATIC)
|
||||
.returnDerivedOf(MinecraftReflection.getRegistryAccessClass())
|
||||
.build()));
|
||||
|
||||
CREATE_SERIALIZATION_CONTEXT = Accessors.getMethodAccessor(
|
||||
FuzzyReflection.fromClass(MinecraftReflection.getHolderLookupProviderClass(), false)
|
||||
.getMethod(FuzzyMethodContract.newBuilder()
|
||||
.banModifier(Modifier.STATIC)
|
||||
.returnDerivedOf(MinecraftReflection.getDynamicOpsClass())
|
||||
.parameterDerivedOf(MinecraftReflection.getDynamicOpsClass())
|
||||
.build()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,4 +67,13 @@ public class MinecraftRegistryAccess {
|
||||
|
||||
return registryAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a RegistryOps using the given DynamicOps as the underlying ops.
|
||||
*
|
||||
* @return a RegistryOps
|
||||
*/
|
||||
public static WrappedDynamicOps createSerializationContext(WrappedDynamicOps dynamicOps) {
|
||||
return WrappedDynamicOps.fromHandle(CREATE_SERIALIZATION_CONTEXT.invoke(get(), dynamicOps.getHandle()));
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,31 @@ import org.bukkit.Server;
|
||||
* @author Kristian
|
||||
*/
|
||||
public final class MinecraftVersion implements Comparable<MinecraftVersion>, Serializable {
|
||||
/**
|
||||
* Version 26.2 - chaos cubed
|
||||
*/
|
||||
public static final MinecraftVersion v26_2 = new MinecraftVersion("26.2");
|
||||
|
||||
/**
|
||||
* Version 26.1 - tiny takeover
|
||||
*/
|
||||
public static final MinecraftVersion v26_1 = new MinecraftVersion("26.1");
|
||||
|
||||
/**
|
||||
* Version 1.21.11 - mounts of mayhem
|
||||
*/
|
||||
public static final MinecraftVersion v1_21_11 = new MinecraftVersion("1.21.11");
|
||||
|
||||
/**
|
||||
* Version 1.21.10 - hotfix for 1.21.9
|
||||
*/
|
||||
public static final MinecraftVersion v1_21_10 = new MinecraftVersion("1.21.10");
|
||||
|
||||
/**
|
||||
* Version 1.21.9 - the copper age drop
|
||||
*/
|
||||
public static final MinecraftVersion v1_21_9 = new MinecraftVersion("1.21.9");
|
||||
|
||||
/**
|
||||
* Version 1.21.6 - chase the skies
|
||||
*/
|
||||
@@ -169,7 +194,7 @@ public final class MinecraftVersion implements Comparable<MinecraftVersion>, Ser
|
||||
/**
|
||||
* The latest release version of minecraft.
|
||||
*/
|
||||
public static final MinecraftVersion LATEST = v1_21_6;
|
||||
public static final MinecraftVersion LATEST = v26_2;
|
||||
|
||||
// used when serializing
|
||||
private static final long serialVersionUID = -8695133558996459770L;
|
||||
|
||||
@@ -2,12 +2,14 @@ package com.comphenix.protocol.utility;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.buffer.ByteBufProcessor;
|
||||
import io.netty.util.ByteProcessor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.GatheringByteChannel;
|
||||
import java.nio.channels.ScatteringByteChannel;
|
||||
import java.nio.charset.Charset;
|
||||
@@ -54,6 +56,16 @@ public class ZeroBuffer extends ByteBuf {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf asReadOnly() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readerIndex() {
|
||||
return 0;
|
||||
@@ -179,36 +191,71 @@ public class ZeroBuffer extends ByteBuf {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShortLE(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedShort(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedShortLE(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMedium(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMediumLE(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedMedium(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnsignedMediumLE(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntLE(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUnsignedInt(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUnsignedIntLE(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLongLE(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getChar(int i) {
|
||||
return 0;
|
||||
@@ -264,6 +311,16 @@ public class ZeroBuffer extends ByteBuf {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(int i, FileChannel fileChannel, long l, int i1) throws IOException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getCharSequence(int i, int i1, Charset charset) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf setBoolean(int i, boolean b) {
|
||||
return null;
|
||||
@@ -279,21 +336,41 @@ public class ZeroBuffer extends ByteBuf {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf setShortLE(int i, int i1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf setMedium(int i, int i1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf setMediumLE(int i, int i1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf setInt(int i, int i1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf setIntLE(int i, int i1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf setLong(int i, long l) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf setLongLE(int i, long l) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf setChar(int i, int i1) {
|
||||
return null;
|
||||
@@ -349,11 +426,21 @@ public class ZeroBuffer extends ByteBuf {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setBytes(int i, FileChannel fileChannel, long l, int i1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf setZero(int i, int i1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setCharSequence(int i, CharSequence charSequence, Charset charset) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readBoolean() {
|
||||
return false;
|
||||
@@ -374,36 +461,71 @@ public class ZeroBuffer extends ByteBuf {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short readShortLE() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readUnsignedShort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readUnsignedShortLE() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readMedium() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readMediumLE() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readUnsignedMedium() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readUnsignedMediumLE() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readInt() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readIntLE() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readUnsignedInt() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readUnsignedIntLE() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readLong() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readLongLE() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char readChar() {
|
||||
return 0;
|
||||
@@ -429,6 +551,11 @@ public class ZeroBuffer extends ByteBuf {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf readRetainedSlice(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf readBytes(ByteBuf byteBuf) {
|
||||
return null;
|
||||
@@ -469,6 +596,16 @@ public class ZeroBuffer extends ByteBuf {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence readCharSequence(int i, Charset charset) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readBytes(FileChannel fileChannel, long l, int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf skipBytes(int i) {
|
||||
return null;
|
||||
@@ -489,21 +626,41 @@ public class ZeroBuffer extends ByteBuf {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf writeShortLE(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf writeMedium(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf writeMediumLE(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf writeInt(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf writeIntLE(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf writeLong(long l) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf writeLongLE(long l) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf writeChar(int i) {
|
||||
return null;
|
||||
@@ -559,11 +716,21 @@ public class ZeroBuffer extends ByteBuf {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writeBytes(FileChannel fileChannel, long l, int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf writeZero(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writeCharSequence(CharSequence charSequence, Charset charset) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(int i, int i1, byte b) {
|
||||
return 0;
|
||||
@@ -585,22 +752,22 @@ public class ZeroBuffer extends ByteBuf {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int forEachByte(ByteBufProcessor byteBufProcessor) {
|
||||
public int forEachByte(ByteProcessor byteProcessor) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int forEachByte(int i, int i1, ByteBufProcessor byteBufProcessor) {
|
||||
public int forEachByte(int i, int i1, ByteProcessor byteProcessor) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int forEachByteDesc(ByteBufProcessor byteBufProcessor) {
|
||||
public int forEachByteDesc(ByteProcessor byteProcessor) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int forEachByteDesc(int i, int i1, ByteBufProcessor byteBufProcessor) {
|
||||
public int forEachByteDesc(int i, int i1, ByteProcessor byteProcessor) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -619,16 +786,31 @@ public class ZeroBuffer extends ByteBuf {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf retainedSlice() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf slice(int i, int i1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf retainedSlice(int i, int i1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf duplicate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf retainedDuplicate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nioBufferCount() {
|
||||
return 0;
|
||||
@@ -738,4 +920,14 @@ public class ZeroBuffer extends ByteBuf {
|
||||
public ByteBuf retain() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf touch() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf touch(Object o) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
@@ -873,6 +874,13 @@ public class BukkitConverters {
|
||||
return ignoreNull(new EquivalentConverter<EntityType>() {
|
||||
@Override
|
||||
public Object getGeneric(EntityType specific) {
|
||||
if (MinecraftVersion.v26_2.atOrAbove()) {
|
||||
// EntityType.byString was removed in 26.2, resolve through the registry instead
|
||||
WrappedRegistry registry = WrappedRegistry.getRegistry(MinecraftReflection.getEntityTypes());
|
||||
NamespacedKey key = specific.getKey();
|
||||
return registry.get(new MinecraftKey(key.getNamespace(), key.getKey()));
|
||||
}
|
||||
|
||||
if (entityTypeFromName == null) {
|
||||
Class<?> entityTypesClass = MinecraftReflection.getEntityTypes();
|
||||
entityTypeFromName = Accessors.getMethodAccessor(
|
||||
|
||||
@@ -36,6 +36,12 @@ public abstract class EnumWrappers {
|
||||
public enum ClientCommand {
|
||||
PERFORM_RESPAWN,
|
||||
REQUEST_STATS,
|
||||
REQUEST_GAMERULE_VALUES,
|
||||
|
||||
/**
|
||||
* @deprecated Removed in 26.1
|
||||
*/
|
||||
@Deprecated
|
||||
OPEN_INVENTORY_ACHIEVEMENT
|
||||
}
|
||||
|
||||
@@ -180,7 +186,8 @@ public abstract class EnumWrappers {
|
||||
DROP_ALL_ITEMS,
|
||||
DROP_ITEM,
|
||||
RELEASE_USE_ITEM,
|
||||
SWAP_HELD_ITEMS("SWAP_ITEM_WITH_OFFHAND");
|
||||
SWAP_HELD_ITEMS("SWAP_ITEM_WITH_OFFHAND"),
|
||||
STAB;
|
||||
|
||||
final String[] aliases;
|
||||
PlayerDigType(String... aliases) {
|
||||
@@ -805,7 +812,7 @@ public abstract class EnumWrappers {
|
||||
}
|
||||
|
||||
try {
|
||||
SOUND_CATEGORY_CLASS = MinecraftReflection.getMinecraftClass("sounds.SoundCategory");
|
||||
SOUND_CATEGORY_CLASS = MinecraftReflection.getMinecraftClass("sounds.SoundCategory", "sounds.SoundSource");
|
||||
} catch (Exception ex) {
|
||||
SOUND_CATEGORY_CLASS = getEnum(PacketType.Play.Server.NAMED_SOUND_EFFECT.getPacketClass(), 0);
|
||||
}
|
||||
@@ -821,13 +828,17 @@ public abstract class EnumWrappers {
|
||||
if (MinecraftVersion.CAVES_CLIFFS_1.atOrAbove()) {
|
||||
HAND_CLASS = MinecraftReflection.getMinecraftClass("world.EnumHand", "world.InteractionHand");
|
||||
|
||||
FuzzyReflection fuzzy = FuzzyReflection.fromClass(MinecraftReflection.getEnumEntityUseActionClass(), true);
|
||||
Method getType = fuzzy.getMethod(FuzzyMethodContract.newBuilder()
|
||||
.parameterCount(0)
|
||||
.returnTypeMatches(FuzzyMatchers.except(Void.class))
|
||||
.build());
|
||||
if (MinecraftVersion.v26_1.atOrAbove()) {
|
||||
// TODO
|
||||
} else {
|
||||
FuzzyReflection fuzzy = FuzzyReflection.fromClass(MinecraftReflection.getEnumEntityUseActionClass(), true);
|
||||
Method getType = fuzzy.getMethod(FuzzyMethodContract.newBuilder()
|
||||
.parameterCount(0)
|
||||
.returnTypeMatches(FuzzyMatchers.except(Void.class))
|
||||
.build());
|
||||
|
||||
ENTITY_USE_ACTION_CLASS = getType.getReturnType();
|
||||
ENTITY_USE_ACTION_CLASS = getType.getReturnType();
|
||||
}
|
||||
} else {
|
||||
HAND_CLASS = getEnum(PacketType.Play.Client.USE_ENTITY.getPacketClass(), 1);
|
||||
ENTITY_USE_ACTION_CLASS = getEnum(PacketType.Play.Client.USE_ENTITY.getPacketClass(), 0);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.comphenix.protocol.wrappers;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
|
||||
/**
|
||||
* Mutable version of PropertyMap
|
||||
* Credit to PaperMC: https://github.com/PaperMC/Paper/blob/main/paper-server/src/main/java/io/papermc/paper/profile/MutablePropertyMap.java
|
||||
*/
|
||||
public class MutablePropertyMap extends PropertyMap {
|
||||
private final Multimap<String, Property> properties = HashMultimap.create();
|
||||
|
||||
public MutablePropertyMap() {
|
||||
super(ImmutableMultimap.of());
|
||||
}
|
||||
|
||||
public MutablePropertyMap(final Multimap<String, Property> properties) {
|
||||
this();
|
||||
this.putAll(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Multimap<String, Property> delegate() {
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public abstract class WrappedBlockData extends AbstractWrapper implements Clonab
|
||||
private static MethodAccessor TO_LEGACY_DATA;
|
||||
private static MethodAccessor GET_BLOCK;
|
||||
private static MethodAccessor BLOCK_FROM_MATERIAL;
|
||||
private static MethodAccessor GET_BLOCK_DATA;
|
||||
private static MethodAccessor DEFAULT_BLOCK_DATA;
|
||||
private static MethodAccessor FROM_LEGACY_DATA;
|
||||
private static MethodAccessor GET_HANDLE;
|
||||
|
||||
@@ -100,7 +100,7 @@ public abstract class WrappedBlockData extends AbstractWrapper implements Clonab
|
||||
.parameterCount(0)
|
||||
.returnTypeExact(IBLOCK_DATA)
|
||||
.build();
|
||||
GET_BLOCK_DATA = Accessors.getMethodAccessor(fuzzy.getMethod(contract));
|
||||
DEFAULT_BLOCK_DATA = Accessors.getMethodAccessor(fuzzy.getMethod(contract));
|
||||
|
||||
fuzzy = FuzzyReflection.fromClass(MinecraftReflection.getCraftBukkitClass("block.data.CraftBlockData"));
|
||||
contract = FuzzyMethodContract
|
||||
@@ -131,7 +131,7 @@ public abstract class WrappedBlockData extends AbstractWrapper implements Clonab
|
||||
@Override
|
||||
public void setType(Material material) {
|
||||
Object block = BLOCK_FROM_MATERIAL.invoke(null, material);
|
||||
setHandle(GET_BLOCK_DATA.invoke(block));
|
||||
setHandle(DEFAULT_BLOCK_DATA.invoke(block));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,7 +141,7 @@ public abstract class WrappedBlockData extends AbstractWrapper implements Clonab
|
||||
|
||||
@Override
|
||||
public void setTypeAndData(Material material, int data) {
|
||||
setHandle(TO_LEGACY_DATA.invoke(null, material, (byte) data));
|
||||
setHandle(FROM_LEGACY_DATA.invoke(null, material, (byte) data));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,7 +151,7 @@ public abstract class WrappedBlockData extends AbstractWrapper implements Clonab
|
||||
|
||||
private static WrappedBlockData createNewData(Material material) {
|
||||
Object block = BLOCK_FROM_MATERIAL.invoke(null, material);
|
||||
return new NewBlockData(GET_BLOCK_DATA.invoke(block));
|
||||
return new NewBlockData(DEFAULT_BLOCK_DATA.invoke(block));
|
||||
}
|
||||
|
||||
private static WrappedBlockData createNewData(Material material, int data) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.Optional;
|
||||
|
||||
import com.comphenix.protocol.wrappers.codecs.WrappedCodec;
|
||||
import com.comphenix.protocol.wrappers.codecs.WrappedDynamicOps;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -42,6 +41,7 @@ public class WrappedChatComponent extends AbstractWrapper implements ClonableWra
|
||||
private static ConstructorAccessor CONSTRUCT_TEXT_COMPONENT = null;
|
||||
|
||||
private static WrappedCodec CODEC;
|
||||
private static WrappedDynamicOps REGISTRY_JSON_OPS;
|
||||
|
||||
static {
|
||||
FuzzyReflection fuzzy = FuzzyReflection.fromClass(SERIALIZER, true);
|
||||
@@ -49,6 +49,7 @@ public class WrappedChatComponent extends AbstractWrapper implements ClonableWra
|
||||
if (MinecraftVersion.v1_21_6.atOrAbove()) {
|
||||
Field codecField = fuzzy.getFieldByType("CODEC", MinecraftReflection.getCodecClass());
|
||||
CODEC = WrappedCodec.fromHandle(Accessors.getFieldAccessor(codecField).get(null));
|
||||
REGISTRY_JSON_OPS = MinecraftRegistryAccess.createSerializationContext(WrappedDynamicOps.json(false));
|
||||
} else if (MinecraftVersion.v1_20_5.atOrAbove()) {
|
||||
SERIALIZE_COMPONENT = Accessors.getMethodAccessor(fuzzy.getMethod(FuzzyMethodContract.newBuilder()
|
||||
.returnTypeExact(String.class)
|
||||
@@ -98,7 +99,7 @@ public class WrappedChatComponent extends AbstractWrapper implements ClonableWra
|
||||
|
||||
private static Object serialize(Object handle) {
|
||||
if (CODEC != null) {
|
||||
Object jobj = CODEC.encode(handle, WrappedDynamicOps.json(false)).getOrThrow(JsonParseException::new);
|
||||
Object jobj = CODEC.encode(handle, REGISTRY_JSON_OPS).getOrThrow(JsonParseException::new);
|
||||
return jobj.toString();
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ public class WrappedChatComponent extends AbstractWrapper implements ClonableWra
|
||||
|
||||
private static Object deserialize(String json) {
|
||||
if (CODEC != null) {
|
||||
return CODEC.parse(JsonParser.parseString(json), WrappedDynamicOps.json(false)).getOrThrow(JsonParseException::new);
|
||||
return CODEC.parse(JsonParser.parseString(json), REGISTRY_JSON_OPS).getOrThrow(JsonParseException::new);
|
||||
}
|
||||
|
||||
if (MinecraftVersion.v1_20_5.atOrAbove()) {
|
||||
|
||||
@@ -35,18 +35,30 @@ public class WrappedGameProfile extends AbstractWrapper {
|
||||
GAME_PROFILE, String.class, String.class);
|
||||
private static final ConstructorAccessor CREATE_UUID_STRING = Accessors.getConstructorAccessorOrNull(
|
||||
GAME_PROFILE, UUID.class, String.class);
|
||||
private static final ConstructorAccessor CREATE_UUID_STRING_PROPERTIES = Accessors.getConstructorAccessorOrNull(
|
||||
GAME_PROFILE, UUID.class, String.class, MinecraftReflection.getGameProfilePropertyMapClass());
|
||||
|
||||
private static final FieldAccessor GET_UUID_STRING = Accessors.getFieldAccessorOrNull(
|
||||
GAME_PROFILE, "id", String.class);
|
||||
|
||||
private static final MethodAccessor GET_ID = Accessors.getMethodAccessorOrNull(
|
||||
GAME_PROFILE, "getId");
|
||||
private static final MethodAccessor GET_NAME = Accessors.getMethodAccessorOrNull(
|
||||
GAME_PROFILE, "getName");
|
||||
private static final MethodAccessor GET_PROPERTIES = Accessors.getMethodAccessorOrNull(
|
||||
GAME_PROFILE, "getProperties");
|
||||
private static final MethodAccessor IS_COMPLETE = Accessors.getMethodAccessorOrNull(
|
||||
GAME_PROFILE, "isComplete");
|
||||
private static MethodAccessor GET_ID;
|
||||
private static MethodAccessor GET_NAME;
|
||||
private static MethodAccessor GET_PROPERTIES;
|
||||
private static MethodAccessor IS_COMPLETE;
|
||||
|
||||
static {
|
||||
GET_ID = Accessors.getMethodAccessorOrNull(GAME_PROFILE, "getId");
|
||||
if (GET_ID == null) {
|
||||
GET_ID = Accessors.getMethodAccessorOrNull(GAME_PROFILE, "id");
|
||||
GET_NAME = Accessors.getMethodAccessorOrNull(GAME_PROFILE, "name");
|
||||
GET_PROPERTIES = Accessors.getMethodAccessorOrNull(GAME_PROFILE, "properties");
|
||||
IS_COMPLETE = Accessors.getMethodAccessorOrNull(GAME_PROFILE, "complete");
|
||||
} else {
|
||||
GET_NAME = Accessors.getMethodAccessorOrNull(GAME_PROFILE, "getName");
|
||||
GET_PROPERTIES = Accessors.getMethodAccessorOrNull(GAME_PROFILE, "getProperties");
|
||||
IS_COMPLETE = Accessors.getMethodAccessorOrNull(GAME_PROFILE, "isComplete");
|
||||
}
|
||||
}
|
||||
|
||||
// Fetching game profile
|
||||
private static FieldAccessor PLAYER_PROFILE;
|
||||
@@ -117,6 +129,51 @@ public class WrappedGameProfile extends AbstractWrapper {
|
||||
this(parseUUID(id), name);
|
||||
}
|
||||
|
||||
private static Object createHandle(UUID uuid, String name, Multimap<String, WrappedSignedProperty> properties) {
|
||||
if (CREATE_STRING_STRING != null) {
|
||||
return CREATE_STRING_STRING.invoke(uuid != null ? uuid.toString() : null, name);
|
||||
}
|
||||
|
||||
if (CREATE_UUID_STRING == null) {
|
||||
throw new IllegalArgumentException("Unsupported GameProfile constructor.");
|
||||
}
|
||||
|
||||
if (!MinecraftVersion.CONFIG_PHASE_PROTOCOL_UPDATE.atOrAbove()) {
|
||||
return CREATE_UUID_STRING.invoke(uuid, name);
|
||||
}
|
||||
|
||||
// 1.20.2+ requires all fields to have a value: null uuid -> UUID(0,0), null name -> empty name
|
||||
// it's not allowed to pass null for both, so we need to pre-check that
|
||||
if (uuid == null && (name == null || name.isEmpty())) {
|
||||
throw new IllegalArgumentException("Name and ID cannot both be blank");
|
||||
}
|
||||
|
||||
// 1.21.9+ made PropertyMap's underlying map immutable, so we need to override it with a mutable map
|
||||
if (MinecraftVersion.v1_21_9.atOrAbove()) {
|
||||
return CREATE_UUID_STRING_PROPERTIES.invoke(uuid == null ? MinecraftGenerator.SYS_UUID : uuid, name == null ? "" : name,
|
||||
convertPropertyMap(properties));
|
||||
}
|
||||
|
||||
return CREATE_UUID_STRING.invoke(uuid == null ? MinecraftGenerator.SYS_UUID : uuid, name == null ? "" : name);
|
||||
}
|
||||
|
||||
private static Object convertPropertyMap(Multimap<String, WrappedSignedProperty> properties) {
|
||||
com.comphenix.protocol.wrappers.MutablePropertyMap map =
|
||||
new com.comphenix.protocol.wrappers.MutablePropertyMap();
|
||||
|
||||
if (properties == null || properties.isEmpty()) {
|
||||
return map;
|
||||
}
|
||||
|
||||
for (String key : properties.keySet()) {
|
||||
for (WrappedSignedProperty property : properties.get(key)) {
|
||||
map.put(key, (com.mojang.authlib.properties.Property) property.getHandle());
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new game profile with the given properties.
|
||||
* <p>
|
||||
@@ -127,24 +184,12 @@ public class WrappedGameProfile extends AbstractWrapper {
|
||||
*/
|
||||
public WrappedGameProfile(UUID uuid, String name) {
|
||||
super(GAME_PROFILE);
|
||||
setHandle(createHandle(uuid, name, null));
|
||||
}
|
||||
|
||||
if (CREATE_STRING_STRING != null) {
|
||||
setHandle(CREATE_STRING_STRING.invoke(uuid != null ? uuid.toString() : null, name));
|
||||
} else if (CREATE_UUID_STRING != null) {
|
||||
if (MinecraftVersion.CONFIG_PHASE_PROTOCOL_UPDATE.atOrAbove()) {
|
||||
// 1.20.2+ requires all fields to have a value: null uuid -> UUID(0,0), null name -> empty name
|
||||
// it's not allowed to pass null for both, so we need to pre-check that
|
||||
if (uuid == null && (name == null || name.isEmpty())) {
|
||||
throw new IllegalArgumentException("Name and ID cannot both be blank");
|
||||
}
|
||||
|
||||
setHandle(CREATE_UUID_STRING.invoke(uuid == null ? MinecraftGenerator.SYS_UUID : uuid, name == null ? "" : name));
|
||||
} else {
|
||||
setHandle(CREATE_UUID_STRING.invoke(uuid, name));
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported GameProfile constructor.");
|
||||
}
|
||||
public WrappedGameProfile(UUID uuid, String name, Multimap<String, WrappedSignedProperty> properties) {
|
||||
super(GAME_PROFILE);
|
||||
setHandle(createHandle(uuid, name, properties));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +202,12 @@ public class WrappedGameProfile extends AbstractWrapper {
|
||||
if (handle == null)
|
||||
return null;
|
||||
|
||||
return new WrappedGameProfile(handle);
|
||||
WrappedGameProfile delegate = new WrappedGameProfile(handle);
|
||||
if (MinecraftVersion.v1_21_9.atOrAbove()) {
|
||||
return new WrappedGameProfile(delegate.getUUID(), delegate.getName(), delegate.getProperties());
|
||||
} else {
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,7 +319,15 @@ public class WrappedGameProfile extends AbstractWrapper {
|
||||
|
||||
if (result == null) {
|
||||
Multimap properties = (Multimap) GET_PROPERTIES.invoke(handle);
|
||||
result = new ConvertedMultimap<String, Object, WrappedSignedProperty>(GuavaWrappers.getBukkitMultimap(properties)) {
|
||||
|
||||
Multimap inner;
|
||||
if (MinecraftVersion.v1_21_9.atOrAbove()) {
|
||||
inner = properties;
|
||||
} else {
|
||||
inner = GuavaWrappers.getBukkitMultimap(properties);
|
||||
}
|
||||
|
||||
result = new ConvertedMultimap<String, Object, WrappedSignedProperty>(inner) {
|
||||
@Override
|
||||
protected Object toInner(WrappedSignedProperty outer) {
|
||||
return outer.handle;
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
package com.comphenix.protocol.wrappers;
|
||||
|
||||
import com.comphenix.protocol.reflect.EquivalentConverter;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.reflect.accessors.Accessors;
|
||||
import com.comphenix.protocol.reflect.accessors.ConstructorAccessor;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* Wrapper around the NMS {@code PositionMoveRotation} record, introduced in Minecraft 1.21.2.
|
||||
* <p>
|
||||
* This type is used in packets such as {@code ENTITY_TELEPORT} and {@code ENTITY_POSITION_SYNC}
|
||||
* to represent combined position, movement delta and rotation.
|
||||
* <p>
|
||||
* Example usage:
|
||||
* <pre>{@code
|
||||
* WrappedPositionMoveRotation posRot = WrappedPositionMoveRotation.create(
|
||||
* new Vector(x, y, z), // position
|
||||
* new Vector(0, 0, 0), // deltaMovement
|
||||
* yaw, // yRot
|
||||
* pitch // xRot
|
||||
* );
|
||||
* packet.getPositionMoveRotation().write(0, posRot);
|
||||
* }</pre>
|
||||
*/
|
||||
public class WrappedPositionMoveRotation extends AbstractWrapper {
|
||||
|
||||
private static Class<?> NMS_CLASS;
|
||||
private static ConstructorAccessor CONSTRUCTOR;
|
||||
private static StructureModifier<Object> BASE_MODIFIER;
|
||||
|
||||
private final StructureModifier<Object> modifier;
|
||||
|
||||
private WrappedPositionMoveRotation(Object handle) {
|
||||
super(getNmsClass());
|
||||
setHandle(handle);
|
||||
this.modifier = getBaseModifier().withTarget(handle);
|
||||
}
|
||||
|
||||
private static Class<?> getNmsClass() {
|
||||
if (NMS_CLASS == null) {
|
||||
NMS_CLASS = MinecraftReflection.getPositionMoveRotationClass();
|
||||
}
|
||||
return NMS_CLASS;
|
||||
}
|
||||
|
||||
private static StructureModifier<Object> getBaseModifier() {
|
||||
if (BASE_MODIFIER == null) {
|
||||
BASE_MODIFIER = new StructureModifier<>(getNmsClass());
|
||||
}
|
||||
return BASE_MODIFIER;
|
||||
}
|
||||
|
||||
private static ConstructorAccessor getConstructor() {
|
||||
if (CONSTRUCTOR == null) {
|
||||
CONSTRUCTOR = Accessors.getConstructorAccessor(
|
||||
getNmsClass(),
|
||||
MinecraftReflection.getVec3DClass(),
|
||||
MinecraftReflection.getVec3DClass(),
|
||||
float.class,
|
||||
float.class
|
||||
);
|
||||
}
|
||||
return CONSTRUCTOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code WrappedPositionMoveRotation} from the given NMS handle.
|
||||
*
|
||||
* @param handle - the NMS {@code PositionMoveRotation} instance.
|
||||
* @return the wrapper.
|
||||
*/
|
||||
public static WrappedPositionMoveRotation fromHandle(Object handle) {
|
||||
return new WrappedPositionMoveRotation(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code WrappedPositionMoveRotation} with the given values.
|
||||
*
|
||||
* @param position - the absolute position.
|
||||
* @param deltaMovement - the movement delta (velocity).
|
||||
* @param yRot - the yaw rotation.
|
||||
* @param xRot - the pitch rotation.
|
||||
* @return a new wrapper instance.
|
||||
*/
|
||||
public static WrappedPositionMoveRotation create(Vector position, Vector deltaMovement, float yRot, float xRot) {
|
||||
EquivalentConverter<Vector> conv = BukkitConverters.getVectorConverter();
|
||||
Object handle = getConstructor().invoke(
|
||||
conv.getGeneric(position),
|
||||
conv.getGeneric(deltaMovement),
|
||||
yRot,
|
||||
xRot
|
||||
);
|
||||
return new WrappedPositionMoveRotation(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the absolute position component.
|
||||
*
|
||||
* @return the position as a Bukkit {@link Vector}.
|
||||
*/
|
||||
public Vector getPosition() {
|
||||
return modifier.withType(MinecraftReflection.getVec3DClass(), BukkitConverters.getVectorConverter()).read(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the absolute position component.
|
||||
*
|
||||
* @param position - the new position.
|
||||
*/
|
||||
public void setPosition(Vector position) {
|
||||
modifier.withType(MinecraftReflection.getVec3DClass(), BukkitConverters.getVectorConverter()).write(0, position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the movement delta (velocity) component.
|
||||
*
|
||||
* @return the delta movement as a Bukkit {@link Vector}.
|
||||
*/
|
||||
public Vector getDeltaMovement() {
|
||||
return modifier.withType(MinecraftReflection.getVec3DClass(), BukkitConverters.getVectorConverter()).read(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the movement delta (velocity) component.
|
||||
*
|
||||
* @param deltaMovement - the new delta movement.
|
||||
*/
|
||||
public void setDeltaMovement(Vector deltaMovement) {
|
||||
modifier.withType(MinecraftReflection.getVec3DClass(), BukkitConverters.getVectorConverter()).write(1, deltaMovement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the yaw rotation (y-axis rotation).
|
||||
*
|
||||
* @return the yaw as a float.
|
||||
*/
|
||||
public float getYRot() {
|
||||
StructureModifier<Float> floats = modifier.withType(float.class);
|
||||
return floats.read(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the yaw rotation (y-axis rotation).
|
||||
*
|
||||
* @param yRot - the new yaw value.
|
||||
*/
|
||||
public void setYRot(float yRot) {
|
||||
modifier.withType(float.class).write(0, yRot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the pitch rotation (x-axis rotation).
|
||||
*
|
||||
* @return the pitch as a float.
|
||||
*/
|
||||
public float getXRot() {
|
||||
StructureModifier<Float> floats = modifier.withType(float.class);
|
||||
return floats.read(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pitch rotation (x-axis rotation).
|
||||
*
|
||||
* @param xRot - the new pitch value.
|
||||
*/
|
||||
public void setXRot(float xRot) {
|
||||
modifier.withType(float.class).write(1, xRot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an {@link EquivalentConverter} that converts between {@code WrappedPositionMoveRotation}
|
||||
* and the underlying NMS handle.
|
||||
*
|
||||
* @return the converter.
|
||||
*/
|
||||
public static EquivalentConverter<WrappedPositionMoveRotation> getConverter() {
|
||||
return Converters.handle(AbstractWrapper::getHandle,
|
||||
WrappedPositionMoveRotation::fromHandle, WrappedPositionMoveRotation.class);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.comphenix.protocol.wrappers;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.comphenix.protocol.injector.StructureCache;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
@@ -90,12 +92,26 @@ public class WrappedTeamParameters extends AbstractWrapper {
|
||||
|
||||
@NotNull
|
||||
public EnumWrappers.ChatFormatting getColor() {
|
||||
if (MinecraftVersion.v26_2.atOrAbove()) {
|
||||
Optional<?> optional = modifier.<Optional<?>>withType(Optional.class).read(0);
|
||||
Object teamColor = optional != null ? optional.orElse(null) : null;
|
||||
if (teamColor == null) {
|
||||
return EnumWrappers.ChatFormatting.RESET;
|
||||
}
|
||||
|
||||
return EnumWrappers.ChatFormatting.valueOf(((Enum<?>) teamColor).name());
|
||||
}
|
||||
|
||||
return modifier
|
||||
.withType(EnumWrappers.getChatFormattingClass(), EnumWrappers.getChatFormattingConverter())
|
||||
.read(0);
|
||||
}
|
||||
|
||||
public int getOptions() {
|
||||
if (MinecraftVersion.v26_2.atOrAbove()) {
|
||||
return (byte) modifier.withType(byte.class).read(0);
|
||||
}
|
||||
|
||||
return (int) modifier.withType(int.class).read(0);
|
||||
}
|
||||
|
||||
@@ -210,9 +226,27 @@ public class WrappedTeamParameters extends AbstractWrapper {
|
||||
wrapped.modifier.withType(String.class).writeSafely(1, collisionRule.toString());
|
||||
}
|
||||
|
||||
wrapped.modifier.withType(EnumWrappers.getChatFormattingClass()).write(0, EnumWrappers.getChatFormattingConverter().getGeneric(color));
|
||||
wrapped.modifier.withType(int.class).write(0, options);
|
||||
if (MinecraftVersion.v26_2.atOrAbove()) {
|
||||
wrapped.modifier.withType(Optional.class).write(0, Optional.ofNullable(toNmsTeamColor(color)));
|
||||
wrapped.modifier.withType(byte.class).write(0, (byte) options);
|
||||
} else {
|
||||
wrapped.modifier.withType(EnumWrappers.getChatFormattingClass()).write(0, EnumWrappers.getChatFormattingConverter().getGeneric(color));
|
||||
wrapped.modifier.withType(int.class).write(0, options);
|
||||
}
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private static Object toNmsTeamColor(EnumWrappers.ChatFormatting color) {
|
||||
Class<?> teamColorClass = MinecraftReflection.getTeamColorClass()
|
||||
.orElseThrow(() -> new IllegalStateException("TeamColor class doesn't exist on this server version"));
|
||||
|
||||
try {
|
||||
return Enum.valueOf((Class) teamColorClass, color.name());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// formatting-only values (e.g. RESET) don't map to a team color
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
import java.util.Base64;
|
||||
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
@@ -23,7 +22,7 @@ public class NbtTextSerializer {
|
||||
* A default instance of this serializer.
|
||||
*/
|
||||
public static final NbtTextSerializer DEFAULT = new NbtTextSerializer();
|
||||
|
||||
|
||||
private NbtBinarySerializer binarySerializer;
|
||||
|
||||
public NbtTextSerializer() {
|
||||
@@ -59,7 +58,7 @@ public class NbtTextSerializer {
|
||||
binarySerializer.serialize(value, dataOutput);
|
||||
|
||||
// Serialize that array
|
||||
return Base64Coder.encodeLines(outputStream.toByteArray());
|
||||
return Base64.getEncoder().encodeToString(outputStream.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +69,7 @@ public class NbtTextSerializer {
|
||||
* @throws IOException If we are unable to parse the input.
|
||||
*/
|
||||
public <TType> NbtWrapper<TType> deserialize(String input) throws IOException {
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(input));
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64.getDecoder().decode(input));
|
||||
|
||||
return binarySerializer.deserialize(new DataInputStream(inputStream));
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.comphenix.protocol.reflect.accessors.Accessors;
|
||||
import com.comphenix.protocol.reflect.accessors.ConstructorAccessor;
|
||||
import com.comphenix.protocol.reflect.accessors.FieldAccessor;
|
||||
import com.comphenix.protocol.reflect.accessors.MethodAccessor;
|
||||
import com.comphenix.protocol.reflect.instances.DefaultInstances;
|
||||
import com.comphenix.protocol.reflect.instances.MinecraftGenerator;
|
||||
import com.comphenix.protocol.utility.MinecraftProtocolVersion;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
@@ -23,6 +25,7 @@ public final class ServerPingRecord implements ServerPingImpl {
|
||||
private static Class<?> SERVER_PING;
|
||||
private static Class<?> PLAYER_SAMPLE_CLASS;
|
||||
private static Class<?> SERVER_DATA_CLASS;
|
||||
private static Class<?> NAME_AND_ID_CLASS;
|
||||
|
||||
private static Class<?> GSON_CLASS;
|
||||
private static MethodAccessor GSON_TO_JSON;
|
||||
@@ -62,7 +65,31 @@ public final class ServerPingRecord implements ServerPingImpl {
|
||||
SAMPLE_WRAPPER = AutoWrapper.wrap(PlayerSample.class, PLAYER_SAMPLE_CLASS);
|
||||
FAVICON_WRAPPER = AutoWrapper.wrap(Favicon.class, MinecraftReflection.getMinecraftClass("network.protocol.status.ServerPing$a", "network.protocol.status.ServerStatus$Favicon"));
|
||||
|
||||
PROFILE_LIST_CONVERTER = BukkitConverters.getListConverter(BukkitConverters.getWrappedGameProfileConverter());
|
||||
if (MinecraftVersion.v1_21_10.atOrAbove()) {
|
||||
NAME_AND_ID_CLASS = MinecraftReflection.getMinecraftClass("server.players.NameAndId");
|
||||
NAME_AND_ID_WRAPPER = AutoWrapper.wrap(NameAndId.class, NAME_AND_ID_CLASS);
|
||||
|
||||
PROFILE_LIST_CONVERTER = BukkitConverters.getListConverter(new EquivalentConverter<>() {
|
||||
@Override
|
||||
public Object getGeneric(WrappedGameProfile specific) {
|
||||
NameAndId wrapper = new NameAndId(specific.getUUID(), specific.getName());
|
||||
return NAME_AND_ID_WRAPPER.getGeneric(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WrappedGameProfile getSpecific(Object generic) {
|
||||
NameAndId wrapper = NAME_AND_ID_WRAPPER.getSpecific(generic);
|
||||
return new WrappedGameProfile(wrapper.id, wrapper.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<WrappedGameProfile> getSpecificType() {
|
||||
return WrappedGameProfile.class;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
PROFILE_LIST_CONVERTER = BukkitConverters.getListConverter(BukkitConverters.getWrappedGameProfileConverter());
|
||||
}
|
||||
|
||||
DEFAULT_DESCRIPTION = WrappedChatComponent.fromLegacyText("A Minecraft Server");
|
||||
|
||||
@@ -124,11 +151,24 @@ public final class ServerPingRecord implements ServerPingImpl {
|
||||
}
|
||||
}
|
||||
|
||||
public static final class NameAndId {
|
||||
public UUID id;
|
||||
public String name;
|
||||
|
||||
public NameAndId(UUID id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public NameAndId() {
|
||||
this(MinecraftGenerator.SYS_UUID, "");
|
||||
}
|
||||
}
|
||||
|
||||
private static AutoWrapper<PlayerSample> SAMPLE_WRAPPER;
|
||||
|
||||
private static AutoWrapper<ServerData> DATA_WRAPPER;
|
||||
|
||||
private static AutoWrapper<Favicon> FAVICON_WRAPPER;
|
||||
private static AutoWrapper<NameAndId> NAME_AND_ID_WRAPPER;
|
||||
|
||||
private WrappedChatComponent description;
|
||||
private PlayerSample playerSample;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.comphenix.protocol;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -20,7 +21,7 @@ import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.RegistryDataLoader;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.server.Bootstrap;
|
||||
import net.minecraft.server.RegistryLayer;
|
||||
import net.minecraft.server.ReloadableServerResources;
|
||||
@@ -32,6 +33,8 @@ import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.server.packs.repository.ServerPacksSource;
|
||||
import net.minecraft.server.packs.resources.MultiPackResourceManager;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.permissions.LevelBasedPermissionSet;
|
||||
import net.minecraft.server.permissions.PermissionSet;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.tags.TagLoader;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -46,18 +49,18 @@ import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.CraftLootTable;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.CraftRegistry;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.inventory.CraftItemFactory;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.tag.CraftBlockTag;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.tag.CraftEntityTag;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.tag.CraftFluidTag;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.tag.CraftItemTag;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.util.CraftNamespacedKey;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.util.Versioning;
|
||||
import org.bukkit.craftbukkit.CraftLootTable;
|
||||
import org.bukkit.craftbukkit.CraftRegistry;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemFactory;
|
||||
import org.bukkit.craftbukkit.tag.CraftBlockTag;
|
||||
import org.bukkit.craftbukkit.tag.CraftEntityTag;
|
||||
import org.bukkit.craftbukkit.tag.CraftFluidTag;
|
||||
import org.bukkit.craftbukkit.tag.CraftItemTag;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.Versioning;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spigotmc.SpigotWorldConfig;
|
||||
|
||||
@@ -76,6 +79,15 @@ public class BukkitInitialization {
|
||||
private boolean initialized;
|
||||
private boolean packaged;
|
||||
|
||||
private static ServerLevel mockServerLevel;
|
||||
|
||||
/**
|
||||
* @return the mocked NMS server level set up during initialization, usable as a Level for constructing test entities
|
||||
*/
|
||||
public static ServerLevel getMockServerLevel() {
|
||||
return mockServerLevel;
|
||||
}
|
||||
|
||||
private BukkitInitialization() {
|
||||
System.out.println("Created new BukkitInitialization on " + Thread.currentThread().getName());
|
||||
}
|
||||
@@ -127,7 +139,15 @@ public class BukkitInitialization {
|
||||
List<net.minecraft.core.Registry.PendingTags<?>> tags = TagLoader.loadTagsForExistingRegistries(resourceManager, layeredAccess1.getLayer(RegistryLayer.STATIC));
|
||||
RegistryAccess.Frozen access1 = layeredAccess1.getAccessForLoading(RegistryLayer.WORLDGEN);
|
||||
List<HolderLookup.RegistryLookup<?>> list1 = TagLoader.buildUpdatedLookups(access1, tags);
|
||||
RegistryAccess.Frozen access2 = RegistryDataLoader.load(resourceManager, list1, RegistryDataLoader.WORLDGEN_REGISTRIES);
|
||||
|
||||
RegistryAccess.Frozen access2;
|
||||
|
||||
try {
|
||||
access2 = RegistryDataLoader.load(resourceManager, list1, RegistryDataLoader.WORLDGEN_REGISTRIES, Executors.newSingleThreadExecutor()).get();
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
LayeredRegistryAccess<RegistryLayer> layeredAccess2 = layeredAccess1.replaceFrom(RegistryLayer.WORLDGEN, access2);
|
||||
RegistryAccess.Frozen registryCustom = layeredAccess2.compositeAccess().freeze();
|
||||
|
||||
@@ -137,11 +157,11 @@ public class BukkitInitialization {
|
||||
tags,
|
||||
FeatureFlags.REGISTRY.allFlags() /* REGISTRY.allFlags() */,
|
||||
Commands.CommandSelection.DEDICATED /* DEDICATED */,
|
||||
0,
|
||||
LevelBasedPermissionSet.ALL,
|
||||
MoreExecutors.directExecutor(),
|
||||
MoreExecutors.directExecutor()
|
||||
).join();
|
||||
dataPackResources.updateStaticRegistryTags();
|
||||
dataPackResources.updateComponentsAndStaticRegistryTags();
|
||||
|
||||
/* try {
|
||||
IRegistry.class.getName();
|
||||
@@ -186,7 +206,7 @@ public class BukkitInitialization {
|
||||
when(mockedServer.getTag(any(), any(), any())).then(mock -> {
|
||||
String registry = mock.getArgument(0);
|
||||
Class<?> clazz = mock.getArgument(2);
|
||||
ResourceLocation key = CraftNamespacedKey.toMinecraft(mock.getArgument(1));
|
||||
Identifier key = CraftNamespacedKey.toMinecraft(mock.getArgument(1));
|
||||
|
||||
switch (registry) {
|
||||
case org.bukkit.Tag.REGISTRY_BLOCKS -> {
|
||||
@@ -235,6 +255,7 @@ public class BukkitInitialization {
|
||||
|
||||
CraftWorld world = mock(CraftWorld.class);
|
||||
when(world.getHandle()).thenReturn(nmsWorld);
|
||||
mockServerLevel = nmsWorld;
|
||||
|
||||
List<World> worlds = Collections.singletonList(world);
|
||||
when(mockedServer.getWorlds()).thenReturn(worlds);
|
||||
|
||||
@@ -41,8 +41,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
|
||||
import org.apache.commons.lang.SerializationUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -105,15 +104,15 @@ import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.protocol.game.ClientboundGameEventPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket.AttributeSnapshot;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation;
|
||||
import net.minecraft.world.entity.animal.CatVariant;
|
||||
import net.minecraft.world.entity.animal.CatVariants;
|
||||
import net.minecraft.world.entity.animal.feline.CatVariant;
|
||||
import net.minecraft.world.entity.animal.feline.CatVariants;
|
||||
import net.minecraft.world.entity.animal.frog.FrogVariant;
|
||||
import net.minecraft.world.entity.animal.frog.FrogVariants;
|
||||
|
||||
@@ -523,15 +522,14 @@ public class PacketContainerTest {
|
||||
|
||||
// Initialize some test data
|
||||
List<AttributeModifier> modifiers = Lists.newArrayList(
|
||||
new AttributeModifier(ResourceLocation.parse("protocollib:test"),10,
|
||||
Operation.ADD_VALUE));
|
||||
new AttributeModifier(Identifier.parse("protocollib:test"),10, Operation.ADD_VALUE));
|
||||
|
||||
// Obtain an AttributeSnapshot instance. This is complicated by the fact that AttributeSnapshots
|
||||
// are inner classes (which is ultimately pointless because AttributeSnapshots don't access any
|
||||
// members of the packet itself)
|
||||
ClientboundUpdateAttributesPacket packet = (ClientboundUpdateAttributesPacket) attribute.getHandle();
|
||||
net.minecraft.core.Registry<Attribute> registry = BuiltInRegistries.ATTRIBUTE;
|
||||
Attribute base = registry.getValue(ResourceLocation.parse("max_health"));
|
||||
Attribute base = registry.getValue(Identifier.parse("max_health"));
|
||||
AttributeSnapshot snapshot = new AttributeSnapshot(registry.wrapAsHolder(base), 20.0D, modifiers);
|
||||
attribute.getSpecificModifier(List.class).write(0, Lists.newArrayList(snapshot));
|
||||
|
||||
@@ -755,7 +753,8 @@ public class PacketContainerTest {
|
||||
assertEquals(2, (int) packet.getGameStateIDs().read(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
// TODO: needs to be fixed for 26.1
|
||||
public void testUseEntity() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Client.USE_ENTITY);
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_21_R5.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
|
||||
@@ -2,10 +2,9 @@ package com.comphenix.protocol.utility;
|
||||
|
||||
public class MinecraftReflectionTestUtil {
|
||||
|
||||
public static final String RELEASE_TARGET = "1.21.6";
|
||||
public static final String PACKAGE_VERSION = "v1_21_R5";
|
||||
public static final String RELEASE_TARGET = "26.1";
|
||||
public static final String NMS = "net.minecraft";
|
||||
public static final String OBC = "org.bukkit.craftbukkit." + PACKAGE_VERSION;
|
||||
public static final String OBC = "org.bukkit.craftbukkit";
|
||||
|
||||
public static void init() {
|
||||
MinecraftReflection.setMinecraftPackage(NMS, OBC);
|
||||
|
||||
@@ -48,7 +48,7 @@ class MinecraftVersionTest {
|
||||
|
||||
@Test
|
||||
void testCurrent() {
|
||||
assertEquals(MinecraftVersion.v1_21_6, MinecraftVersion.getCurrentVersion());
|
||||
assertEquals(MinecraftVersion.LATEST, MinecraftVersion.getCurrentVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -9,6 +9,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.comphenix.protocol.reflect.EquivalentConverter;
|
||||
import net.minecraft.world.item.ItemStackTemplate;
|
||||
import net.minecraft.world.item.Items;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -22,7 +25,7 @@ import net.minecraft.advancements.DisplayInfo;
|
||||
import net.minecraft.core.ClientAsset;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.contents.PlainTextContents;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
|
||||
public class AutoWrapperTest {
|
||||
|
||||
@@ -37,7 +40,7 @@ public class AutoWrapperTest {
|
||||
display.title = WrappedChatComponent.fromText("Test123");
|
||||
display.description = WrappedChatComponent.fromText("Test567");
|
||||
display.item = new ItemStack(Material.GOLD_INGOT);
|
||||
display.background = Optional.of(new ClientAsset(ResourceLocation.fromNamespaceAndPath("minecraft", "test")));
|
||||
display.background = Optional.of(new ClientAsset.ResourceTexture(Identifier.fromNamespaceAndPath("minecraft", "test")));
|
||||
display.frameType = WrappedFrameType.CHALLENGE;
|
||||
display.announceChat = false;
|
||||
display.showToast = true;
|
||||
@@ -55,7 +58,7 @@ public class AutoWrapperTest {
|
||||
validateRawText(nms.getTitle(), "Test123");
|
||||
validateRawText(nms.getDescription(), "Test567");
|
||||
assertSame(AdvancementType.CHALLENGE, nms.getType());
|
||||
assertSame(MinecraftReflection.getBukkitItemStack(nms.getIcon()).getType(), Material.GOLD_INGOT);
|
||||
assertSame(getItemStackTemplateConverter().getSpecific(nms.getIcon()).getType(), Material.GOLD_INGOT);
|
||||
assertEquals(5f, nms.getX(), 0f);
|
||||
assertEquals(67f, nms.getY(), 0f);
|
||||
}
|
||||
@@ -63,10 +66,10 @@ public class AutoWrapperTest {
|
||||
@Test
|
||||
public void testFromNms() {
|
||||
DisplayInfo display = new DisplayInfo(
|
||||
(net.minecraft.world.item.ItemStack)MinecraftReflection.getMinecraftItemStack(new ItemStack(Material.ENDER_EYE)),
|
||||
new ItemStackTemplate(Items.ENDER_EYE),
|
||||
Component.literal("Test123"),
|
||||
Component.literal("Test567"),
|
||||
Optional.of(new ClientAsset(ResourceLocation.fromNamespaceAndPath("minecraft", "test"))),
|
||||
Optional.of(new ClientAsset.ResourceTexture(Identifier.fromNamespaceAndPath("minecraft", "test"))),
|
||||
AdvancementType.CHALLENGE,
|
||||
true,
|
||||
false,
|
||||
@@ -94,7 +97,7 @@ public class AutoWrapperTest {
|
||||
.wrap(WrappedAdvancementDisplay.class, "advancements.AdvancementDisplay", "advancements.DisplayInfo")
|
||||
.field(0, BukkitConverters.getWrappedChatComponentConverter())
|
||||
.field(1, BukkitConverters.getWrappedChatComponentConverter())
|
||||
.field(2, BukkitConverters.getItemStackConverter())
|
||||
.field(2, getItemStackTemplateConverter())
|
||||
.field(3, Converters.optional(Converters.passthrough(ClientAsset.class)))
|
||||
.field(4, EnumWrappers.getGenericConverter(
|
||||
getMinecraftClass("advancements.AdvancementType", "advancements.AdvancementFrameType", "advancements.FrameType"),
|
||||
@@ -113,6 +116,28 @@ public class AutoWrapperTest {
|
||||
GOAL
|
||||
}
|
||||
|
||||
private static EquivalentConverter<ItemStack> getItemStackTemplateConverter() {
|
||||
return Converters.ignoreNull(new EquivalentConverter<ItemStack>() {
|
||||
|
||||
@Override
|
||||
public Object getGeneric(ItemStack specific) {
|
||||
var nmsItemStack = (net.minecraft.world.item.ItemStack) MinecraftReflection.getMinecraftItemStack(specific);
|
||||
return ItemStackTemplate.fromNonEmptyStack(nmsItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSpecific(Object generic) {
|
||||
var nmsItemStack = ((ItemStackTemplate) generic).create();
|
||||
return MinecraftReflection.getBukkitItemStack(nmsItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ItemStack> getSpecificType() {
|
||||
return ItemStack.class;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static final class WrappedAdvancementDisplay {
|
||||
|
||||
public WrappedChatComponent title;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ChunkCoordIntPairTest {
|
||||
(net.minecraft.world.level.ChunkPos) ChunkCoordIntPair.getConverter().
|
||||
getGeneric(specific);
|
||||
|
||||
assertEquals(1, roundtrip.x);
|
||||
assertEquals(2, roundtrip.z);
|
||||
assertEquals(1, roundtrip.x());
|
||||
assertEquals(2, roundtrip.z());
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,8 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
public class EnumWrappersTest {
|
||||
|
||||
private static final Set<String> KNOWN_INVALID = Sets.newHashSet(
|
||||
"Particle", "WorldBorderAction", "CombatEventType", "TitleAction", "ChatType", "TitleAction", "ScoreboardAction"
|
||||
"Particle", "WorldBorderAction", "CombatEventType", "TitleAction", "ChatType", "TitleAction",
|
||||
"ScoreboardAction", "EntityUseAction"
|
||||
);
|
||||
|
||||
@BeforeAll
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket.AttributeSnapshot;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -96,7 +96,7 @@ public class WrappedAttributeTest {
|
||||
|
||||
Registry<Attribute> registry = BuiltInRegistries.ATTRIBUTE;
|
||||
String attributeKey = attribute.getAttributeKey();
|
||||
ResourceLocation key = ResourceLocation.parse(attributeKey);
|
||||
Identifier key = Identifier.parse(attributeKey);
|
||||
Attribute base = registry.getValue(key);
|
||||
Holder<Attribute> holder = registry.wrapAsHolder(base);
|
||||
return new AttributeSnapshot(holder, attribute.getBaseValue(), modifiers);
|
||||
@@ -104,7 +104,7 @@ public class WrappedAttributeTest {
|
||||
|
||||
private AttributeModifier getModifierCopy(WrappedAttributeModifier modifier) {
|
||||
AttributeModifier.Operation operation = AttributeModifier.Operation.values()[modifier.getOperation().getId()];
|
||||
return new AttributeModifier((ResourceLocation) com.comphenix.protocol.wrappers.MinecraftKey.getConverter().getGeneric(modifier.getKey()),
|
||||
return new AttributeModifier((Identifier) com.comphenix.protocol.wrappers.MinecraftKey.getConverter().getGeneric(modifier.getKey()),
|
||||
modifier.getAmount(), operation);
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,9 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.GlassPane;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.block.impl.CraftStainedGlassPane;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.block.impl.CraftStainedGlassPane;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.comphenix.protocol.wrappers;
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
@@ -25,16 +24,13 @@ public class WrappedComponentStyleTest {
|
||||
net.minecraft.network.chat.Style style = net.minecraft.network.chat.Style.EMPTY.withColor(ChatFormatting.RED).withBold(true);
|
||||
WrappedComponentStyle wrapped = new WrappedComponentStyle(style);
|
||||
JsonElement json = wrapped.getJson();
|
||||
assertEquals("{\"bold\":true,\"color\":\"red\"}", json.toString());
|
||||
assertEquals("{\"color\":\"red\",\"bold\":true}", json.toString());
|
||||
assertEquals(style, WrappedComponentStyle.fromJson(json).getHandle());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStyleAdventureConversion() {
|
||||
Style adventureStyle = Style.style(NamedTextColor.GREEN, TextDecoration.BOLD);
|
||||
// TODO(fix): wait for https://github.com/KyoriPowered/adventure/issues/1194 to be fixed
|
||||
// .clickEvent(ClickEvent.changePage(10));
|
||||
|
||||
WrappedComponentStyle wrapped = AdventureComponentConverter.fromStyle(adventureStyle);
|
||||
assertEquals(adventureStyle, AdventureComponentConverter.fromWrapper(wrapped));
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
|
||||
import net.minecraft.world.entity.projectile.ThrownEgg;
|
||||
import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEgg;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.entity.CraftEgg;
|
||||
import org.bukkit.craftbukkit.entity.CraftEgg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -46,7 +46,7 @@ public class WrappedDataWatcherTest {
|
||||
public static void prepare() {
|
||||
BukkitInitialization.initializeAll();
|
||||
|
||||
ThrownEgg nmsEgg = new ThrownEgg(null, 0, 0, 0, net.minecraft.world.item.ItemStack.EMPTY);
|
||||
ThrownEgg nmsEgg = new ThrownEgg(BukkitInitialization.getMockServerLevel(), 0, 0, 0, net.minecraft.world.item.ItemStack.EMPTY);
|
||||
mockEntity = new CraftEgg(null, nmsEgg);
|
||||
}
|
||||
|
||||
@@ -201,7 +201,8 @@ public class WrappedDataWatcherTest {
|
||||
assertEquals(Particle.CAMPFIRE_COSY_SMOKE, ((WrappedParticle) wdvs.get(5).getValue()).getParticle());
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
// TODO: CompoundTag has been removed as a data watcher type (replaced with data components)
|
||||
public void testNBT() {
|
||||
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.UUID;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
@@ -27,8 +28,8 @@ public class WrappedGameProfileTest {
|
||||
"ProtocolLib");
|
||||
WrappedGameProfile wrapper = WrappedGameProfile.fromHandle(profile);
|
||||
|
||||
assertEquals(profile.getId(), wrapper.getUUID());
|
||||
assertEquals(profile.getName(), wrapper.getName());
|
||||
assertEquals(profile.id(), wrapper.getUUID());
|
||||
assertEquals(profile.name(), wrapper.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,18 +49,18 @@ public class WrappedGameProfileTest {
|
||||
|
||||
@Test
|
||||
void testGetProperties() {
|
||||
GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes("ProtocolLib".getBytes(StandardCharsets.UTF_8)),
|
||||
"ProtocolLib");
|
||||
|
||||
String name = "test";
|
||||
String value = "test";
|
||||
String signature = null;
|
||||
|
||||
profile.getProperties().put(name, new Property(name, value, signature));
|
||||
Multimap<String, Property> properties = ImmutableListMultimap.of(name, new Property(name, value));
|
||||
|
||||
GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes("ProtocolLib".getBytes(StandardCharsets.UTF_8)),
|
||||
"ProtocolLib", new PropertyMap(properties));
|
||||
|
||||
WrappedGameProfile wrapper = WrappedGameProfile.fromHandle(profile);
|
||||
Multimap<String, WrappedSignedProperty> properties = wrapper.getProperties();
|
||||
WrappedSignedProperty property = properties.get(name).iterator().next();
|
||||
Multimap<String, WrappedSignedProperty> wrappedProperties = wrapper.getProperties();
|
||||
WrappedSignedProperty property = wrappedProperties.get(name).iterator().next();
|
||||
|
||||
assertEquals(property.getName(), name);
|
||||
assertEquals(property.getValue(), value);
|
||||
@@ -77,7 +78,7 @@ public class WrappedGameProfileTest {
|
||||
wrapper.getProperties().put(name, new WrappedSignedProperty(name, value, signature));
|
||||
|
||||
GameProfile profile = (GameProfile) wrapper.getHandle();
|
||||
PropertyMap properties = profile.getProperties();
|
||||
PropertyMap properties = profile.properties();
|
||||
Property property = properties.get(name).iterator().next();
|
||||
|
||||
assertEquals(property.name(), name);
|
||||
|
||||
@@ -37,7 +37,8 @@ public class WrappedParticleTest {
|
||||
assertEquals(before.getData(), after.getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
// TODO: changed to ItemStackTemplate
|
||||
public void testItemStacks() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.WORLD_PARTICLES);
|
||||
WrappedParticle before = WrappedParticle.create(Particle.ITEM, new ItemStack(Material.FLINT_AND_STEEL));
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.comphenix.protocol.wrappers;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
|
||||
import net.minecraft.world.entity.PositionMoveRotation;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class WrappedPositionMoveRotationTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
BukkitInitialization.initializeAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndRead() {
|
||||
Vector position = new Vector(1.5, 64.0, -3.5);
|
||||
Vector delta = new Vector(0.1, -0.05, 0.2);
|
||||
float yRot = 45.0f;
|
||||
float xRot = -10.0f;
|
||||
|
||||
WrappedPositionMoveRotation created = WrappedPositionMoveRotation.create(position, delta, yRot, xRot);
|
||||
|
||||
assertEquals(position.getX(), created.getPosition().getX(), 1e-6);
|
||||
assertEquals(position.getY(), created.getPosition().getY(), 1e-6);
|
||||
assertEquals(position.getZ(), created.getPosition().getZ(), 1e-6);
|
||||
|
||||
assertEquals(delta.getX(), created.getDeltaMovement().getX(), 1e-6);
|
||||
assertEquals(delta.getY(), created.getDeltaMovement().getY(), 1e-6);
|
||||
assertEquals(delta.getZ(), created.getDeltaMovement().getZ(), 1e-6);
|
||||
|
||||
assertEquals(yRot, created.getYRot(), 1e-6f);
|
||||
assertEquals(xRot, created.getXRot(), 1e-6f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEntityPositionSyncPacket() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_POSITION_SYNC);
|
||||
|
||||
Vector position = new Vector(10.0, 70.0, -5.0);
|
||||
Vector delta = new Vector(0.0, 0.0, 0.0);
|
||||
float yRot = 90.0f;
|
||||
float xRot = 0.0f;
|
||||
|
||||
packet.getPositionMoveRotation().write(0,
|
||||
WrappedPositionMoveRotation.create(position, delta, yRot, xRot));
|
||||
|
||||
WrappedPositionMoveRotation result = packet.getPositionMoveRotation().read(0);
|
||||
|
||||
assertNotNull(result);
|
||||
|
||||
assertEquals(position.getX(), result.getPosition().getX(), 1e-6);
|
||||
assertEquals(position.getY(), result.getPosition().getY(), 1e-6);
|
||||
assertEquals(position.getZ(), result.getPosition().getZ(), 1e-6);
|
||||
|
||||
assertEquals(delta.getX(), result.getDeltaMovement().getX(), 1e-6);
|
||||
assertEquals(delta.getY(), result.getDeltaMovement().getY(), 1e-6);
|
||||
assertEquals(delta.getZ(), result.getDeltaMovement().getZ(), 1e-6);
|
||||
|
||||
assertEquals(yRot, result.getYRot(), 1e-6f);
|
||||
assertEquals(xRot, result.getXRot(), 1e-6f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEntityTeleportPacket() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
|
||||
|
||||
Vector position = new Vector(-100.5, 200.0, 300.75);
|
||||
Vector delta = new Vector(0.0, 0.0, 0.0);
|
||||
float yRot = 180.0f;
|
||||
float xRot = 30.0f;
|
||||
|
||||
packet.getPositionMoveRotation().write(0,
|
||||
WrappedPositionMoveRotation.create(position, delta, yRot, xRot));
|
||||
|
||||
WrappedPositionMoveRotation result = packet.getPositionMoveRotation().read(0);
|
||||
|
||||
assertNotNull(result);
|
||||
|
||||
assertEquals(position.getX(), result.getPosition().getX(), 1e-6);
|
||||
assertEquals(position.getY(), result.getPosition().getY(), 1e-6);
|
||||
assertEquals(position.getZ(), result.getPosition().getZ(), 1e-6);
|
||||
|
||||
assertEquals(delta.getX(), result.getDeltaMovement().getX(), 1e-6);
|
||||
assertEquals(delta.getY(), result.getDeltaMovement().getY(), 1e-6);
|
||||
assertEquals(delta.getZ(), result.getDeltaMovement().getZ(), 1e-6);
|
||||
|
||||
assertEquals(yRot, result.getYRot(), 1e-6f);
|
||||
assertEquals(xRot, result.getXRot(), 1e-6f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromHandle() {
|
||||
PositionMoveRotation nmsHandle = new PositionMoveRotation(
|
||||
new Vec3(5.0, 65.0, 5.0),
|
||||
new Vec3(0.0, -0.1, 0.0),
|
||||
270.0f,
|
||||
-45.0f);
|
||||
|
||||
WrappedPositionMoveRotation wrapper = WrappedPositionMoveRotation.fromHandle(nmsHandle);
|
||||
|
||||
assertEquals(5.0, wrapper.getPosition().getX(), 1e-6);
|
||||
assertEquals(65.0, wrapper.getPosition().getY(), 1e-6);
|
||||
assertEquals(5.0, wrapper.getPosition().getZ(), 1e-6);
|
||||
|
||||
assertEquals(0.0, wrapper.getDeltaMovement().getX(), 1e-6);
|
||||
assertEquals(-0.1, wrapper.getDeltaMovement().getY(), 1e-6);
|
||||
assertEquals(0.0, wrapper.getDeltaMovement().getZ(), 1e-6);
|
||||
|
||||
assertEquals(270.0f, wrapper.getYRot(), 1e-6f);
|
||||
assertEquals(-45.0f, wrapper.getXRot(), 1e-6f);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.comphenix.protocol.wrappers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
@@ -11,10 +14,13 @@ import com.comphenix.protocol.wrappers.WrappedServerPing.CompressedImage;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.server.players.NameAndId;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -73,10 +79,29 @@ public class WrappedServerPingTest {
|
||||
|
||||
assertArrayEquals(original, roundTrip.getFavicon().getData());
|
||||
|
||||
CompressedImage copy = CompressedImage.fromBase64Png(Base64Coder.encodeLines(tux.getData()));
|
||||
CompressedImage copy = CompressedImage.fromBase64Png(Base64.getEncoder().encodeToString(tux.getData()));
|
||||
assertArrayEquals(copy.getData(), roundTrip.getFavicon().getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPlayers() {
|
||||
ClientboundStatusResponsePacket packet = new ClientboundStatusResponsePacket(new ServerStatus(
|
||||
Component.literal("A Minecraft Server"),
|
||||
Optional.of(new ServerStatus.Players(2, 2, List.of(
|
||||
new NameAndId(UUID.randomUUID(), "Player1"),
|
||||
new NameAndId(UUID.randomUUID(), "Player2")
|
||||
))),
|
||||
Optional.empty(),
|
||||
Optional.empty(),
|
||||
false
|
||||
));
|
||||
|
||||
PacketContainer container = PacketContainer.fromPacket(packet);
|
||||
|
||||
WrappedServerPing wrappedServerStatus = container.getServerPings().read(0);
|
||||
assertEquals(2, wrappedServerStatus.getPlayers().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultData() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Status.Server.SERVER_INFO);
|
||||
|
||||
@@ -10,8 +10,8 @@ import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundOpenBookPacket;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.CraftRegistry;
|
||||
import org.bukkit.craftbukkit.v1_21_R5.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.CraftRegistry;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -5,14 +5,16 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.TeamCollisionRule;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.TeamVisibility;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
||||
import net.minecraft.world.scores.Team;
|
||||
import net.minecraft.world.scores.TeamColor;
|
||||
|
||||
public class WrappedTeamParametersTest {
|
||||
@BeforeAll
|
||||
@@ -47,12 +49,12 @@ public class WrappedTeamParametersTest {
|
||||
assertEquals(1, wrapped.getOptions());
|
||||
|
||||
ClientboundSetPlayerTeamPacket.Parameters handle = (ClientboundSetPlayerTeamPacket.Parameters) wrapped.getHandle();
|
||||
assertEquals(handle.getDisplayName(), displayName);
|
||||
assertEquals(handle.getPlayerPrefix(), prefix);
|
||||
assertEquals(handle.getPlayerSuffix(), suffix);
|
||||
assertEquals(handle.getNametagVisibility(), Team.Visibility.ALWAYS);
|
||||
assertEquals(handle.getCollisionRule(), Team.CollisionRule.NEVER);
|
||||
assertEquals(handle.getColor(), ChatFormatting.RED);
|
||||
assertEquals(handle.getOptions(), 1);
|
||||
assertEquals(handle.displayName(), displayName);
|
||||
assertEquals(handle.playerPrefix(), prefix);
|
||||
assertEquals(handle.playerSuffix(), suffix);
|
||||
assertEquals(handle.nameTagVisibility(), Team.Visibility.ALWAYS);
|
||||
assertEquals(handle.collisionRule(), Team.CollisionRule.NEVER);
|
||||
assertEquals(handle.color(), Optional.of(TeamColor.RED));
|
||||
assertEquals(handle.options(), 1);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user