Commit graph

81 commits

Author SHA1 Message Date
AlexProgrammerDE
bbe41efdb6 Move packets to proper packages & implement game thread metadata for every packet 2024-10-21 15:48:50 +02:00
Alex
fda25b5929
Fix/proxy protocol (#862)
Some checks failed
Java CI with Gradle / build (push) Has been cancelled
Deploy / build (push) Has been cancelled
2024-10-10 11:59:34 -04:00
Alex
f8460356db
Split incoming/outgoing packet registry, transition protocol states correctly (#841)
Some checks failed
Java CI with Gradle / build (push) Has been cancelled
Deploy / build (push) Has been cancelled
* Initial code changes

* Make it compile

* Small inlining

* Make less detectable by anticheats and fix keepalive during configuration

* Fix keepalive edge case

* Properly switch inbound protocol in server listener

* Add flow control

* Make toggling automatic keepalive work in another way

* Remove ping pong packets again

* Address review

* Handle keepalive in configuration

* Only spawn keepalive after login is acknowledged

* Prevent very unlikely race conditions with keepalive being switched during a task

* Add debug log for packet serialization and state switching

* Add one more debug print

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/Session.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/protocol/MinecraftProtocol.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/protocol/MinecraftProtocol.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Mark packet as nonnull

* Fix outbound writing race conditions

* Ensure packets are always sent on the event loop

This replicates the same approach Mojang uses in their networking code.

* Reduce log verbosity

* Put errors into debug

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/tcp/TcpClientSession.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Add comment to always running in event loop

* Handle auto read earlier to prevent race conditions

* Make instance dynamic

* Revert "Make instance dynamic"

This reverts commit 7f8affbdc5.

* Make flush packet priority

* Do not hide original line that is the cause of the exception

* Cancel packet using exception rather than return

* Properly iterate through parents

* Set log level to debug for unit tests

* Revert "Properly iterate through parents"

This reverts commit 4e2b64d983.

* Revert "Cancel packet using exception rather than return"

This reverts commit 6507e77bbe.

* Add write length filter

* Reuse bytebuf for fake flush to avoid unnecessary allocations

* Make tests happy

* Remake dropping packets

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/tcp/TcpServer.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Fix space

* Rename to flush packet

* Add mojmap reference

* Share keepalive code

* Fix compilation

* Revert a tiny bit closer to vanilla

* Inline lambda

* Inherit annotation

* Inherit annotation 2

* Use checkerframework annotation

* Fixup grammar slightly

* Add reset states method

* Add log marker for packet logging

---------

Co-authored-by: chris <github@onechris.mozmail.com>
2024-10-08 21:45:26 +08:00
Alex
b2c9268633
Implement static compression and encryption pipeline (#858)
Some checks failed
Java CI with Gradle / build (push) Has been cancelled
Deploy / build (push) Has been cancelled
* Implement static compression and encryption pipeline

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/Session.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/Session.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/Session.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Update Session.java

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/tcp/TcpSession.java

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>

* Use temp var

* Add nullable annotation

* enable -> create

* Rename encryption method

* Fix compression id

* Fix -1 compression in ServerListener

* Compress and encrypt in unit tests

---------

Co-authored-by: chris <github@onechris.mozmail.com>
Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>
2024-09-20 00:40:36 +08:00
Alex
de6bbe5f82
Allow accessing backing class for a channel instead of only its factory (#859)
Some checks failed
Java CI with Gradle / build (push) Has been cancelled
Deploy / build (push) Has been cancelled
Some netty libraries that are poorly coded only accept classes. Example: https://github.com/CloudburstMC/Network/pull/42
2024-09-16 21:44:28 -04:00
Alex
4148fa9b1f
Static sizer and timeout handlers in the pipeline (#833)
Some checks failed
Java CI with Gradle / build (push) Has been cancelled
Deploy / build (push) Has been cancelled
* Improve pipeline

This simplifies all pipeline code and ensures some listeners like the sizer are always present. The code already assumed that the sizer is always there and thus causes issues. The sizer can be deactivated still now and has pretty much no performance losses from this. The profit from this PR is that there is less logic with modifying the PR and thus developers interacting with the channel can assume specific things about the order and placements of elements in the pipeline. This will be useful once ViaVersion is supported, and it is expected that certain elements always are in the pipeline and don't change. My plan is to also always have an encryption and compression handler in the pipeline that is controlled via AttributeKeys from netty, but for that first #828 needs to be merged. So this PR only completes the goal partially, but that's fine. PR is ready for review like it is right now.

* Revert some stuff

* Fix channel race condition

* Fix closing race condition

* Prevent client race conditions.

* Fix test failure, idk how, idk why, but it works now

* Address review

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/BuiltinFlags.java

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/BuiltinFlags.java

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/BuiltinFlags.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/tcp/TcpServer.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/BuiltinFlags.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/BuiltinFlags.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/tcp/TcpServer.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/tcp/TcpServer.java

Co-authored-by: chris <github@onechris.mozmail.com>

* Update protocol/src/main/java/org/geysermc/mcprotocollib/network/tcp/TcpServer.java

Co-authored-by: chris <github@onechris.mozmail.com>

---------

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>
Co-authored-by: chris <github@onechris.mozmail.com>
2024-09-10 15:16:58 +08:00
masmc05
716f229e65
Support shouldAuthenticate = false (#856)
Some checks failed
Java CI with Gradle / build (push) Has been cancelled
Deploy / build (push) Has been cancelled
2024-09-03 00:34:43 +02:00
Alex
bb38c8ad9a
Optimize stack (#828)
* Increase encryption performance

* Release bufs when decrypting fails

* Use correct exceptions

* Improve compression performance

* Rename as requested by @Redned235

* Address review

* var name consistency

---------

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>
2024-07-28 00:26:14 +02:00
Eclipse
ab9bcbe151
Properly read/write food components (#843) 2024-07-24 21:30:06 -04:00
Alex
41eccedb93
Streamline api (#832)
This basically makes MinecraftCodec stateless and removes unused APIs.
The MinecraftCodecHelper has a state for an unused registry API, which is not needed at all. Developers can just send their own registry as seen in ServerListener. These only exist because there was an attempt at allowing multi-version support inside MinecraftCodecHelper, but that's not gonna be necessary if ViaVersion support gets added to MCPL.
The option to add back logic for multi-version support is fully open for the future. I didn't remove MinecraftCodecHelper being instance-based, so it's fully possible to readd the multi-version logic back in the future. Just level events and sounds being dynamic is not enough for multi-version support and thus should be removed to streamline the API.
This also removes many workarounds from the code that cause possible inconsistency. Often the MinecraftCodecHelper gets initialized in the tests with empty parameters. This removes them as parameters and removes the need to provide them by moving them to the object itself.
PacketCodecs were also improved to decrease the inheritance issues and streamline the code flow and remove the UnsupportedOperationExceptions being needed.
BufferedPacket was also removed since it's useless for Minecraft.
2024-07-20 16:26:32 -04:00
Alex
05a699d1ba
Fix edge-case where Texture#toString has a NullPointer, fix join requests (#838)
* Fix edge-case where Texture#toString has a NullPointer because gson set a null metadata

Also changes NORMAL name to WIDE since that's the accurate name.

* Fix join requests

Fixes #837
2024-07-18 12:20:02 +02:00
Alex
86903ecd73
Allow nullable primitives (#835)
* Allow nullable primitives

* Add missing annotations
2024-07-11 20:22:17 +02:00
Alex
2b2af7a424
Use translatable components like vanilla and cleanup type casts (#831)
* Use translatable components like vanilla and cleanup type casts

Just a few messages becoming dynamic using translatable components like vanilla instead of being hardcoded.

* Use checkerframework

* Readd disconnect string methods

* Do not make nullable
2024-07-07 17:31:18 +02:00
Alex
002754f3af
Fix proxy null check (#836) 2024-07-04 22:08:45 +02:00
Alex
060a4ee6df
Fix optional status fields (#821)
* Make code more readable before changes

* Use proper kyori methods

* Make PlayerInfo and VersionInfo optional

* Sort ServerStatusInfo fields in the way they appear in the packet
2024-06-21 01:54:29 +02:00
Alex
f2858940ca
Add slf4j to tests (#834)
This shows slf4j info logs in tests.
2024-06-18 17:14:41 +02:00
Alex
471e92ec6a
Replace MCAuth with RK_01 MinecraftAuth (#795)
* Initial work on moving over mcauth

* Initial work on importing MinecraftAuth

* Make compile

* Remove extra headers code

* Switch to different http utils

* Merge changes

* Cleanup

* Remove unused exceptions and constructors

* Implement proxies

* Fixup proxy stuff

* Cleanup

* Remove SR license header

* Remove custom exceptions

* Move auth into main module

Auth has become so small that it's not worth keeping separate

* Make ProxyInfo be part of network again

* Fix indent

* Allow null id and name in GameProfile

* Fix remaining logs

* Make texture checker more accurate

* Fix spaces

* Update dependencies

* Remove usage of var

* Use faster approach for reading raw uuids.
2024-06-17 13:23:42 -07:00
Alex
5624d7729a
Add coverage (#784) 2024-06-17 00:16:08 -07:00
basaigh
bdca10f1f9
Merge pull request #825
* Switch to Mojang mapped level event names
2024-06-16 16:41:20 +01:00
AJ Ferguson
4f5f6506fe Add usingConvertsTo in FoodProperties 2024-06-16 00:54:15 -04:00
basaigh
66b326f8a4
Merge pull request #820 from AlexProgrammerDE/better-status-packet
Allow using arbitrary json as the status packet
2024-06-16 02:42:25 +01:00
basaigh
dcf9d02d3a Fix ATTRIBUTE_MODIFIERS item component 2024-06-14 21:24:50 +01:00
Camotoy
f9cc9ee6f6
Prepare for release protocol 2024-06-12 22:50:37 -04:00
basaigh
cdb19eb946 Merge branch 'refs/heads/master' into feature/1.21
# Conflicts:
#	protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodecHelper.java
#	protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/chat/BuiltinChatType.java
2024-06-12 19:29:36 +01:00
basaigh
9fa4df56ae 1.21-rc1 2024-06-12 17:57:16 +01:00
Alex
97b68eddff
Use built-in ResourceLocation type (#811)
* Use built-in ResourceLocation type

* Use kyori Key instead of built-in type

* Fix missing keys

* Fix packets with incorrect resource location types

* Fix more packets with invalid resource locations

* Update jigsaw packet to use ResourceLocation

* Fix test compilation

* Fully use Key for ResourceProperties

* Fix all Key.key() warnings

* Fix HolderSet revert

* Address review
2024-06-10 22:22:17 +01:00
Camotoy
784e91c647
Merge remote-tracking branch 'origin/master' into feature/1.21 2024-06-09 15:36:13 -04:00
Camotoy
cac043d629
Holder helper methods and chat changes 2024-06-02 20:42:03 -04:00
Camotoy
2aed9da732
Merge remote-tracking branch 'origin/feature/1.21' into feature/1.21 2024-06-02 16:57:09 -04:00
basaigh
defc08d310 1.21-pre2 2024-06-02 16:57:42 +01:00
basaigh
2cccc328f9 1.21-pre1 2024-06-02 16:38:52 +01:00
Alex
ebc06dc94e
Add Slf4j (#808)
* Add slf4j

* Use lombok inside tests

* Fix double error printing

* Remove lombok annotation
2024-06-02 11:25:35 -04:00
basaigh
019b09247f 24w21a 2024-06-02 15:25:56 +01:00
basaigh
8965b5dc43 24w20a 2024-06-02 13:33:35 +01:00
Camotoy
937a571600
Merge remote-tracking branch 'origin/master' into feature/1.21 2024-05-31 23:10:25 -04:00
AlexProgrammerDE
f8f2a80f04 Make requested changes 2 2024-05-23 08:00:18 +02:00
AlexProgrammerDE
249dd153f6 Make requested changes 2024-05-23 07:59:29 +02:00
AlexProgrammerDE
6caa14e467 Allow using arbitrary json as the status packet 2024-05-22 19:59:49 +02:00
basaigh
1989a81610 24w19b 2024-05-22 18:39:18 +01:00
basaigh
ba9a35e43c 24w19a 2024-05-22 18:38:12 +01:00
Alex
a724a8fdb4
Implement HolderSet class and cleanup item codec (#818)
* Implement HolderSet class and cleanup item codec

* Also validate both being set case

* Fix equals and hashcode by migrating from a record to a class

* Change field names to match vanilla
2024-05-19 23:00:22 -04:00
onebeastchris
a1b559d20f fix typo in "FOLLOW_TRANFERS" 2024-05-18 20:42:11 +02:00
chris
bfaef4322b
Allow users of the default client listener to decide whether to automatically follow transfer packets (#817) 2024-05-18 18:23:24 +02:00
Alex
92acb01155
Implement some serialization better (#812)
* Implement some serialization better

* Fix buf naming
2024-05-17 22:13:05 +02:00
Alex
1b80c1b6eb
Fix writing mobeffectinstances (#814) 2024-05-16 16:28:23 -04:00
basaigh
d54eefcae1
Add missing new effects (#815) 2024-05-16 21:39:29 +02:00
Camotoy
ea95c5d3b2
Include networkCodec with all feature flags 2024-05-15 01:18:28 -04:00
Camotoy
115d3d4db2
Add flag to control sending KnownPacksPacket 2024-05-15 00:52:26 -04:00
Camotoy
d5298b3974
Bump to snapshot 2024-05-13 22:33:11 -04:00
Camotoy
98f0582029
Release 1.20.6-1 2024-05-13 22:24:56 -04:00