Class QueryEvent<T>
java.lang.Object
net.minestom.server.extras.query.event.QueryEvent<T>
- Type Parameters:
T
- the type of the response
- All Implemented Interfaces:
Event
,CancellableEvent
- Direct Known Subclasses:
BasicQueryEvent
,FullQueryEvent
An event called when a query is received and ready to be responded to.
-
Constructor Summary
ConstructorDescriptionQueryEvent
(@NotNull SocketAddress sender, int sessionID, T response) Creates a new query event. -
Method Summary
Modifier and TypeMethodDescriptionGets the query response that will be sent back to the sender.@NotNull SocketAddress
Gets the socket address of the initiator of the query.int
Gets the Session ID of the initiator of the query.boolean
Gets if theEvent
should be cancelled or not.void
setCancelled
(boolean cancel) Marks theEvent
as cancelled or not.void
setQueryResponse
(T response) Sets the query response that will be sent back to the sender.
-
Constructor Details
-
QueryEvent
Creates a new query event.- Parameters:
sender
- the sendersessionID
- the session ID of the query senderresponse
- the initial response
-
-
Method Details
-
getQueryResponse
Gets the query response that will be sent back to the sender. This can be mutated.- Returns:
- the response
-
setQueryResponse
Sets the query response that will be sent back to the sender.- Parameters:
response
- the response
-
getSender
Gets the socket address of the initiator of the query.- Returns:
- the initiator
-
getSessionID
public int getSessionID()Gets the Session ID of the initiator of the query.- Returns:
- the session ID
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableEvent
Gets if theEvent
should be cancelled or not.- Specified by:
isCancelled
in interfaceCancellableEvent
- Returns:
- true if the event should be cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableEvent
Marks theEvent
as cancelled or not.- Specified by:
setCancelled
in interfaceCancellableEvent
- Parameters:
cancel
- true if the event should be cancelled, false otherwise
-