Commit graph

78 commits

Author SHA1 Message Date
Camotoy
f4c07f23b5
Merge remote-tracking branch 'origin/master' into feature/1.21.2
Some checks failed
Java CI with Gradle / build (push) Has been cancelled
2024-10-17 14:08:01 -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
basaigh
c69a8c3537 24w33a 2024-08-24 15:15:45 +01: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
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
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
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
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
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
Alex
7cd054175a
Optimize imports & add spaces (#802)
* Optimize imports

* Revert "Optimize imports"

This reverts commit beb00d647f.

* Optimize imports 2

* Revert line length changes

* More optimized imports

* Revert again

* More import cleanup
2024-04-28 16:43:27 +02:00
Alex
d74e292201 Revamp flag system (#789) 2024-04-24 08:58:52 +02:00
Alex
fa6b59ad02 Move package/license to GeyserMC, gradle conventions and submodules (#782)
* Change packages

* Move everything to a protocol submodule

* gradle conventions, update license

---------

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>
2024-04-24 08:58:19 +02:00
Alex
4e54830fbc Remove unused exceptions, use java 9+ features and checkerframework, other cleanup (#780) 2024-04-24 08:50:31 +02:00
basaigh
a90e2f270a Add full support for the transfer packet
I hope
2024-04-11 23:39:55 +01:00
basaigh
7cdfa6ef36 24w04a 2024-02-10 20:55:38 +00:00
basaigh
8f1834d906 Update tests 2024-02-07 23:10:29 +00:00
Alex
ff317f1a9a
Migrate to gradle, fix examples (#769) 2023-12-19 13:01:53 -05:00
basaigh
1c57135e6c 1.20.2-pre1 2023-09-06 18:06:21 +01:00
basaigh
48c189f651 23w31a part 2 electric boogaloo
Fixed tests, updated the login cycle and some misc touch-ups
2023-09-06 18:06:19 +01:00
Kas-tle
910a0009b9
Merge packetlib w/ commit history 2023-03-09 21:38:07 +00:00
D3ATHBRINGER13
48ea5a2c53
Update the example to 1.19.2 (#712)
* Update the example to 1.19.2 and fix the malformed network codec left in the tests.

* We really need to decide on a standard name for this.
2022-11-05 16:30:19 -04:00
Camotoy
54fc9f0750
Rename MessageType; use Object2IntMap for Statistics 2022-06-15 18:28:40 -04:00
Camotoy
3023c4d1b0
The MessageType registry is flexible 2022-06-08 22:26:01 -04:00
RednedEpic
3a51f530c6 PacketLib 3.0
Changes:
- Removed NetInput/NetOutput and replaced them with ByteBuf
- Added PacketSerializer to PacketDefinition
- Added packet codecs which implementations can supply with custom readers/writers for buffers
2022-05-29 12:40:39 -05:00
circuit10
55fe033136
Add new 1.18 tags in example (#678) 2021-12-09 14:02:32 -05:00
Camotoy
8eca14983a Update for PacketLib changes 2021-11-24 23:33:39 -05:00
Camotoy
9e38c61927 Remove allocations for packet receive and send events
These were just replaced with functions that call the session and packet.
2021-11-24 23:32:14 -05:00
Camotoy
62492c961a
Entity metadata refactor; remove some MagicValues usages 2021-11-15 14:51:03 -05:00
RednedEpic
5b4ba5b8d0 Merge branch 'feature/1.18' into feature/codec-refactor 2021-11-13 20:10:44 -06:00
RednedEpic
64410dbe48 Implement packet codec system to remove expensive protocol state switches
With the way this lib used to previously work, any time the protocol state changed, all the packet maps got cleared and had new packets inserted into them depending on the protocol state. This was unnecessarily expensive and although called rarely, it was not ideal.

The packet codecs added are static, immutable and can be reused across sessions. The codec system also opens up the door for multi-version capability in the future.
2021-11-13 16:44:55 -06:00
RednedEpic
459e5287cc Update examples to reflect changes done 2021-11-13 12:15:43 -06:00
Camotoy
73659fe559
Update example 2021-11-12 17:37:25 -05:00
D3ATHBRINGER13
8fcf4df994
Refactor to use Mojmap packet names (#662)
This allows packet name parity with Minecraft itself.
2021-11-12 12:59:12 -05:00
Steveice10
270261ba2d Update to latest MCAuthLib commit. 2021-09-06 15:05:31 -07:00
Steveice10
893cc683cb Update to latest PacketLib commit. 2021-04-20 18:28:14 -07:00
Steveice10
bcf5232781 Tidy up auth data handling. 2021-03-30 11:23:41 -07:00
Steveice10
19a9b2be35 Collapse Client and Server into *ClientSession and ConnectionListener. 2021-01-15 12:45:06 -08:00
Steveice10
ccbd52dffd Replace Message API with Adventure component parsing. 2020-11-21 13:42:36 -08:00
Steveice10
c38a9fe61e Add missing imports 2020-10-15 14:56:16 -07:00
Steveice10
2ac116a075 Revise chunk storage code based on latest logic. 2020-10-13 16:18:56 -07:00
rtm516
0d78575081
Fix dimension tag in example 2020-10-10 17:52:13 +01:00
Steveice10
6c66d7e27b Replace specifying proxy with specifying custom auth service clients. 2020-08-29 11:16:34 -07:00
Steveice10
46b46001f6 Remove equals and hashCode ignore from chunks and fix example. 2020-07-10 17:31:26 -07:00
RednedEpic
795ae325b8 Resolve merge conflicts 2020-06-20 15:52:20 -05:00
Steveice10
f142eab3a2 Overhaul JSON message classes to be immutable and use a builder pattern. 2020-06-06 14:54:40 -07:00
Steveice10
1840d5aa3d Remove server list icon decoding as ImageIO/BufferedImage do not exist on Android. 2020-06-03 14:58:49 -07:00
RednedEpic
20f73c5e1e Update to 20w20a 2020-05-13 16:06:26 -05:00
Steveice10
3c6cbb2cff Update for PacketLib changes. 2020-02-26 18:22:38 -08:00
Steveice10
6663b2e66f Fix example code. 2019-12-17 16:45:32 -08:00