Add basic implementation.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.velocitypowered.api.proxy;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
|
||||
import com.velocitypowered.api.server.ServerInfo;
|
||||
import com.velocitypowered.api.util.MessagePosition;
|
||||
import net.kyori.text.Component;
|
||||
@@ -12,7 +13,7 @@ import java.util.UUID;
|
||||
/**
|
||||
* Represents a player who is connected to the proxy.
|
||||
*/
|
||||
public interface Player extends CommandSource, InboundConnection {
|
||||
public interface Player extends CommandSource, InboundConnection, ChannelMessageSource {
|
||||
/**
|
||||
* Returns the player's current username.
|
||||
* @return the username
|
||||
|
@@ -4,6 +4,7 @@ import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.event.EventManager;
|
||||
import com.velocitypowered.api.plugin.PluginManager;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelRegistrar;
|
||||
import com.velocitypowered.api.scheduler.Scheduler;
|
||||
import com.velocitypowered.api.server.ServerInfo;
|
||||
|
||||
@@ -101,4 +102,10 @@ public interface ProxyServer {
|
||||
* @return the scheduler instance
|
||||
*/
|
||||
Scheduler getScheduler();
|
||||
|
||||
/**
|
||||
* Gets the {@link ChannelRegistrar} instance.
|
||||
* @return the channel registrar
|
||||
*/
|
||||
ChannelRegistrar getChannelRegistrar();
|
||||
}
|
||||
|
@@ -1,11 +1,12 @@
|
||||
package com.velocitypowered.api.proxy;
|
||||
|
||||
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 {
|
||||
public interface ServerConnection extends ChannelMessageSource {
|
||||
ServerInfo getServerInfo();
|
||||
|
||||
Player getPlayer();
|
||||
|
@@ -4,4 +4,5 @@ package com.velocitypowered.api.proxy.messages;
|
||||
* Represents a kind of channel identifier.
|
||||
*/
|
||||
public interface ChannelIdentifier {
|
||||
String getId();
|
||||
}
|
||||
|
@@ -0,0 +1,4 @@
|
||||
package com.velocitypowered.api.proxy.messages;
|
||||
|
||||
public interface ChannelMessageSource {
|
||||
}
|
@@ -1,4 +1,11 @@
|
||||
package com.velocitypowered.api.proxy.messages;
|
||||
|
||||
/**
|
||||
* Represents an interface to register and unregister {@link MessageHandler} instances for handling plugin messages from
|
||||
* the client or the server.
|
||||
*/
|
||||
public interface ChannelRegistrar {
|
||||
void register(MessageHandler handler, ChannelIdentifier... identifiers);
|
||||
|
||||
void unregister(ChannelIdentifier... identifiers);
|
||||
}
|
||||
|
@@ -0,0 +1,6 @@
|
||||
package com.velocitypowered.api.proxy.messages;
|
||||
|
||||
public enum ChannelSide {
|
||||
FROM_SERVER,
|
||||
FROM_CLIENT
|
||||
}
|
@@ -40,4 +40,9 @@ public final class LegacyChannelIdentifier implements ChannelIdentifier {
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,10 @@
|
||||
package com.velocitypowered.api.proxy.messages;
|
||||
|
||||
public interface MessageHandler {
|
||||
ForwardStatus handle(ChannelMessageSource source, ChannelSide side, byte[] data);
|
||||
|
||||
enum ForwardStatus {
|
||||
FORWARD,
|
||||
HANDLED
|
||||
}
|
||||
}
|
@@ -61,4 +61,9 @@ public final class MinecraftChannelIdentifier implements ChannelIdentifier {
|
||||
public int hashCode() {
|
||||
return Objects.hash(namespace, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return namespace + ":" + name;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user