mirror of
https://github.com/ViaVersion/ViaRewind.git
synced 2026-11-04 17:00:20 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6424ddb56 | ||
|
|
00bd23a639 | ||
|
|
7a6d73bd20 | ||
|
|
118fab1ba2 | ||
|
|
79ab8df038 | ||
|
|
824908a72f | ||
|
|
27136c2e3a |
No files matched your search
@@ -17,7 +17,7 @@ jobs:
|
||||
cache-disabled: true
|
||||
cache-provider: basic
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 25
|
||||
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
cache-disabled: true
|
||||
cache-provider: basic
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 25
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.foojay.resolver.convention.plugin)
|
||||
implementation(libs.classtokenreplacer.plugin)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from(files("../gradle/libs.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
group = property("project_group") as String
|
||||
version = property("project_version") as String
|
||||
description = property("project_description") as String
|
||||
|
||||
if (project == rootProject) {
|
||||
(findProperty("project_name") as String?)?.let { base.archivesName = it }
|
||||
}
|
||||
|
||||
// The Kotlin plugin picks up the Java toolchain, so no Kotlin specific configuration is needed
|
||||
val jvmVersion = (property("jvm_version") as String).toInt()
|
||||
java {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(jvmVersion)
|
||||
sourceCompatibility = JavaVersion.toVersion(jvmVersion)
|
||||
targetCompatibility = JavaVersion.toVersion(jvmVersion)
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
options.compilerArgs.addAll(listOf("-nowarn", "-Xlint:-unchecked", "-Xlint:-deprecation"))
|
||||
}
|
||||
|
||||
tasks.withType<Javadoc>().configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
(options as StandardJavadocDocletOptions).apply {
|
||||
addBooleanOption("Xdoclint:none", true)
|
||||
quiet()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
val projectName = project.name
|
||||
from("LICENSE") {
|
||||
rename { "LICENSE_$projectName" }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
signing
|
||||
}
|
||||
|
||||
val projectName = property("project_name") as String
|
||||
val ownerId = property("publish_owner_id") as String
|
||||
val ownerName = property("publish_owner_name") as String
|
||||
val ownerMail = property("publish_owner_mail") as String
|
||||
val githubAccount = findProperty("publish_github_account") as String? ?: ownerId
|
||||
val licenseName = findProperty("publish_license") as String? ?: "Apache-2.0"
|
||||
val githubRepository = "github.com/$githubAccount/$projectName"
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
groupId = project.group.toString()
|
||||
artifactId = project.name
|
||||
version = project.version.toString()
|
||||
|
||||
from(components["java"])
|
||||
|
||||
pom {
|
||||
name = projectName
|
||||
// Lazy so that a description set in the build script body is picked up
|
||||
description = provider { project.description }
|
||||
url = "https://$githubRepository"
|
||||
licenses {
|
||||
license {
|
||||
name = licenseName
|
||||
url = "https://$githubRepository/blob/main/LICENSE"
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = ownerId
|
||||
name = ownerName
|
||||
email = ownerMail
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection = "scm:git:git://$githubRepository.git"
|
||||
developerConnection = "scm:git:ssh://$githubRepository.git"
|
||||
url = "https://$githubRepository"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
isRequired = false
|
||||
sign(publishing.publications)
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention")
|
||||
}
|
||||
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
||||
dependencyResolutionManagement {
|
||||
// Repositories live in the settings only, a project or plugin declaring its own fails the build
|
||||
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://maven.florianreuth.de/releases")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
java
|
||||
}
|
||||
|
||||
val embeddedDependencies = configurations.create("embeddedDependencies") {
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = true
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
dependsOn(embeddedDependencies)
|
||||
from({ embeddedDependencies.map { zipTree(it) } }) {
|
||||
exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA")
|
||||
}
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package de.florianreuth.baseproject
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.ListProperty
|
||||
import org.gradle.api.provider.ValueSource
|
||||
import org.gradle.api.provider.ValueSourceParameters
|
||||
import org.gradle.process.ExecOperations
|
||||
import java.io.ByteArrayOutputStream
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Short hash of the latest commit, or "unknown" if Git is unavailable.
|
||||
*/
|
||||
fun Project.latestCommitHash(): String = runGitCommand(listOf("rev-parse", "--short", "HEAD"))
|
||||
|
||||
/**
|
||||
* Message of the latest commit, or "unknown" if Git is unavailable.
|
||||
*/
|
||||
fun Project.latestCommitMessage(): String = runGitCommand(listOf("log", "-1", "--pretty=%B"))
|
||||
|
||||
/**
|
||||
* Name of the current branch, or "unknown" if Git is unavailable.
|
||||
*/
|
||||
fun Project.branchName(): String = runGitCommand(listOf("rev-parse", "--abbrev-ref", "HEAD"))
|
||||
|
||||
/**
|
||||
* Runs a Git command through a configuration-cache compatible [ValueSource].
|
||||
*
|
||||
* @param args the arguments passed to `git`
|
||||
* @return the trimmed output, or "unknown" if the command fails or prints nothing
|
||||
*/
|
||||
fun Project.runGitCommand(args: List<String>): String {
|
||||
return providers.of(GitCommand::class.java) { parameters.args.set(args) }.getOrNull() ?: "unknown"
|
||||
}
|
||||
|
||||
abstract class GitCommand : ValueSource<String, GitCommand.GitCommandParameters> {
|
||||
|
||||
@get:Inject
|
||||
abstract val execOperations: ExecOperations
|
||||
|
||||
interface GitCommandParameters : ValueSourceParameters {
|
||||
val args: ListProperty<String>
|
||||
}
|
||||
|
||||
override fun obtain(): String? {
|
||||
try {
|
||||
val output = ByteArrayOutputStream()
|
||||
execOperations.exec {
|
||||
commandLine = listOf("git") + parameters.args.get()
|
||||
standardOutput = output
|
||||
isIgnoreExitValue = true
|
||||
}
|
||||
|
||||
return output.toString(Charsets.UTF_8).trim().takeIf { it.isNotBlank() }
|
||||
} catch (_: Exception) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of BaseProject - https://github.com/florianreuth/BaseProject
|
||||
* Copyright (C) 2024-2026 Florian Reuth <git@florianreuth.de>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package de.florianreuth.baseproject
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.initialization.Settings
|
||||
|
||||
/**
|
||||
* Includes `<rootProject.name>-<name>` for every name, located in the `<name>` folder.
|
||||
*
|
||||
* @param names the subproject folder names
|
||||
*/
|
||||
fun Settings.setupViaSubprojects(vararg names: String) {
|
||||
names.forEach { name ->
|
||||
include("${rootProject.name}-$name")
|
||||
project(":${rootProject.name}-$name").projectDir = settingsDir.resolve(name)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Version, channel and changelog of a Modrinth / Hangar upload of a ViaVersion project.
|
||||
*
|
||||
* @property isRelease whether the project version has no pre-release suffix
|
||||
* @property isMainBranch whether the current Git branch is the main branch
|
||||
* @property version the project version, suffixed with the GitHub run number for non-releases
|
||||
* @property changelog a link to the GitHub releases for releases, otherwise [commitChangelog]
|
||||
* @property commitChangelog a link to and the message of the latest commit
|
||||
*/
|
||||
class ViaRelease(
|
||||
val isRelease: Boolean,
|
||||
val isMainBranch: Boolean,
|
||||
val version: String,
|
||||
val changelog: String,
|
||||
val commitChangelog: String
|
||||
) {
|
||||
val modrinthVersionType: String
|
||||
get() = if (isRelease) "release" else if (isMainBranch) "beta" else "alpha"
|
||||
|
||||
val hangarChannel: String
|
||||
get() = if (isRelease) "Release" else if (isMainBranch) "Snapshot" else "Alpha"
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the release information from the project version and Git; the repository is `ViaVersion/<project_name>`.
|
||||
*
|
||||
* @param mainBranch the name of the branch releases are published from
|
||||
* @return the release information of the current build
|
||||
*/
|
||||
fun Project.viaRelease(mainBranch: String): ViaRelease {
|
||||
val baseVersion = version.toString()
|
||||
val isRelease = !baseVersion.contains('-')
|
||||
val repository = "https://github.com/ViaVersion/${property("project_name")}"
|
||||
val commitHash = latestCommitHash()
|
||||
val commitChangelog = "[$commitHash]($repository/commit/$commitHash) ${latestCommitMessage()}"
|
||||
|
||||
return ViaRelease(
|
||||
isRelease = isRelease,
|
||||
isMainBranch = branchName() == mainBranch,
|
||||
version = if (isRelease) baseVersion else baseVersion + "+" + System.getenv("GITHUB_RUN_NUMBER"),
|
||||
changelog = if (isRelease) "See [GitHub]($repository) for release notes." else commitChangelog,
|
||||
commitChangelog = commitChangelog
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import de.florianreuth.baseproject.latestCommitHash
|
||||
import net.raphimc.classtokenreplacer.extension.ClassTokenReplacerExtension
|
||||
|
||||
plugins {
|
||||
java
|
||||
id("net.raphimc.class-token-replacer")
|
||||
}
|
||||
|
||||
val implVersion = "git-${property("project_name")}-${project.version}:${latestCommitHash()}"
|
||||
sourceSets.configureEach {
|
||||
extensions.getByType<ClassTokenReplacerExtension>().apply {
|
||||
property("\${version}", project.version)
|
||||
property("\${impl_version}", implVersion)
|
||||
}
|
||||
}
|
||||
|
||||
// With replaceInPlace the plugin only finalizes classes with the replacement, so the jar could pack unreplaced classes
|
||||
tasks.jar {
|
||||
dependsOn("replaceTokens")
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "Via"
|
||||
url = uri("https://repo.viaversion.com/")
|
||||
credentials {
|
||||
username = findProperty("ViaUsername") as String?
|
||||
password = findProperty("ViaPassword") as String?
|
||||
}
|
||||
authentication {
|
||||
create<BasicAuthentication>("basic")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
plugins {
|
||||
java
|
||||
id("base.java")
|
||||
id("via.maven_publish")
|
||||
}
|
||||
|
||||
val libs = project.the<VersionCatalogsExtension>().named("libs")
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.findLibrary("viaversion").get())
|
||||
compileOnly(libs.findLibrary("viabackwards").get())
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
val projectVersion = project.version
|
||||
val projectDescription = project.description
|
||||
filesMatching(listOf("plugin.yml", "fabric.mod.json", "META-INF/sponge_plugins.json")) {
|
||||
expand(mapOf("version" to projectVersion, "description" to projectDescription))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
plugins {
|
||||
id("publishing.viaversion")
|
||||
}
|
||||
|
||||
// base.maven_publish reads these when applied, so it is applied only after they are set
|
||||
extra["publish_github_account"] = "ViaVersion"
|
||||
extra["publish_license"] = "GPL-3.0"
|
||||
apply(plugin = "base.maven_publish")
|
||||
@@ -0,0 +1,47 @@
|
||||
// Task to quickly test/debug code changes using https://github.com/ViaVersion/ViaProxy
|
||||
// For further instructions see the ViaProxy repository README
|
||||
plugins {
|
||||
java
|
||||
}
|
||||
|
||||
val viaProxy = configurations.create("viaProxy")
|
||||
|
||||
dependencies {
|
||||
addProvider<MinimalExternalModuleDependency, ExternalModuleDependency>(
|
||||
viaProxy.name,
|
||||
project.the<VersionCatalogsExtension>().named("libs").findLibrary("viaproxy").get()
|
||||
) {
|
||||
isTransitive = false
|
||||
}
|
||||
}
|
||||
|
||||
val prepareViaProxyFiles by tasks.registering(Copy::class) {
|
||||
dependsOn(project.tasks.jar)
|
||||
|
||||
from(project.tasks.jar.get().archiveFile.get().asFile)
|
||||
into(layout.projectDirectory.dir("run/jars"))
|
||||
|
||||
val projectName = project.name
|
||||
rename { "${projectName}.jar" }
|
||||
}
|
||||
|
||||
val cleanupViaProxyFiles by tasks.registering(Delete::class) {
|
||||
delete(
|
||||
layout.projectDirectory.file("run/jars/${project.name}.jar"),
|
||||
layout.projectDirectory.dir("run/logs")
|
||||
)
|
||||
}
|
||||
|
||||
tasks.register<JavaExec>("runViaProxy") {
|
||||
dependsOn(prepareViaProxyFiles)
|
||||
finalizedBy(cleanupViaProxyFiles)
|
||||
|
||||
mainClass.set("net.raphimc.viaproxy.ViaProxy")
|
||||
classpath = viaProxy
|
||||
workingDir = layout.projectDirectory.dir("run").asFile
|
||||
jvmArgs = listOf("-DskipUpdateCheck")
|
||||
|
||||
if (System.getProperty("viaproxy.gui.autoStart") != null) {
|
||||
jvmArgs("-Dviaproxy.gui.autoStart")
|
||||
}
|
||||
}
|
||||
+20
-79
@@ -1,68 +1,20 @@
|
||||
import de.florianreuth.baseproject.core.configureEmbeddedDependencies
|
||||
import de.florianreuth.baseproject.integration.branchName
|
||||
import de.florianreuth.baseproject.integration.latestCommitHash
|
||||
import de.florianreuth.baseproject.integration.latestCommitMessage
|
||||
import de.florianreuth.baseproject.setupProject
|
||||
import de.florianreuth.baseproject.setupViaPublishing
|
||||
import net.raphimc.classtokenreplacer.extension.ClassTokenReplacerExtension
|
||||
import de.florianreuth.baseproject.viaRelease
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
id("io.papermc.hangar-publish-plugin")
|
||||
id("com.modrinth.minotaur")
|
||||
id("de.florianreuth.baseproject")
|
||||
id("net.raphimc.class-token-replacer") apply false
|
||||
alias(libs.plugins.hangar.publish)
|
||||
alias(libs.plugins.minotaur)
|
||||
id("base.java")
|
||||
id("via.maven_publish")
|
||||
id("configuration.embedded_dependencies")
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
||||
setupProject()
|
||||
setupViaPublishing()
|
||||
|
||||
repositories {
|
||||
maven("https://repo.viaversion.com")
|
||||
maven("https://repo.papermc.io/repository/maven-public")
|
||||
maven("https://maven.fabricmc.net")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val commitHash = latestCommitHash()
|
||||
|
||||
subprojects {
|
||||
|
||||
apply(plugin = "net.raphimc.class-token-replacer")
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.viaversion:viaversion:5.12.0")
|
||||
compileOnly("com.viaversion:viabackwards:5.12.0")
|
||||
}
|
||||
|
||||
extensions.getByType<SourceSetContainer>().configureEach {
|
||||
extensions.getByType(ClassTokenReplacerExtension::class.java).apply {
|
||||
property("\${version}", project.version)
|
||||
property("\${impl_version}", "git-ViaRewind-${project.version}:${commitHash}")
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
processResources {
|
||||
val projectVersion = project.version
|
||||
val projectDescription = project.description
|
||||
filesMatching(listOf("plugin.yml", "fabric.mod.json", "META-INF/sponge_plugins.json")) {
|
||||
expand(mapOf("version" to projectVersion, "description" to projectDescription))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val shade = configureEmbeddedDependencies()
|
||||
|
||||
dependencies {
|
||||
subprojects.forEach {
|
||||
shade(it)
|
||||
}
|
||||
embeddedDependencies(projects.viarewindCommon)
|
||||
embeddedDependencies(projects.viarewindBukkit)
|
||||
embeddedDependencies(projects.viarewindFabric)
|
||||
embeddedDependencies(projects.viarewindSponge)
|
||||
embeddedDependencies(projects.viarewindVelocity)
|
||||
}
|
||||
|
||||
tasks {
|
||||
@@ -73,29 +25,18 @@ tasks {
|
||||
}
|
||||
}
|
||||
|
||||
val branch = branchName()
|
||||
val baseVersion = version as String
|
||||
val isRelease = !baseVersion.contains('-')
|
||||
val isMainBranch = branch == "master"
|
||||
if (!isRelease || isMainBranch) { // Only publish releases from the main branch
|
||||
val suffixedVersion = if (isRelease) baseVersion else baseVersion + "+" + System.getenv("GITHUB_RUN_NUMBER")
|
||||
val changelogContent = if (isRelease) {
|
||||
"See [GitHub](https://github.com/ViaVersion/ViaRewind) for release notes."
|
||||
} else {
|
||||
val commitHash = latestCommitHash()
|
||||
"[$commitHash](https://github.com/ViaVersion/ViaRewind/commit/$commitHash) ${latestCommitMessage()}"
|
||||
}
|
||||
|
||||
val release = viaRelease("master")
|
||||
if (!release.isRelease || release.isMainBranch) { // Only publish releases from the main branch
|
||||
modrinth {
|
||||
val mcVersions: List<String> = (property("minecraft_versions") as String)
|
||||
.split(",")
|
||||
.map { it.trim() }
|
||||
token.set(System.getenv("MODRINTH_TOKEN"))
|
||||
projectId.set("viarewind")
|
||||
versionType.set(if (isRelease) "release" else if (isMainBranch) "beta" else "alpha")
|
||||
versionNumber.set(suffixedVersion)
|
||||
versionName.set(suffixedVersion)
|
||||
changelog.set(changelogContent)
|
||||
versionType.set(release.modrinthVersionType)
|
||||
versionNumber.set(release.version)
|
||||
versionName.set(release.version)
|
||||
changelog.set(release.changelog)
|
||||
uploadFile.set(tasks.jar.flatMap { it.archiveFile })
|
||||
gameVersions.set(mcVersions)
|
||||
loaders.add("fabric")
|
||||
@@ -116,10 +57,10 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch
|
||||
|
||||
hangarPublish {
|
||||
publications.register("plugin") {
|
||||
version.set(suffixedVersion)
|
||||
version.set(release.version)
|
||||
id.set("ViaRewind")
|
||||
channel.set(if (isRelease) "Release" else if (isMainBranch) "Snapshot" else "Alpha")
|
||||
changelog.set(changelogContent)
|
||||
channel.set(release.hangarChannel)
|
||||
changelog.set(release.changelog)
|
||||
apiKey.set(System.getenv("HANGAR_TOKEN"))
|
||||
platforms {
|
||||
paper {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
dependencies {
|
||||
compileOnly(project(":viarewind-common"))
|
||||
compileOnly("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT")
|
||||
plugins {
|
||||
id("via.addon_subproject")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(projects.viarewindCommon)
|
||||
compileOnly(libs.spigot.api)
|
||||
}
|
||||
+8
-41
@@ -1,44 +1,11 @@
|
||||
val viaProxy: Configuration by configurations.creating
|
||||
plugins {
|
||||
id("via.addon_subproject")
|
||||
id("extra.fill_build_constants")
|
||||
id("via.run_viaproxy")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.netty:netty-all:4.0.20.Final")
|
||||
compileOnly("com.google.guava:guava:17.0")
|
||||
compileOnly("com.velocitypowered:velocity-native:3.4.0-SNAPSHOT")
|
||||
|
||||
viaProxy("net.raphimc:ViaProxy:[3.0.0,4.0.0)") {
|
||||
isTransitive = false
|
||||
}
|
||||
}
|
||||
|
||||
// Task to quickly test/debug code changes using https://github.com/ViaVersion/ViaProxy
|
||||
// For further instructions see the ViaProxy repository README
|
||||
val prepareViaProxyFiles by tasks.registering(Copy::class) {
|
||||
dependsOn(project.tasks.jar)
|
||||
|
||||
from(project.tasks.jar.get().archiveFile.get().asFile)
|
||||
into(layout.projectDirectory.dir("run/jars"))
|
||||
|
||||
val projectName = project.name
|
||||
rename { "${projectName}.jar" }
|
||||
}
|
||||
|
||||
val cleanupViaProxyFiles by tasks.registering(Delete::class) {
|
||||
delete(
|
||||
layout.projectDirectory.file("run/jars/${project.name}.jar"),
|
||||
layout.projectDirectory.dir("run/logs")
|
||||
)
|
||||
}
|
||||
|
||||
tasks.register<JavaExec>("runViaProxy") {
|
||||
dependsOn(prepareViaProxyFiles)
|
||||
finalizedBy(cleanupViaProxyFiles)
|
||||
|
||||
mainClass.set("net.raphimc.viaproxy.ViaProxy")
|
||||
classpath = viaProxy
|
||||
workingDir = layout.projectDirectory.dir("run").asFile
|
||||
jvmArgs = listOf("-DskipUpdateCheck")
|
||||
|
||||
if (System.getProperty("viaproxy.gui.autoStart") != null) {
|
||||
jvmArgs("-Dviaproxy.gui.autoStart")
|
||||
}
|
||||
compileOnly(libs.netty.all)
|
||||
compileOnly(libs.guava)
|
||||
compileOnly(libs.velocity.native)
|
||||
}
|
||||
@@ -91,4 +91,13 @@ public interface ViaRewindPlatform {
|
||||
return "decompress";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the platform's compression handler also writes the packet length. Only used in the 1.8 -> 1.7 protocol.
|
||||
*
|
||||
* @return true if the compression handler writes the packet length
|
||||
*/
|
||||
default boolean compressHandlerWritesLength() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -17,14 +17,24 @@
|
||||
*/
|
||||
package com.viaversion.viarewind.api.minecraft.netty;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
public class ForwardMessageToByteEncoder extends MessageToByteEncoder<ByteBuf> {
|
||||
|
||||
private final boolean writeLength;
|
||||
|
||||
public ForwardMessageToByteEncoder(final boolean writeLength) {
|
||||
this.writeLength = writeLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) {
|
||||
if (writeLength) {
|
||||
Types.VAR_INT.writePrimitive(out, msg.readableBytes());
|
||||
}
|
||||
out.writeBytes(msg);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class TrackingCompressionHandlerProvider extends CompressionHandlerProvid
|
||||
|
||||
if (compressor != null) { // We can neutralize the effect of compressor to the client
|
||||
pipeline.replace(decompressor, decompressor, new EmptyChannelHandler());
|
||||
pipeline.replace(compressor, compressor, new ForwardMessageToByteEncoder());
|
||||
pipeline.replace(compressor, compressor, new ForwardMessageToByteEncoder(ViaRewind.getPlatform().compressHandlerWritesLength()));
|
||||
} else {
|
||||
throw new IllegalStateException("Couldn't remove compression for 1.7!");
|
||||
}
|
||||
|
||||
+5
-3
@@ -412,9 +412,11 @@ public class EntityPacketRewriter1_9 extends VREntityRewriter<ClientboundPackets
|
||||
public void register() {
|
||||
map(Types.VAR_INT); // Entity id
|
||||
handler(wrapper -> {
|
||||
// todo check if this is correct for the own player
|
||||
// 1.8 clients write their own equipment to armorInventory[slot] without the -1 offset,
|
||||
// shifting armor up one slot; the window 0 set slot packets already carry it.
|
||||
final int entityId = wrapper.get(Types.VAR_INT, 0);
|
||||
int slot = wrapper.read(Types.VAR_INT);
|
||||
if (slot == 1) {
|
||||
if (slot == 1 || entityId == wrapper.user().getEntityTracker(protocol).clientEntityId()) {
|
||||
wrapper.cancel();
|
||||
} else if (slot > 1) {
|
||||
slot -= 1;
|
||||
@@ -573,7 +575,7 @@ public class EntityPacketRewriter1_9 extends VREntityRewriter<ClientboundPackets
|
||||
protected void registerRewrites() {
|
||||
// Handle new entities
|
||||
mapEntityTypeWithData(EntityTypes1_9.EntityType.SHULKER, EntityTypes1_9.EntityType.MAGMA_CUBE).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_9.EntityType.SHULKER_BULLET, EntityTypes1_9.EntityType.WITCH).plainName();
|
||||
mapObjectType(EntityTypes1_9.ObjectType.SHULKER_BULLET, EntityTypes1_9.ObjectType.WITHER_SKULL, -1).plainName();
|
||||
|
||||
// Entity data rewrite
|
||||
filter().handler(this::handleEntityData);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
dependencies {
|
||||
compileOnly(project(":viarewind-common"))
|
||||
compileOnly("net.fabricmc:fabric-loader:0.11.3")
|
||||
compileOnly("org.apache.logging.log4j:log4j-api:2.17.1")
|
||||
plugins {
|
||||
id("via.addon_subproject")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(projects.viarewindCommon)
|
||||
compileOnly(libs.fabric.loader)
|
||||
compileOnly(libs.log4j.api)
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ jvm_version=17
|
||||
|
||||
project_group=com.viaversion
|
||||
project_name=ViaRewind
|
||||
project_version=4.2.0
|
||||
project_version=4.2.1-SNAPSHOT
|
||||
project_description=ViaVersion addon to allow 1.8.x and 1.7.x clients on newer server versions.
|
||||
|
||||
publish_owner_id=florianreuth
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
[versions]
|
||||
viaversion = "5.12.0"
|
||||
velocity = "3.4.0"
|
||||
|
||||
[libraries]
|
||||
foojay-resolver-convention-plugin = { module = "org.gradle.toolchains.foojay-resolver-convention:org.gradle.toolchains.foojay-resolver-convention.gradle.plugin", version = "1.0.0" }
|
||||
classtokenreplacer-plugin = { module = "net.raphimc.class-token-replacer:net.raphimc.class-token-replacer.gradle.plugin", version = "1.1.7" }
|
||||
viaproxy = { module = "net.raphimc:ViaProxy", version = "[3.0.0,4.0.0)" }
|
||||
viaversion = { module = "com.viaversion:viaversion", version.ref = "viaversion" }
|
||||
viabackwards = { module = "com.viaversion:viabackwards", version.ref = "viaversion" }
|
||||
netty-all = { module = "io.netty:netty-all", version = "4.0.20.Final" }
|
||||
guava = { module = "com.google.guava:guava", version = "17.0" }
|
||||
velocity-native = { module = "com.velocitypowered:velocity-native", version = "3.4.0-SNAPSHOT" }
|
||||
spigot-api = { module = "org.spigotmc:spigot-api", version = "1.12.2-R0.1-SNAPSHOT" }
|
||||
fabric-loader = { module = "net.fabricmc:fabric-loader", version = "0.11.3" }
|
||||
log4j-api = { module = "org.apache.logging.log4j:log4j-api", version = "2.17.1" }
|
||||
velocity-api = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" }
|
||||
|
||||
[plugins]
|
||||
hangar-publish = { id = "io.papermc.hangar-publish-plugin", version = "0.1.4" }
|
||||
minotaur = { id = "com.modrinth.minotaur", version = "2.+" }
|
||||
Vendored
BIN
Binary file not shown.
+2
-2
@@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionSha256Sum=acd53f1edaf02f1a8ff99879f8a34b302661a057d9b063ae9e35b552f804d20a
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
|
||||
distributionSha256Sum=bafd5ce9cfaea0fbccfdc8439a1ac42fbd4cd9c89dc9a988228d8a2639a58e6c
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.0-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
|
||||
Vendored
+41
-11
@@ -26,6 +26,33 @@
|
||||
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||
setlocal EnableExtensions
|
||||
|
||||
@rem Catch executions from older scripts and ensure they exit cleanly.
|
||||
@rem This can be removed once we can be reasonably confident that few people
|
||||
@rem will be migrating directly to this new wrapper.
|
||||
goto afterSafetyNet
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
goto exitWithErrorLevel
|
||||
:afterSafetyNet
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
@@ -45,13 +72,14 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
1>&2 echo.
|
||||
1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
1>&2 echo.
|
||||
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
|
||||
1>&2 echo location of your Java installation.
|
||||
|
||||
"%COMSPEC%" /c exit 1
|
||||
goto exitWithErrorLevel
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
@@ -59,13 +87,14 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
1>&2 echo.
|
||||
1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
1>&2 echo.
|
||||
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
|
||||
1>&2 echo location of your Java installation.
|
||||
|
||||
"%COMSPEC%" /c exit 1
|
||||
goto exitWithErrorLevel
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
@@ -75,8 +104,9 @@ echo location of your Java installation. 1>&2
|
||||
@rem Execute gradlew
|
||||
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||
@rem which allows us to clear the local environment before executing the java command
|
||||
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel
|
||||
|
||||
@rem This label must not be changed. We rely on old scripts being able to jump to this point.
|
||||
:exitWithErrorLevel
|
||||
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||
+13
-23
@@ -1,31 +1,21 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven("https://maven.florianreuth.de/releases")
|
||||
}
|
||||
import de.florianreuth.baseproject.setupViaSubprojects
|
||||
|
||||
plugins {
|
||||
id("de.florianreuth.baseproject") version "3.0.2"
|
||||
id("io.papermc.hangar-publish-plugin") version "0.1.4"
|
||||
id("net.raphimc.class-token-replacer") version "1.1.7"
|
||||
id("com.modrinth.minotaur") version "2.+"
|
||||
}
|
||||
pluginManagement {
|
||||
includeBuild("build-logic")
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
|
||||
id("base.settings")
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
maven("https://repo.viaversion.com")
|
||||
maven("https://repo.papermc.io/repository/maven-public")
|
||||
maven("https://maven.fabricmc.net")
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "viarewind"
|
||||
|
||||
setupViaSubproject("common")
|
||||
setupViaSubproject("bukkit")
|
||||
setupViaSubproject("fabric")
|
||||
setupViaSubproject("sponge")
|
||||
setupViaSubproject("velocity")
|
||||
|
||||
fun setupViaSubproject(name: String) {
|
||||
include("viarewind-$name")
|
||||
project(":viarewind-$name").projectDir = file(name)
|
||||
}
|
||||
setupViaSubprojects("common", "bukkit", "fabric", "sponge", "velocity")
|
||||
@@ -1,3 +1,7 @@
|
||||
dependencies {
|
||||
compileOnly(project(":viarewind-common"))
|
||||
plugins {
|
||||
id("via.addon_subproject")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(projects.viarewindCommon)
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
dependencies {
|
||||
compileOnly(project(":viarewind-common"))
|
||||
compileOnly("com.velocitypowered:velocity-api:3.4.0")?.also { annotationProcessor(it) }
|
||||
plugins {
|
||||
id("via.addon_subproject")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(projects.viarewindCommon)
|
||||
compileOnly(libs.velocity.api)
|
||||
annotationProcessor(libs.velocity.api)
|
||||
}
|
||||
@@ -79,4 +79,9 @@ public class VelocityPlugin implements ViaRewindPlatform {
|
||||
return "compression-decoder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compressHandlerWritesLength() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user