Skip to content

Commit

Permalink
Merge branch 'PaperMC:dev/3.0.0' into dev/3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RedstoneWizard08 authored Dec 7, 2023
2 parents 1b548df + 07a525b commit 8fc2a4b
Show file tree
Hide file tree
Showing 94 changed files with 3,094 additions and 1,161 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ gradle-app.setting
logs/
/velocity.toml
/forwarding.secret
forwarding.secret
velocity.toml
server-icon.png
/bin/
run/
Expand Down
38 changes: 0 additions & 38 deletions Jenkinsfile

This file was deleted.

5 changes: 5 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
`java-library`
`maven-publish`
id("velocity-publish")
}

java {
Expand Down Expand Up @@ -29,6 +30,10 @@ dependencies {
api("net.kyori:adventure-text-serializer-legacy")
api("net.kyori:adventure-text-serializer-plain")
api("net.kyori:adventure-text-minimessage")
api("net.kyori:adventure-text-logger-slf4j")
api("net.kyori:adventure-text-serializer-ansi")

api(libs.snakeyaml)

api(libs.slf4j)
api(libs.guice)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ServerPreConnectEvent(Player player, RegisteredServer originalServer) {
*
* @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
* @param previousServer the server the player is connected to
*/
public ServerPreConnectEvent(Player player, RegisteredServer originalServer,
@Nullable RegisteredServer previousServer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public enum ProtocolVersion {
MINECRAFT_1_19_1(760, "1.19.1", "1.19.2"),
MINECRAFT_1_19_3(761, "1.19.3"),
MINECRAFT_1_19_4(762, "1.19.4"),
MINECRAFT_1_20(763, "1.20", "1.20.1");
MINECRAFT_1_20(763, "1.20", "1.20.1"),
MINECRAFT_1_20_2(764, "1.20.2");

private static final int SNAPSHOT_BIT = 30;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
* Copyright (C) 2018-2022 Velocity Contributors
* Copyright (C) 2018-2023 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/

package com.velocitypowered.api.permission;

import java.util.Optional;
import net.kyori.adventure.util.TriState;
import org.checkerframework.checker.nullness.qual.Nullable;

Expand Down Expand Up @@ -66,6 +67,21 @@ public static Tristate fromNullableBoolean(@Nullable Boolean val) {
return val ? TRUE : FALSE;
}

/**
* Returns a {@link Tristate} from an {@link Optional}.
*
* <p>Unlike {@link #fromBoolean(boolean)}, this method returns {@link #UNDEFINED}
* if the value is empty.</p>
*
* @param val the optional boolean value
* @return {@link #UNDEFINED}, {@link #TRUE} or {@link #FALSE}, if the value is empty,
* <code>true</code> or <code>false</code>, respectively.
*/
public static Tristate fromOptionalBoolean(Optional<Boolean> val) {
return val.map(Tristate::fromBoolean).orElse(UNDEFINED);
}


private final boolean booleanValue;

Tristate(boolean booleanValue) {
Expand Down
12 changes: 9 additions & 3 deletions api/src/main/java/com/velocitypowered/api/proxy/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
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;

/**
Expand Down Expand Up @@ -148,10 +147,17 @@ public interface Player extends
/**
* Clears the tab list header and footer for the player.
*
* @deprecated Use {@link TabList#clearHeaderAndFooter()}.
* @deprecated Use {@link Player#clearPlayerListHeaderAndFooter()}.
*/
@Deprecated
void clearHeaderAndFooter();
default void clearHeaderAndFooter() {
clearPlayerListHeaderAndFooter();
}

/**
* Clears the player list header and footer.
*/
void clearPlayerListHeaderAndFooter();

/**
* Returns the player's player list header.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public interface ProxyServer extends Audience {
*/
void shutdown();

/**
* Closes all listening endpoints for this server.
* This includes the main minecraft listener and query channel.
*/
void closeListeners();

/**
* Retrieves the player currently connected to this proxy by their Minecraft username. The search
* is case-insensitive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ public interface TabList {
*/
void addEntry(TabListEntry entry);

/**
* Adds a {@link Iterable} of {@link TabListEntry}'s to the {@link Player}'s tab list.
*
* @param entries to add to the tab list
*/
default void addEntries(Iterable<TabListEntry> entries) {
for (TabListEntry entry : entries) {
addEntry(entry);
}
}

/**
* Adds an array of {@link TabListEntry}'s to the {@link Player}'s tab list.
*
* @param entries to add to the tab list
*/
default void addEntries(TabListEntry... entries) {
for (TabListEntry entry : entries) {
addEntry(entry);
}
}

/**
* Removes the {@link TabListEntry} from the tab list with the {@link GameProfile} identified with
* the specified {@link UUID}.
Expand Down
17 changes: 17 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
`kotlin-dsl`
alias(libs.plugins.spotless)
}

dependencies {
// this is OK as long as the same version catalog is used in the main build and build-logic
// see https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation("com.diffplug.spotless:spotless-plugin-gradle:${libs.plugins.spotless.get().version}")
}

spotless {
kotlin {
licenseHeaderFile(rootProject.file("../HEADER.txt"))
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("UnstableApiUsage")

dependencyResolutionManagement {
repositories {
mavenCentral()
Expand All @@ -9,3 +11,5 @@ dependencyResolutionManagement {
}
}
}

rootProject.name = "build-logic"
6 changes: 6 additions & 0 deletions build-logic/src/main/kotlin/LibsAccessor.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Project
import org.gradle.kotlin.dsl.getByType

val Project.libs: LibrariesForLibs
get() = rootProject.extensions.getByType()
10 changes: 10 additions & 0 deletions build-logic/src/main/kotlin/velocity-checkstyle.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
checkstyle
}

extensions.configure<CheckstyleExtension> {
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
maxErrors = 0
maxWarnings = 0
toolVersion = libs.checkstyle.get().version.toString()
}
29 changes: 29 additions & 0 deletions build-logic/src/main/kotlin/velocity-init-manifest.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.withType
import java.io.ByteArrayOutputStream

val currentShortRevision = ByteArrayOutputStream().use {
exec {
executable = "git"
args = listOf("rev-parse", "HEAD")
standardOutput = it
}
it.toString().trim().substring(0, 8)
}

tasks.withType<Jar> {
manifest {
val buildNumber = System.getenv("BUILD_NUMBER")
val velocityHumanVersion: String =
if (project.version.toString().endsWith("-SNAPSHOT")) {
if (buildNumber == null) {
"${project.version} (git-$currentShortRevision)"
} else {
"${project.version} (git-$currentShortRevision-b$buildNumber)"
}
} else {
archiveVersion.get()
}
attributes["Implementation-Version"] = velocityHumanVersion
}
}
33 changes: 33 additions & 0 deletions build-logic/src/main/kotlin/velocity-publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
java
`maven-publish`
}

extensions.configure<PublishingExtension> {
repositories {
maven {
credentials(PasswordCredentials::class.java)

name = "paper"
val base = "https://repo.papermc.io/repository/maven"
val releasesRepoUrl = "$base-releases/"
val snapshotsRepoUrl = "$base-snapshots/"
setUrl(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
}
}
publications {
create<MavenPublication>("maven") {
from(components["java"])
pom {
name.set("Velocity")
description.set("The modern, next-generation Minecraft server proxy")
url.set("https://papermc.io/software/velocity")
scm {
url.set("https://github.com/PaperMC/Velocity")
connection.set("scm:git:https://github.com/PaperMC/Velocity.git")
developerConnection.set("scm:git:https://github.com/PaperMC/Velocity.git")
}
}
}
}
}
15 changes: 15 additions & 0 deletions build-logic/src/main/kotlin/velocity-spotless.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessPlugin

apply<SpotlessPlugin>()

extensions.configure<SpotlessExtension> {
java {
if (project.name == "velocity-api") {
licenseHeaderFile(file("HEADER.txt"))
} else {
licenseHeaderFile(rootProject.file("HEADER.txt"))
}
removeUnusedImports()
}
}
17 changes: 4 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
import com.velocitypowered.script.VelocityCheckstylePlugin
import com.velocitypowered.script.VelocityPublishPlugin
import com.velocitypowered.script.VelocitySpotlessPlugin

plugins {
`java-library`
id("velocity-checkstyle") apply false
id("velocity-spotless") apply false
}

subprojects {
apply<JavaLibraryPlugin>()

apply<VelocityCheckstylePlugin>()
apply<VelocityPublishPlugin>()
apply<VelocitySpotlessPlugin>()
apply(plugin = "velocity-checkstyle")
apply(plugin = "velocity-spotless")

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

repositories {
mavenCentral()
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") // adventure
maven("https://repo.papermc.io/repository/maven-public/")
}

dependencies {
testImplementation(rootProject.libs.junit)
}
Expand Down
37 changes: 0 additions & 37 deletions buildSrc/build.gradle.kts

This file was deleted.

Loading

0 comments on commit 8fc2a4b

Please sign in to comment.