#3864: Add ServerLinks API
This commit is contained in:
77
api/src/main/java/net/md_5/bungee/api/ServerLink.java
Normal file
77
api/src/main/java/net/md_5/bungee/api/ServerLink.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
/**
|
||||
* Represents a server link which may be sent to the client.
|
||||
*/
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class ServerLink
|
||||
{
|
||||
|
||||
/**
|
||||
* The links type.
|
||||
*
|
||||
* Note: This value is nullable, if null, label is non-null.
|
||||
*/
|
||||
private final LinkType type;
|
||||
|
||||
/**
|
||||
* The label for the link.
|
||||
*
|
||||
* Note: This value is nullable, if null, type is non-null.
|
||||
*/
|
||||
private final BaseComponent label;
|
||||
|
||||
/**
|
||||
* The URL that is displayed.
|
||||
*/
|
||||
@NonNull
|
||||
private final String url;
|
||||
|
||||
/**
|
||||
* Creates a link with a specified type and URL.
|
||||
*
|
||||
* @param type the type of the link
|
||||
* @param url the URL to be displayed
|
||||
*/
|
||||
public ServerLink(@NonNull LinkType type, @NonNull String url)
|
||||
{
|
||||
this.type = type;
|
||||
this.label = null;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a link with a label and URL.
|
||||
*
|
||||
* @param label the label to be displayed
|
||||
* @param url the URL to be displayed
|
||||
*/
|
||||
public ServerLink(@NonNull BaseComponent label, @NonNull String url)
|
||||
{
|
||||
this.type = null;
|
||||
this.label = label;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public enum LinkType
|
||||
{
|
||||
|
||||
REPORT_BUG,
|
||||
COMMUNITY_GUIDELINES,
|
||||
SUPPORT,
|
||||
STATUS,
|
||||
FEEDBACK,
|
||||
COMMUNITY,
|
||||
WEBSITE,
|
||||
FORUMS,
|
||||
NEWS,
|
||||
ANNOUNCEMENTS;
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.api.connection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -8,6 +9,7 @@ import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ServerConnectRequest;
|
||||
import net.md_5.bungee.api.ServerLink;
|
||||
import net.md_5.bungee.api.SkinConfiguration;
|
||||
import net.md_5.bungee.api.Title;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@@ -411,4 +413,16 @@ public interface ProxiedPlayer extends Connection, CommandSender
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
void showDialog(Dialog dialog);
|
||||
|
||||
/**
|
||||
* Sends server links to the player.
|
||||
*
|
||||
* Note: The links already sent to the player will be overwritten. Also, the
|
||||
* backend server is able to override links sent by the proxy.
|
||||
*
|
||||
* @param serverLinks the server links to send
|
||||
* @throws IllegalStateException if the player's version is not at least
|
||||
* 1.21
|
||||
*/
|
||||
void sendServerLinks(List<ServerLink> serverLinks);
|
||||
}
|
||||
|
Reference in New Issue
Block a user