Class PluginMessageEvent
java.lang.Object
me.internalizable.numdrassl.api.event.connection.PluginMessageEvent
Event fired when a plugin message is received from a backend server.
Plugin messages allow backend servers to communicate with the proxy through registered channels. This is commonly used for cross-server synchronization.
Example Usage
@Subscribe
public void onPluginMessage(PluginMessageEvent event) {
if (event.getIdentifier().getId().equals("luckperms:data")) {
byte[] data = event.getData();
// Process the LuckPerms sync data
// Mark as handled to prevent forwarding
event.setResult(ForwardResult.handled());
}
}
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents the result of plugin message handling. -
Constructor Summary
ConstructorsConstructorDescriptionPluginMessageEvent(ChannelIdentifier identifier, Object source, byte[] data) Creates a new plugin message event. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getData()Gets the message data.Gets the channel identifier for this message.Gets the forward result for this message.Gets the source of this message.voidSets whether this message should be forwarded.
-
Constructor Details
-
PluginMessageEvent
public PluginMessageEvent(@Nonnull ChannelIdentifier identifier, @Nonnull Object source, @Nonnull byte[] data) Creates a new plugin message event.- Parameters:
identifier- the channel identifiersource- the source (RegisteredServer or Player)data- the message data
-
-
Method Details
-
getIdentifier
Gets the channel identifier for this message.- Returns:
- the channel identifier
-
getSource
Gets the source of this message.This can be either a
RegisteredServer(if the message came from a backend) or aPlayer(if it came from a client).- Returns:
- the message source
-
getData
@Nonnull public byte[] getData()Gets the message data.- Returns:
- the raw message bytes
-
getResult
Gets the forward result for this message.- Returns:
- the forward result
-
setResult
Sets whether this message should be forwarded.- Parameters:
result- the forward result
-