Skip to content

Commit

Permalink
Updated Upstream (Plazma)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaKR93 committed May 15, 2024
1 parent 556ee86 commit 286e917
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 108 deletions.
39 changes: 39 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[*]
charset=utf-8
end_of_line=lf
insert_final_newline=true
indent_style=space
indent_size=4
ij_any_block_comment_add_space = false
ij_any_block_comment_at_first_column = false
ij_any_line_comment_at_first_column = false
ij_any_line_comment_add_space = true
max_line_length = 120
ij_visual_guides = 80

[*.tiny]
indent_style=tab

[*.bat]
end_of_line=crlf

[*.yml]
indent_size=2

[*.patch]
trim_trailing_whitespace=false

[*.java]
ij_continuation_indent_size = 4
ij_java_class_count_to_use_import_on_demand = 999999
ij_java_insert_inner_class_imports = false
ij_java_names_count_to_use_import_on_demand = 999999
ij_java_imports_layout = *,|,$*
ij_java_generate_final_locals = true
ij_java_generate_final_parameters = true

[*-Server/src/main/resources/data/**/*.json]
indent_size = 2

[paper-api-generator/generated/**/*.java]
ij_java_imports_layout = $*,|,*
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* text=auto eol=lf

*.sh text eol=lf
gradlew text eol=lf
*.bat text eol=crlf

*.jar binary
118 changes: 68 additions & 50 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import io.papermc.paperweight.patcher.tasks.CheckoutRepo
import io.papermc.paperweight.util.*
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import paper.libs.com.google.gson.JsonObject

plugins {
java
Expand All @@ -13,9 +15,7 @@ plugins {
repositories {
mavenCentral()
maven("https://papermc.io/repo/repository/maven-public/") {
content {
onlyForConfigurations(configurations.paperclip.name)
}
content { onlyForConfigurations(configurations.paperclip.name) }
}
}

Expand All @@ -40,19 +40,12 @@ allprojects {
java.toolchain.languageVersion.set(JavaLanguageVersion.of(jdkVersion))

publishing {
repositories {
maven {
name = "githubPackage"
url = uri("https://maven.pkg.github.com/$projectRepo") // Volt - Change this

credentials {
username = System.getenv("GITHUB_USERNAME")
password = System.getenv("GITHUB_TOKEN")
}
}
repositories.maven("https://maven.pkg.github.com/$projectRepo") {
name = "githubPackage"

publications.register<MavenPublication>("gpr") {
from(components["java"])
credentials {
username = System.getenv("GITHUB_USERNAME")
password = System.getenv("GITHUB_TOKEN")
}
}
}
Expand All @@ -61,9 +54,12 @@ allprojects {
subprojects {
tasks {
withType<JavaCompile>().configureEach {
options.compilerArgs.addAll(listOf("--add-modules=jdk.incubator.vector", "-Xmaxwarns", "1"))
options.encoding = Charsets.UTF_8.name()
options.release = jdkVersion
options.compilerArgs.addAll(listOf(
"--add-modules=jdk.incubator.vector",
"-Xmaxwarns", "1"
))
}

withType<Javadoc> {
Expand All @@ -85,7 +81,6 @@ subprojects {

repositories {
mavenCentral()
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://jitpack.io")
}
Expand All @@ -104,37 +99,36 @@ paperweight {
withStandardPatcher {
baseName("Plazma")

apiPatchDir = layout.projectDirectory.dir("patches/api")
apiOutputDir = layout.projectDirectory.dir("$projectName-API")

serverPatchDir = layout.projectDirectory.dir("patches/server")
serverOutputDir = layout.projectDirectory.dir("$projectName-Server")
}
apiPatchDir = projectDir.resolve("patches/api")
apiOutputDir = projectDir.resolve("$projectName-API")

patchTasks.register("mojangApi") {
isBareDirectory = true
upstreamDirPath = "Plazma-MojangAPI"
patchDir = layout.projectDirectory.dir("patches/mojang-api")
outputDir = layout.projectDirectory.dir("$projectName-MojangAPI")
serverPatchDir = projectDir.resolve("patches/server")
serverOutputDir = projectDir.resolve("$projectName-Server")
}

patchTasks.register("generatedApi") {
isBareDirectory = true
upstreamDirPath = "paper-api-generator/generated"
patchDir = layout.projectDirectory.dir("patches/generated-api")
outputDir = layout.projectDirectory.dir("paper-api-generator/generated")
patchDir = projectDir.resolve("patches/generated-api")
outputDir = projectDir.resolve("paper-api-generator/generated")
}

patchTasks.register("versionCatalogs") {
isBareDirectory = true
upstreamDirPath = "libs"
patchDir = layout.projectDirectory.dir("patches/version-catalog")
outputDir = layout.projectDirectory.dir("libs")
patchDir = projectDir.resolve("patches/version-catalog")
outputDir = projectDir.resolve("libs")
}
}
}

val github = "https://api.github.com/repos/PlazmaMC/PlazmaBukkit/"

tasks {
withType<CheckoutRepo> {
ref.set(project.property("plazmaCommit").toString())
}

applyPatches {
dependsOn("applyVersionCatalogsPatches")
dependsOn("applyGeneratedApiPatches")
Expand All @@ -147,7 +141,6 @@ tasks {

generateDevelopmentBundle {
apiCoordinates = "$group:$projectName-api"
mojangApiCoordinates = "$group:$projectName-mojangapi"
libraryRepositories.set(
listOf(
"https://repo.maven.apache.org/maven2/",
Expand All @@ -158,16 +151,20 @@ tasks {
}

register("checkNeedsUpdate") {
var latest: String = ""
var latest = ""

doFirst {
val commit = layout.cache.resolve("commit.json")
download.get().download("https://api.github.com/repos/PlazmaMC/PlazmaBukkit/commits/$upstreamRef", commit)
latest = gson.fromJson<paper.libs.com.google.gson.JsonObject>(commit)["sha"].asString
download.get().download(
"$github/commits/$upstreamRef",
commit
)

latest = gson.fromJson<JsonObject>(commit)["sha"].asString
}

doLast {
println(latest != property("plazmaCommit"))
println(latest != project.property("plazmaCommit"))
}
}

Expand All @@ -178,20 +175,36 @@ tasks {

doFirst {
val commit = layout.cache.resolve("commit.json")
download.get().download("https://api.github.com/repos/PlazmaMC/PlazmaBukkit/commits/$upstreamRef", commit)
val latestCommit = gson.fromJson<paper.libs.com.google.gson.JsonObject>(commit)["sha"].asString
download.get().download(
"$github/commits/$upstreamRef",
commit
)

val latestCommit = gson.fromJson<JsonObject>(commit)["sha"].asString

val compare = layout.cache.resolve("compare.json")
download.get().download("https://api.github.com/repos/PlazmaMC/PlazmaBukkit/compare/$upstreamCommitValue...$upstreamRef", compare)
gson.fromJson<paper.libs.com.google.gson.JsonObject>(compare)["commits"].asJsonArray.forEach {
builder.append("PlazmaMC/PlazmaBukkit@${it.asJsonObject["sha"].asString.subSequence(0, 7)}: ${it.asJsonObject["commit"].asJsonObject["message"].asString.split("\n")[0]}\n")
download.get().download(
"$github/compare/$upstreamCommitValue...$upstreamRef",
compare
)

gson.fromJson<JsonObject>(compare)["commits"].asJsonArray.forEach {
builder.append("PlazmaMC/PlazmaBukkit")
builder.append("@")
builder.append(it.asJsonObject["sha"].asString.subSequence(0, 7))
builder.append(": ")
builder.append(it.asJsonObject["commit"].asJsonObject["message"].asString.split("\n")[0])
builder.append("\n")
}

copy {
from(file)
into(tempDir)
filter {
it.replace("plazmaCommit = .*".toRegex(), "plazmaCommit = $latestCommit")
it.replace(
"plazmaCommit = .*".toRegex(),
"plazmaCommit = $latestCommit"
)
}
}

Expand All @@ -203,6 +216,7 @@ tasks {
from(tempDir.file("gradle.properties"))
into(project.file(file).parent)
}

project.file("compare.txt").writeText(builder.toString())
}

Expand All @@ -211,15 +225,19 @@ tasks {

clean {
doLast {
projectDir.resolve(".gradle/caches").deleteRecursively()
listOf("$projectName-API", "$projectName-MojangAPI", "$projectName-Server", "paper-api-generator", "run").forEach {
listOf(
".gradle/caches",
"$projectName-API",
"$projectName-Server",
"paper-api-generator",
"run",

// remove dev environment files
"0001-fixup.patch",
"compare.txt"
).forEach {
projectDir.resolve(it).deleteRecursively()
}

// remove dev environment files
listOf("0001-fixup.patch", "compare.txt").forEach {
projectDir.resolve(it).delete()
}
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions fxapi

This file was deleted.

14 changes: 0 additions & 14 deletions fxsrv

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ plazmaRef = dev/1.20.6
jdkVersion = 21

# Volt - Use ./gradlew updateUpstream to update this value
plazmaCommit = 069250da5981752ace0db45a789ccd38b64475cc
plazmaCommit = 718927ee70839d1cde38417811fe0fa0dd711ba0
52 changes: 52 additions & 0 deletions initDev
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# To initialize your development environment,
# run below command in your terminal:
# source ./initDev

export PROJECT_DIR=$(pwd)

alias api="cd $PROJECT_DIR/*-API"
alias srv="cd $PROJECT_DIR/*-Server"

alias ap="./gradlew --no-rebuild applyPatches"
alias aap="./gradlew --no-rebuild applyAPIPatches"
alias agp="./gradlew --no-rebuild applyGeneratedAPIPatches"
alias asp="./gradlew --no-rebuild applyServerPatches"

alias rp="./gradlew --no-rebuild rebuildPatches"
alias rap="./gradlew --no-rebuild rebuildAPIPatches"
alias rgp="./gradlew --no-rebuild rebuildGeneratedAPIPatches"
alias rsp="./gradlew --no-rebuild rebuildServerPatches"

alias lg="git log --oneline base..HEAD"
alias rc="git rebase --autosquash -i base"
alias rcc="git rebase --continue"

# generate Fixup patches for Server
function fs() {
cd *-Server

git add .
git commit -m "fixup"
git format-patch -1
mv 0001-fixup.patch ../

cd ../
}

# generate Fixup patches for API
function fa() {
cd *-API

git add .
git commit -m "fixup"
git format-patch -1
mv 0001-fixup.patch ../

cd ../
}

# ReApply Server Patches
function rasp() {
rm -rf *-Server
./gradlew applyServerPatches
}
Empty file removed patches/mojang-api/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions patches/server/0002-Throw-on-startup.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Throw on startup


diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index e2adac04fa1721cbb5430b6b46ec406c76d45c2a..e7d2ad60694c1bac6d2c5f7d35ecc42790cdb42e 100644
index b6c9e81249bba59856d96ff71610b687fd9c4396..d1b3ede396d89c0056194ff41e6bf2d9603e5d79 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -284,6 +284,18 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@@ -286,6 +286,18 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
}
// Paper end - Unix domain socket support

Expand Down
Loading

0 comments on commit 286e917

Please sign in to comment.