-
-
Notifications
You must be signed in to change notification settings - Fork 674
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
Add ServerCustomPayloadEvent #4589
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I've added a few comments.
api/src/main/java/org/geysermc/geyser/api/event/java/ServerCustomPayloadEvent.java
Outdated
Show resolved
Hide resolved
api/src/main/java/org/geysermc/geyser/api/event/java/ServerCustomPayloadEvent.java
Outdated
Show resolved
Hide resolved
api/src/main/java/org/geysermc/geyser/api/event/java/ServerCustomPayloadEvent.java
Outdated
Show resolved
Hide resolved
api/src/main/java/org/geysermc/geyser/api/event/java/ServerCustomPayloadEvent.java
Outdated
Show resolved
Hide resolved
api/src/main/java/org/geysermc/geyser/api/event/java/ServerCustomPayloadEvent.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCustomPayloadTranslator.java
Outdated
Show resolved
Hide resolved
Co-authored-by: chris <github@onechris.mozmail.com>
…t clear Co-authored-by: chris <github@onechris.mozmail.com>
Co-authored-by: chris <github@onechris.mozmail.com>
Alright all requested changes are done :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, missed these
.../src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCustomPayloadTranslator.java
Outdated
Show resolved
Hide resolved
api/src/main/java/org/geysermc/geyser/api/event/java/ServerCustomPayloadEvent.java
Outdated
Show resolved
Hide resolved
Alright done |
.../src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCustomPayloadTranslator.java
Outdated
Show resolved
Hide resolved
Done |
I think having an event for custom payloads is a feature that would be great to have in the API, however I think it should be a bit higher-level than this. I'm thinking a more polished network API is the direction I'd want to go with Geyser, since messing with raw buffers on an API level is not the greatest. The design I'm thinking of is a bit of a hybrid between the Fabric and Forge APIs, namely enforcing registering custom channels with message handlers. Something along the lines of: @Subscribe
public void onDefineNetworkChannels(GeyserDefineNetworkChannelsEvent event) {
event.register(NetworkChannel.of(this, "my_message"), MyMessage::new)
} With a message looking like: public record MyMessage(int num) {
public MyMessage(MessageBuffer buffer) {
this(buffer.read(MessageType.INT));
}
public void encode(MessageBuffer buffer) {
buffer.write(MessageType.INT, this.num);
}
} And sending being handled by running: GeyserConnection connection = ...
GeyserApi.api().networkManager().send(connection, new MyMessage(5));
All of this would happen over custom payload packets under the hood, but just means we can offer something higher level than just having a raw binary and enforcing a proper codec. With something like this, the event would then need to be modified to instead have a I know this is something that is far larger in scope than what is done here, however if you'd like to work on something like this, feel free to reach out on Discord and I'd be happy to go into more detail and offer support where needed. Also very welcome to feedback and suggestions too. |
Since this isn't the implementation we want to have to Geyser, I'll close this PR. Thank you so much for the PR anyway! |
This pull request adds
ServerCustomPayloadEvent
to the plugin's API. This allows extensions/addons to understand some special custom payloads (also known as plugin messages) and act accordingly. This event is not called when floodgate custom payloads are received.