Add support for sending plugin messages over the wire

This commit is contained in:
Andrew Steinborn
2018-08-22 00:53:02 -04:00
parent 8352f7fa70
commit c36f417b1e
7 changed files with 48 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
package com.velocitypowered.api.proxy;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
import com.velocitypowered.api.server.ServerInfo;
import com.velocitypowered.api.util.MessagePosition;
@@ -13,7 +14,7 @@ import java.util.UUID;
/**
* Represents a player who is connected to the proxy.
*/
public interface Player extends CommandSource, InboundConnection, ChannelMessageSource {
public interface Player extends CommandSource, InboundConnection, ChannelMessageSource, ChannelMessageSink {
/**
* Returns the player's current username.
* @return the username

View File

@@ -1,12 +1,13 @@
package com.velocitypowered.api.proxy;
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
import com.velocitypowered.api.server.ServerInfo;
/**
* Represents a connection to a backend server from the proxy for a client.
*/
public interface ServerConnection extends ChannelMessageSource {
public interface ServerConnection extends ChannelMessageSource, ChannelMessageSink {
ServerInfo getServerInfo();
Player getPlayer();

View File

@@ -0,0 +1,5 @@
package com.velocitypowered.api.proxy.messages;
public interface ChannelMessageSink {
void sendPluginMessage(ChannelIdentifier identifier, byte[] data);
}

View File

@@ -1,7 +1,7 @@
package com.velocitypowered.api.proxy.messages;
public interface MessageHandler {
ForwardStatus handle(ChannelMessageSource source, ChannelSide side, byte[] data);
ForwardStatus handle(ChannelMessageSource source, ChannelSide side, ChannelIdentifier identifier, byte[] data);
enum ForwardStatus {
FORWARD,