ProxiedPlayer interface

This commit is contained in:
Andrew Steinborn
2018-08-04 01:40:37 -04:00
parent 9438d087e2
commit 9bcdc413d7
4 changed files with 122 additions and 1 deletions

View File

@@ -0,0 +1,60 @@
package com.velocitypowered.api.proxy;
import com.velocitypowered.api.server.ServerInfo;
import com.velocitypowered.api.util.MessagePosition;
import net.kyori.text.Component;
import javax.annotation.Nonnull;
import java.net.InetSocketAddress;
import java.util.Optional;
import java.util.UUID;
/**
* Represents a player who is connected to the proxy.
*/
public interface ProxiedPlayer {
/**
* Returns the player's current username.
* @return the username
*/
String getUsername();
/**
* Returns the player's UUID.
* @return the UUID
*/
UUID getUniqueId();
/**
* Returns the server that the player is currently connected to.
* @return an {@link Optional} the server that the player is connected to, which may be empty
*/
Optional<ServerInfo> getCurrentServer();
/**
* Returns the player's IP address.
* @return the player's IP
*/
InetSocketAddress getRemoteAddress();
/**
* Determine whether or not the player remains online.
* @return whether or not the player active
*/
boolean isActive();
/**
* Sends a chat message to the player's client.
* @param component the chat message to send
*/
default void sendMessage(@Nonnull Component component) {
sendMessage(component, MessagePosition.CHAT);
}
/**
* Sends a chat message to the player's client in the specified position.
* @param component the chat message to send
* @param position the position for the message
*/
void sendMessage(@Nonnull Component component, @Nonnull MessagePosition position);
}

View File

@@ -0,0 +1,20 @@
package com.velocitypowered.api.util;
/**
* Represents where a chat message is going to be sent.
*/
public enum MessagePosition {
/**
* The chat message will appear in the client's HUD. These messages can be filtered out by the client.
*/
CHAT,
/**
* The chat message will appear in the client's HUD and can't be dismissed.
*/
SYSTEM,
/**
* The chat message will appear above the player's main HUD. This text format doesn't support many component features,
* such as hover events.
*/
ACTION_BAR
}