-
-
Notifications
You must be signed in to change notification settings - Fork 74
feat: add cookies #507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add cookies #507
Conversation
Thank you! I'll try to merge when I find the time |
As an afterthought, can we move all public cookie logic into a standalone package? I'm trying to avoid adding more functions to the Player interface. I'm thinking a |
Okay I'll take a look at it 👍 |
Okay I think i managed to resolve every requested change. @robinbraemer Is this how you visioned the cookie package? The only thing I don't really like is how the CookieResponseEvent doesn't return the Cookie structure, since its not possible due to import cycle. This also made it so I needed to put the map in the proxy package instead of the cookie package but I don't think that is a problem. |
When this can be merged, I’m waiting for it |
There are a few things I have to iterate on.
|
Hello, cookie packets were introduced in Minecraft 1.20.5 along with transfer packets, an underrated feature that can be particularly useful in multi-proxy scenarios. That’s why I found it unfortunate that this functionality wasn’t included in the Gate API, so I decided to add it myself!
I added three functions to the
player
variable:player.CookieStore(key key.Key, payload []byte) error
This function sends a cookie to the player, storing it even between transfers until the player disconnects. It returns an error if:
player.CookieRequest(key key.Key) error
This function requests a cookie from the player. The player then sends a response packet, which can be handled with the
PlayerCookieResponseEvent
(explained later). It returns an error if:player.CookieRequestWithResult(key key.Key) ([]byte, error)
This function retrieves a cookie immediately instead of relying on
PlayerCookieResponseEvent
. It waits for a response from the player for up to 5 seconds. It returns an error if:I added a new event called
PlayerCookieResponseEvent
, which listens for cookie response packets. This event contains the player, key, and payload. If the requested cookie is not found, an empty payload is returned.You can test the features with this wonderful mod that I found called: CookieJar by Tis_awesomeness.