Class PluginMessageEvent
java.lang.Object
com.velocitypowered.api.event.connection.PluginMessageEvent
- All Implemented Interfaces:
ResultedEvent<PluginMessageEvent.ForwardResult>
@AwaitingEvent
public final class PluginMessageEvent
extends Object
implements ResultedEvent<PluginMessageEvent.ForwardResult>
This event is fired when a plugin message is sent to the proxy, either from a client (
Player) or a server (ServerConnection). Velocity will wait on this event to finish
firing before discarding the sent plugin message (if handled) or forwarding it to the server.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA result determining whether or not to forward this message on.Nested classes/interfaces inherited from interface com.velocitypowered.api.event.ResultedEvent
ResultedEvent.ComponentResult, ResultedEvent.GenericResult, ResultedEvent.Result -
Constructor Summary
ConstructorsConstructorDescriptionPluginMessageEvent(ChannelMessageSource source, ChannelMessageSink target, ChannelIdentifier identifier, byte[] data) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns the plugin message payload as aByteArrayDataInput.Returns the plugin message payload as aByteArrayInputStream.byte[]getData()Gets the raw payload of the plugin message.Gets the channel identifier this message was sent on.Returns the result associated with this event.Gets the source that sent this plugin message (aPlayerorServerConnection).Gets the target recipient of this plugin message.voidSets the result of this event.toString()
-
Constructor Details
-
PluginMessageEvent
public PluginMessageEvent(ChannelMessageSource source, ChannelMessageSink target, ChannelIdentifier identifier, byte[] data) Creates a new instance.- Parameters:
source- the source of the plugin messagetarget- the destination of the plugin messageidentifier- the channel for this plugin messagedata- the payload of the plugin message
-
-
Method Details
-
getResult
Description copied from interface:ResultedEventReturns the result associated with this event.- Specified by:
getResultin interfaceResultedEvent<PluginMessageEvent.ForwardResult>- Returns:
- the result of this event
-
setResult
Description copied from interface:ResultedEventSets the result of this event. The result must be non-null.- Specified by:
setResultin interfaceResultedEvent<PluginMessageEvent.ForwardResult>- Parameters:
result- the new result
-
getSource
Gets the source that sent this plugin message (aPlayerorServerConnection).- Returns:
- the message source
-
getTarget
Gets the target recipient of this plugin message.- Returns:
- the message sink
-
getIdentifier
Gets the channel identifier this message was sent on.- Returns:
- the plugin message identifier
-
getData
public byte[] getData()Gets the raw payload of the plugin message.- Returns:
- a copy of the message data
-
dataAsInputStream
Returns the plugin message payload as aByteArrayInputStream.- Returns:
- the input stream wrapping the data
-
dataAsDataStream
Returns the plugin message payload as aByteArrayDataInput.- Returns:
- the data input stream for reading structured data
-
toString
-