Class ServerListPingEvent

java.lang.Object
net.minestom.server.event.server.ServerListPingEvent
All Implemented Interfaces:
Event, CancellableEvent

public class ServerListPingEvent extends Object implements CancellableEvent
Called when a PlayerConnection sends a status packet, usually to display information on the server list.
  • Constructor Details

    • ServerListPingEvent

      public ServerListPingEvent(@NotNull @NotNull ServerListPingType type)
      Creates a new server list ping event with no player connection.
      Parameters:
      type - the ping type to respond with
    • ServerListPingEvent

      public ServerListPingEvent(@Nullable @Nullable PlayerConnection connection, @NotNull @NotNull ServerListPingType type)
      Creates a new server list ping event.
      Parameters:
      connection - the player connection, if the ping type is modern
      type - the ping type to respond with
  • Method Details

    • getResponseData

      @NotNull public @NotNull ResponseData getResponseData()
      Gets the response data that is sent to the client. This is mutable and can be modified to change what is returned.
      Returns:
      the response data being returned
    • setResponseData

      public void setResponseData(@NotNull @NotNull ResponseData responseData)
      Sets the response data, overwriting the exiting data.
      Parameters:
      responseData - the new data
    • getConnection

      @Nullable public @Nullable PlayerConnection getConnection()
      PlayerConnection of received packet. Note that the player has not joined the server at this time. This will only be non-null for modern server list pings.
      Returns:
      the playerConnection.
    • getPingType

      @NotNull public @NotNull ServerListPingType getPingType()
      Gets the ping type that the client is pinging with.
      Returns:
      the ping type
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: CancellableEvent
      Gets if the Event should be cancelled or not.
      Specified by:
      isCancelled in interface CancellableEvent
      Returns:
      true if the event should be cancelled
    • setCancelled

      public void setCancelled(boolean cancel)
      Cancelling this event will cause the server to appear offline in the vanilla server list. Note that this will have no effect if the ping version is ServerListPingType.OPEN_TO_LAN.
      Specified by:
      setCancelled in interface CancellableEvent
      Parameters:
      cancel - true if the event should be cancelled, false otherwise