Convert Velocity buildscripts to Kotlin DSL (#918)
Spiritually indebted to #518 and @alexstaeding. There's a minor break - we're going up to 3.2.0-SNAPSHOT as the API now compiles against Java 11. But this is more academic in practice.
This commit is contained in:
119
api/build.gradle
119
api/build.gradle
@@ -1,119 +0,0 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'checkstyle'
|
||||
}
|
||||
|
||||
apply plugin: 'org.cadixdev.licenser'
|
||||
apply from: '../gradle/checkstyle.gradle'
|
||||
apply from: '../gradle/publish.gradle'
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
license {
|
||||
header = project.file('HEADER.txt')
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
ap {
|
||||
compileClasspath += main.compileClasspath + main.output
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api 'com.google.code.gson:gson:2.9.0'
|
||||
api "com.google.guava:guava:${guavaVersion}"
|
||||
|
||||
// DEPRECATED: Will be removed in Velocity Polymer
|
||||
api 'com.moandjiezana.toml:toml4j:0.7.2'
|
||||
|
||||
api(platform("net.kyori:adventure-bom:${adventureVersion}"))
|
||||
api("net.kyori:adventure-api")
|
||||
api("net.kyori:adventure-text-serializer-gson")
|
||||
api("net.kyori:adventure-text-serializer-legacy")
|
||||
api("net.kyori:adventure-text-serializer-plain")
|
||||
api("net.kyori:adventure-text-minimessage")
|
||||
|
||||
api "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
api 'com.google.inject:guice:5.0.1'
|
||||
api "org.checkerframework:checker-qual:${checkerFrameworkVersion}"
|
||||
api 'com.velocitypowered:velocity-brigadier:1.0.0-SNAPSHOT'
|
||||
|
||||
api "org.spongepowered:configurate-hocon:${configurateVersion}"
|
||||
api "org.spongepowered:configurate-yaml:${configurateVersion}"
|
||||
api "org.spongepowered:configurate-gson:${configurateVersion}"
|
||||
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar) {
|
||||
classifier 'javadoc'
|
||||
from javadoc
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
classifier 'sources'
|
||||
from sourceSets.main.allSource
|
||||
from sourceSets.ap.output
|
||||
}
|
||||
|
||||
jar {
|
||||
from sourceSets.ap.output
|
||||
manifest {
|
||||
attributes 'Automatic-Module-Name': 'com.velocitypowered.api'
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
from sourceSets.ap.output
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives javadocJar
|
||||
archives shadowJar
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.encoding = 'UTF-8'
|
||||
options.charSet = 'UTF-8'
|
||||
options.source = '8'
|
||||
options.links(
|
||||
'https://www.slf4j.org/apidocs/',
|
||||
'https://guava.dev/releases/25.1-jre/api/docs/',
|
||||
'https://google.github.io/guice/api-docs/5.0.1/javadoc/',
|
||||
'https://docs.oracle.com/en/java/javase/11/docs/api//',
|
||||
"https://jd.adventure.kyori.net/api/${adventureVersion}/"
|
||||
)
|
||||
|
||||
// Disable the crazy super-strict doclint tool in Java 8
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
|
||||
// Mark sources as Java 8 source compatible
|
||||
options.source = '8'
|
||||
|
||||
// Remove 'undefined' from seach paths when generating javadoc for a non-modular project (JDK-8215291)
|
||||
if (JavaVersion.current() >= JavaVersion.VERSION_1_9 && JavaVersion.current() < JavaVersion.VERSION_12) {
|
||||
options.addBooleanOption('-no-module-directories', true)
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
|
||||
artifact sourcesJar
|
||||
artifact javadocJar
|
||||
}
|
||||
}
|
||||
}
|
80
api/build.gradle.kts
Normal file
80
api/build.gradle.kts
Normal file
@@ -0,0 +1,80 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
license {
|
||||
header(project.file("HEADER.txt"))
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
|
||||
sourceSets["main"].java {
|
||||
srcDir("src/ap/java")
|
||||
}
|
||||
}
|
||||
|
||||
val gsonVersion: String by project.extra
|
||||
val guiceVersion: String by project.extra
|
||||
val guavaVersion: String by project.extra
|
||||
val adventureVersion: String by project.extra
|
||||
val slf4jVersion: String by project.extra
|
||||
val checkerFrameworkVersion: String by project.extra
|
||||
val configurateVersion: String by project.extra
|
||||
|
||||
dependencies {
|
||||
api("com.google.code.gson:gson:$gsonVersion")
|
||||
api("com.google.guava:guava:$guavaVersion")
|
||||
|
||||
// DEPRECATED: Will be removed in Velocity Polymer
|
||||
api("com.moandjiezana.toml:toml4j:0.7.2")
|
||||
|
||||
api(platform("net.kyori:adventure-bom:${adventureVersion}"))
|
||||
api("net.kyori:adventure-api")
|
||||
api("net.kyori:adventure-text-serializer-gson")
|
||||
api("net.kyori:adventure-text-serializer-legacy")
|
||||
api("net.kyori:adventure-text-serializer-plain")
|
||||
api("net.kyori:adventure-text-minimessage")
|
||||
|
||||
api("org.slf4j:slf4j-api:$slf4jVersion")
|
||||
api("com.google.inject:guice:$guiceVersion")
|
||||
api("org.checkerframework:checker-qual:${checkerFrameworkVersion}")
|
||||
api("com.velocitypowered:velocity-brigadier:1.0.0-SNAPSHOT")
|
||||
|
||||
api("org.spongepowered:configurate-hocon:${configurateVersion}")
|
||||
api("org.spongepowered:configurate-yaml:${configurateVersion}")
|
||||
api("org.spongepowered:configurate-gson:${configurateVersion}")
|
||||
}
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
manifest {
|
||||
attributes["Automatic-Module-Name"] = "com.velocitypowered.api"
|
||||
}
|
||||
}
|
||||
withType<Javadoc> {
|
||||
exclude("com/velocitypowered/api/plugin/ap/**")
|
||||
|
||||
val o = options as StandardJavadocDocletOptions
|
||||
o.encoding = "UTF-8"
|
||||
o.source = "8"
|
||||
|
||||
o.links(
|
||||
"https://www.slf4j.org/apidocs/",
|
||||
"https://guava.dev/releases/$guavaVersion/api/docs/",
|
||||
"https://google.github.io/guice/api-docs/$guiceVersion/javadoc/",
|
||||
"https://docs.oracle.com/en/java/javase/11/docs/api/",
|
||||
"https://jd.adventure.kyori.net/api/$adventureVersion/"
|
||||
)
|
||||
|
||||
// Disable the crazy super-strict doclint tool in Java 8
|
||||
o.addStringOption("Xdoclint:none", "-quiet")
|
||||
|
||||
// Remove "undefined" from search paths when generating javadoc for a non-modular project (JDK-8215291)
|
||||
if (JavaVersion.current() >= JavaVersion.VERSION_1_9 && JavaVersion.current() < JavaVersion.VERSION_12) {
|
||||
o.addBooleanOption("-no-module-directories", true)
|
||||
}
|
||||
}
|
||||
}
|
@@ -27,6 +27,9 @@ import javax.tools.Diagnostic;
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.StandardLocation;
|
||||
|
||||
/**
|
||||
* Annotation processor for Velocity.
|
||||
*/
|
||||
@SupportedAnnotationTypes({"com.velocitypowered.api.plugin.Plugin"})
|
||||
public class PluginAnnotationProcessor extends AbstractProcessor {
|
||||
|
||||
|
@@ -19,6 +19,9 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Serialized version of {@link com.velocitypowered.api.plugin.PluginDescription}.
|
||||
*/
|
||||
public final class SerializedPluginDescription {
|
||||
|
||||
public static final Pattern ID_PATTERN = Pattern.compile("[a-z][a-z0-9-_]{0,63}");
|
||||
@@ -130,6 +133,9 @@ public final class SerializedPluginDescription {
|
||||
+ '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a dependency.
|
||||
*/
|
||||
public static final class Dependency {
|
||||
|
||||
private final String id;
|
||||
|
@@ -84,6 +84,7 @@ public interface CommandManager {
|
||||
|
||||
/**
|
||||
* Retrieves the {@link CommandMeta} from the specified command alias, if registered.
|
||||
*
|
||||
* @param alias the command alias to lookup
|
||||
* @return an {@link CommandMeta} of the alias
|
||||
*/
|
||||
|
@@ -29,6 +29,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
|
||||
|
||||
/**
|
||||
* Constructs a CommandExecuteEvent.
|
||||
*
|
||||
* @param commandSource the source executing the command
|
||||
* @param command the command being executed without first slash
|
||||
*/
|
||||
@@ -43,7 +44,8 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the original command being executed without first slash.
|
||||
* Gets the original command being executed without the first slash.
|
||||
*
|
||||
* @return the original command being executed
|
||||
*/
|
||||
public String getCommand() {
|
||||
@@ -108,6 +110,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
|
||||
|
||||
/**
|
||||
* Allows the command to be sent, without modification.
|
||||
*
|
||||
* @return the allowed result
|
||||
*/
|
||||
public static CommandResult allowed() {
|
||||
@@ -116,6 +119,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
|
||||
|
||||
/**
|
||||
* Prevents the command from being executed.
|
||||
*
|
||||
* @return the denied result
|
||||
*/
|
||||
public static CommandResult denied() {
|
||||
@@ -123,7 +127,9 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents the command from being executed, but forward command to server.
|
||||
* Forwards the command to server instead of executing it on the proxy. This is the
|
||||
* default behavior when a command is not registered on Velocity.
|
||||
*
|
||||
* @return the forward result
|
||||
*/
|
||||
public static CommandResult forwardToServer() {
|
||||
@@ -132,6 +138,7 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
|
||||
|
||||
/**
|
||||
* Prevents the command from being executed on proxy, but forward command to server.
|
||||
*
|
||||
* @param newCommand the command without first slash to use instead
|
||||
* @return a result with a new command being forwarded to server
|
||||
*/
|
||||
@@ -141,7 +148,9 @@ public final class CommandExecuteEvent implements ResultedEvent<CommandResult> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the command to be executed, but silently replaced old command with another.
|
||||
* Allows the command to be executed, but silently replaces the command with a different
|
||||
* command.
|
||||
*
|
||||
* @param newCommand the command to use instead without first slash
|
||||
* @return a result with a new command
|
||||
*/
|
||||
|
@@ -29,6 +29,7 @@ public class PlayerAvailableCommandsEvent {
|
||||
|
||||
/**
|
||||
* Constructs an available commands event.
|
||||
*
|
||||
* @param player the targeted player
|
||||
* @param rootNode the Brigadier root node
|
||||
*/
|
||||
|
@@ -51,6 +51,9 @@ public final class DisconnectEvent {
|
||||
+ '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* The status of the connection when the player disconnected.
|
||||
*/
|
||||
public enum LoginStatus {
|
||||
|
||||
SUCCESSFUL_LOGIN,
|
||||
|
@@ -37,6 +37,7 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param connection the connection logging into the proxy
|
||||
* @param username the player's username
|
||||
*/
|
||||
|
@@ -35,6 +35,7 @@ public final class GameProfileRequestEvent {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param connection the connection connecting to the proxy
|
||||
* @param originalProfile the original {@link GameProfile} for the user
|
||||
* @param onlineMode whether or not the user connected in online or offline mode
|
||||
|
@@ -35,6 +35,7 @@ public final class KickedFromServerEvent implements
|
||||
|
||||
/**
|
||||
* Creates a {@code KickedFromServerEvent} instance.
|
||||
*
|
||||
* @param player the player affected
|
||||
* @param server the server the player disconnected from
|
||||
* @param originalReason the reason for being kicked, optional
|
||||
|
@@ -28,6 +28,7 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
|
||||
|
||||
/**
|
||||
* Constructs a PlayerChatEvent.
|
||||
*
|
||||
* @param player the player sending the message
|
||||
* @param message the message being sent
|
||||
*/
|
||||
@@ -96,6 +97,7 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
|
||||
|
||||
/**
|
||||
* Allows the message to be sent, without modification.
|
||||
*
|
||||
* @return the allowed result
|
||||
*/
|
||||
public static ChatResult allowed() {
|
||||
@@ -104,6 +106,7 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
|
||||
|
||||
/**
|
||||
* Prevents the message from being sent.
|
||||
*
|
||||
* @return the denied result
|
||||
*/
|
||||
public static ChatResult denied() {
|
||||
@@ -111,7 +114,8 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the message to be sent, but silently replaced with another.
|
||||
* Allows the message to be sent, but silently replaces it with another.
|
||||
*
|
||||
* @param message the message to use instead
|
||||
* @return a result with a new message
|
||||
*/
|
||||
|
@@ -28,6 +28,7 @@ public class PlayerChooseInitialServerEvent {
|
||||
|
||||
/**
|
||||
* Constructs a PlayerChooseInitialServerEvent.
|
||||
*
|
||||
* @param player the player that was connected
|
||||
* @param initialServer the initial server selected, may be {@code null}
|
||||
*/
|
||||
@@ -46,9 +47,10 @@ public class PlayerChooseInitialServerEvent {
|
||||
|
||||
/**
|
||||
* Sets the new initial server.
|
||||
*
|
||||
* @param server the initial server the player should connect to
|
||||
*/
|
||||
public void setInitialServer(RegisteredServer server) {
|
||||
public void setInitialServer(@Nullable RegisteredServer server) {
|
||||
this.initialServer = server;
|
||||
}
|
||||
|
||||
|
@@ -30,6 +30,7 @@ public class PlayerResourcePackStatusEvent {
|
||||
|
||||
/**
|
||||
* Instantiates this event.
|
||||
*
|
||||
* @deprecated Use {@link PlayerResourcePackStatusEvent#PlayerResourcePackStatusEvent
|
||||
* (Player, Status, ResourcePackInfo)} instead.
|
||||
*/
|
||||
|
@@ -33,6 +33,7 @@ public final class ServerConnectedEvent {
|
||||
|
||||
/**
|
||||
* Constructs a ServerConnectedEvent.
|
||||
*
|
||||
* @param player the player that was connected
|
||||
* @param server the server the player was connected to
|
||||
* @param previousServer the server the player was previously connected to, null if none
|
||||
|
@@ -37,6 +37,7 @@ public class ServerLoginPluginMessageEvent implements ResultedEvent<ResponseResu
|
||||
|
||||
/**
|
||||
* Constructs a new {@code ServerLoginPluginMessageEvent}.
|
||||
*
|
||||
* @param connection the connection on which the plugin message was sent
|
||||
* @param identifier the channel identifier for the message sent
|
||||
* @param contents the contents of the message
|
||||
@@ -114,6 +115,9 @@ public class ServerLoginPluginMessageEvent implements ResultedEvent<ResponseResu
|
||||
+ '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* The result class, containing a response to the login plugin message sent by the server.
|
||||
*/
|
||||
public static class ResponseResult implements ResultedEvent.Result {
|
||||
|
||||
private static final ResponseResult UNKNOWN = new ResponseResult(null);
|
||||
|
@@ -33,6 +33,7 @@ public final class ServerPreConnectEvent implements
|
||||
|
||||
/**
|
||||
* Creates the ServerPreConnectEvent.
|
||||
*
|
||||
* @param player the player who is connecting to a server
|
||||
* @param originalServer the server the player was trying to connect to
|
||||
*/
|
||||
@@ -43,6 +44,7 @@ public final class ServerPreConnectEvent implements
|
||||
|
||||
/**
|
||||
* Creates the ServerPreConnectEvent.
|
||||
*
|
||||
* @param player the player who is connecting to a server
|
||||
* @param originalServer the server the player was trying to connect to
|
||||
* @param previousServer the server the player ís connected to
|
||||
@@ -57,6 +59,7 @@ public final class ServerPreConnectEvent implements
|
||||
|
||||
/**
|
||||
* Returns the player connecting to the server.
|
||||
*
|
||||
* @return the player connecting to the server
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
@@ -77,6 +80,7 @@ public final class ServerPreConnectEvent implements
|
||||
* Returns the server that the player originally tried to connect to. To get the server the
|
||||
* player will connect to, see the {@link ServerResult} of this event. To get the server the
|
||||
* player is currently on when this event is fired, use {@link #getPreviousServer()}.
|
||||
*
|
||||
* @return the server that the player originally tried to connect to
|
||||
*/
|
||||
public RegisteredServer getOriginalServer() {
|
||||
@@ -88,6 +92,7 @@ public final class ServerPreConnectEvent implements
|
||||
* {@link Player#getCurrentServer()} as the current server might get reset after server kicks to
|
||||
* prevent connection issues. This is {@code null} if they were not connected to another server
|
||||
* beforehand (for instance, if the player has just joined the proxy).
|
||||
*
|
||||
* @return the server the player is currently connected to.
|
||||
*/
|
||||
public @Nullable RegisteredServer getPreviousServer() {
|
||||
@@ -137,6 +142,7 @@ public final class ServerPreConnectEvent implements
|
||||
* Returns a result that will prevent players from connecting to another server. If this result
|
||||
* is used, then {@link ConnectionRequestBuilder#connect()}'s result will have the status
|
||||
* {@link Status#CONNECTION_CANCELLED}.
|
||||
*
|
||||
* @return a result to deny conneections
|
||||
*/
|
||||
public static ServerResult denied() {
|
||||
@@ -145,6 +151,7 @@ public final class ServerPreConnectEvent implements
|
||||
|
||||
/**
|
||||
* Allows the player to connect to the specified server.
|
||||
*
|
||||
* @param server the new server to connect to
|
||||
* @return a result to allow the player to connect to the specified server
|
||||
*/
|
||||
|
@@ -28,7 +28,7 @@ public class ServerResourcePackSendEvent implements ResultedEvent<ResultedEvent.
|
||||
|
||||
/**
|
||||
* Constructs a new ServerResourcePackSendEvent.
|
||||
*
|
||||
*
|
||||
* @param receivedResourcePack The resource pack the server sent.
|
||||
* @param serverConnection The connection this occurred on.
|
||||
*/
|
||||
|
@@ -29,6 +29,7 @@ public class TabCompleteEvent {
|
||||
|
||||
/**
|
||||
* Constructs a new TabCompleteEvent instance.
|
||||
*
|
||||
* @param player the player
|
||||
* @param partialMessage the partial message
|
||||
* @param suggestions the initial list of suggestions
|
||||
@@ -41,6 +42,7 @@ public class TabCompleteEvent {
|
||||
|
||||
/**
|
||||
* Returns the player requesting the tab completion.
|
||||
*
|
||||
* @return the requesting player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
@@ -49,6 +51,7 @@ public class TabCompleteEvent {
|
||||
|
||||
/**
|
||||
* Returns the message being partially completed.
|
||||
*
|
||||
* @return the partial message
|
||||
*/
|
||||
public String getPartialMessage() {
|
||||
@@ -57,6 +60,7 @@ public class TabCompleteEvent {
|
||||
|
||||
/**
|
||||
* Returns all the suggestions provided to the user, as a mutable list.
|
||||
*
|
||||
* @return the suggestions
|
||||
*/
|
||||
public List<String> getSuggestions() {
|
||||
|
@@ -7,6 +7,9 @@
|
||||
|
||||
package com.velocitypowered.api.plugin;
|
||||
|
||||
/**
|
||||
* Thrown if a JAR in the plugin directory does not look valid.
|
||||
*/
|
||||
public class InvalidPluginException extends Exception {
|
||||
|
||||
public InvalidPluginException() {
|
||||
|
@@ -27,6 +27,7 @@ public final class PluginDependency {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param id the plugin ID
|
||||
* @param version an optional version
|
||||
* @param optional whether or not this dependency is optional
|
||||
|
@@ -12,14 +12,33 @@ import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Allows the server to communicate with a client logging into the proxy using login plugin
|
||||
* messages.
|
||||
* Represents a connextion that is in the login phase. This is most useful in conjunction
|
||||
* for login plugin messages.
|
||||
*/
|
||||
public interface LoginPhaseConnection extends InboundConnection, KeyIdentifiable {
|
||||
|
||||
/**
|
||||
* Sends a login plugin message to the client, and provides a consumer to react to the
|
||||
* response to the client. The login process will not continue until there are no more
|
||||
* login plugin messages that require responses.
|
||||
*
|
||||
* @param identifier the channel identifier to use
|
||||
* @param contents the message to send
|
||||
* @param consumer the consumer that will respond to the message
|
||||
*/
|
||||
void sendLoginPluginMessage(ChannelIdentifier identifier, byte[] contents,
|
||||
MessageConsumer consumer);
|
||||
|
||||
/**
|
||||
* Consumes the message.
|
||||
*/
|
||||
interface MessageConsumer {
|
||||
|
||||
/**
|
||||
* Consumes the message and responds to it.
|
||||
*
|
||||
* @param responseBody the message from the client, if any
|
||||
*/
|
||||
void onMessageResponse(byte @Nullable [] responseBody);
|
||||
}
|
||||
}
|
||||
|
@@ -32,13 +32,17 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.event.HoverEventSource;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a player who is connected to the proxy.
|
||||
*/
|
||||
public interface Player extends CommandSource, Identified, InboundConnection,
|
||||
ChannelMessageSource, ChannelMessageSink, HoverEventSource<HoverEvent.ShowEntity>, Keyed, KeyIdentifiable {
|
||||
public interface Player extends
|
||||
/* Fundamental Velocity interfaces */
|
||||
CommandSource, InboundConnection, ChannelMessageSource, ChannelMessageSink,
|
||||
/* Adventure-specific interfaces */
|
||||
Identified, HoverEventSource<HoverEvent.ShowEntity>, Keyed, KeyIdentifiable {
|
||||
|
||||
/**
|
||||
* Returns the player's current username.
|
||||
@@ -48,8 +52,8 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
||||
String getUsername();
|
||||
|
||||
/**
|
||||
* Returns the locale the proxy will use to send messages translated via the Adventure global translator.
|
||||
* By default, the value of {@link PlayerSettings#getLocale()} is used.
|
||||
* Returns the locale the proxy will use to send messages translated via the Adventure global
|
||||
* translator. By default, the value of {@link PlayerSettings#getLocale()} is used.
|
||||
*
|
||||
* <p>This can be {@code null} when the client has not yet connected to any server.</p>
|
||||
*
|
||||
|
@@ -30,6 +30,7 @@ public interface IdentifiedKey extends KeySigned {
|
||||
|
||||
/**
|
||||
* Validates a signature against this public key.
|
||||
*
|
||||
* @param signature the signature data
|
||||
* @param toVerify the signed data
|
||||
*
|
||||
@@ -53,6 +54,9 @@ public interface IdentifiedKey extends KeySigned {
|
||||
*/
|
||||
Revision getKeyRevision();
|
||||
|
||||
/**
|
||||
* The different versions of player keys, per Minecraft version.
|
||||
*/
|
||||
enum Revision {
|
||||
GENERIC_V1(ImmutableSet.of(), ImmutableSet.of(ProtocolVersion.MINECRAFT_1_19)),
|
||||
LINKED_V2(ImmutableSet.of(), ImmutableSet.of(ProtocolVersion.MINECRAFT_1_19_1));
|
||||
|
@@ -7,15 +7,18 @@
|
||||
|
||||
package com.velocitypowered.api.proxy.crypto;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Identifies a type with a public RSA signature.
|
||||
*/
|
||||
public interface KeyIdentifiable {
|
||||
|
||||
/**
|
||||
* Returns the timed identified key of the object context.
|
||||
* <p>Only available in 1.19 and newer</p>
|
||||
* Returns the timed identified key of the object context. This is only available if the client
|
||||
* is running Minecraft 1.19 or newer.
|
||||
*
|
||||
* @return the key or null if not available
|
||||
*/
|
||||
IdentifiedKey getIdentifiedKey();
|
||||
@Nullable IdentifiedKey getIdentifiedKey();
|
||||
}
|
||||
|
@@ -12,6 +12,9 @@ import java.security.PublicKey;
|
||||
import java.time.Instant;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Represents the signature of a signed object.
|
||||
*/
|
||||
public interface KeySigned {
|
||||
|
||||
/**
|
||||
|
@@ -9,6 +9,9 @@ package com.velocitypowered.api.proxy.crypto;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A signed message.
|
||||
*/
|
||||
public interface SignedMessage extends KeySigned {
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,8 @@
|
||||
|
||||
package com.velocitypowered.api.proxy.messages;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -49,13 +50,16 @@ public final class MinecraftChannelIdentifier implements ChannelIdentifier {
|
||||
* @return a new channel identifier
|
||||
*/
|
||||
public static MinecraftChannelIdentifier create(String namespace, String name) {
|
||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(namespace), "namespace is null or empty");
|
||||
Preconditions.checkArgument(name != null, "namespace is null or empty");
|
||||
Preconditions.checkArgument(VALID_IDENTIFIER_REGEX.matcher(namespace).matches(),
|
||||
"namespace is not valid, must match: %s got %s", VALID_IDENTIFIER_REGEX.toString(), namespace);
|
||||
Preconditions
|
||||
.checkArgument(VALID_IDENTIFIER_REGEX.matcher(name).matches(),
|
||||
"name is not valid, must match: %s got %s", VALID_IDENTIFIER_REGEX.toString(), name);
|
||||
checkArgument(!Strings.isNullOrEmpty(namespace), "namespace is null or empty");
|
||||
checkArgument(name != null, "namespace is null or empty");
|
||||
checkArgument(VALID_IDENTIFIER_REGEX.matcher(namespace).matches(),
|
||||
"namespace is not valid, must match: %s got %s",
|
||||
VALID_IDENTIFIER_REGEX.toString(),
|
||||
namespace);
|
||||
checkArgument(VALID_IDENTIFIER_REGEX.matcher(name).matches(),
|
||||
"name is not valid, must match: %s got %s",
|
||||
VALID_IDENTIFIER_REGEX.toString(),
|
||||
name);
|
||||
return new MinecraftChannelIdentifier(namespace, name);
|
||||
}
|
||||
|
||||
|
@@ -67,12 +67,18 @@ public interface PlayerSettings {
|
||||
*/
|
||||
boolean isClientListingAllowed();
|
||||
|
||||
/**
|
||||
* The client's current chat display mode.
|
||||
*/
|
||||
enum ChatMode {
|
||||
SHOWN,
|
||||
COMMANDS_ONLY,
|
||||
HIDDEN
|
||||
}
|
||||
|
||||
/**
|
||||
* The player's selected dominant hand.
|
||||
*/
|
||||
enum MainHand {
|
||||
LEFT,
|
||||
RIGHT
|
||||
|
@@ -10,6 +10,9 @@ package com.velocitypowered.api.proxy.player;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Represents the information for a resource pack to apply that can be sent to the client.
|
||||
*/
|
||||
public interface ResourcePackInfo {
|
||||
|
||||
/**
|
||||
@@ -75,12 +78,12 @@ public interface ResourcePackInfo {
|
||||
ResourcePackInfo.Builder asBuilder();
|
||||
|
||||
/**
|
||||
* Returns a copy of this {@link ResourcePackInfo} instance as a builder with the new URL as the pack URL so that
|
||||
* it can be modified.
|
||||
* Returns a copy of this {@link ResourcePackInfo} instance as a builder, using the new URL.
|
||||
* <p/>
|
||||
* It is <b>not</b> guaranteed that
|
||||
* {@code resourcePackInfo.asBuilder(resourcePackInfo.getUrl()).build().equals(resourcePackInfo)} is true.
|
||||
* That is due to the transient {@link ResourcePackInfo#getOrigin()} and
|
||||
* {@link ResourcePackInfo#getOriginalOrigin()} fields.
|
||||
* {@code resourcePackInfo.asBuilder(resourcePackInfo.getUrl()).build().equals(resourcePackInfo)}
|
||||
* is true, because the {@link ResourcePackInfo#getOrigin()} and
|
||||
* {@link ResourcePackInfo#getOriginalOrigin()} fields are transient.
|
||||
*
|
||||
* @param newUrl The new URL to use in the updated builder.
|
||||
*
|
||||
@@ -88,6 +91,9 @@ public interface ResourcePackInfo {
|
||||
*/
|
||||
ResourcePackInfo.Builder asBuilder(String newUrl);
|
||||
|
||||
/**
|
||||
* Builder for {@link ResourcePackInfo} instances.
|
||||
*/
|
||||
interface Builder {
|
||||
|
||||
/**
|
||||
|
@@ -10,6 +10,9 @@ package com.velocitypowered.api.proxy.player;
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Represents what, if any, extended parts of the skin this player has.
|
||||
*/
|
||||
public final class SkinParts {
|
||||
|
||||
private final byte bitmask;
|
||||
|
@@ -121,7 +121,7 @@ public interface TabListEntry extends KeyIdentifiable {
|
||||
TabListEntry setGameMode(int gameMode);
|
||||
|
||||
/**
|
||||
* Whether or not the entry is listed, when listed they will be visible to other players in the tab list.
|
||||
* Returns whether or not this player will be visible to other players in the tab list.
|
||||
*
|
||||
* @return Whether this entry is listed; only changeable in 1.19.3 and above
|
||||
*/
|
||||
@@ -193,7 +193,7 @@ public interface TabListEntry extends KeyIdentifiable {
|
||||
|
||||
/**
|
||||
* Sets the {@link IdentifiedKey} of the {@link TabListEntry}.
|
||||
* <p>This is only intended and only works for players currently <b>not</b> connected to this proxy.</p>
|
||||
* <p>This only works for players currently <b>not</b> connected to this proxy.</p>
|
||||
* <p>For any player currently connected to this proxy this will be filled automatically.</p>
|
||||
* <p>Will ignore mismatching key revisions data.</p>
|
||||
*
|
||||
|
@@ -245,6 +245,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Sets the hostname for the response.
|
||||
*
|
||||
* @param hostname the hostname to set
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
@@ -255,6 +256,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Sets the game version for the response.
|
||||
*
|
||||
* @param gameVersion the game version to set
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
@@ -265,6 +267,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Sets the map that will appear in the response.
|
||||
*
|
||||
* @param map the map to set
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
@@ -275,6 +278,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Sets the players that are currently claimed to be online.
|
||||
*
|
||||
* @param currentPlayers a non-negative number representing all players online
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
@@ -286,6 +290,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Sets the maximum number of players this server purportedly can hold.
|
||||
*
|
||||
* @param maxPlayers a non-negative number representing the maximum number of builders
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
@@ -297,6 +302,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Sets the host where this proxy is running.
|
||||
*
|
||||
* @param proxyHost the host where the proxy is running
|
||||
* @return this instance, for chaining
|
||||
*/
|
||||
@@ -307,6 +313,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Sets the port where this proxy is running.
|
||||
*
|
||||
* @param proxyPort the port where the proxy is running
|
||||
* @return this instance, for chaining
|
||||
*/
|
||||
@@ -319,6 +326,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Adds the specified players to the player list.
|
||||
*
|
||||
* @param players the players to add
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
@@ -329,6 +337,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Adds the specified players to the player list.
|
||||
*
|
||||
* @param players the players to add
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
@@ -339,6 +348,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Removes all players from the builder. This does not affect {@link #getCurrentPlayers()}.
|
||||
*
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder clearPlayers() {
|
||||
@@ -348,6 +358,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Sets the proxy version.
|
||||
*
|
||||
* @param proxyVersion the proxy version to set
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
@@ -358,6 +369,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Adds the specified plugins to the plugins list.
|
||||
*
|
||||
* @param plugins the plugins to add
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
@@ -368,6 +380,7 @@ public final class QueryResponse {
|
||||
|
||||
/**
|
||||
* Adds the specified plugins to the plugins list.
|
||||
*
|
||||
* @param plugins the plugins to add
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
|
@@ -191,6 +191,7 @@ public final class ServerPing {
|
||||
|
||||
/**
|
||||
* Uses the modified {@code mods} list in the response.
|
||||
*
|
||||
* @param mods the mods list to use
|
||||
* @return this build, for chaining
|
||||
*/
|
||||
@@ -240,6 +241,7 @@ public final class ServerPing {
|
||||
/**
|
||||
* Uses the information from this builder to create a new {@link ServerPing} instance. The
|
||||
* builder can be re-used after this event has been called.
|
||||
*
|
||||
* @return a new {@link ServerPing} instance
|
||||
*/
|
||||
public ServerPing build() {
|
||||
@@ -303,6 +305,12 @@ public final class ServerPing {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the version of the server sent to the client. A protocol version
|
||||
* that does not match the client's protocol version will show up on the server
|
||||
* list as an incompatible version, but the client will still permit the user
|
||||
* to connect to the server anyway.
|
||||
*/
|
||||
public static final class Version {
|
||||
|
||||
private final int protocol;
|
||||
@@ -310,6 +318,7 @@ public final class ServerPing {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param protocol the protocol version as an integer
|
||||
* @param name a friendly name for the protocol version
|
||||
*/
|
||||
@@ -352,6 +361,10 @@ public final class ServerPing {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents what the players the server purports to have online, its maximum capacity,
|
||||
* and a sample of players on the server.
|
||||
*/
|
||||
public static final class Players {
|
||||
|
||||
private final int online;
|
||||
@@ -360,6 +373,7 @@ public final class ServerPing {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param online the number of online players
|
||||
* @param max the maximum number of players
|
||||
* @param sample a sample of players on the server
|
||||
@@ -410,6 +424,9 @@ public final class ServerPing {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A player returned in the sample field of the server ping players field.
|
||||
*/
|
||||
public static final class SamplePlayer {
|
||||
|
||||
private final String name;
|
||||
|
@@ -7,6 +7,9 @@
|
||||
|
||||
package com.velocitypowered.api.scheduler;
|
||||
|
||||
/**
|
||||
* Enumerates all possible task statuses.
|
||||
*/
|
||||
public enum TaskStatus {
|
||||
/**
|
||||
* The task is scheduled and is currently running.
|
||||
|
@@ -24,6 +24,7 @@ public final class GameProfile {
|
||||
|
||||
/**
|
||||
* Creates a new Mojang game profile.
|
||||
*
|
||||
* @param id the UUID for the profile
|
||||
* @param name the profile's username
|
||||
* @param properties properties for the profile
|
||||
@@ -35,6 +36,7 @@ public final class GameProfile {
|
||||
|
||||
/**
|
||||
* Creates a new Mojang game profile.
|
||||
*
|
||||
* @param undashedId the undashed, Mojang-style UUID for the profile
|
||||
* @param name the profile's username
|
||||
* @param properties properties for the profile
|
||||
@@ -53,6 +55,7 @@ public final class GameProfile {
|
||||
|
||||
/**
|
||||
* Returns the undashed, Mojang-style UUID.
|
||||
*
|
||||
* @return the undashed UUID
|
||||
*/
|
||||
public String getUndashedId() {
|
||||
@@ -61,6 +64,7 @@ public final class GameProfile {
|
||||
|
||||
/**
|
||||
* Returns the UUID associated with this game profile.
|
||||
*
|
||||
* @return the UUID
|
||||
*/
|
||||
public UUID getId() {
|
||||
@@ -69,6 +73,7 @@ public final class GameProfile {
|
||||
|
||||
/**
|
||||
* Returns the username associated with this profile.
|
||||
*
|
||||
* @return the username
|
||||
*/
|
||||
public String getName() {
|
||||
@@ -77,6 +82,7 @@ public final class GameProfile {
|
||||
|
||||
/**
|
||||
* Returns an immutable list of profile properties associated with this profile.
|
||||
*
|
||||
* @return the properties associated with this profile
|
||||
*/
|
||||
public List<Property> getProperties() {
|
||||
@@ -183,6 +189,7 @@ public final class GameProfile {
|
||||
|
||||
/**
|
||||
* Creates a profile property entry.
|
||||
*
|
||||
* @param name the name of the property
|
||||
* @param value the value of the property
|
||||
* @param signature the Mojang signature for the property
|
||||
|
@@ -13,6 +13,9 @@ import com.google.gson.annotations.SerializedName;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents the information for a Forge mod list.
|
||||
*/
|
||||
public final class ModInfo {
|
||||
|
||||
public static final ModInfo DEFAULT = new ModInfo("FML", ImmutableList.of());
|
||||
@@ -20,6 +23,12 @@ public final class ModInfo {
|
||||
private final String type;
|
||||
private final List<Mod> modList;
|
||||
|
||||
/**
|
||||
* Constructs a new ModInfo instance.
|
||||
*
|
||||
* @param type the Forge server list version to use
|
||||
* @param modList the mods to present to the client
|
||||
*/
|
||||
public ModInfo(String type, List<Mod> modList) {
|
||||
this.type = Preconditions.checkNotNull(type, "type");
|
||||
this.modList = ImmutableList.copyOf(modList);
|
||||
@@ -58,6 +67,9 @@ public final class ModInfo {
|
||||
return Objects.hash(type, modList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a mod to send to the client.
|
||||
*/
|
||||
public static final class Mod {
|
||||
|
||||
@SerializedName("modid")
|
||||
|
Reference in New Issue
Block a user