Skip to content

Commit

Permalink
Convert Velocity buildscripts to Kotlin DSL (#918)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
astei authored Jan 1, 2023
1 parent ffa4c95 commit d72d707
Show file tree
Hide file tree
Showing 300 changed files with 2,880 additions and 2,169 deletions.
119 changes: 0 additions & 119 deletions api/build.gradle

This file was deleted.

80 changes: 80 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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

This comment has been minimized.

Copy link
@Kamillaova

Kamillaova Jan 3, 2023

(options as StandardJavadocDocletOptions).run {
  ...
}
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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import javax.tools.FileObject;
import javax.tools.StandardLocation;

/**
* Annotation processor for Velocity.
*/
@SupportedAnnotationTypes({"com.velocitypowered.api.plugin.Plugin"})
public class PluginAnnotationProcessor extends AbstractProcessor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
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}");
Expand Down Expand Up @@ -130,6 +133,9 @@ public String toString() {
+ '}';
}

/**
* Represents a dependency.
*/
public static final class Dependency {

private final String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ default void register(String alias, Command command, String... otherAliases) {

/**
* 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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -43,7 +44,8 @@ public CommandSource getCommandSource() {
}

/**
* 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() {
Expand Down Expand Up @@ -108,6 +110,7 @@ public String toString() {

/**
* Allows the command to be sent, without modification.
*
* @return the allowed result
*/
public static CommandResult allowed() {
Expand All @@ -116,14 +119,17 @@ public static CommandResult allowed() {

/**
* Prevents the command from being executed.
*
* @return the denied result
*/
public static CommandResult denied() {
return DENIED;
}

/**
* 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() {
Expand All @@ -132,6 +138,7 @@ public static CommandResult forwardToServer() {

/**
* 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
*/
Expand All @@ -141,7 +148,9 @@ public static CommandResult forwardToServer(@NonNull String newCommand) {
}

/**
* 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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class PlayerAvailableCommandsEvent {

/**
* Constructs an available commands event.
*
* @param player the targeted player
* @param rootNode the Brigadier root node
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public String toString() {
+ '}';
}

/**
* The status of the connection when the player disconnected.
*/
public enum LoginStatus {

SUCCESSFUL_LOGIN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -96,6 +97,7 @@ public String toString() {

/**
* Allows the message to be sent, without modification.
*
* @return the allowed result
*/
public static ChatResult allowed() {
Expand All @@ -104,14 +106,16 @@ public static ChatResult allowed() {

/**
* Prevents the message from being sent.
*
* @return the denied result
*/
public static ChatResult denied() {
return DENIED;
}

/**
* 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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*/
Expand All @@ -46,9 +47,10 @@ public Optional<RegisteredServer> getInitialServer() {

/**
* 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;
}

Expand Down
Loading

0 comments on commit d72d707

Please sign in to comment.