mirror of
https://github.com/ViaVersion/ViaRewind-Legacy-Support.git
synced 2026-11-05 01:10:06 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e1cf69ebe | ||
|
|
18988d97c0 | ||
|
|
15045d2188 | ||
|
|
ee905820eb | ||
|
|
c62c7ed62a | ||
|
|
53bde6ba43 | ||
|
|
3eac764559 | ||
|
|
34ce9102e1 | ||
|
|
d63b405bdb | ||
|
|
dc51b8899c | ||
|
|
d3b6a41bc6 | ||
|
|
bcfa25eec9 | ||
|
|
e68e15dd9f | ||
|
|
788d87086e | ||
|
|
03a6fe6c2a | ||
|
|
54523d7de9 | ||
|
|
33c3c4c641 | ||
|
|
5a0f6621cf | ||
|
|
ba47756eb8 | ||
|
|
e700bca43e | ||
|
|
91b9f6d9b7 | ||
|
|
2494d08d3e | ||
|
|
8593bd7d7c | ||
|
|
054f899180 | ||
|
|
8329a04a5c | ||
|
|
2be0cfd5b5 | ||
|
|
e83dd73a66 | ||
|
|
b6f89c9893 | ||
|
|
c98f0f8970 | ||
|
|
6602e3ff67 | ||
|
|
7910288083 | ||
|
|
a2ccc0a7de | ||
|
|
f01f255b2b | ||
|
|
e8dc069437 | ||
|
|
baac8ae938 | ||
|
|
e22e37d975 | ||
|
|
6b495ebb20 | ||
|
|
2e6acfaf04 | ||
|
|
9dd1dc8e4d | ||
|
|
3030d07fec | ||
|
|
081c9c9a6f | ||
|
|
64039f847c | ||
|
|
5380fc9c1b | ||
|
|
28f14ce635 | ||
|
|
30725d9545 |
No files matched your search
@@ -0,0 +1,16 @@
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
tab_width = 4
|
||||
|
||||
[*.java]
|
||||
ij_java_class_count_to_use_import_on_demand = 999999
|
||||
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
|
||||
|
||||
[{*.json,*.yml}]
|
||||
indent_size = 2
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
github: FlorianMichael
|
||||
custom: ['https://florianmichael.de/donate', 'https://viaversion.com/donate', 'https://creeper123123321.github.io/#donate']
|
||||
github: florianreuth
|
||||
custom: ['https://florianreuth.de/donate', 'https://creeper123123321.github.io/#donate']
|
||||
@@ -0,0 +1,22 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "gradle"
|
||||
cooldown:
|
||||
default-days: 7
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
groups:
|
||||
all-dependencies:
|
||||
patterns:
|
||||
- "*"
|
||||
- package-ecosystem: "github-actions"
|
||||
cooldown:
|
||||
default-days: 7
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
groups:
|
||||
all-dependencies:
|
||||
patterns:
|
||||
- "*"
|
||||
+23
-19
@@ -1,28 +1,32 @@
|
||||
name: ViaRewind-Legacy-Support CI
|
||||
name: Build
|
||||
on: [pull_request, push, workflow_dispatch]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-26.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
|
||||
with:
|
||||
cache-disabled: true
|
||||
cache-provider: basic
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 25
|
||||
check-latest: true
|
||||
- name: Cache Dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
run: ./gradlew build --stacktrace
|
||||
- name: Upload Artifacts to GitHub
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/libs/
|
||||
if-no-files-found: error
|
||||
@@ -8,19 +8,25 @@ on:
|
||||
jobs:
|
||||
publish:
|
||||
if: github.repository_owner == 'ViaVersion'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-26.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
|
||||
with:
|
||||
cache-disabled: true
|
||||
cache-provider: basic
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 25
|
||||
check-latest: true
|
||||
- name: Publish
|
||||
env:
|
||||
HANGAR_TOKEN: ${{ secrets.HANGAR_TOKEN }}
|
||||
run: ./gradlew build publishAllPublicationsToHangar
|
||||
run: ./gradlew build publishAllPublicationsToHangar --stacktrace
|
||||
+9
-4
@@ -4,6 +4,7 @@
|
||||
build/
|
||||
out/
|
||||
classes/
|
||||
.kotlin/
|
||||
|
||||
# Eclipse
|
||||
|
||||
@@ -12,11 +13,13 @@ classes/
|
||||
# Idea
|
||||
|
||||
.idea/
|
||||
!.idea/copyright/*
|
||||
!.idea/scopes/*
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# VScode
|
||||
# VSCode
|
||||
|
||||
.settings/
|
||||
.vscode/
|
||||
@@ -26,6 +29,8 @@ bin/
|
||||
|
||||
# macOS
|
||||
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
DS_Store
|
||||
|
||||
# Misc
|
||||
|
||||
run/
|
||||
@@ -29,7 +29,7 @@ Installing this plugin requires nothing more than putting it in your plugins fol
|
||||
|
||||
- The **Lily Pad** bounding box is being modified. This prevents 1.7.x-1.8.x from glitching if they try to walk over **Lily Pads**.
|
||||
- The **Ladder** bounding box is being modified. This prevents 1.7.x-1.8.x from glitching if they try to climb **Ladders**.
|
||||
- If a 1.7.x player opens an **Enchantment Table** this plugin takes Lapis Lazuli from his/her inventory and puts it in the **Enchantment Table**.
|
||||
- If a 1.7.x player opens an **Enchantment Table** this plugin takes Lapis Lazuli from their inventory and puts it in the **Enchantment Table**.
|
||||
- 1.7.x-1.8.x can interact with **Brewing Stands** to add/remove Blaze Powder to/from them.
|
||||
- Play block placement and item pickup **sounds** to 1.7.x-1.8.x players.
|
||||
- Velocity is applied during **Elytra flight** for players below 1.9.
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.foojay.resolver.convention.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,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,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,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")
|
||||
-120
@@ -1,120 +0,0 @@
|
||||
plugins {
|
||||
id "java-library"
|
||||
id "maven-publish"
|
||||
id "io.papermc.hangar-publish-plugin" version "0.1.2"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
url = uri("https://repo.viaversion.com")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://repo.maven.apache.org/maven2/")
|
||||
}
|
||||
}
|
||||
|
||||
version = project.maven_version
|
||||
group = project.maven_group
|
||||
|
||||
dependencies {
|
||||
compileOnly "com.viaversion:viaversion-api:4.10.0"
|
||||
compileOnly "org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("plugin.yml") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from(components.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
tasks.withType(Javadoc) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Publishing
|
||||
|
||||
def latestCommitHash() {
|
||||
def byteOut = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'git', 'rev-parse', '--short', 'HEAD'
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return byteOut.toString('UTF-8').trim()
|
||||
}
|
||||
|
||||
def latestCommitMessage() {
|
||||
def byteOut = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'git', 'log', '-1', '--pretty=%B'
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return byteOut.toString('UTF-8').trim()
|
||||
}
|
||||
|
||||
def branchName() {
|
||||
def byteOut = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD'
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return byteOut.toString('UTF-8').trim()
|
||||
}
|
||||
|
||||
def baseVersion = project.maven_version
|
||||
def isRelease = !baseVersion.contains('-')
|
||||
def suffixedVersion = isRelease ? baseVersion : baseVersion + "+" + System.getenv("GITHUB_RUN_NUMBER")
|
||||
def commitHash = latestCommitHash()
|
||||
def changelogContent = "[${commitHash}](https://github.com/ViaVersion/iaRewind-Legacy-Support/commit/${commitHash}) ${latestCommitMessage()}"
|
||||
def branch = branchName()
|
||||
def isMainBranch = branch == "master"
|
||||
hangarPublish {
|
||||
publications.register("plugin") {
|
||||
version.set(suffixedVersion)
|
||||
id.set("ViaRewindLegacySupport")
|
||||
channel.set(isRelease ? "Release" : isMainBranch ? "Snapshot" : "Alpha")
|
||||
changelog.set(changelogContent)
|
||||
apiKey.set(System.getenv("HANGAR_TOKEN"))
|
||||
platforms {
|
||||
PAPER {
|
||||
jar.set(tasks.jar.archiveFile)
|
||||
platformVersions.set([property('mcVersionRange') as String])
|
||||
dependencies.hangar("ViaVersion") {
|
||||
required.set(true)
|
||||
}
|
||||
dependencies.hangar("ViaBackwards") {
|
||||
required.set(false)
|
||||
}
|
||||
dependencies.hangar("ViaRewind") {
|
||||
required.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import de.florianreuth.baseproject.viaRelease
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
alias(libs.plugins.hangar.publish)
|
||||
id("base.java")
|
||||
id("via.maven_publish")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.viaversion.api)
|
||||
compileOnly(libs.spigot.api)
|
||||
}
|
||||
|
||||
tasks {
|
||||
processResources {
|
||||
val projectVersion = project.version
|
||||
val projectDescription = project.description
|
||||
filesMatching("plugin.yml") {
|
||||
expand(mapOf("version" to projectVersion, "description" to projectDescription))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val release = viaRelease("master")
|
||||
hangarPublish {
|
||||
publications.register("plugin") {
|
||||
version.set(release.version)
|
||||
id.set("ViaRewindLegacySupport")
|
||||
channel.set(release.hangarChannel)
|
||||
changelog.set(release.commitChangelog)
|
||||
apiKey.set(System.getenv("HANGAR_TOKEN"))
|
||||
platforms {
|
||||
paper {
|
||||
jar.set(tasks.jar.flatMap { it.archiveFile })
|
||||
platformVersions.set(listOf(property("minecraft_version_range") as String))
|
||||
dependencies.hangar("ViaVersion") {
|
||||
required.set(true)
|
||||
}
|
||||
dependencies.hangar("ViaBackwards") {
|
||||
required.set(false)
|
||||
}
|
||||
dependencies.hangar("ViaRewind") {
|
||||
required.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.named("publishPluginPublicationToHangar") {
|
||||
notCompatibleWithConfigurationCache("")
|
||||
}
|
||||
+14
-5
@@ -1,10 +1,19 @@
|
||||
# gradle
|
||||
# Gradle Properties
|
||||
org.gradle.jvmargs=-Xmx8G
|
||||
org.gradle.parallel=true
|
||||
org.gradle.configuration-cache=true
|
||||
|
||||
# Project Details
|
||||
jvm_version=17
|
||||
|
||||
# project
|
||||
maven_version=1.5.1
|
||||
maven_group=com.viaversion
|
||||
project_group=com.viaversion
|
||||
project_name=ViaRewind-Legacy-Support
|
||||
project_version=1.5.5-SNAPSHOT
|
||||
project_description=Provides additional features for ViaRewind for Paper servers.
|
||||
|
||||
mcVersionRange=1.8-1.20.6
|
||||
publish_owner_id=florianreuth
|
||||
publish_owner_name=Florian Reuth
|
||||
publish_owner_mail=git@florianreuth.de
|
||||
|
||||
# Hangar Publishing
|
||||
minecraft_version_range=1.8-26.3
|
||||
@@ -0,0 +1,7 @@
|
||||
[libraries]
|
||||
foojay-resolver-convention-plugin = { module = "org.gradle.toolchains.foojay-resolver-convention:org.gradle.toolchains.foojay-resolver-convention.gradle.plugin", version = "1.0.0" }
|
||||
viaversion-api = { module = "com.viaversion:viaversion-api", version = "5.10.0" }
|
||||
spigot-api = { module = "org.spigotmc:spigot-api", version = "1.16.5-R0.1-SNAPSHOT" }
|
||||
|
||||
[plugins]
|
||||
hangar-publish = { id = "io.papermc.hangar-publish-plugin", version = "0.1.4" }
|
||||
Vendored
BIN
Binary file not shown.
+2
-1
@@ -1,6 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionSha256Sum=21bd5da2de49b642904077f38c0efdc7778e92b3ed0889392dca61b97e389607
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -15,10 +15,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
# gradlew start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
@@ -27,7 +29,7 @@
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
# ksh gradlew
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -84,7 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -112,7 +114,6 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -145,7 +146,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -153,7 +154,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -170,7 +171,6 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -202,16 +202,15 @@ fi
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+112
-92
@@ -1,92 +1,112 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem gradlew startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@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
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
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:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
@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 & 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%
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = "ViaRewind-Legacy-Support"
|
||||
@@ -0,0 +1,16 @@
|
||||
pluginManagement {
|
||||
includeBuild("build-logic")
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("base.settings")
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
maven("https://repo.viaversion.com")
|
||||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "viarewind-legacy-support"
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,15 +18,16 @@
|
||||
|
||||
package com.viaversion.viarewind.legacysupport;
|
||||
|
||||
import com.viaversion.viarewind.legacysupport.feature.BlockCollisionChanges;
|
||||
import com.viaversion.viarewind.legacysupport.versioninfo.VersionInformer;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viarewind.legacysupport.feature.AnvilCostFix;
|
||||
import com.viaversion.viarewind.legacysupport.feature.AreaEffectCloudEmulator;
|
||||
import com.viaversion.viarewind.legacysupport.feature.SlimeBounceEmulator;
|
||||
import com.viaversion.viarewind.legacysupport.feature.BlockCollisionChanges;
|
||||
import com.viaversion.viarewind.legacysupport.feature.BlockPlaceSoundEmulator;
|
||||
import com.viaversion.viarewind.legacysupport.feature.BrewingInteractionEmulator;
|
||||
import com.viaversion.viarewind.legacysupport.feature.ElytraVelocityEmulator;
|
||||
import com.viaversion.viarewind.legacysupport.feature.EnchantingGuiEmulator;
|
||||
import com.viaversion.viarewind.legacysupport.feature.BlockPlaceSoundEmulator;
|
||||
import com.viaversion.viarewind.legacysupport.feature.SlimeBounceEmulator;
|
||||
import com.viaversion.viarewind.legacysupport.versioninfo.VersionInformer;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -58,6 +59,13 @@ public class BukkitPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
final FileConfiguration config = getConfig();
|
||||
|
||||
if (serverProtocol.equals(ProtocolVersion.v1_8)) {
|
||||
if (config.getBoolean("anvil-cost-fix")) {
|
||||
Bukkit.getPluginManager().registerEvents(new AnvilCostFix(), BukkitPlugin.this);
|
||||
}
|
||||
}
|
||||
|
||||
if (serverProtocol.newerThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
if (config.getBoolean("enchanting-gui-fix")) {
|
||||
Bukkit.getPluginManager().registerEvents(new EnchantingGuiEmulator(), BukkitPlugin.this);
|
||||
@@ -66,6 +74,7 @@ public class BukkitPlugin extends JavaPlugin {
|
||||
Bukkit.getPluginManager().registerEvents(new SlimeBounceEmulator(), BukkitPlugin.this);
|
||||
}
|
||||
}
|
||||
|
||||
if (serverProtocol.newerThanOrEqualTo(ProtocolVersion.v1_9)) {
|
||||
if (config.getBoolean("sound-fix")) {
|
||||
Bukkit.getPluginManager().registerEvents(new BlockPlaceSoundEmulator(BukkitPlugin.this), BukkitPlugin.this);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viarewind.legacysupport.feature;
|
||||
|
||||
import com.viaversion.viarewind.legacysupport.BukkitPlugin;
|
||||
import com.viaversion.viarewind.legacysupport.util.NMSUtil;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.AnvilInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class AnvilCostFix implements Listener {
|
||||
@EventHandler
|
||||
public void onInventoryClickEvent(InventoryClickEvent event) {
|
||||
Inventory inventory = event.getInventory();
|
||||
|
||||
if (inventory instanceof AnvilInventory) {
|
||||
Bukkit.getScheduler().runTaskLater(BukkitPlugin.getInstance(), () -> {
|
||||
for (HumanEntity entity : inventory.getViewers()) {
|
||||
if (entity instanceof Player) {
|
||||
refreshAnvilInventoryPlayer((Player) entity);
|
||||
}
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshAnvilInventoryPlayer(Player player) {
|
||||
Object nmsPlayer = NMSUtil.getNMSPlayer(player);
|
||||
|
||||
try {
|
||||
Object activeContainer = nmsPlayer.getClass().getField("activeContainer").get(nmsPlayer);
|
||||
|
||||
if (activeContainer.getClass().getSimpleName().equals("ContainerAnvil")) {
|
||||
Object cost = activeContainer.getClass().getField("a").get(activeContainer);
|
||||
|
||||
nmsPlayer.getClass().getMethod("setContainerData", activeContainer.getClass().getSuperclass(), int.class, int.class).invoke(nmsPlayer, activeContainer, cost, cost);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
BukkitPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to refresh anvil inventory", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,9 +18,13 @@
|
||||
|
||||
package com.viaversion.viarewind.legacysupport.feature;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viarewind.legacysupport.BukkitPlugin;
|
||||
import com.viaversion.viarewind.legacysupport.util.NMSUtil;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
@@ -30,21 +34,20 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AreaEffectCloudEmulator implements Listener {
|
||||
private final ArrayList<AreaEffectCloud> effectClouds = new ArrayList<>();
|
||||
|
||||
public AreaEffectCloudEmulator(final BukkitPlugin plugin) {
|
||||
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||
final Set<Player> affectedPlayers = Bukkit.getOnlinePlayers().stream().filter(p -> Via.getAPI().getPlayerProtocolVersion(p).newerThanOrEqualTo(ProtocolVersion.v1_8)).collect(Collectors.toSet());
|
||||
final Set<Player> affectedPlayers = Bukkit.getOnlinePlayers().stream().filter(p -> Via.getAPI().getPlayerProtocolVersion(p).olderThanOrEqualTo(ProtocolVersion.v1_8)).collect(Collectors.toSet());
|
||||
effectClouds.removeIf(e -> !e.isValid());
|
||||
effectClouds.forEach(cloud -> {
|
||||
final Location location = cloud.getLocation();
|
||||
final float radius = cloud.getRadius();
|
||||
final Object data = NMSUtil.NEWER_THAN_V1_20_5
|
||||
? cloud.getColor()
|
||||
: null;
|
||||
|
||||
float area = (float) Math.PI * radius * radius;
|
||||
|
||||
@@ -64,10 +67,11 @@ public class AreaEffectCloudEmulator implements Listener {
|
||||
affectedPlayers.stream().filter(player -> player.getWorld() == location.getWorld()).forEach(player -> {
|
||||
|
||||
player.spawnParticle(
|
||||
cloud.getParticle(),
|
||||
location.getX() + f3, location.getY(), location.getZ() + f6,
|
||||
0,
|
||||
r / 255f, g / 255f, b / 255f
|
||||
cloud.getParticle(),
|
||||
location.getX() + f3, location.getY(), location.getZ() + f6,
|
||||
0,
|
||||
r / 255f, g / 255f, b / 255f,
|
||||
data
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
+269
-22
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,23 +18,29 @@
|
||||
|
||||
package com.viaversion.viarewind.legacysupport.feature;
|
||||
|
||||
import com.viaversion.viarewind.legacysupport.util.NMSUtil;
|
||||
import com.viaversion.viarewind.legacysupport.util.ReflectionUtil;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.viaversion.viarewind.legacysupport.util.ReflectionUtil.*;
|
||||
import static com.viaversion.viarewind.legacysupport.util.NMSUtil.*;
|
||||
import static com.viaversion.viarewind.legacysupport.util.NMSUtil.getNMSBlockClass;
|
||||
import static com.viaversion.viarewind.legacysupport.util.ReflectionUtil.getFieldAccessible;
|
||||
|
||||
public class BlockCollisionChanges {
|
||||
|
||||
public static void fixLilyPad(final Logger logger, final ProtocolVersion serverVersion) {
|
||||
try {
|
||||
final Field boundingBoxField = getFieldAccessible(getNMSBlockClass("BlockWaterLily"), serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_20_2) ? "a" : "b");
|
||||
final String BlockWaterLilyClassName = NMSUtil.NEWER_THAN_V26_1 ? "LilyPadBlock" : "BlockWaterLily";
|
||||
final String boundingBoxFieldName = NMSUtil.NEWER_THAN_V26_1 ? "SHAPE" : serverVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_3) ? "b" : "a";
|
||||
final Field boundingBoxField = getFieldAccessible(getNMSBlockClass(BlockWaterLilyClassName), boundingBoxFieldName);
|
||||
|
||||
setBoundingBox(boundingBoxField.get(null), 0.0625, 0.0, 0.0625, 0.9375, 0.015625, 0.9375);
|
||||
} catch (Exception ex) {
|
||||
@@ -44,9 +50,10 @@ public class BlockCollisionChanges {
|
||||
|
||||
public static void fixCarpet(final Logger logger, final ProtocolVersion serverVersion) {
|
||||
try {
|
||||
final Class<?> blockCarpetClass = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_16_4) ? getNMSBlockClass("BlockCarpet") : getNMSBlockClass("CarpetBlock");
|
||||
final String boundingBoxFieldName = NMSUtil.NEWER_THAN_V26_1 ? "SHAPE" : serverVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_3) ? "b" : "a";
|
||||
final String blockCarpetClassName = serverVersion.newerThanOrEqualTo(ProtocolVersion.v1_17) ? "CarpetBlock" : "BlockCarpet";
|
||||
final Field boundingBoxField = getFieldAccessible(getNMSBlockClass(blockCarpetClassName), boundingBoxFieldName);
|
||||
|
||||
final Field boundingBoxField = getFieldAccessible(blockCarpetClass, serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_20_2) ? "a" : "b");
|
||||
setBoundingBox(boundingBoxField.get(0), 0.0D, -0.0000001D, 0.0D, 1.0D, 0.0000001D, 1.0D);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Could not fix carpet bounding box.", ex);
|
||||
@@ -55,22 +62,62 @@ public class BlockCollisionChanges {
|
||||
|
||||
public static void fixLadder(final Logger logger, final ProtocolVersion serverVersion) {
|
||||
try {
|
||||
final boolean pre1_12_2 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_12_2);
|
||||
final boolean pre1_13_2 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_13_2);
|
||||
final boolean pre1_16_4 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_16_4);
|
||||
final boolean pre1_20_2 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_20_2);
|
||||
if (serverVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
||||
final Class<?> blockLadderClass = getNMSBlockClass(NMSUtil.NEWER_THAN_V26_1 ? "LadderBlock" : "BlockLadder");
|
||||
|
||||
final Class<?> blockLadderClass = getNMSBlockClass("BlockLadder");
|
||||
final Map<String, double[]> overrides = new HashMap<>();
|
||||
overrides.put("EAST", new double[]{0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D});
|
||||
overrides.put("WEST", new double[]{0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D});
|
||||
overrides.put("SOUTH", new double[]{0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D});
|
||||
overrides.put("NORTH", new double[]{0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D});
|
||||
|
||||
final Field boundingBoxEastField = getFieldAccessible(blockLadderClass, pre1_12_2 ? "b" : pre1_13_2 ? "c" : pre1_16_4 ? "c" : pre1_20_2 ? "d" : "e");
|
||||
final Field boundingBoxWestField = getFieldAccessible(blockLadderClass, pre1_12_2 ? "c" : pre1_13_2 ? "o" : pre1_16_4 ? "d" : pre1_20_2 ? "e" : "f");
|
||||
final Field boundingBoxSouthField = getFieldAccessible(blockLadderClass, pre1_12_2 ? "d" : pre1_13_2 ? "p" : pre1_16_4 ? "e" : pre1_20_2 ? "f" : "g");
|
||||
final Field boundingBoxNorthField = getFieldAccessible(blockLadderClass, pre1_12_2 ? "e" : pre1_13_2 ? "q" : pre1_16_4 ? "f" : pre1_20_2 ? "g" : "h");
|
||||
Map<Object, Object> shapesMap = null;
|
||||
for (Field field : blockLadderClass.getDeclaredFields()) {
|
||||
if (!Modifier.isStatic(field.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
if (!Map.class.isAssignableFrom(field.getType())) {
|
||||
continue;
|
||||
}
|
||||
field.setAccessible(true);
|
||||
final Object value = field.get(null);
|
||||
if (value instanceof Map<?, ?>) {
|
||||
@SuppressWarnings("unchecked") final Map<Object, Object> casted = (Map<Object, Object>) value;
|
||||
shapesMap = casted;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setBoundingBox(boundingBoxEastField.get(null), 0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D);
|
||||
setBoundingBox(boundingBoxWestField.get(null), 0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
setBoundingBox(boundingBoxSouthField.get(null), 0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D);
|
||||
setBoundingBox(boundingBoxNorthField.get(null), 0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D);
|
||||
boolean updated = false;
|
||||
if (shapesMap != null) {
|
||||
updated = updateShapesMap(shapesMap, overrides);
|
||||
}
|
||||
|
||||
if (!updated) {
|
||||
updated = updateShapeConstants(blockLadderClass, overrides);
|
||||
}
|
||||
|
||||
if (!updated) {
|
||||
throw new IllegalStateException("Could not adjust ladder shapes for modern versions");
|
||||
}
|
||||
} else {
|
||||
final boolean pre1_12_2 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_12_2);
|
||||
final boolean pre1_13_2 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_13_2);
|
||||
final boolean pre1_16_4 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_16_4);
|
||||
final boolean pre1_20_2 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_20_2);
|
||||
|
||||
final Class<?> blockLadderClass = getNMSBlockClass("BlockLadder");
|
||||
|
||||
final Field boundingBoxEastField = getFieldAccessible(blockLadderClass, pre1_12_2 ? "b" : pre1_13_2 ? "c" : pre1_16_4 ? "c" : pre1_20_2 ? "d" : "e");
|
||||
final Field boundingBoxWestField = getFieldAccessible(blockLadderClass, pre1_12_2 ? "c" : pre1_13_2 ? "o" : pre1_16_4 ? "d" : pre1_20_2 ? "e" : "f");
|
||||
final Field boundingBoxSouthField = getFieldAccessible(blockLadderClass, pre1_12_2 ? "d" : pre1_13_2 ? "p" : pre1_16_4 ? "e" : pre1_20_2 ? "f" : "g");
|
||||
final Field boundingBoxNorthField = getFieldAccessible(blockLadderClass, pre1_12_2 ? "e" : pre1_13_2 ? "q" : pre1_16_4 ? "f" : pre1_20_2 ? "g" : "h");
|
||||
|
||||
setBoundingBox(boundingBoxEastField.get(null), 0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D);
|
||||
setBoundingBox(boundingBoxWestField.get(null), 0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
setBoundingBox(boundingBoxSouthField.get(null), 0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D);
|
||||
setBoundingBox(boundingBoxNorthField.get(null), 0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Could not fix ladder bounding box.", ex);
|
||||
}
|
||||
@@ -144,7 +191,7 @@ public class BlockCollisionChanges {
|
||||
// Handle Paper voxel shape caching by clearing the cache
|
||||
final Class<?> voxelShape = voxelShapeArray.getClass().getSuperclass();
|
||||
|
||||
final Field shape = getFieldAccessible(voxelShape, "a");
|
||||
final Field shape = getFieldAccessible(voxelShape, NMSUtil.NEWER_THAN_V26_1 ? "shape" : "a");
|
||||
final Field cachedShapeData = getFieldAccessible(shape.getType(), "cachedShapeData");
|
||||
if (cachedShapeData == null) { // No Paper or too old version
|
||||
return;
|
||||
@@ -154,7 +201,207 @@ public class BlockCollisionChanges {
|
||||
final Field isEmpty = getFieldAccessible(voxelShape, "isEmpty");
|
||||
isEmpty.setBoolean(voxelShapeArray, true);
|
||||
|
||||
final Method initCache = voxelShape.getDeclaredMethod("initCache");
|
||||
final Method initCache = ReflectionUtil.findMethod(voxelShape, new String[]{"initCache", "moonrise$initCache"});
|
||||
if (initCache == null) {
|
||||
throw new IllegalStateException("Could not find initCache method in " + voxelShape.getName());
|
||||
}
|
||||
initCache.invoke(voxelShapeArray);
|
||||
}
|
||||
|
||||
private static boolean updateShapesMap(final Map<Object, Object> shapes, final Map<String, double[]> overrides) throws ReflectiveOperationException {
|
||||
if (shapes == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Class<?> directionClass = Class.forName("net.minecraft.core.Direction");
|
||||
final Class<?> shapesClass = Class.forName("net.minecraft.world.phys.shapes.Shapes");
|
||||
final Class<?> blockClass = Class.forName("net.minecraft.world.level.block.Block");
|
||||
|
||||
Method shapesBoxMethod = ReflectionUtil.findMethod(shapesClass, new String[]{"box", "a"}, double.class, double.class, double.class, double.class, double.class, double.class);
|
||||
if (shapesBoxMethod != null) {
|
||||
shapesBoxMethod.setAccessible(true);
|
||||
}
|
||||
|
||||
Method blockBoxMethod = ReflectionUtil.findMethod(blockClass, new String[]{"box", "a"}, double.class, double.class, double.class, double.class, double.class, double.class);
|
||||
if (blockBoxMethod != null) {
|
||||
blockBoxMethod.setAccessible(true);
|
||||
}
|
||||
|
||||
Method shapesCreateMethod = null;
|
||||
Constructor<?> aabbConstructor = null;
|
||||
if (shapesBoxMethod == null) {
|
||||
final Class<?> aabbClass = Class.forName("net.minecraft.world.phys.AABB");
|
||||
shapesCreateMethod = ReflectionUtil.findMethod(shapesClass, new String[]{"create", "a"}, aabbClass);
|
||||
if (shapesCreateMethod != null) {
|
||||
shapesCreateMethod.setAccessible(true);
|
||||
aabbConstructor = aabbClass.getDeclaredConstructor(double.class, double.class, double.class, double.class, double.class, double.class);
|
||||
aabbConstructor.setAccessible(true);
|
||||
}
|
||||
}
|
||||
|
||||
final Method directionValueOf = directionClass.getMethod("valueOf", String.class);
|
||||
directionValueOf.setAccessible(true);
|
||||
|
||||
boolean updated = false;
|
||||
try {
|
||||
for (Map.Entry<String, double[]> entry : overrides.entrySet()) {
|
||||
final Object direction = directionValueOf.invoke(null, entry.getKey());
|
||||
final Object voxelShape = createVoxelShape(shapesBoxMethod, blockBoxMethod, shapesCreateMethod, aabbConstructor, entry.getValue());
|
||||
shapes.put(direction, voxelShape);
|
||||
updated = true;
|
||||
}
|
||||
} catch (UnsupportedOperationException ex) {
|
||||
return false;
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
private static boolean updateShapeConstants(final Class<?> blockLadderClass, final Map<String, double[]> overrides) throws ReflectiveOperationException {
|
||||
final Class<?> voxelShapeInterface = Class.forName("net.minecraft.world.phys.shapes.VoxelShape");
|
||||
|
||||
boolean updated = false;
|
||||
for (Field field : blockLadderClass.getDeclaredFields()) {
|
||||
if (!Modifier.isStatic(field.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
field.setAccessible(true);
|
||||
final Object shapeObject = field.get(null);
|
||||
if (shapeObject == null) {
|
||||
continue;
|
||||
}
|
||||
if (!voxelShapeInterface.isAssignableFrom(shapeObject.getClass())
|
||||
&& !shapeObject.getClass().getSimpleName().contains("VoxelShape")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final double[] currentBounds = getBoundingBoxValues(shapeObject);
|
||||
if (currentBounds == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String orientation = detectOrientation(currentBounds);
|
||||
if (orientation == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final double[] override = overrides.get(orientation);
|
||||
if (override == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
setBoundingBox(shapeObject, override);
|
||||
updated = true;
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
private static double[] getBoundingBoxValues(final Object boundingBox) throws ReflectiveOperationException {
|
||||
switch (boundingBox.getClass().getSimpleName()) {
|
||||
case "AxisAlignedBB":
|
||||
return getAxisAlignedBBValues(boundingBox);
|
||||
case "VoxelShapeArray":
|
||||
case "ArrayVoxelShape":
|
||||
return getVoxelShapeArrayValues(boundingBox);
|
||||
case "AABBVoxelShape":
|
||||
return getAABBVoxelShapeValues(boundingBox);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static double[] getAABBVoxelShapeValues(final Object boundingBox) throws ReflectiveOperationException {
|
||||
for (Field field : boundingBox.getClass().getFields()) {
|
||||
if (field.getType().getSimpleName().equals("AxisAlignedBB")) {
|
||||
return getBoundingBoxValues(field.get(boundingBox));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static double[] getAxisAlignedBBValues(final Object boundingBox) throws ReflectiveOperationException {
|
||||
final Field[] doubleFields = Arrays.stream(boundingBox.getClass().getDeclaredFields()).filter(f -> f.getType() == double.class && !Modifier.isStatic(f.getModifiers())).toArray(Field[]::new);
|
||||
|
||||
if (doubleFields.length < 6) {
|
||||
throw new IllegalStateException("Invalid field count for " + boundingBox.getClass().getName() + ": " + doubleFields.length);
|
||||
}
|
||||
|
||||
final double[] values = new double[6];
|
||||
for (int i = 0; i < 6; i++) {
|
||||
final Field currentField = doubleFields[i];
|
||||
currentField.setAccessible(true);
|
||||
values[i] = currentField.getDouble(boundingBox);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
private static double[] getVoxelShapeArrayValues(final Object voxelShapeArray) throws ReflectiveOperationException {
|
||||
final Field[] doubleListFields = Arrays.stream(voxelShapeArray.getClass().getDeclaredFields()).filter(f -> f.getType().getSimpleName().equals("DoubleList")).toArray(Field[]::new);
|
||||
|
||||
if (doubleListFields.length < 3) {
|
||||
throw new IllegalStateException("Invalid field count for " + voxelShapeArray.getClass().getName() + ": " + doubleListFields.length);
|
||||
}
|
||||
|
||||
final double[] values = new double[6];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
final Field field = doubleListFields[i];
|
||||
field.setAccessible(true);
|
||||
final Object doubleList = field.get(voxelShapeArray);
|
||||
if (doubleList == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Method getDouble = ReflectionUtil.findMethod(doubleList.getClass(), new String[]{"getDouble", "get"}, int.class);
|
||||
if (getDouble == null) {
|
||||
return null;
|
||||
}
|
||||
getDouble.setAccessible(true);
|
||||
|
||||
values[i] = ((Number) getDouble.invoke(doubleList, 0)).doubleValue();
|
||||
values[i + 3] = ((Number) getDouble.invoke(doubleList, 1)).doubleValue();
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
private static String detectOrientation(final double[] bounds) {
|
||||
final double epsilon = 1.0E-3;
|
||||
final double minX = bounds[0];
|
||||
final double minZ = bounds[2];
|
||||
final double maxX = bounds[3];
|
||||
final double maxZ = bounds[5];
|
||||
|
||||
if (minX <= epsilon && maxX <= 0.5D) {
|
||||
return "EAST";
|
||||
}
|
||||
if (maxX >= 1.0D - epsilon && minX >= 0.5D) {
|
||||
return "WEST";
|
||||
}
|
||||
if (minZ <= epsilon && maxZ <= 0.5D) {
|
||||
return "SOUTH";
|
||||
}
|
||||
if (maxZ >= 1.0D - epsilon && minZ >= 0.5D) {
|
||||
return "NORTH";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Object createVoxelShape(final Method shapesBoxMethod, final Method blockBoxMethod,
|
||||
final Method shapesCreateMethod, final Constructor<?> aabbConstructor,
|
||||
final double[] values) throws ReflectiveOperationException {
|
||||
if (shapesBoxMethod != null) {
|
||||
return shapesBoxMethod.invoke(null, values[0], values[1], values[2], values[3], values[4], values[5]);
|
||||
}
|
||||
if (shapesCreateMethod != null && aabbConstructor != null) {
|
||||
final Object aabb = aabbConstructor.newInstance(values[0], values[1], values[2], values[3], values[4], values[5]);
|
||||
return shapesCreateMethod.invoke(null, aabb);
|
||||
}
|
||||
if (blockBoxMethod != null) {
|
||||
final double scale = 16.0D;
|
||||
return blockBoxMethod.invoke(null,
|
||||
values[0] * scale, values[1] * scale, values[2] * scale,
|
||||
values[3] * scale, values[4] * scale, values[5] * scale);
|
||||
}
|
||||
throw new IllegalStateException("Unable to create voxel shape for ladder bounding box.");
|
||||
}
|
||||
}
|
||||
+56
-55
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,9 +18,11 @@
|
||||
|
||||
package com.viaversion.viarewind.legacysupport.feature;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viarewind.legacysupport.BukkitPlugin;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
@@ -36,11 +38,11 @@ import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerExpChangeEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static com.viaversion.viarewind.legacysupport.util.ReflectionUtil.*;
|
||||
import static com.viaversion.viarewind.legacysupport.util.NMSUtil.*;
|
||||
import static com.viaversion.viarewind.legacysupport.util.NMSUtil.getBlockPositionClass;
|
||||
import static com.viaversion.viarewind.legacysupport.util.NMSUtil.getGamePacketClass;
|
||||
import static com.viaversion.viarewind.legacysupport.util.NMSUtil.getSoundCategoryClass;
|
||||
import static com.viaversion.viarewind.legacysupport.util.NMSUtil.sendPacket;
|
||||
import static com.viaversion.viarewind.legacysupport.util.ReflectionUtil.getMethod;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class BlockPlaceSoundEmulator implements Listener {
|
||||
@@ -81,52 +83,20 @@ public class BlockPlaceSoundEmulator implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
final Player player = e.getPlayer();
|
||||
if (Via.getAPI().getPlayerProtocolVersion(player).newerThanOrEqualTo(ProtocolVersion.v1_9)) return;
|
||||
|
||||
if (Via.getAPI().getServerVersion().lowestSupportedProtocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
player.playSound(e.getBlockPlaced().getLocation(), e.getBlock().getBlockData().getSoundGroup().getPlaceSound(), 1.0f, 0.8f);
|
||||
} else {
|
||||
try {
|
||||
playBlockPlaceSoundNMS(player, e.getBlock());
|
||||
} catch (Exception exception) {
|
||||
Via.getPlatform().getLogger().log(Level.SEVERE, "Could not play block place sound.", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onItemPickUp(Player player) {
|
||||
final float volume = 0.2f;
|
||||
final float pitch = (float) ((Math.random() - Math.random()) * 0.7f + 1.0f) * 2.0f;
|
||||
|
||||
playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, volume, pitch);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
private void onExperienceOrbPickup(PlayerExpChangeEvent e) {
|
||||
final float volume = 0.1f;
|
||||
final float pitch = (float) (0.5f * ((Math.random() - Math.random()) * 0.7f + 1.8f));
|
||||
|
||||
playSound(e.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, volume, pitch);
|
||||
}
|
||||
|
||||
private static void playSound(final Location loc, final Sound sound, final float volume, final float pitch) {
|
||||
Bukkit.getOnlinePlayers().stream()
|
||||
.filter(p -> p.getWorld() == loc.getWorld())
|
||||
.filter(p -> p.getLocation().distanceSquared(loc) < (double) 16 * (double) 16)
|
||||
.filter(p -> Via.getAPI().getPlayerVersion(p) <= 47)
|
||||
.forEach(p -> {
|
||||
if (isSoundCategory) {
|
||||
p.playSound(loc, sound, SoundCategory.valueOf("PLAYERS"), volume, pitch);
|
||||
} else {
|
||||
p.playSound(loc, sound, volume, pitch);
|
||||
}
|
||||
});
|
||||
.filter(p -> p.getWorld() == loc.getWorld())
|
||||
.filter(p -> p.getLocation().distanceSquared(loc) < (double) 16 * (double) 16)
|
||||
.filter(p -> Via.getAPI().getPlayerVersion(p) <= 47)
|
||||
.forEach(p -> {
|
||||
if (isSoundCategory) {
|
||||
p.playSound(loc, sound, SoundCategory.valueOf("PLAYERS"), volume, pitch);
|
||||
} else {
|
||||
p.playSound(loc, sound, volume, pitch);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 1.8.8 -> 1.16.5
|
||||
private static void playBlockPlaceSoundNMS(Player player, Block block) throws Exception {
|
||||
World world = block.getWorld();
|
||||
@@ -198,13 +168,13 @@ public class BlockPlaceSoundEmulator implements Listener {
|
||||
private static void playSound(Player player, Object soundEffect, Object soundCategory, double x, double y, double z, float volume, float pitch) {
|
||||
try {
|
||||
Object packet = getGamePacketClass("PacketPlayOutNamedSoundEffect").getConstructor(
|
||||
soundEffect.getClass(), soundCategory.getClass(),
|
||||
double.class, double.class, double.class,
|
||||
float.class, float.class
|
||||
soundEffect.getClass(), soundCategory.getClass(),
|
||||
double.class, double.class, double.class,
|
||||
float.class, float.class
|
||||
).newInstance(
|
||||
soundEffect, soundCategory,
|
||||
x, y, z,
|
||||
volume, pitch
|
||||
soundEffect, soundCategory,
|
||||
x, y, z,
|
||||
volume, pitch
|
||||
);
|
||||
|
||||
// Volume = 1
|
||||
@@ -214,4 +184,35 @@ public class BlockPlaceSoundEmulator implements Listener {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
final Player player = e.getPlayer();
|
||||
if (Via.getAPI().getPlayerProtocolVersion(player).newerThanOrEqualTo(ProtocolVersion.v1_9)) return;
|
||||
|
||||
if (Via.getAPI().getServerVersion().lowestSupportedProtocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
player.playSound(e.getBlockPlaced().getLocation(), e.getBlock().getBlockData().getSoundGroup().getPlaceSound(), 1.0f, 0.8f);
|
||||
} else {
|
||||
try {
|
||||
playBlockPlaceSoundNMS(player, e.getBlock());
|
||||
} catch (Exception exception) {
|
||||
Via.getPlatform().getLogger().log(Level.SEVERE, "Could not play block place sound.", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onItemPickUp(Player player) {
|
||||
final float volume = 0.2f;
|
||||
final float pitch = (float) ((Math.random() - Math.random()) * 0.7f + 1.0f) * 2.0f;
|
||||
|
||||
playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, volume, pitch);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
private void onExperienceOrbPickup(PlayerExpChangeEvent e) {
|
||||
final float volume = 0.1f;
|
||||
final float pitch = (float) (0.5f * ((Math.random() - Math.random()) * 0.7f + 1.8f));
|
||||
|
||||
playSound(e.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, volume, pitch);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+4
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,6 +23,8 @@ import com.viaversion.viarewind.legacysupport.util.NMSUtil;
|
||||
import com.viaversion.viarewind.legacysupport.util.ReflectionUtil;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -30,9 +32,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ElytraVelocityEmulator implements Listener {
|
||||
|
||||
@@ -42,7 +41,7 @@ public class ElytraVelocityEmulator implements Listener {
|
||||
if (nmsPlayer == null) return false;
|
||||
|
||||
try {
|
||||
final Method getFlag = ReflectionUtil.getMethod(nmsPlayer.getClass(), "getFlag", int.class);
|
||||
final Method getFlag = ReflectionUtil.findMethod(nmsPlayer.getClass(), new String[]{"getSharedFlag", "getFlag"}, int.class);
|
||||
return (boolean) getFlag.invoke(nmsPlayer, 7);
|
||||
} catch (Exception e) {
|
||||
BukkitPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to get player flag", e);
|
||||
|
||||
+2
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,6 +20,7 @@ package com.viaversion.viarewind.legacysupport.feature;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -31,8 +32,6 @@ import org.bukkit.inventory.EnchantingInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class EnchantingGuiEmulator implements Listener {
|
||||
|
||||
|
||||
+17
-16
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -31,26 +31,27 @@ import org.bukkit.util.Vector;
|
||||
@SuppressWarnings({"unchecked", "DataFlowIssue"})
|
||||
public class SlimeBounceEmulator implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
if (e.getTo().getY() >= e.getFrom().getY()) return; // Only check upwards motion
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
if (e.getTo().getY() >= e.getFrom().getY()) return; // Only check upwards motion
|
||||
|
||||
final Player player = e.getPlayer();
|
||||
if (Via.getAPI().getPlayerProtocolVersion(player).newerThanOrEqualTo(ProtocolVersion.v1_8)) return; // Only apply for 1.7 and below players
|
||||
final Player player = e.getPlayer();
|
||||
if (Via.getAPI().getPlayerProtocolVersion(player).newerThanOrEqualTo(ProtocolVersion.v1_8))
|
||||
return; // Only apply for 1.7 and below players
|
||||
|
||||
if (Math.floor(e.getTo().getY()) + 0.01 < e.getTo().getY()) return;
|
||||
if (player.isSneaking()) return;
|
||||
if (Math.floor(e.getTo().getY()) + 0.01 < e.getTo().getY()) return;
|
||||
if (player.isSneaking()) return;
|
||||
|
||||
final Block block = e.getTo().clone().add(0, -0.1, 0).getBlock();
|
||||
if (block.getType() != Material.SLIME_BLOCK) return;
|
||||
final Block block = e.getTo().clone().add(0, -0.1, 0).getBlock();
|
||||
if (block.getType() != Material.SLIME_BLOCK) return;
|
||||
|
||||
final Vector newVelocity = player.getVelocity();
|
||||
final Vector newVelocity = player.getVelocity();
|
||||
|
||||
final double deltaY = (e.getTo().getY() - e.getFrom().getY());
|
||||
if (deltaY >- 0.11) return; // Only bounce if the player is falling down
|
||||
final double deltaY = (e.getTo().getY() - e.getFrom().getY());
|
||||
if (deltaY > -0.11) return; // Only bounce if the player is falling down
|
||||
|
||||
newVelocity.setY(-deltaY * 1.05);
|
||||
newVelocity.setY(-deltaY * 1.05);
|
||||
|
||||
player.setVelocity(newVelocity);
|
||||
}
|
||||
player.setVelocity(newVelocity);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,18 +19,20 @@ package com.viaversion.viarewind.legacysupport.util;
|
||||
|
||||
import com.viaversion.viarewind.legacysupport.BukkitPlugin;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static com.viaversion.viarewind.legacysupport.util.ReflectionUtil.failSafeGetClass;
|
||||
|
||||
public class NMSUtil {
|
||||
|
||||
public static final boolean NEWER_THAN_V26_1 = BukkitPlugin.getInstance().getServerProtocol().newerThanOrEqualTo(ProtocolVersion.v26_1);
|
||||
public static final boolean NEWER_THAN_V1_20_5 = BukkitPlugin.getInstance().getServerProtocol().newerThanOrEqualTo(ProtocolVersion.v1_20_5);
|
||||
public static final boolean NEWER_THAN_V1_17 = BukkitPlugin.getInstance().getServerProtocol().newerThanOrEqualTo(ProtocolVersion.v1_17);
|
||||
public static String nmsVersionPackage;
|
||||
private static Field playerConnectionField;
|
||||
|
||||
@@ -41,7 +43,9 @@ public class NMSUtil {
|
||||
}
|
||||
|
||||
public static Class<?> getBlockPositionClass() {
|
||||
if (BukkitPlugin.getInstance().getServerProtocol().newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
if (NEWER_THAN_V26_1) {
|
||||
return failSafeGetClass("net.minecraft.core.BlockPos");
|
||||
} else if (NEWER_THAN_V1_17) {
|
||||
return failSafeGetClass("net.minecraft.core.BlockPosition");
|
||||
} else {
|
||||
return getLegacyNMSClass("BlockPosition");
|
||||
@@ -49,7 +53,7 @@ public class NMSUtil {
|
||||
}
|
||||
|
||||
public static Class<?> getNMSBlockClass(final String name) {
|
||||
if (BukkitPlugin.getInstance().getServerProtocol().newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
if (NEWER_THAN_V1_17) {
|
||||
return failSafeGetClass("net.minecraft.world.level.block." + name);
|
||||
} else {
|
||||
return getLegacyNMSClass(name);
|
||||
@@ -57,7 +61,9 @@ public class NMSUtil {
|
||||
}
|
||||
|
||||
public static Class getSoundCategoryClass() { // Bypass generics
|
||||
if (BukkitPlugin.getInstance().getServerProtocol().newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
if (NEWER_THAN_V26_1) {
|
||||
return failSafeGetClass("net.minecraft.sounds.SoundSource");
|
||||
} else if (NEWER_THAN_V1_17) {
|
||||
return failSafeGetClass("net.minecraft.sounds.SoundCategory");
|
||||
} else {
|
||||
return getLegacyNMSClass("SoundCategory");
|
||||
@@ -65,7 +71,7 @@ public class NMSUtil {
|
||||
}
|
||||
|
||||
public static Class<?> getPacketClass() {
|
||||
if (BukkitPlugin.getInstance().getServerProtocol().newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
if (NEWER_THAN_V1_17) {
|
||||
return failSafeGetClass("net.minecraft.network.protocol.Packet");
|
||||
} else {
|
||||
return getLegacyNMSClass("Packet");
|
||||
@@ -73,7 +79,7 @@ public class NMSUtil {
|
||||
}
|
||||
|
||||
public static Class<?> getGamePacketClass(final String packet) {
|
||||
if (BukkitPlugin.getInstance().getServerProtocol().newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
if (NEWER_THAN_V1_17) {
|
||||
return failSafeGetClass("net.minecraft.network.protocol.game." + packet);
|
||||
} else {
|
||||
return getLegacyNMSClass(packet);
|
||||
@@ -81,7 +87,9 @@ public class NMSUtil {
|
||||
}
|
||||
|
||||
public static Class<?> getPlayerConnectionClass() {
|
||||
if (BukkitPlugin.getInstance().getServerProtocol().newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
if (NEWER_THAN_V26_1) {
|
||||
return failSafeGetClass("net.minecraft.server.network.ServerGamePacketListenerImpl");
|
||||
} else if (NEWER_THAN_V1_17) {
|
||||
return failSafeGetClass("net.minecraft.server.network.PlayerConnection");
|
||||
} else {
|
||||
return getLegacyNMSClass("PlayerConnection");
|
||||
@@ -128,7 +136,7 @@ public class NMSUtil {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Method sendPacket = ReflectionUtil.findMethod(playerConnection.getClass(), new String[] {"sendPacket", "a"}, getPacketClass());
|
||||
final Method sendPacket = ReflectionUtil.findMethod(playerConnection.getClass(), new String[]{"sendPacket", "a"}, getPacketClass());
|
||||
sendPacket.invoke(playerConnection, packet);
|
||||
} catch (IllegalAccessException | InvocationTargetException | NullPointerException e) {
|
||||
BukkitPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to send packet to player", e);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.viaversion.viarewind.legacysupport.util;
|
||||
|
||||
import com.viaversion.viarewind.legacysupport.BukkitPlugin;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -80,7 +79,8 @@ public class ReflectionUtil {
|
||||
Field field = null;
|
||||
try {
|
||||
field = clazz.getDeclaredField(fieldName);
|
||||
} catch (NoSuchFieldException ignored) {} // Cache non-existing field too
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
} // Cache non-existing field too
|
||||
fieldCache.put(key, field);
|
||||
return field;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of ViaRewind-Legacy-Support - https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
* Copyright (C) 2018-2024 ViaVersion and contributors
|
||||
* Copyright (C) 2018-2026 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package com.viaversion.viarewind.legacysupport.versioninfo;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viarewind.legacysupport.BukkitPlugin;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -35,7 +35,7 @@ public class VersionInformer implements Listener {
|
||||
|
||||
public VersionInformer(final BukkitPlugin plugin, final FileConfiguration config) {
|
||||
final String message = ChatColor.translateAlternateColorCodes('&', config.getString("versioninfo.message")).
|
||||
replace("%version%", Bukkit.getVersion().split(" ")[2].replace(")", ""));
|
||||
replace("%version%", Bukkit.getVersion().split(" ")[2].replace(")", ""));
|
||||
|
||||
this.versionMessage = message.split(System.lineSeparator());
|
||||
maxVersion = config.getInt("versioninfo.max-version");
|
||||
|
||||
@@ -6,6 +6,9 @@ brewing-stand-gui-fix: true
|
||||
# Automatically put lapis lazuli in enchanting tables for clients lower than 1.8
|
||||
enchanting-gui-fix: true
|
||||
#
|
||||
# Fixes anvil cost on 1.8 servers for clients lower than 1.8
|
||||
anvil-cost-fix: true
|
||||
#
|
||||
# Fix the lily pad bounding box to prevent clients lower than 1.9 from glitching
|
||||
lily-pad-fix: true
|
||||
#
|
||||
@@ -33,4 +36,4 @@ versioninfo:
|
||||
active: false
|
||||
max-version: 47
|
||||
interval: JOIN
|
||||
message: '&7[&6Info&7] This server is running Minecraft %version%. The best gameplay experience is only guaranteed if you are using this version.'
|
||||
message: '&7[&6Info&7] This server is running Minecraft %version%. The best gameplay experience is only guaranteed if you are using this version.'
|
||||
@@ -1,9 +1,10 @@
|
||||
name: ViaRewind-Legacy-Support
|
||||
version: ${version}
|
||||
description: ${description}
|
||||
main: com.viaversion.viarewind.legacysupport.BukkitPlugin
|
||||
api-version: 1.13
|
||||
|
||||
authors: [FlorianMichael/EnZaXD, Gerrygames]
|
||||
authors: [EnZaXD, Gerrygames]
|
||||
website: https://github.com/ViaVersion/ViaRewind-Legacy-Support
|
||||
|
||||
depend: [ViaRewind]
|
||||
Reference in new issue
Block a user