Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to the latest Minecraft version with Velocity migration #28

Open
wants to merge 38 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7a469eb
Bump minecraft version
p0loskun Sep 7, 2024
be75bca
Added new dependencies
p0loskun Sep 15, 2024
391a4c2
Updated gradle build scripts
p0loskun Sep 15, 2024
83d52e0
Updated API
p0loskun Sep 15, 2024
3ccaa8f
Updated API
p0loskun Sep 15, 2024
7c16063
Updated Packet API
p0loskun Sep 15, 2024
5fdf98c
Some improvements
p0loskun Sep 15, 2024
e70782f
Fixed CustomInventory#clone
p0loskun Sep 15, 2024
3a5f430
Renamed map builders
p0loskun Sep 15, 2024
f3de87f
Updated docs
p0loskun Sep 18, 2024
9d7aa48
Updated docs
p0loskun Sep 18, 2024
c2ea718
Bump gradle
p0loskun Sep 18, 2024
16cd373
Enable JavaDocs
p0loskun Sep 18, 2024
13f4337
Some restyle
p0loskun Sep 20, 2024
e8f01e3
Language and resource APIs have been moved to the "common" module
p0loskun Sep 20, 2024
fd62bc0
test
p0loskun Sep 25, 2024
2f81f68
test
p0loskun Sep 25, 2024
2a3e048
Bump Gradle
p0loskun Sep 26, 2024
4bd06e5
Added test for common module
p0loskun Sep 26, 2024
a254cc8
Bump APIs
p0loskun Sep 27, 2024
d4468b8
Fixed constants
p0loskun Sep 29, 2024
28a6506
Added example of usage to Resource annotation
p0loskun Oct 2, 2024
6acefdb
Updated APIs
p0loskun Oct 2, 2024
8c9d5c3
Added suppression
p0loskun Oct 2, 2024
0f865b8
Added Order and Ordered interfaces
p0loskun Oct 5, 2024
5ebecad
Moved some methods
p0loskun Oct 5, 2024
780f5fa
Some improvements
p0loskun Oct 5, 2024
1263a97
Fixed status equals
p0loskun Oct 5, 2024
2e9eff0
Added support for different handler parameter types
p0loskun Oct 5, 2024
8c497dd
Added Velocity module
p0loskun Oct 5, 2024
e47b469
bim bim bom bom
p0loskun Oct 5, 2024
9a681c0
Updated structure
p0loskun Oct 5, 2024
c54beb9
Fixed Commodore listener
p0loskun Oct 12, 2024
2064e54
Strong acceleration of the executor's performance
p0loskun Oct 12, 2024
a1775f5
Improve editor config
p0loskun Oct 12, 2024
e0da3ae
Improve handler executor
p0loskun Oct 12, 2024
8e93ca5
Create "build-logic", separate api and implementation
p0loskun Oct 19, 2024
1b25d64
Fixed block breaking
p0loskun Oct 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 5 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ root = true

[*]
charset = utf-8
end_of_line = lf
tab_width = 4
indent_size = 4
indent_style = space
tab_width = 4
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120
ij_visual_guides = 80
ij_visual_guides = 80, 120
ij_continuation_indent_size = 8

[*.java]
Expand Down Expand Up @@ -264,5 +266,5 @@ ij_json_space_before_colon = false
ij_json_space_before_comma = false
ij_json_wrap_long_lines = false

[{*.yml,*.md}]
[*.{yml,md}]
indent_size = 2
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#file: noinspection YAMLSchemaValidation

blank_issues_enabled: false
contact_links:
- name: Issue with site (whomine.net)
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#file: noinspection Annotator

name: Java CI with Gradle

on:
Expand All @@ -13,7 +15,7 @@ jobs:
strategy:
fail-fast: true
matrix:
java: [ '17' ]
java: [ '21' ]
steps:
- if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v4
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#file: noinspection Annotator

name: "CodeQL"

on:
Expand Down Expand Up @@ -27,7 +29,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
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`
}

repositories {
mavenCentral()
gradlePluginPortal()

maven("https://repo.papermc.io/repository/maven-public/")
}

dependencies {
compileOnly(gradleApi())
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(libs.shadow)
implementation(libs.paper.userdev)
}
11 changes: 11 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@file:Suppress("UnstableApiUsage")

dependencyResolutionManagement {
versionCatalogs {
register("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

rootProject.name = "build-logic"
18 changes: 18 additions & 0 deletions build-logic/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@file:Suppress("unused")

import com.github.jengelman.gradle.plugins.shadow.internal.DependencyFilter
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.provider.Provider

fun DependencyFilter.exclude(provider: Provider<ExternalModuleDependency>): DependencyFilter? =
exclude(provider.get())

fun DependencyFilter.exclude(dependency: ExternalModuleDependency): DependencyFilter? =
exclude(dependency("${dependency.group}:${dependency.name}:.*"))

fun DependencyFilter.include(provider: Provider<ExternalModuleDependency>): DependencyFilter? =
include(provider.get())

fun DependencyFilter.include(dependency: ExternalModuleDependency): DependencyFilter? =
include(dependency("${dependency.group}:${dependency.name}:.*"))

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()
52 changes: 52 additions & 0 deletions build-logic/src/main/kotlin/Projects.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@file:Suppress("MemberVisibilityCanBePrivate", "unused")

import org.gradle.api.Project

const val WHOMINE_PREFIX = "WhoMine"
const val WHOLIB_PREFIX = "WhoLib"

interface Projects {
val projectName: String
val projectPath: String
val projectDir: String
get() = projectName
val buildDir: String
get() = "build/$projectDir"

fun asProject(root: Project): Project =
root.project(projectPath)

fun exists(root: Project): Boolean =
root.findProject(projectPath) != null

companion object {
fun fromName(name: String): Projects? =
Libs.fromName(name) ?: Platforms.fromName(name)
}
}

enum class Libs(prefix: String = WHOLIB_PREFIX) : Projects {
Common, Paper, Velocity;

override val projectName: String = "$prefix-${name.lowercase()}"
override val projectPath: String = ":$projectName"
override val projectDir: String = "lib/$projectName"

companion object {
fun fromName(name: String): Projects? =
values().find { it.projectName == name }
}
}

enum class Platforms(prefix: String = WHOMINE_PREFIX) : Projects {
Paper, Velocity;

override val projectName: String = "$prefix-${name.lowercase()}"
override val projectPath: String = ":$projectName"
override val projectDir: String = "platform/$projectName"

companion object {
fun fromName(name: String): Projects? =
values().find { it.projectName == name }
}
}
86 changes: 86 additions & 0 deletions build-logic/src/main/kotlin/Properties.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.jvm.toolchain.JavaLanguageVersion

val utf8: String = Charsets.UTF_8.name()

val Project.javaVersionInt: Int
get() = (
getProperty("java.version")
?: throw IllegalStateException("Java version not set")
).toString().toInt()

val Project.javaVersion: JavaVersion
get() = JavaVersion.toVersion(javaVersionInt)

val Project.javaLanguageVersion: JavaLanguageVersion
get() = JavaLanguageVersion.of(javaVersionInt)

val Project.javaCompilerArgs: String
get() = (
getProperty("java.compilerArgs")
?: throw IllegalStateException("Java compiler args not set")
).toString()

val Project.projectGroup: String
get() = (
getProperty("project.group")
?: throw IllegalStateException("Project group not set")
).toString()

val Project.projectVersion: Any
get() = (
getProperty("project.version")
?: throw IllegalStateException("Project version not set")
)

val Project.projectDescription: String
get() = (
getProperty("project.description")
?: throw IllegalStateException("Project description not set")
).toString()

val Project.paperVersion: String
get() = (
getProperty("paper.version")
?: throw IllegalStateException("Paper version not set")
).toString()

val Project.projectAuthor: String
get() = (
getProperty("project.author")
?: throw IllegalStateException("Author not set")
).toString()

val Project.projectContributors: String
get() = (
getProperty("project.contributors")
?: throw IllegalStateException("Contributors not set")
).toString()

val Project.projectWebsite: String
get() = (
getProperty("project.website")
?: throw IllegalStateException("Website not set")
).toString()

fun apiVersion(minecraftVersion: String): String {
val parts = minecraftVersion.split('.')

return if (parts.size < 2) {
throw IllegalStateException("Invalid Minecraft version: '$minecraftVersion'")
} else {
"'${parts[0]}.${parts[1]}'"
}
}

fun Project.getProperty(name: String): Any? {
return rootProject.property(name)
}

fun Project.getProperty(
name: String,
default: Any
): Any {
return rootProject.property(name) ?: default
}
71 changes: 71 additions & 0 deletions build-logic/src/main/kotlin/whomine.base.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
plugins {
`java-library`
}

group = projectGroup
version = projectVersion
description = projectDescription

java {
toolchain {
languageVersion.set(javaLanguageVersion)
}

sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}

repositories {
mavenCentral()

maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.codemc.org/repository/maven-public/")
maven("https://maven.playpro.com")
}

dependencies {
if (project.name != Libs.Common.projectName) {
compileOnlyApi(Libs.Common.asProject(rootProject))
}

compileOnlyApi(libs.adventure.api)
compileOnlyApi(libs.adventure.ansi)
compileOnlyApi(libs.adventure.gson)
compileOnlyApi(libs.adventure.legacy)
compileOnlyApi(libs.adventure.plain)
compileOnlyApi(libs.adventure.minimessage)
compileOnlyApi(libs.asm.api)
compileOnlyApi(libs.asm.commons)
compileOnlyApi(libs.fastutil)
compileOnlyApi(libs.google.guava)
compileOnlyApi(libs.google.gson)
compileOnlyApi(libs.google.jsr305)
compileOnlyApi(libs.jackson.annotations)
compileOnlyApi(libs.jda)
compileOnlyApi(libs.jetbrains.annotations)
compileOnlyApi(libs.netty.buffer)
}

sourceSets {
main {
java.srcDir(Libs.Common.asProject(rootProject).sourceSets.main.get().java.srcDirs)
}
}

tasks {
compileJava {
options.encoding = utf8

options.release.set(javaVersionInt)
options.compilerArgs.add(javaCompilerArgs)
}

javadoc {
options.encoding = utf8
setDestinationDir(file("$rootDir/build/javadoc"))
}

processResources {
filteringCharset = utf8
}
}
34 changes: 34 additions & 0 deletions build-logic/src/main/kotlin/whomine.library.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import org.gradle.kotlin.dsl.invoke

plugins {
id("whomine.shadow")
}

dependencies {
runtimeClasspath(libs.adventure.api)
runtimeClasspath(libs.adventure.ansi)
runtimeClasspath(libs.adventure.gson)
runtimeClasspath(libs.adventure.legacy)
runtimeClasspath(libs.adventure.plain)
runtimeClasspath(libs.adventure.minimessage)
runtimeClasspath(libs.asm.api)
runtimeClasspath(libs.asm.commons)
runtimeClasspath(libs.fastutil)
runtimeClasspath(libs.google.guava)
runtimeClasspath(libs.google.gson)
runtimeClasspath(libs.google.jsr305)
runtimeClasspath(libs.jackson.annotations)
runtimeClasspath(libs.jda)
runtimeClasspath(libs.jetbrains.annotations)
runtimeClasspath(libs.netty.buffer)
}

tasks {
jar {
destinationDirectory.set(file("$rootDir/build/lib"))
}

shadowJar {
destinationDirectory.set(file("$rootDir/build/lib"))
}
}
8 changes: 8 additions & 0 deletions build-logic/src/main/kotlin/whomine.paperweight.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
id("whomine.base")
id("io.papermc.paperweight.userdev")
}

dependencies {
paperweight.paperDevBundle(paperVersion)
}
17 changes: 17 additions & 0 deletions build-logic/src/main/kotlin/whomine.platform.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import org.gradle.kotlin.dsl.invoke

plugins {
id("whomine.shadow")
}

tasks {
jar {
enabled = false
}

shadowJar {
destinationDirectory.set(file("$rootDir/build/platform"))

archiveClassifier.set("")
}
}
Loading