Package dev.jorel.commandapi.network
Class VelocityCommandAPIMessenger
java.lang.Object
dev.jorel.commandapi.network.CommandAPIMessenger<com.velocitypowered.api.proxy.messages.ChannelMessageSource,com.velocitypowered.api.proxy.messages.ChannelMessageSink>
dev.jorel.commandapi.network.VelocityCommandAPIMessenger
public class VelocityCommandAPIMessenger
extends CommandAPIMessenger<com.velocitypowered.api.proxy.messages.ChannelMessageSource,com.velocitypowered.api.proxy.messages.ChannelMessageSink>
A
CommandAPIMessenger for sending and receiving messages on Velocity.
Velocity may receive messages from a Client (Player) or a Server (ServerConnection). The common
interface is ChannelMessageSource (coming into Velocity) and ChannelMessageSink (going out of
Velocity). Packets may be handled differently depending on their direction, so check which of these two sent
the packet before continuing.
-
Constructor Summary
ConstructorsConstructorDescriptionVelocityCommandAPIMessenger(Object plugin, com.velocitypowered.api.proxy.ProxyServer proxy) Creates a newVelocityCommandAPIMessenger. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intgetConnectionProtocolVersion(com.velocitypowered.api.proxy.messages.ChannelMessageSink target) voidonPlayerLeave(com.velocitypowered.api.event.connection.DisconnectEvent event) voidonPluginMessageEvent(com.velocitypowered.api.event.connection.PluginMessageEvent event) voidonServerConnected(com.velocitypowered.api.event.player.ServerPostConnectEvent event) voidsendRawBytes(CommandAPIProtocol protocol, com.velocitypowered.api.proxy.messages.ChannelMessageSink target, byte[] bytes) voidsetPlayerProtocolVersion(com.velocitypowered.api.proxy.Player player, int protocolVersion) Sets theCommandAPIProtocol.PROTOCOL_VERSIONbeing used by the given player.voidsetServerProtocolVersion(com.velocitypowered.api.proxy.ServerConnection server, int protocolVersion) Sets theCommandAPIProtocol.PROTOCOL_VERSIONbeing used by the given server.Methods inherited from class dev.jorel.commandapi.network.CommandAPIMessenger
messageReceived, sendPacket
-
Constructor Details
-
VelocityCommandAPIMessenger
Creates a newVelocityCommandAPIMessenger.- Parameters:
plugin- The plugin object (annotated byPlugin) sending and receiving messages.proxy- TheProxyServerthe plugin is running on.
-
-
Method Details
-
onServerConnected
public void onServerConnected(com.velocitypowered.api.event.player.ServerPostConnectEvent event) -
onPlayerLeave
public void onPlayerLeave(com.velocitypowered.api.event.connection.DisconnectEvent event) -
close
public void close()- Specified by:
closein classCommandAPIMessenger<com.velocitypowered.api.proxy.messages.ChannelMessageSource,com.velocitypowered.api.proxy.messages.ChannelMessageSink>
-
setServerProtocolVersion
public void setServerProtocolVersion(com.velocitypowered.api.proxy.ServerConnection server, int protocolVersion) Sets theCommandAPIProtocol.PROTOCOL_VERSIONbeing used by the given server. This is only intended to be called byVelocityHandshakePacketHandler.handleSetVersionPacket(ChannelMessageSource, SetVersionPacket)when aSetVersionPacketis received.- Parameters:
server- The server that sent theSetVersionPacket.protocolVersion- TheCommandAPIProtocol.PROTOCOL_VERSIONin theSetVersionPacket.
-
setPlayerProtocolVersion
public void setPlayerProtocolVersion(com.velocitypowered.api.proxy.Player player, int protocolVersion) Sets theCommandAPIProtocol.PROTOCOL_VERSIONbeing used by the given player. This is only intended to be called byVelocityHandshakePacketHandler.handleSetVersionPacket(ChannelMessageSource, SetVersionPacket)when aSetVersionPacketis received.- Parameters:
player- The player that sent theSetVersionPacket.protocolVersion- TheCommandAPIProtocol.PROTOCOL_VERSIONin theSetVersionPacket.
-
getConnectionProtocolVersion
public int getConnectionProtocolVersion(com.velocitypowered.api.proxy.messages.ChannelMessageSink target) - Specified by:
getConnectionProtocolVersionin classCommandAPIMessenger<com.velocitypowered.api.proxy.messages.ChannelMessageSource,com.velocitypowered.api.proxy.messages.ChannelMessageSink>
-
onPluginMessageEvent
public void onPluginMessageEvent(com.velocitypowered.api.event.connection.PluginMessageEvent event) -
sendRawBytes
public void sendRawBytes(CommandAPIProtocol protocol, com.velocitypowered.api.proxy.messages.ChannelMessageSink target, byte[] bytes) - Specified by:
sendRawBytesin classCommandAPIMessenger<com.velocitypowered.api.proxy.messages.ChannelMessageSource,com.velocitypowered.api.proxy.messages.ChannelMessageSink>
-