mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
Compare commits
68 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 539248f6b7 | |||
| eeaa87ba98 | |||
| 8e7153a746 | |||
| db9188607b | |||
| 1382c7a0fd | |||
| f32609bc68 | |||
| 73134c81c2 | |||
| 55c0be20b4 | |||
| 142376573c | |||
| 4e1ed9f1ea | |||
| 5ad3f1a7a2 | |||
| 685e046063 | |||
| 82b41fb1c1 | |||
| f4202e2521 | |||
| b2567f9176 | |||
| c117357202 | |||
| d6af0e8b8f | |||
| 845bb4d94a | |||
| c2b793e1b9 | |||
| d9624c17ba | |||
| 6fcc5bdf64 | |||
| 17ee9902b5 | |||
| 41d56ec949 | |||
| 9fc0203456 | |||
| 8830b4c4ed | |||
| 7b232528f1 | |||
| da10f0df5f | |||
| 37cd603575 | |||
| a49044b522 | |||
| 5bd78b4444 | |||
| c38e8025cd | |||
| 3dd706b4a8 | |||
| 015ca99475 | |||
| 52a58acd28 | |||
| ae28c64647 | |||
| fe63f489c9 | |||
| 862f9914fa | |||
| 497a3e84bc | |||
| d469171e4d | |||
| b9ff4bdc40 | |||
| 16e4f0a923 | |||
| 403c990083 | |||
| e61baba175 | |||
| cf768d67bd | |||
| 4fc037ebce | |||
| a202df9f0a | |||
| c062684a3c | |||
| 99306b6fee | |||
| b2561f55ae | |||
| 341dd10e3f | |||
| a9af606ae9 | |||
| 23c7b0c753 | |||
| 8ea1db382f | |||
| bc9ac1cc13 | |||
| 6178282386 | |||
| d1d01f90b8 | |||
| 799008f652 | |||
| a78f83f6f4 | |||
| 25f676f7f3 | |||
| 554fba008e | |||
| 5f0a601e5b | |||
| a79e341ea8 | |||
| 4c3b3b09ad | |||
| f6f68d1971 | |||
| 460114ac01 | |||
| d67d998dc1 | |||
| f1c3cf46e1 | |||
| 45dd92e0f4 |
135 changed files with 2051 additions and 1243 deletions
82
.github/workflows/gradle.yml
vendored
82
.github/workflows/gradle.yml
vendored
|
|
@ -8,12 +8,9 @@
|
||||||
name: Java CI with Gradle
|
name: Java CI with Gradle
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches: [ "v1.x.x", "v2.x.x" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "v1.x.x", "v2.x.x" ]
|
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
branches: [ "v1.x.x" ]
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
|
||||||
|
|
@ -26,46 +23,37 @@ jobs:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
MODRINTH_VERSIONS: '["1.18.x", "1.19.x", "1.20.x", "1.21.x", "26.1.x", "26.2.x"]'
|
MODRINTH_VERSIONS: '["1.18.x", "1.19.x", "1.20.x"]'
|
||||||
MODRINTH_PLATFORMS: '["spigot", "paper", "purpur", "folia"]'
|
MODRINTH_PLATFORMS: '["spigot", "paper", "purpur", "folia"]'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- name: Set up JDKs
|
- name: Set up JDKs
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
java-version: |
|
java-version: |
|
||||||
21
|
21
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
cache: gradle
|
|
||||||
|
|
||||||
- name: Cache Gradle root and wrapper
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches
|
|
||||||
~/.gradle/wrapper
|
|
||||||
key: gradle-root-${{ runner.os }}-${{ hashFiles('build.gradle*') }}
|
|
||||||
restore-keys: gradle-root-${{ runner.os }}-
|
|
||||||
|
|
||||||
# Setup paperweight cache
|
|
||||||
- name: Cache paperweight
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
./nms/*/.gradle/caches/paperweight
|
|
||||||
key: paperweight-submodules-${{ runner.os }}-${{ hashFiles('nms/*/build.gradle*') }}
|
|
||||||
restore-keys: |
|
|
||||||
paperweight-submodules-${{ runner.os }}-
|
|
||||||
|
|
||||||
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
|
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
|
||||||
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
|
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@v5
|
uses: gradle/actions/setup-gradle@v6
|
||||||
|
|
||||||
- name: Make gradlew executable
|
- name: Make gradlew executable
|
||||||
run: chmod +x ./gradlew
|
run: chmod +x ./gradlew
|
||||||
|
|
||||||
|
# Setup paperweight cache
|
||||||
|
- name: Cache paperweight
|
||||||
|
uses: actions/cache@v6
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
./nms/*/.gradle/caches/paperweight
|
||||||
|
./.gradle/caches/paperweight
|
||||||
|
key: paperweight-submodules-${{ runner.os }}-${{ hashFiles('nms/*/build.gradle*') }}
|
||||||
|
restore-keys: |
|
||||||
|
paperweight-submodules-${{ runner.os }}-
|
||||||
|
|
||||||
- name: Get small commit hash
|
- name: Get small commit hash
|
||||||
if: ${{ github.event_name != 'release' && success() }}
|
if: ${{ github.event_name != 'release' && success() }}
|
||||||
run: echo "SMALL_COMMIT_HASH=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
|
run: echo "SMALL_COMMIT_HASH=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
|
||||||
|
|
@ -75,7 +63,7 @@ jobs:
|
||||||
|
|
||||||
# only submit dependency on push
|
# only submit dependency on push
|
||||||
- name: Generate and submit dependency graph
|
- name: Generate and submit dependency graph
|
||||||
uses: gradle/actions/dependency-submission@v4
|
uses: gradle/actions/dependency-submission@v6
|
||||||
if: ${{ github.event_name == 'push' && success() }}
|
if: ${{ github.event_name == 'push' && success() }}
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
|
|
@ -91,16 +79,16 @@ jobs:
|
||||||
|
|
||||||
# upload the named jars as artifact
|
# upload the named jars as artifact
|
||||||
- name: Upload online JAR artifact
|
- name: Upload online JAR artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: CustomAnvil.jar
|
|
||||||
path: build/libs/${{ env.ONLINE_JAR_NAME }}
|
path: build/libs/${{ env.ONLINE_JAR_NAME }}
|
||||||
|
archive: false
|
||||||
|
|
||||||
- name: Upload offline JAR file
|
- name: Upload offline JAR file
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: CustomAnvil-offline.jar
|
|
||||||
path: build/libs/${{ env.OFFLINE_JAR_NAME }}
|
path: build/libs/${{ env.OFFLINE_JAR_NAME }}
|
||||||
|
archive: false
|
||||||
|
|
||||||
- name: Summarize tests results
|
- name: Summarize tests results
|
||||||
uses: jeantessier/test-summary-action@v1
|
uses: jeantessier/test-summary-action@v1
|
||||||
|
|
@ -109,33 +97,12 @@ jobs:
|
||||||
# upload the jar to release
|
# upload the jar to release
|
||||||
- name: Upload jar to release
|
- name: Upload jar to release
|
||||||
if: ${{ github.event_name == 'release' && success() }}
|
if: ${{ github.event_name == 'release' && success() }}
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v3
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
build/libs/${{ env.ONLINE_JAR_NAME }}
|
build/libs/${{ env.ONLINE_JAR_NAME }}
|
||||||
build/libs/${{ env.OFFLINE_JAR_NAME }}
|
build/libs/${{ env.OFFLINE_JAR_NAME }}
|
||||||
|
|
||||||
- name: Hangar release
|
|
||||||
if: ${{ (github.event_name != 'release' || github.event_name != 'push') && github.repository_owner == 'alexcrea' && success() }}
|
|
||||||
env:
|
|
||||||
HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}
|
|
||||||
RELEASE_CHANGELOG: ${{ github.event.release.body }}
|
|
||||||
run: ./gradlew publishAllPublicationsToHangar --stacktrace
|
|
||||||
|
|
||||||
- name: Modrinth publish alpha
|
|
||||||
if: ${{ github.event_name == 'push' && github.repository_owner == 'alexcrea' && success() }}
|
|
||||||
uses: cloudnode-pro/modrinth-publish@v2
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.MODRINTH_TOKEN }}
|
|
||||||
project: S75Ueiq9
|
|
||||||
name: dev-${{ env.SMALL_COMMIT_HASH }}
|
|
||||||
version: dev-${{ env.SMALL_COMMIT_HASH }}
|
|
||||||
loaders: ${{ env.MODRINTH_PLATFORMS }}
|
|
||||||
game-versions: ${{ env.MODRINTH_VERSIONS }}
|
|
||||||
channel: alpha
|
|
||||||
files: build/libs/${{ env.ONLINE_JAR_NAME }}
|
|
||||||
changelog: ${{ github.event.head_commit.message }}
|
|
||||||
|
|
||||||
- name: Modrinth publish release
|
- name: Modrinth publish release
|
||||||
if: ${{ github.event_name == 'release' && github.repository_owner == 'alexcrea' && success() }}
|
if: ${{ github.event_name == 'release' && github.repository_owner == 'alexcrea' && success() }}
|
||||||
uses: cloudnode-pro/modrinth-publish@v2
|
uses: cloudnode-pro/modrinth-publish@v2
|
||||||
|
|
@ -156,8 +123,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
webhook-url: ${{ secrets.RELEASE_WEBHOOK_URL }}
|
webhook-url: ${{ secrets.RELEASE_WEBHOOK_URL }}
|
||||||
content: |
|
content: |
|
||||||
${{ github.event.release.prerelease == false && '<@&1338546156325568642>' || '<@&1352296092989001768>' }}
|
<@&1525259349423947867>
|
||||||
# New ${{ github.event.release.prerelease && 'beta ' || '' }}version of custom anvil ! <:CustomAnvil:1262550667986342001>([Modrinth](https://modrinth.com/plugin/customanvil), [Hangar](https://hangar.papermc.io/alexcrea/CustomAnvil) and [GitHub](${{ github.event.release.html_url }}) links)
|
# New bugfix for CustomAnvil v1 ! <:CustomAnvil:1262550667986342001> [Modrinth](https://modrinth.com/plugin/customanvil) and [GitHub](${{ github.event.release.html_url }}) links
|
||||||
-# note: automated release. spigot is not uploaded yet.
|
|
||||||
|
|
||||||
${{ github.event.release.body }}
|
${{ github.event.release.body }}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ These plugins have compatibility handled by custom anvil. seek help on custom an
|
||||||
Also use ExcellentEnchant max enchant limit
|
Also use ExcellentEnchant max enchant limit
|
||||||
|
|
||||||
- [EcoEnchant](https://www.spigotmc.org/resources/ecoenchants-%E2%AD%95-250-enchantments-%E2%9C%85-create-custom-enchants-%E2%9C%A8-essentials-cmi-support.79573/) by Auxilor:
|
- [EcoEnchant](https://www.spigotmc.org/resources/ecoenchants-%E2%AD%95-250-enchantments-%E2%9C%85-create-custom-enchants-%E2%9C%A8-essentials-cmi-support.79573/) by Auxilor:
|
||||||
Need to use /anvilconfigreload or a server restart to add newly added enchantment.
|
Need to use /ca reload or a server restart to add newly added enchantment.
|
||||||
Use EcoEnchant restriction system but new restriction can be added in custom anvil
|
Use EcoEnchant restriction system but new restriction can be added in custom anvil
|
||||||
|
|
||||||
- [Enchantment²](https://www.spigotmc.org/resources/enchants-squared-the-enchantsplus-rewrite-custom-enchantments-that-act-like-vanilla-ones.86747/) by Athlaeos:
|
- [Enchantment²](https://www.spigotmc.org/resources/enchants-squared-the-enchantsplus-rewrite-custom-enchantments-that-act-like-vanilla-ones.86747/) by Athlaeos:
|
||||||
|
|
@ -40,6 +40,8 @@ Custom Items support is considered unstable. If you find issue please report it
|
||||||
- [Disenchantment](https://www.spigotmc.org/resources/disenchantment-1-21-1-1-20-6-new-book-splitting-mechanics.110741/) by H7KZ
|
- [Disenchantment](https://www.spigotmc.org/resources/disenchantment-1-21-1-1-20-6-new-book-splitting-mechanics.110741/) by H7KZ
|
||||||
Partially use Custom Anvil maximum XP settings (>= 6.1.5)
|
Partially use Custom Anvil maximum XP settings (>= 6.1.5)
|
||||||
|
|
||||||
|
- [EnchantedBook](https://modrinth.com/plugin/enchantedbook) by Minacle
|
||||||
|
|
||||||
- [HavenBags](https://www.spigotmc.org/resources/havenbags-shulker-like-player-bound-bags-1-17-1-21-4.110420/) by hyperdefined
|
- [HavenBags](https://www.spigotmc.org/resources/havenbags-shulker-like-player-bound-bags-1-17-1-21-4.110420/) by hyperdefined
|
||||||
For bag upgrade and skin via anvil. (version >= 1.31.0)
|
For bag upgrade and skin via anvil. (version >= 1.31.0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,8 @@ ca.bypass.level: Allow player to bypass every level limit (no custom limit)
|
||||||
|
|
||||||
# Command permissions
|
# Command permissions
|
||||||
ca.command.reload: Allow administrator to reload the plugin's configs
|
ca.command.reload: Allow administrator to reload the plugin's configs
|
||||||
ca.command.diagnostic: Allow adminastator to diagnistic some simple problem with the plugin
|
ca.command.diagnostic: Get debug information about the plugin and server
|
||||||
|
ca.command.enchantment: Allows to set enchantment to holden item
|
||||||
ca.config.edit: Allow administrator to edit the plugin's config in game
|
ca.config.edit: Allow administrator to edit the plugin's config in game
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -5,24 +5,23 @@ import groovy.util.NodeList
|
||||||
import io.papermc.hangarpublishplugin.model.HangarPublication
|
import io.papermc.hangarpublishplugin.model.HangarPublication
|
||||||
import io.papermc.hangarpublishplugin.model.Platforms
|
import io.papermc.hangarpublishplugin.model.Platforms
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
import java.io.ByteArrayOutputStream
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.3.0"
|
kotlin("jvm") version "2.4.0"
|
||||||
java
|
java
|
||||||
id("org.jetbrains.dokka").version("1.9.20")
|
id("org.jetbrains.dokka").version("2.2.0")
|
||||||
id("com.gradleup.shadow").version("9.3.0")
|
id("com.gradleup.shadow").version("9.6.1")
|
||||||
// Maven publish
|
// Maven publish
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
signing
|
signing
|
||||||
id("cn.lalaki.central").version("1.2.8")
|
id("cn.lalaki.central").version("2.0.8")
|
||||||
// Paper
|
// Paper
|
||||||
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17" apply false
|
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21" apply false
|
||||||
id("io.papermc.hangar-publish-plugin") version "0.1.2"
|
id("io.papermc.hangar-publish-plugin") version "0.1.4"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "xyz.alexcrea"
|
group = "xyz.alexcrea"
|
||||||
version = "1.17.6"
|
version = "1.20.1"
|
||||||
|
|
||||||
val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null
|
val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null
|
||||||
val isPreRelease = System.getenv("IS_GITHUB_PRERELEASE") == "true"
|
val isPreRelease = System.getenv("IS_GITHUB_PRERELEASE") == "true"
|
||||||
|
|
@ -34,9 +33,6 @@ repositories {
|
||||||
// EcoEnchants
|
// EcoEnchants
|
||||||
maven(url = "https://repo.auxilor.io/repository/maven-public/")
|
maven(url = "https://repo.auxilor.io/repository/maven-public/")
|
||||||
|
|
||||||
// ExcellentEnchants
|
|
||||||
maven(url = "https://repo.nightexpressdev.com/releases")
|
|
||||||
|
|
||||||
// ItemsAdder
|
// ItemsAdder
|
||||||
maven(url = "https://maven.devs.beer/")
|
maven(url = "https://maven.devs.beer/")
|
||||||
|
|
||||||
|
|
@ -58,7 +54,7 @@ dependencies {
|
||||||
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
|
||||||
|
|
||||||
// fast stats
|
// fast stats
|
||||||
implementation("dev.faststats.metrics:bukkit:0.27.0")
|
implementation("dev.faststats.metrics:bukkit:0.29.0")
|
||||||
|
|
||||||
// minimessage
|
// minimessage
|
||||||
implementation("net.kyori:adventure-text-minimessage:4.25.0")
|
implementation("net.kyori:adventure-text-minimessage:4.25.0")
|
||||||
|
|
@ -72,21 +68,22 @@ dependencies {
|
||||||
compileOnly(files("libs/EnchantsSquared.jar"))
|
compileOnly(files("libs/EnchantsSquared.jar"))
|
||||||
|
|
||||||
// EcoEnchants & item
|
// EcoEnchants & item
|
||||||
compileOnly("com.willfp:libreforge:4.79.0:all")
|
compileOnly("com.willfp:libreforge:2026.32:all")
|
||||||
compileOnly("com.willfp:eco:6.74.5")
|
compileOnly("com.willfp:eco:2026.32")
|
||||||
|
|
||||||
compileOnly("com.willfp:EcoEnchants:12.11.1")
|
compileOnly("com.willfp:EcoEnchants:2026.32:all")
|
||||||
compileOnly(project(":impl:LegacyEcoEnchant"))
|
compileOnly(project(":impl:LegacyEcoEnchant"))
|
||||||
|
|
||||||
compileOnly("com.willfp:EcoItems:5.66.0")
|
compileOnly("com.willfp:EcoItems:5.66.0")
|
||||||
|
|
||||||
// ExcellentEnchants
|
// ExcellentEnchants
|
||||||
implementation(project(":impl:ExcellentEnchant5_4"))
|
implementation(project(":impl:ExcellentEnchant5_4"))
|
||||||
compileOnly("su.nightexpress.excellentenchants:Core:5.1.0") {
|
compileOnly(files("libs/ExcellentEnchants/ExcellentEnchants-4.3.3-striped.jar")) // For pre v5 excellent enchants
|
||||||
exclude("org.spigotmc")
|
compileOnly(files("libs/ExcellentEnchants/ExcellentEnchants-4.1.0-striped.jar")) // For legacy excellent enchants
|
||||||
}
|
// early v5 excellent enchants
|
||||||
compileOnly(files("libs/ExcellentEnchants-4.3.3-striped.jar")) // For pre v5 excellent enchants
|
compileOnly(files("libs/ExcellentEnchants/Core-5.1.0.jar"))
|
||||||
compileOnly(files("libs/ExcellentEnchants-4.1.0-striped.jar")) // For legacy excellent enchants
|
compileOnly(files("libs/ExcellentEnchants/API-5.1.0.jar"))
|
||||||
|
compileOnly(files("libs/ExcellentEnchants/main-2.7.9.jar"))
|
||||||
|
|
||||||
// Disenchantment
|
// Disenchantment
|
||||||
compileOnly(files("libs/Disenchantment-6.1.5.jar"))
|
compileOnly(files("libs/Disenchantment-6.1.5.jar"))
|
||||||
|
|
@ -168,7 +165,7 @@ allprojects {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_16)
|
jvmTarget.set(JvmTarget.JVM_16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +177,10 @@ tasks {
|
||||||
|
|
||||||
fun ShadowJar.configureBaseShadow(suffix: String, libraries: Array<String>) {
|
fun ShadowJar.configureBaseShadow(suffix: String, libraries: Array<String>) {
|
||||||
val processedSuffix = if(suffix.isEmpty()) "" else "-$suffix"
|
val processedSuffix = if(suffix.isEmpty()) "" else "-$suffix"
|
||||||
val name = "${rootProject.name}-${effectiveVersion}${processedSuffix}.jar"
|
val version = effectiveVersion
|
||||||
|
val name = "${rootProject.name}-${version}${processedSuffix}.jar"
|
||||||
|
val librariesExpendTo = libraries.joinToString(transform = { "\"$it\"" })
|
||||||
|
|
||||||
archiveFileName.set(name)
|
archiveFileName.set(name)
|
||||||
|
|
||||||
// Shadow necessary dependency
|
// Shadow necessary dependency
|
||||||
|
|
@ -189,8 +189,8 @@ tasks {
|
||||||
|
|
||||||
filesMatching("plugin.yml") {
|
filesMatching("plugin.yml") {
|
||||||
expand(
|
expand(
|
||||||
"version" to effectiveVersion + processedSuffix,
|
"version" to version + processedSuffix,
|
||||||
"libraries" to libraries.joinToString(transform = { "\"$it\"" }),
|
"libraries" to librariesExpendTo,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,7 +202,7 @@ tasks {
|
||||||
shadowJar {
|
shadowJar {
|
||||||
configureBaseShadow("",
|
configureBaseShadow("",
|
||||||
arrayOf(
|
arrayOf(
|
||||||
"org.jetbrains.kotlin:kotlin-stdlib:2.3.0",
|
"org.jetbrains.kotlin:kotlin-stdlib:2.4.0",
|
||||||
"net.kyori:adventure-text-minimessage:4.25.0",
|
"net.kyori:adventure-text-minimessage:4.25.0",
|
||||||
"net.kyori:adventure-text-serializer-plain:4.25.0",
|
"net.kyori:adventure-text-serializer-plain:4.25.0",
|
||||||
"net.kyori:adventure-text-serializer-legacy:4.25.0",
|
"net.kyori:adventure-text-serializer-legacy:4.25.0",
|
||||||
|
|
@ -214,7 +214,7 @@ tasks {
|
||||||
exclude("net/kyori/**")
|
exclude("net/kyori/**")
|
||||||
}
|
}
|
||||||
|
|
||||||
val offlineJar by registering(ShadowJar::class) {
|
val offlineJar = register<ShadowJar>("offlineJar") {
|
||||||
configureBaseShadow("offline", emptyArray())
|
configureBaseShadow("offline", emptyArray())
|
||||||
|
|
||||||
from(sourceSets.main.get().output)
|
from(sourceSets.main.get().output)
|
||||||
|
|
@ -228,12 +228,12 @@ tasks {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourcesJar by tasks.registering(Jar::class) {
|
val sourcesJar = tasks.register<Jar>("sourcesJar") {
|
||||||
archiveClassifier.set("sources")
|
archiveClassifier.set("sources")
|
||||||
from(kotlin.sourceSets.main.get().kotlin)
|
from(kotlin.sourceSets.main.get().kotlin)
|
||||||
}
|
}
|
||||||
|
|
||||||
val javadocJar by tasks.registering(Jar::class, fun Jar.() {
|
val javadocJar = tasks.register<Jar>("javadocJar", fun Jar.() {
|
||||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||||
description = "Assembles Javadoc JAR"
|
description = "Assembles Javadoc JAR"
|
||||||
archiveClassifier.set("javadoc")
|
archiveClassifier.set("javadoc")
|
||||||
|
|
@ -357,36 +357,25 @@ publishing {
|
||||||
}
|
}
|
||||||
|
|
||||||
// hangar publish
|
// hangar publish
|
||||||
|
fun latestCommitMessage(): Provider<String> {
|
||||||
fun executeGitCommand(vararg command: String): String {
|
return providers.exec {
|
||||||
val byteOut = ByteArrayOutputStream()
|
commandLine("git", "log", "-1", "--pretty=%B")
|
||||||
exec {
|
}.standardOutput.asText.map(String::trim)
|
||||||
commandLine = listOf("git", *command)
|
|
||||||
standardOutput = byteOut
|
|
||||||
}
|
|
||||||
return byteOut.toString(Charsets.UTF_8.name()).trim()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun changelog(isOnline: Boolean): Provider<String> {
|
||||||
fun latestCommitMessage(): String {
|
val changelog = if(isDevBuild) latestCommitMessage()
|
||||||
return executeGitCommand("log", "-1", "--pretty=%B")
|
else providers.environmentVariable("RELEASE_CHANGELOG")
|
||||||
}
|
|
||||||
|
|
||||||
fun changelog(isOnline: Boolean): String {
|
|
||||||
var changelog = if(isDevBuild) latestCommitMessage()
|
|
||||||
else System.getenv("RELEASE_CHANGELOG")
|
|
||||||
|
|
||||||
if(!isOnline) {
|
|
||||||
changelog = "This is an offline version of the plugin. \\\n" +
|
|
||||||
"This mean that this plugin libraries are shaded into this plugin \\\n" +
|
|
||||||
"You likely want to use the normal version of this plugin\n\n" + changelog
|
|
||||||
}
|
|
||||||
|
|
||||||
if(changelog == null || changelog.isEmpty()) {
|
|
||||||
changelog = "empty changelog"
|
|
||||||
}
|
|
||||||
|
|
||||||
return changelog
|
return changelog
|
||||||
|
.filter{!it.isEmpty()}
|
||||||
|
.map {
|
||||||
|
if(!isOnline)
|
||||||
|
return@map "This is an offline version of the plugin. \\\n" +
|
||||||
|
"This mean that this plugin libraries are shaded into this plugin \\\n" +
|
||||||
|
"You likely want to use the normal version of this plugin\n\n" + it
|
||||||
|
else return@map it
|
||||||
|
}.orElse("empty changelog")
|
||||||
}
|
}
|
||||||
|
|
||||||
hangarPublish {
|
hangarPublish {
|
||||||
|
|
@ -400,6 +389,7 @@ hangarPublish {
|
||||||
channel.set(if (isDevBuild || isPreRelease) devChannel else releaseChannel)
|
channel.set(if (isDevBuild || isPreRelease) devChannel else releaseChannel)
|
||||||
|
|
||||||
changelog.set(changelog(isOnline))
|
changelog.set(changelog(isOnline))
|
||||||
|
|
||||||
id.set("CustomAnvil")
|
id.set("CustomAnvil")
|
||||||
apiKey.set(System.getenv("HANGAR_API_TOKEN"))
|
apiKey.set(System.getenv("HANGAR_API_TOKEN"))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# What service of metric should custom anvil use
|
# What service of metric should custom anvil use
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# material conflicts
|
# material conflicts
|
||||||
|
|
@ -160,13 +160,6 @@ restriction_sweeping_edge:
|
||||||
enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ]
|
enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ]
|
||||||
notAffectedGroups: [ enchanted_book, swords ]
|
notAffectedGroups: [ enchanted_book, swords ]
|
||||||
|
|
||||||
# Do not exist in 1.18, that mean useInFuture will be set to true
|
|
||||||
# useInFuture set to true also mean it will not warn if there is an issue
|
|
||||||
restriction_swift_sneak:
|
|
||||||
useInFuture: true
|
|
||||||
enchantments: [ minecraft:swift_sneak ]
|
|
||||||
notAffectedGroups: [ enchanted_book, leggings ]
|
|
||||||
|
|
||||||
restriction_thorns:
|
restriction_thorns:
|
||||||
enchantments: [ minecraft:thorns ]
|
enchantments: [ minecraft:thorns ]
|
||||||
notAffectedGroups: [ enchanted_book, armors ]
|
notAffectedGroups: [ enchanted_book, armors ]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# Please note this config use spigot material names.
|
# Please note this config use spigot material names.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# Unit repair configuration
|
# Unit repair configuration
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# What service of metric should custom anvil use
|
# What service of metric should custom anvil use
|
||||||
|
|
@ -154,7 +154,6 @@ enchant_limits:
|
||||||
minecraft:knockback: 2
|
minecraft:knockback: 2
|
||||||
minecraft:fire_aspect: 2
|
minecraft:fire_aspect: 2
|
||||||
minecraft:looting: 3
|
minecraft:looting: 3
|
||||||
minecraft:sweeping: 3
|
|
||||||
minecraft:sweeping_edge: 3
|
minecraft:sweeping_edge: 3
|
||||||
minecraft:efficiency: 5
|
minecraft:efficiency: 5
|
||||||
minecraft:unbreaking: 3
|
minecraft:unbreaking: 3
|
||||||
|
|
@ -293,9 +292,6 @@ enchant_values:
|
||||||
minecraft:swift_sneak:
|
minecraft:swift_sneak:
|
||||||
item: 8
|
item: 8
|
||||||
book: 4
|
book: 4
|
||||||
minecraft:sweeping:
|
|
||||||
item: 4
|
|
||||||
book: 2
|
|
||||||
minecraft:sweeping_edge:
|
minecraft:sweeping_edge:
|
||||||
item: 4
|
item: 4
|
||||||
book: 2
|
book: 2
|
||||||
|
|
@ -480,6 +476,32 @@ monetary_cost:
|
||||||
work_penalty: 1.0 # for work penalty (aka use penalty)
|
work_penalty: 1.0 # for work penalty (aka use penalty)
|
||||||
recipe: 1.0 # for custom anvil recipe cost
|
recipe: 1.0 # for custom anvil recipe cost
|
||||||
|
|
||||||
|
# Chance that an anvil get degraded
|
||||||
|
# set it to zero if you wish to disable it
|
||||||
|
anvil_degradation: 0.12
|
||||||
|
|
||||||
|
# see https://www.digminecraft.com/lists/sound_list_pc.php
|
||||||
|
# for a list of most of the sounds
|
||||||
|
anvil_sound:
|
||||||
|
enabled: true
|
||||||
|
# The sound are weighted so if there is multiples of them one is selected randomly
|
||||||
|
# so if you want to add a "rare sound" as an easter egg you can !
|
||||||
|
# If invalid, it will be removed from the list. and if empty it will use the default
|
||||||
|
use:
|
||||||
|
default:
|
||||||
|
sound: block.anvil.use
|
||||||
|
category: blocks
|
||||||
|
volume: 1.0
|
||||||
|
pitch: 1.0
|
||||||
|
weight: 1.0
|
||||||
|
destroy:
|
||||||
|
default:
|
||||||
|
sound: block.anvil.destroy
|
||||||
|
category: blocks
|
||||||
|
volume: 1.0
|
||||||
|
pitch: 1.0
|
||||||
|
weight: 1.0
|
||||||
|
|
||||||
# Whether to show debug logging
|
# Whether to show debug logging
|
||||||
debug_log: false
|
debug_log: false
|
||||||
|
|
||||||
|
|
@ -489,5 +511,5 @@ debug_log_verbose: false
|
||||||
# Whether to show inside the console or require to run /ca debug get
|
# Whether to show inside the console or require to run /ca debug get
|
||||||
display_debug_in_console: false
|
display_debug_in_console: false
|
||||||
|
|
||||||
configVersion: 1.15.5
|
configVersion: 1.17.7
|
||||||
lowMinecraftVersion: 1.21.11
|
lowMinecraftVersion: 1.21.11
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# material conflicts
|
# material conflicts
|
||||||
|
|
@ -270,16 +270,12 @@ restriction_soul_speed:
|
||||||
|
|
||||||
restriction_sweeping_edge:
|
restriction_sweeping_edge:
|
||||||
enchantments:
|
enchantments:
|
||||||
- minecraft:sweeping
|
|
||||||
- minecraft:sweeping_edge
|
- minecraft:sweeping_edge
|
||||||
notAffectedGroups:
|
notAffectedGroups:
|
||||||
- enchanted_book
|
- enchanted_book
|
||||||
- swords
|
- swords
|
||||||
|
|
||||||
# Do not exist in 1.18, that mean useInFuture will be set to true
|
|
||||||
# useInFuture set to true also mean it will not warn if there is an issue
|
|
||||||
restriction_swift_sneak:
|
restriction_swift_sneak:
|
||||||
useInFuture: true
|
|
||||||
enchantments:
|
enchantments:
|
||||||
- minecraft:swift_sneak
|
- minecraft:swift_sneak
|
||||||
notAffectedGroups:
|
notAffectedGroups:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# Please note this config use spigot material names.
|
# Please note this config use spigot material names.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# Unit repair configuration
|
# Unit repair configuration
|
||||||
|
|
@ -104,7 +104,7 @@ leather:
|
||||||
phantom_membrane:
|
phantom_membrane:
|
||||||
elytra: 0.25
|
elytra: 0.25
|
||||||
|
|
||||||
scute:
|
turtle_scute:
|
||||||
turtle_helmet: 0.25
|
turtle_helmet: 0.25
|
||||||
|
|
||||||
oak_planks:
|
oak_planks:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# What service of metric should custom anvil use
|
# What service of metric should custom anvil use
|
||||||
|
|
@ -152,7 +152,6 @@ enchant_limits:
|
||||||
minecraft:knockback: 2
|
minecraft:knockback: 2
|
||||||
minecraft:fire_aspect: 2
|
minecraft:fire_aspect: 2
|
||||||
minecraft:looting: 3
|
minecraft:looting: 3
|
||||||
minecraft:sweeping: 3
|
|
||||||
minecraft:sweeping_edge: 3
|
minecraft:sweeping_edge: 3
|
||||||
minecraft:efficiency: 5
|
minecraft:efficiency: 5
|
||||||
minecraft:unbreaking: 3
|
minecraft:unbreaking: 3
|
||||||
|
|
@ -290,9 +289,6 @@ enchant_values:
|
||||||
minecraft:swift_sneak:
|
minecraft:swift_sneak:
|
||||||
item: 8
|
item: 8
|
||||||
book: 4
|
book: 4
|
||||||
minecraft:sweeping:
|
|
||||||
item: 4
|
|
||||||
book: 2
|
|
||||||
minecraft:sweeping_edge:
|
minecraft:sweeping_edge:
|
||||||
item: 4
|
item: 4
|
||||||
book: 2
|
book: 2
|
||||||
|
|
@ -472,6 +468,33 @@ monetary_cost:
|
||||||
work_penalty: 1.0 # for work penalty (aka use penalty)
|
work_penalty: 1.0 # for work penalty (aka use penalty)
|
||||||
recipe: 1.0 # for custom anvil recipe cost
|
recipe: 1.0 # for custom anvil recipe cost
|
||||||
|
|
||||||
|
# Chance that an anvil get degraded
|
||||||
|
# set it to zero if you wish to disable it
|
||||||
|
anvil_degradation: 0.12
|
||||||
|
|
||||||
|
# see https://www.digminecraft.com/lists/sound_list_pc.php
|
||||||
|
# for a list of most of the sounds
|
||||||
|
anvil_sound:
|
||||||
|
enabled: true
|
||||||
|
# The sound are weighted so if there is multiples of them one is selected randomly
|
||||||
|
# so if you want to add a "rare sound" as an easter egg you can !
|
||||||
|
# If invalid, it will be removed from the list. and if empty it will use the default
|
||||||
|
use:
|
||||||
|
default:
|
||||||
|
sound: block.anvil.use
|
||||||
|
category: blocks
|
||||||
|
volume: 1.0
|
||||||
|
pitch: 1.0
|
||||||
|
weight: 1.0
|
||||||
|
destroy:
|
||||||
|
default:
|
||||||
|
sound: block.anvil.destroy
|
||||||
|
category: blocks
|
||||||
|
volume: 1.0
|
||||||
|
pitch: 1.0
|
||||||
|
weight: 1.0
|
||||||
|
|
||||||
|
|
||||||
# Whether to show debug logging
|
# Whether to show debug logging
|
||||||
debug_log: false
|
debug_log: false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# material conflicts
|
# material conflicts
|
||||||
|
|
@ -267,16 +267,12 @@ restriction_soul_speed:
|
||||||
|
|
||||||
restriction_sweeping_edge:
|
restriction_sweeping_edge:
|
||||||
enchantments:
|
enchantments:
|
||||||
- minecraft:sweeping
|
|
||||||
- minecraft:sweeping_edge
|
- minecraft:sweeping_edge
|
||||||
notAffectedGroups:
|
notAffectedGroups:
|
||||||
- enchanted_book
|
- enchanted_book
|
||||||
- swords
|
- swords
|
||||||
|
|
||||||
# Do not exist in 1.18, that mean useInFuture will be set to true
|
|
||||||
# useInFuture set to true also mean it will not warn if there is an issue
|
|
||||||
restriction_swift_sneak:
|
restriction_swift_sneak:
|
||||||
useInFuture: true
|
|
||||||
enchantments:
|
enchantments:
|
||||||
- minecraft:swift_sneak
|
- minecraft:swift_sneak
|
||||||
notAffectedGroups:
|
notAffectedGroups:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# Please note this config use spigot material names.
|
# Please note this config use spigot material names.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# Unit repair configuration
|
# Unit repair configuration
|
||||||
|
|
@ -98,7 +98,7 @@ leather:
|
||||||
phantom_membrane:
|
phantom_membrane:
|
||||||
elytra: 0.25
|
elytra: 0.25
|
||||||
|
|
||||||
scute:
|
turtle_scute:
|
||||||
turtle_helmet: 0.25
|
turtle_helmet: 0.25
|
||||||
|
|
||||||
oak_planks:
|
oak_planks:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# What service of metric should custom anvil use
|
# What service of metric should custom anvil use
|
||||||
|
|
@ -152,7 +152,6 @@ enchant_limits:
|
||||||
minecraft:knockback: 2
|
minecraft:knockback: 2
|
||||||
minecraft:fire_aspect: 2
|
minecraft:fire_aspect: 2
|
||||||
minecraft:looting: 3
|
minecraft:looting: 3
|
||||||
minecraft:sweeping: 3
|
|
||||||
minecraft:sweeping_edge: 3
|
minecraft:sweeping_edge: 3
|
||||||
minecraft:efficiency: 5
|
minecraft:efficiency: 5
|
||||||
minecraft:unbreaking: 3
|
minecraft:unbreaking: 3
|
||||||
|
|
@ -287,9 +286,6 @@ enchant_values:
|
||||||
minecraft:swift_sneak:
|
minecraft:swift_sneak:
|
||||||
item: 8
|
item: 8
|
||||||
book: 4
|
book: 4
|
||||||
minecraft:sweeping:
|
|
||||||
item: 4
|
|
||||||
book: 2
|
|
||||||
minecraft:sweeping_edge:
|
minecraft:sweeping_edge:
|
||||||
item: 4
|
item: 4
|
||||||
book: 2
|
book: 2
|
||||||
|
|
@ -460,6 +456,33 @@ monetary_cost:
|
||||||
work_penalty: 1.0 # for work penalty (aka use penalty)
|
work_penalty: 1.0 # for work penalty (aka use penalty)
|
||||||
recipe: 1.0 # for custom anvil recipe cost
|
recipe: 1.0 # for custom anvil recipe cost
|
||||||
|
|
||||||
|
# Chance that an anvil get degraded
|
||||||
|
# set it to zero if you wish to disable it
|
||||||
|
anvil_degradation: 0.12
|
||||||
|
|
||||||
|
# see https://www.digminecraft.com/lists/sound_list_pc.php
|
||||||
|
# for a list of most of the sounds
|
||||||
|
anvil_sound:
|
||||||
|
enabled: true
|
||||||
|
# The sound are weighted so if there is multiples of them one is selected randomly
|
||||||
|
# so if you want to add a "rare sound" as an easter egg you can !
|
||||||
|
# If invalid, it will be removed from the list. and if empty it will use the default
|
||||||
|
use:
|
||||||
|
default:
|
||||||
|
sound: block.anvil.use
|
||||||
|
category: blocks
|
||||||
|
volume: 1.0
|
||||||
|
pitch: 1.0
|
||||||
|
weight: 1.0
|
||||||
|
destroy:
|
||||||
|
default:
|
||||||
|
sound: block.anvil.destroy
|
||||||
|
category: blocks
|
||||||
|
volume: 1.0
|
||||||
|
pitch: 1.0
|
||||||
|
weight: 1.0
|
||||||
|
|
||||||
|
|
||||||
# Whether to show debug logging
|
# Whether to show debug logging
|
||||||
debug_log: false
|
debug_log: false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# material conflicts
|
# material conflicts
|
||||||
|
|
@ -157,13 +157,10 @@ restriction_soul_speed:
|
||||||
notAffectedGroups: [ enchanted_book, boots ]
|
notAffectedGroups: [ enchanted_book, boots ]
|
||||||
|
|
||||||
restriction_sweeping_edge:
|
restriction_sweeping_edge:
|
||||||
enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ]
|
enchantments: [ minecraft:sweeping_edge ]
|
||||||
notAffectedGroups: [ enchanted_book, swords ]
|
notAffectedGroups: [ enchanted_book, swords ]
|
||||||
|
|
||||||
# Do not exist in 1.18, that mean useInFuture will be set to true
|
|
||||||
# useInFuture set to true also mean it will not warn if there is an issue
|
|
||||||
restriction_swift_sneak:
|
restriction_swift_sneak:
|
||||||
useInFuture: true
|
|
||||||
enchantments: [ minecraft:swift_sneak ]
|
enchantments: [ minecraft:swift_sneak ]
|
||||||
notAffectedGroups: [ enchanted_book, leggings ]
|
notAffectedGroups: [ enchanted_book, leggings ]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# Please note this config use spigot material names.
|
# Please note this config use spigot material names.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# It is recommended that you use /ca config to edit theses config.
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||||
#
|
#
|
||||||
|
|
||||||
# Unit repair configuration
|
# Unit repair configuration
|
||||||
|
|
@ -98,7 +98,7 @@ leather:
|
||||||
phantom_membrane:
|
phantom_membrane:
|
||||||
elytra: 0.25
|
elytra: 0.25
|
||||||
|
|
||||||
scute:
|
turtle_scute:
|
||||||
turtle_helmet: 0.25
|
turtle_helmet: 0.25
|
||||||
|
|
||||||
oak_planks:
|
oak_planks:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
org.gradle.configuration-cache=true
|
||||||
|
|
||||||
# Signing
|
# Signing
|
||||||
signing.secretKeyRingFile=~/.gnupg/secring.gpg
|
signing.secretKeyRingFile=~/.gnupg/secring.gpg
|
||||||
|
|
@ -6,8 +7,8 @@ signing.secretKeyRingFile=~/.gnupg/secring.gpg
|
||||||
kotlin.daemon.jvmargs=-Xmx8G
|
kotlin.daemon.jvmargs=-Xmx8G
|
||||||
|
|
||||||
# list of nms
|
# list of nms
|
||||||
subprojects.reobfnms=v1_17R1,v1_18R1,v1_18R2,v1_19R1,v1_19R2,v1_19R3,v1_20R1,v1_20R2,v1_20R3,v1_20R4,v1_21R1,v1_21R2,v1_21R3,v1_21R4,v1_21R5,v1_21R6,v1_21R7
|
subprojects.reobfnms=v1_17R1,v1_18R1,v1_18R2
|
||||||
|
|
||||||
# list of version for hangar release
|
# list of version for hangar release
|
||||||
paperVersion=1.18-26.2
|
paperVersion=1.18-1.20.5
|
||||||
|
|
||||||
|
|
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ group = rootProject.group
|
||||||
version = rootProject.version
|
version = rootProject.version
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.3.0"
|
kotlin("jvm") version "2.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ group = rootProject.group
|
||||||
version = rootProject.version
|
version = rootProject.version
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.3.0"
|
kotlin("jvm") version "2.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Imitate needed class and method to support legacy version of EcoEnchant
|
// Imitate needed class and method to support legacy version of EcoEnchant
|
||||||
|
|
|
||||||
BIN
libs/ExcellentEnchants/API-5.1.0.jar
Normal file
BIN
libs/ExcellentEnchants/API-5.1.0.jar
Normal file
Binary file not shown.
BIN
libs/ExcellentEnchants/Core-5.1.0.jar
Normal file
BIN
libs/ExcellentEnchants/Core-5.1.0.jar
Normal file
Binary file not shown.
BIN
libs/ExcellentEnchants/main-2.7.9.jar
Normal file
BIN
libs/ExcellentEnchants/main-2.7.9.jar
Normal file
Binary file not shown.
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_16)
|
jvmTarget.set(JvmTarget.JVM_16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,36 +57,28 @@ object PlatformUtil {
|
||||||
} else {
|
} else {
|
||||||
val legacyLore = ArrayList<String?>(lore.size)
|
val legacyLore = ArrayList<String?>(lore.size)
|
||||||
for (component in lore) {
|
for (component in lore) {
|
||||||
legacyLore.add(if(component == null) null
|
legacyLore.add(
|
||||||
else legacy_mm.serialize(component))
|
if (component == null) null
|
||||||
|
else legacy_mm.serialize(component)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lore = legacyLore
|
this.lore = legacyLore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display name
|
|
||||||
private val useCustomName = hasMethod(ItemStack::class.java, "customName")
|
|
||||||
|
|
||||||
fun ItemMeta.componentDisplayName(): Component? {
|
fun ItemMeta.componentDisplayName(): Component? {
|
||||||
if(useCustomName){
|
|
||||||
if(!this.hasCustomName()) return null
|
|
||||||
return this.customName()
|
|
||||||
}else if(isPaper){
|
|
||||||
if (!this.hasDisplayName()) return null
|
if (!this.hasDisplayName()) return null
|
||||||
return this.displayName()
|
|
||||||
|
return if (isPaper) {
|
||||||
|
this.displayName()
|
||||||
} else {
|
} else {
|
||||||
if(!this.hasDisplayName()) return null
|
legacy_mm.deserialize(this.displayName)
|
||||||
|
|
||||||
val legacy = this.displayName
|
|
||||||
return legacy_mm.deserialize(legacy)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ItemMeta.setComponentDisplayName(component: Component?) {
|
fun ItemMeta.setComponentDisplayName(component: Component?, fallback: String? = null) {
|
||||||
if(useCustomName){
|
if (isPaper) {
|
||||||
this.customName(component)
|
|
||||||
}else if(isPaper){
|
|
||||||
this.displayName(component)
|
this.displayName(component)
|
||||||
} else {
|
} else {
|
||||||
if (component == null) {
|
if (component == null) {
|
||||||
|
|
@ -94,7 +86,7 @@ object PlatformUtil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val legacy = legacy_mm.serialize(component)
|
val legacy = fallback ?: legacy_mm.serialize(component)
|
||||||
this.setDisplayName(legacy)
|
this.setDisplayName(legacy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_18)
|
jvmTarget.set(JvmTarget.JVM_18)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
@file:Suppress("DEPRECATION", "removal")
|
||||||
package xyz.alexcrea.cuanvil.dependency.datapack
|
package xyz.alexcrea.cuanvil.dependency.datapack
|
||||||
|
|
||||||
import io.papermc.paper.datapack.Datapack
|
import io.papermc.paper.datapack.Datapack
|
||||||
|
|
@ -21,18 +22,21 @@ object DataPackTester {
|
||||||
return Bukkit.getDatapackManager().enabledPacks
|
return Bukkit.getDatapackManager().enabledPacks
|
||||||
.stream().map { obj: Datapack -> obj.name }
|
.stream().map { obj: Datapack -> obj.name }
|
||||||
.toList()
|
.toList()
|
||||||
} catch (e: NoSuchMethodException) {
|
} catch (_: NoSuchMethodException) {
|
||||||
try {
|
try {
|
||||||
DataPack::class.java.getDeclaredMethod("getKey")
|
DataPack::class.java.getDeclaredMethod("getKey")
|
||||||
} catch (e: NoSuchMethodException) {
|
} catch (_: NoSuchMethodException) {
|
||||||
System.err.println("Could not find compatible datapack manager")
|
System.err.println("Could not find compatible datapack manager")
|
||||||
System.err.println("If you are using a datapack that should be compatible with CustomAnvil. It will not get detected...")
|
System.err.println("If you are using a datapack that should be compatible with CustomAnvil. It will not get detected...")
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
return legacyNames
|
return legacyNames
|
||||||
} catch (e: Exception){
|
} catch (_: Exception){
|
||||||
// Assume cause UnimplementedOperationException on mock server
|
// Assume cause UnimplementedOperationException on mock server
|
||||||
return Collections.emptyList()
|
return Collections.emptyList()
|
||||||
|
} catch(_: NoSuchMethodError) {
|
||||||
|
// Idk newer spigot may not have that ?
|
||||||
|
return Collections.emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ object AnvilTitleUtil {
|
||||||
|
|
||||||
private val runTaskMap = HashMap<UUID, ScheduledTask>()
|
private val runTaskMap = HashMap<UUID, ScheduledTask>()
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
private fun actualRename(view: InventoryView, name: String, player: HumanEntity, anvilDialog: AnvilRenameDialog) {
|
private fun actualRename(view: InventoryView, name: String, player: HumanEntity, anvilDialog: AnvilRenameDialog) {
|
||||||
runTaskMap.remove(player.uniqueId)
|
runTaskMap.remove(player.uniqueId)
|
||||||
if (view.title == name) return
|
if (view.title == name) return
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_16)
|
jvmTarget.set(JvmTarget.JVM_16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_17)
|
jvmTarget.set(JvmTarget.JVM_17)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_17)
|
jvmTarget.set(JvmTarget.JVM_17)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_17)
|
jvmTarget.set(JvmTarget.JVM_17)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_17)
|
jvmTarget.set(JvmTarget.JVM_17)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_17)
|
jvmTarget.set(JvmTarget.JVM_17)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_18)
|
jvmTarget.set(JvmTarget.JVM_18)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_18)
|
jvmTarget.set(JvmTarget.JVM_18)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_18)
|
jvmTarget.set(JvmTarget.JVM_18)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
||||||
jvmTarget.set(JvmTarget.JVM_18)
|
jvmTarget.set(JvmTarget.JVM_18)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package xyz.alexcrea.cuanvil.util
|
package xyz.alexcrea.cuanvil.util
|
||||||
|
|
||||||
|
import org.bukkit.Material
|
||||||
import org.bukkit.inventory.meta.Damageable
|
import org.bukkit.inventory.meta.Damageable
|
||||||
|
|
||||||
// I LOVE support of old versions and needing to do modules like that
|
// I LOVE support of old versions and needing to do modules like that
|
||||||
|
|
@ -10,8 +11,8 @@ object MaxDamageCheckerUtil {
|
||||||
/**
|
/**
|
||||||
* @return max damage or int max if not set
|
* @return max damage or int max if not set
|
||||||
*/
|
*/
|
||||||
fun getMaxDamage(meta: Damageable): Int {
|
fun getMaxDamage(type: Material, meta: Damageable): Int {
|
||||||
if(!meta.hasMaxDamage()) return Integer.MAX_VALUE
|
if(!meta.hasMaxDamage()) return type.maxDurability.toInt()
|
||||||
return meta.maxDamage
|
return meta.maxDamage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
1
nms/v1_21R1/.gitignore
vendored
1
nms/v1_21R1/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
.lastDeploymentsId
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("io.papermc.paperweight.userdev")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project(":nms:nms-common"))
|
|
||||||
|
|
||||||
// Used for nms
|
|
||||||
paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT")
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set target version
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
|
||||||
sourceCompatibility = "21"
|
|
||||||
targetCompatibility = "21"
|
|
||||||
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
compilerOptions {
|
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package xyz.alexcrea.cuanvil.dependency.packet.versions
|
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
|
|
||||||
import net.minecraft.world.entity.player.Abilities
|
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer
|
|
||||||
import org.bukkit.entity.Player
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
|
|
||||||
|
|
||||||
class V1_21R1_PacketManager : PacketManagerBase(), PacketManager {
|
|
||||||
override val canSetInstantBuild: Boolean
|
|
||||||
get() = true
|
|
||||||
|
|
||||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
|
|
||||||
val nmsPlayer = (player as CraftPlayer).handle
|
|
||||||
val playerAbilities = nmsPlayer.abilities
|
|
||||||
val sendedAbilities: Abilities
|
|
||||||
if (playerAbilities.instabuild == instantBuild) {
|
|
||||||
sendedAbilities = playerAbilities
|
|
||||||
} else {
|
|
||||||
sendedAbilities = Abilities()
|
|
||||||
sendedAbilities.invulnerable = playerAbilities.invulnerable
|
|
||||||
sendedAbilities.flying = playerAbilities.flying
|
|
||||||
sendedAbilities.mayfly = playerAbilities.mayfly
|
|
||||||
sendedAbilities.instabuild = instantBuild
|
|
||||||
sendedAbilities.mayBuild = playerAbilities.mayBuild
|
|
||||||
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
|
|
||||||
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
|
|
||||||
}
|
|
||||||
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
|
|
||||||
nmsPlayer.connection.send(packet)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1
nms/v1_21R2/.gitignore
vendored
1
nms/v1_21R2/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
.lastDeploymentsId
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("io.papermc.paperweight.userdev")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project(":nms:nms-common"))
|
|
||||||
|
|
||||||
// Used for nms
|
|
||||||
paperweight.paperDevBundle("1.21.3-R0.1-SNAPSHOT")
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set target version
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
|
||||||
sourceCompatibility = "21"
|
|
||||||
targetCompatibility = "21"
|
|
||||||
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
compilerOptions {
|
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package xyz.alexcrea.cuanvil.dependency.packet.versions
|
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
|
|
||||||
import net.minecraft.world.entity.player.Abilities
|
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer
|
|
||||||
import org.bukkit.entity.Player
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
|
|
||||||
|
|
||||||
class V1_21R2_PacketManager : PacketManagerBase(), PacketManager {
|
|
||||||
override val canSetInstantBuild: Boolean
|
|
||||||
get() = true
|
|
||||||
|
|
||||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
|
|
||||||
val nmsPlayer = (player as CraftPlayer).handle
|
|
||||||
val playerAbilities = nmsPlayer.abilities
|
|
||||||
val sendedAbilities: Abilities
|
|
||||||
if (playerAbilities.instabuild == instantBuild) {
|
|
||||||
sendedAbilities = playerAbilities
|
|
||||||
} else {
|
|
||||||
sendedAbilities = Abilities()
|
|
||||||
sendedAbilities.invulnerable = playerAbilities.invulnerable
|
|
||||||
sendedAbilities.flying = playerAbilities.flying
|
|
||||||
sendedAbilities.mayfly = playerAbilities.mayfly
|
|
||||||
sendedAbilities.instabuild = instantBuild
|
|
||||||
sendedAbilities.mayBuild = playerAbilities.mayBuild
|
|
||||||
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
|
|
||||||
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
|
|
||||||
}
|
|
||||||
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
|
|
||||||
nmsPlayer.connection.send(packet)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1
nms/v1_21R3/.gitignore
vendored
1
nms/v1_21R3/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
.lastDeploymentsId
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("io.papermc.paperweight.userdev")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project(":nms:nms-common"))
|
|
||||||
|
|
||||||
// Used for nms
|
|
||||||
paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT")
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set target version
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
|
||||||
sourceCompatibility = "21"
|
|
||||||
targetCompatibility = "21"
|
|
||||||
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
compilerOptions {
|
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package xyz.alexcrea.cuanvil.dependency.packet.versions
|
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
|
|
||||||
import net.minecraft.world.entity.player.Abilities
|
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer
|
|
||||||
import org.bukkit.entity.Player
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
|
|
||||||
|
|
||||||
class V1_21R3_PacketManager : PacketManagerBase(), PacketManager {
|
|
||||||
override val canSetInstantBuild: Boolean
|
|
||||||
get() = true
|
|
||||||
|
|
||||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
|
|
||||||
val nmsPlayer = (player as CraftPlayer).handle
|
|
||||||
val playerAbilities = nmsPlayer.abilities
|
|
||||||
val sendedAbilities: Abilities
|
|
||||||
if (playerAbilities.instabuild == instantBuild) {
|
|
||||||
sendedAbilities = playerAbilities
|
|
||||||
} else {
|
|
||||||
sendedAbilities = Abilities()
|
|
||||||
sendedAbilities.invulnerable = playerAbilities.invulnerable
|
|
||||||
sendedAbilities.flying = playerAbilities.flying
|
|
||||||
sendedAbilities.mayfly = playerAbilities.mayfly
|
|
||||||
sendedAbilities.instabuild = instantBuild
|
|
||||||
sendedAbilities.mayBuild = playerAbilities.mayBuild
|
|
||||||
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
|
|
||||||
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
|
|
||||||
}
|
|
||||||
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
|
|
||||||
nmsPlayer.connection.send(packet)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1
nms/v1_21R4/.gitignore
vendored
1
nms/v1_21R4/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
.lastDeploymentsId
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("io.papermc.paperweight.userdev")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project(":nms:nms-common"))
|
|
||||||
|
|
||||||
// Used for nms
|
|
||||||
paperweight.paperDevBundle("1.21.5-R0.1-SNAPSHOT")
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set target version
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
|
||||||
sourceCompatibility = "21"
|
|
||||||
targetCompatibility = "21"
|
|
||||||
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
compilerOptions {
|
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package xyz.alexcrea.cuanvil.dependency.packet.versions
|
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
|
|
||||||
import net.minecraft.world.entity.player.Abilities
|
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer
|
|
||||||
import org.bukkit.entity.Player
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
|
|
||||||
|
|
||||||
class V1_21R4_PacketManager : PacketManagerBase(), PacketManager {
|
|
||||||
override val canSetInstantBuild: Boolean
|
|
||||||
get() = true
|
|
||||||
|
|
||||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
|
|
||||||
val nmsPlayer = (player as CraftPlayer).handle
|
|
||||||
val playerAbilities = nmsPlayer.abilities
|
|
||||||
val sendedAbilities: Abilities
|
|
||||||
if (playerAbilities.instabuild == instantBuild) {
|
|
||||||
sendedAbilities = playerAbilities
|
|
||||||
} else {
|
|
||||||
sendedAbilities = Abilities()
|
|
||||||
sendedAbilities.invulnerable = playerAbilities.invulnerable
|
|
||||||
sendedAbilities.flying = playerAbilities.flying
|
|
||||||
sendedAbilities.mayfly = playerAbilities.mayfly
|
|
||||||
sendedAbilities.instabuild = instantBuild
|
|
||||||
sendedAbilities.mayBuild = playerAbilities.mayBuild
|
|
||||||
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
|
|
||||||
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
|
|
||||||
}
|
|
||||||
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
|
|
||||||
nmsPlayer.connection.send(packet)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1
nms/v1_21R5/.gitignore
vendored
1
nms/v1_21R5/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
.lastDeploymentsId
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("io.papermc.paperweight.userdev")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project(":nms:nms-common"))
|
|
||||||
|
|
||||||
// Used for nms
|
|
||||||
paperweight.paperDevBundle("1.21.6-R0.1-SNAPSHOT")
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set target version
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
|
||||||
sourceCompatibility = "21"
|
|
||||||
targetCompatibility = "21"
|
|
||||||
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
compilerOptions {
|
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package xyz.alexcrea.cuanvil.dependency.packet.versions
|
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
|
|
||||||
import net.minecraft.world.entity.player.Abilities
|
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer
|
|
||||||
import org.bukkit.entity.Player
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
|
|
||||||
|
|
||||||
class V1_21R5_PacketManager : PacketManagerBase(), PacketManager {
|
|
||||||
override val canSetInstantBuild: Boolean
|
|
||||||
get() = true
|
|
||||||
|
|
||||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
|
|
||||||
val nmsPlayer = (player as CraftPlayer).handle
|
|
||||||
val playerAbilities = nmsPlayer.abilities
|
|
||||||
val sendedAbilities: Abilities
|
|
||||||
if (playerAbilities.instabuild == instantBuild) {
|
|
||||||
sendedAbilities = playerAbilities
|
|
||||||
} else {
|
|
||||||
sendedAbilities = Abilities()
|
|
||||||
sendedAbilities.invulnerable = playerAbilities.invulnerable
|
|
||||||
sendedAbilities.flying = playerAbilities.flying
|
|
||||||
sendedAbilities.mayfly = playerAbilities.mayfly
|
|
||||||
sendedAbilities.instabuild = instantBuild
|
|
||||||
sendedAbilities.mayBuild = playerAbilities.mayBuild
|
|
||||||
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
|
|
||||||
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
|
|
||||||
}
|
|
||||||
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
|
|
||||||
nmsPlayer.connection.send(packet)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1
nms/v1_21R6/.gitignore
vendored
1
nms/v1_21R6/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
.lastDeploymentsId
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("io.papermc.paperweight.userdev")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project(":nms:nms-common"))
|
|
||||||
|
|
||||||
// Used for nms
|
|
||||||
paperweight.paperDevBundle("1.21.10-R0.1-SNAPSHOT")
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set target version
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
|
||||||
sourceCompatibility = "21"
|
|
||||||
targetCompatibility = "21"
|
|
||||||
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
compilerOptions {
|
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package xyz.alexcrea.cuanvil.dependency.packet.versions
|
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
|
|
||||||
import net.minecraft.world.entity.player.Abilities
|
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer
|
|
||||||
import org.bukkit.entity.Player
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
|
|
||||||
|
|
||||||
class V1_21R6_PacketManager : PacketManagerBase(), PacketManager {
|
|
||||||
override val canSetInstantBuild: Boolean
|
|
||||||
get() = true
|
|
||||||
|
|
||||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
|
|
||||||
val nmsPlayer = (player as CraftPlayer).handle
|
|
||||||
val playerAbilities = nmsPlayer.abilities
|
|
||||||
val sendedAbilities: Abilities
|
|
||||||
if (playerAbilities.instabuild == instantBuild) {
|
|
||||||
sendedAbilities = playerAbilities
|
|
||||||
} else {
|
|
||||||
sendedAbilities = Abilities()
|
|
||||||
sendedAbilities.invulnerable = playerAbilities.invulnerable
|
|
||||||
sendedAbilities.flying = playerAbilities.flying
|
|
||||||
sendedAbilities.mayfly = playerAbilities.mayfly
|
|
||||||
sendedAbilities.instabuild = instantBuild
|
|
||||||
sendedAbilities.mayBuild = playerAbilities.mayBuild
|
|
||||||
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
|
|
||||||
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
|
|
||||||
}
|
|
||||||
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
|
|
||||||
nmsPlayer.connection.send(packet)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1
nms/v1_21R7/.gitignore
vendored
1
nms/v1_21R7/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
.lastDeploymentsId
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("io.papermc.paperweight.userdev")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project(":nms:nms-common"))
|
|
||||||
|
|
||||||
// Used for nms
|
|
||||||
paperweight.paperDevBundle("1.21.11-R0.1-SNAPSHOT")
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set target version
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
|
||||||
sourceCompatibility = "21"
|
|
||||||
targetCompatibility = "21"
|
|
||||||
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
compilerOptions {
|
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package xyz.alexcrea.cuanvil.dependency.packet.versions
|
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
|
|
||||||
import net.minecraft.world.entity.player.Abilities
|
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer
|
|
||||||
import org.bukkit.entity.Player
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
|
|
||||||
|
|
||||||
class V1_21R7_PacketManager : PacketManagerBase(), PacketManager {
|
|
||||||
override val canSetInstantBuild: Boolean
|
|
||||||
get() = true
|
|
||||||
|
|
||||||
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
|
|
||||||
val nmsPlayer = (player as CraftPlayer).handle
|
|
||||||
val playerAbilities = nmsPlayer.abilities
|
|
||||||
val sendedAbilities: Abilities
|
|
||||||
if (playerAbilities.instabuild == instantBuild) {
|
|
||||||
sendedAbilities = playerAbilities
|
|
||||||
} else {
|
|
||||||
sendedAbilities = Abilities()
|
|
||||||
sendedAbilities.invulnerable = playerAbilities.invulnerable
|
|
||||||
sendedAbilities.flying = playerAbilities.flying
|
|
||||||
sendedAbilities.mayfly = playerAbilities.mayfly
|
|
||||||
sendedAbilities.instabuild = instantBuild
|
|
||||||
sendedAbilities.mayBuild = playerAbilities.mayBuild
|
|
||||||
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
|
|
||||||
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
|
|
||||||
}
|
|
||||||
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
|
|
||||||
nmsPlayer.connection.send(packet)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -128,7 +128,7 @@ public class EnchantmentApi {
|
||||||
* @return The custom anvil enchantment of this key. null if not found.
|
* @return The custom anvil enchantment of this key. null if not found.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static CAEnchantment getByKey(@NotNull NamespacedKey key) {
|
public static CAEnchantment getByKey(@Nullable NamespacedKey key) {
|
||||||
return CAEnchantment.getByKey(key);
|
return CAEnchantment.getByKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,16 @@ package xyz.alexcrea.cuanvil.api;
|
||||||
import io.delilaheve.CustomAnvil;
|
import io.delilaheve.CustomAnvil;
|
||||||
import kotlin.Triple;
|
import kotlin.Triple;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager;
|
import xyz.alexcrea.cuanvil.dependency.DependencyManager;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.global.UnitRepairConfigGui;
|
import xyz.alexcrea.cuanvil.gui.config.global.UnitRepairConfigGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.list.MappedGuiListConfigGui;
|
|
||||||
import xyz.alexcrea.cuanvil.gui.config.list.UnitRepairElementListGui;
|
import xyz.alexcrea.cuanvil.gui.config.list.UnitRepairElementListGui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom Anvil api for unit repair.
|
* Custom Anvil api for unit repair.
|
||||||
|
|
@ -22,7 +20,8 @@ import java.util.List;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class UnitRepairApi {
|
public class UnitRepairApi {
|
||||||
|
|
||||||
private UnitRepairApi(){}
|
private UnitRepairApi() {
|
||||||
|
}
|
||||||
|
|
||||||
private static Object saveChangeTask = null;
|
private static Object saveChangeTask = null;
|
||||||
|
|
||||||
|
|
@ -39,6 +38,19 @@ public class UnitRepairApi {
|
||||||
return addUnitRepair(unit, repairable, 0.25, false);
|
return addUnitRepair(unit, repairable, 0.25, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write and add a custom anvil unit repair recipe.
|
||||||
|
* Will not write the recipe if it already exists or was deleted.
|
||||||
|
* Set the value to minecraft default value (0.25 = 25%)
|
||||||
|
*
|
||||||
|
* @param unit The unit material used to repair the bellow item.
|
||||||
|
* @param repairable The item to be repaired.
|
||||||
|
* @return true if successful.
|
||||||
|
*/
|
||||||
|
public static boolean addUnitRepair(@NotNull NamespacedKey unit, @NotNull NamespacedKey repairable) {
|
||||||
|
return addUnitRepair(unit, repairable, 0.25, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write and add a custom anvil unit repair recipe.
|
* Write and add a custom anvil unit repair recipe.
|
||||||
* Will not write the recipe if it already exists or was deleted.
|
* Will not write the recipe if it already exists or was deleted.
|
||||||
|
|
@ -63,8 +75,22 @@ public class UnitRepairApi {
|
||||||
* @return true if successful.
|
* @return true if successful.
|
||||||
*/
|
*/
|
||||||
public static boolean addUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value, boolean overrideDeleted) {
|
public static boolean addUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value, boolean overrideDeleted) {
|
||||||
|
return addUnitRepair(unit.getKey(), repairable.getKey(), value, overrideDeleted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write and add a custom anvil unit repair recipe.
|
||||||
|
* Will not write the recipe if it already exists.
|
||||||
|
*
|
||||||
|
* @param unit The unit material used to repair the bellow item.
|
||||||
|
* @param repairable The item to be repaired.
|
||||||
|
* @param value The amount to be repaired by every unit. (1% = 0.01)
|
||||||
|
* @param overrideDeleted If we should write even if the recipe was previously deleted.
|
||||||
|
* @return true if successful.
|
||||||
|
*/
|
||||||
|
public static boolean addUnitRepair(@NotNull NamespacedKey unit, @NotNull NamespacedKey repairable, double value, boolean overrideDeleted) {
|
||||||
FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
||||||
String path = unit.name().toLowerCase() + "." + repairable.name().toLowerCase();
|
String path = unit.toString().toLowerCase() + "." + repairable.toString().toLowerCase();
|
||||||
|
|
||||||
if (!overrideDeleted && ConfigHolder.UNIT_REPAIR_HOLDER.isDeleted(path)) return false;
|
if (!overrideDeleted && ConfigHolder.UNIT_REPAIR_HOLDER.isDeleted(path)) return false;
|
||||||
if (config.contains(path)) return false;
|
if (config.contains(path)) return false;
|
||||||
|
|
@ -83,10 +109,23 @@ public class UnitRepairApi {
|
||||||
* @return true if successful.
|
* @return true if successful.
|
||||||
*/
|
*/
|
||||||
public static boolean setUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value) {
|
public static boolean setUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value) {
|
||||||
|
return setUnitRepair(unit.getKey(), repairable.getKey(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write and add a custom anvil unit repair recipe.
|
||||||
|
* Do not check if it previously existed or exist.
|
||||||
|
*
|
||||||
|
* @param unit The unit material used to repair the bellow item.
|
||||||
|
* @param repairable The item to be repaired.
|
||||||
|
* @param value The amount to be repaired by every unit. (1% = 0.01)
|
||||||
|
* @return true if successful.
|
||||||
|
*/
|
||||||
|
public static boolean setUnitRepair(@NotNull NamespacedKey unit, @NotNull NamespacedKey repairable, double value) {
|
||||||
FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
||||||
|
|
||||||
String repairableName = repairable.name().toLowerCase();
|
String repairableName = repairable.toString().toLowerCase();
|
||||||
String path = unit.name().toLowerCase() + "." + repairableName;
|
String path = unit.toString().toLowerCase() + "." + repairableName;
|
||||||
|
|
||||||
// Add to config then prepare save
|
// Add to config then prepare save
|
||||||
config.set(path, value);
|
config.set(path, value);
|
||||||
|
|
@ -97,7 +136,7 @@ public class UnitRepairApi {
|
||||||
if (repairConfigGui != null) {
|
if (repairConfigGui != null) {
|
||||||
UnitRepairElementListGui elementGui = repairConfigGui.getInstanceOrCreate(unit).getStored();
|
UnitRepairElementListGui elementGui = repairConfigGui.getInstanceOrCreate(unit).getStored();
|
||||||
|
|
||||||
if(elementGui != null) elementGui.updateValueForGeneric(repairableName, true);
|
if (elementGui != null) elementGui.updateValueForGeneric(repairable, true);
|
||||||
repairConfigGui.updateValueForGeneric(unit, true);
|
repairConfigGui.updateValueForGeneric(unit, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,38 +151,46 @@ public class UnitRepairApi {
|
||||||
* @return true if successful.
|
* @return true if successful.
|
||||||
*/
|
*/
|
||||||
public static boolean removeUnitRepair(@NotNull Material unit, @NotNull Material repairable) {
|
public static boolean removeUnitRepair(@NotNull Material unit, @NotNull Material repairable) {
|
||||||
|
return removeUnitRepair(unit.getKey(), repairable.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a custom anvil unit repair recipe.
|
||||||
|
*
|
||||||
|
* @param unit The unit material used to repair the bellow item.
|
||||||
|
* @param repairable The item used to be repaired.
|
||||||
|
* @return true if successful.
|
||||||
|
*/
|
||||||
|
public static boolean removeUnitRepair(@NotNull NamespacedKey unit, @NotNull NamespacedKey repairable) {
|
||||||
// Delete every possible variation and save to file
|
// Delete every possible variation and save to file
|
||||||
String unitName = unit.name();
|
|
||||||
String repairableName = repairable.name();
|
|
||||||
|
|
||||||
FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
||||||
config.set(unitName.toLowerCase() + "." + repairableName.toUpperCase(), null);
|
config.set(unit.getKey() + "." + repairable.getKey(), null);
|
||||||
config.set(unitName.toUpperCase() + "." + repairableName.toLowerCase(), null);
|
config.set(unit.getKey() + "." + repairable, null);
|
||||||
config.set(unitName.toUpperCase() + "." + repairableName.toUpperCase(), null);
|
config.set(unit + "." + repairable.getKey(), null);
|
||||||
config.set(unitName.toLowerCase() + "." + repairableName.toLowerCase(), null);
|
config.set(unit + "." + repairable, null);
|
||||||
|
|
||||||
// Test if it was the last value of this section
|
// Test if it was the last value of this section
|
||||||
boolean lastValue = false;
|
boolean lastValue = false;
|
||||||
if(config.isConfigurationSection(unitName.toLowerCase())) {
|
if (config.isConfigurationSection(unit.toString())) {
|
||||||
ConfigurationSection section = config.getConfigurationSection(unitName.toLowerCase());
|
ConfigurationSection section = config.getConfigurationSection(unit.toString());
|
||||||
|
|
||||||
if (section != null && section.getKeys(false).isEmpty()) {
|
if (section != null && section.getKeys(false).isEmpty()) {
|
||||||
lastValue = true;
|
lastValue = true;
|
||||||
config.set(unitName.toLowerCase(), null);
|
config.set(unit.toString(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (config.isConfigurationSection(unitName.toUpperCase())) {
|
} else if (config.isConfigurationSection(unit.getKey())) {
|
||||||
ConfigurationSection section = config.getConfigurationSection(unitName.toUpperCase());
|
ConfigurationSection section = config.getConfigurationSection(unit.getKey());
|
||||||
if (section != null && section.getKeys(false).isEmpty()) {
|
if (section != null && section.getKeys(false).isEmpty()) {
|
||||||
lastValue = true;
|
lastValue = true;
|
||||||
config.set(unitName.toUpperCase(), null);
|
config.set(unit.getKey(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else lastValue = true;
|
} else lastValue = true;
|
||||||
|
|
||||||
|
|
||||||
// We only need to "delete" as the lower case to be counted as deleted
|
ConfigHolder.UNIT_REPAIR_HOLDER.delete(unit.toString().toLowerCase() + "." + repairable.toString().toLowerCase());
|
||||||
ConfigHolder.UNIT_REPAIR_HOLDER.delete(unitName.toLowerCase() + "." + repairableName.toLowerCase());
|
|
||||||
prepareSaveTask();
|
prepareSaveTask();
|
||||||
|
|
||||||
// Remove from gui
|
// Remove from gui
|
||||||
|
|
@ -151,7 +198,7 @@ public class UnitRepairApi {
|
||||||
if (repairConfigGui != null) {
|
if (repairConfigGui != null) {
|
||||||
UnitRepairElementListGui elementGui = repairConfigGui.getInstanceOrCreate(unit).getStored();
|
UnitRepairElementListGui elementGui = repairConfigGui.getInstanceOrCreate(unit).getStored();
|
||||||
|
|
||||||
if(elementGui != null) elementGui.removeGeneric(repairableName);
|
if (elementGui != null) elementGui.removeGeneric(repairable);
|
||||||
if (lastValue) {
|
if (lastValue) {
|
||||||
repairConfigGui.removeGeneric(unit);
|
repairConfigGui.removeGeneric(unit);
|
||||||
}
|
}
|
||||||
|
|
@ -174,6 +221,7 @@ public class UnitRepairApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get every unit repair recipes.
|
* Get every unit repair recipes.
|
||||||
|
*
|
||||||
* @return An immutable collection of unit repair recipes.
|
* @return An immutable collection of unit repair recipes.
|
||||||
* <p>
|
* <p>
|
||||||
* Each element of the provided triple represent a part of the recipe
|
* Each element of the provided triple represent a part of the recipe
|
||||||
|
|
@ -182,7 +230,10 @@ public class UnitRepairApi {
|
||||||
* <li>Second object is the item to be repaired.
|
* <li>Second object is the item to be repaired.
|
||||||
* <li>Last object is the amount to be repaired by every unit. (1% = 0.01)
|
* <li>Last object is the amount to be repaired by every unit. (1% = 0.01)
|
||||||
* </ul>
|
* </ul>
|
||||||
|
* @deprecated some may be missing. use {@link #getModernUnitRepairs()}
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@NotNull
|
@NotNull
|
||||||
public static List<Triple<Material, Material, Double>> getUnitRepairs() {
|
public static List<Triple<Material, Material, Double>> getUnitRepairs() {
|
||||||
List<Triple<Material, Material, Double>> mutableList = new ArrayList<>();
|
List<Triple<Material, Material, Double>> mutableList = new ArrayList<>();
|
||||||
|
|
@ -215,4 +266,53 @@ public class UnitRepairApi {
|
||||||
return Collections.unmodifiableList(mutableList);
|
return Collections.unmodifiableList(mutableList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get every unit repair recipes.
|
||||||
|
*
|
||||||
|
* @return An immutable collection of unit repair recipes.
|
||||||
|
* <p>
|
||||||
|
* <li>First map contain a key the unit material used to repair the bellow item and value the second map
|
||||||
|
* <li>Second map contain as key the item to be repaired and as value the amount to be repaired by every unit. (1% = 0.01)
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static Map<NamespacedKey, Map<NamespacedKey, Double>> getModernUnitRepairs() {
|
||||||
|
Map<NamespacedKey, Map<NamespacedKey, Double>> mutableList = new HashMap<>();
|
||||||
|
|
||||||
|
FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
||||||
|
for (String unitKey : config.getKeys(false)) {
|
||||||
|
// Test if config section exist
|
||||||
|
if (!config.isConfigurationSection(unitKey)) continue;
|
||||||
|
|
||||||
|
// Test if unit is a material
|
||||||
|
NamespacedKey unit = NamespacedKey.fromString(unitKey.toLowerCase());
|
||||||
|
if (unit == null) continue;
|
||||||
|
|
||||||
|
Map<NamespacedKey, Double> map;
|
||||||
|
if (!mutableList.containsKey(unit)) {
|
||||||
|
map = new HashMap<>();
|
||||||
|
mutableList.put(unit, map);
|
||||||
|
} else {
|
||||||
|
map = mutableList.get(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterate over reparable items
|
||||||
|
ConfigurationSection section = config.getConfigurationSection(unitKey);
|
||||||
|
for (String repairableKey : section.getKeys(false)) {
|
||||||
|
// Test if value section exist
|
||||||
|
if (!section.isDouble(repairableKey)) continue;
|
||||||
|
|
||||||
|
// Test if repairable is valid a material
|
||||||
|
NamespacedKey repairable = NamespacedKey.fromString(repairableKey.toLowerCase());
|
||||||
|
if (repairable == null) continue;
|
||||||
|
|
||||||
|
// Add the values
|
||||||
|
map.put(repairable, section.getDouble(repairableKey));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mutableList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import xyz.alexcrea.cuanvil.enchant.bulk.BulkCleanEnchantOperation;
|
import xyz.alexcrea.cuanvil.enchant.bulk.BulkCleanEnchantOperation;
|
||||||
import xyz.alexcrea.cuanvil.enchant.bulk.BulkGetEnchantOperation;
|
import xyz.alexcrea.cuanvil.enchant.bulk.BulkGetEnchantOperation;
|
||||||
import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
|
import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
|
||||||
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -45,6 +46,14 @@ public interface CAEnchantment {
|
||||||
@NotNull
|
@NotNull
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the enchantment name prettified (upper spaced case)
|
||||||
|
* @return Prettier enchantment name
|
||||||
|
*/
|
||||||
|
default String getPrettyName() {
|
||||||
|
return CasedStringUtil.snakeToUpperSpacedCase(getName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default maximum level of this enchantment.
|
* Get the default maximum level of this enchantment.
|
||||||
* @return The default maximum level of this enchantment.
|
* @return The default maximum level of this enchantment.
|
||||||
|
|
@ -221,7 +230,7 @@ public interface CAEnchantment {
|
||||||
* @param key The enchantment key
|
* @param key The enchantment key
|
||||||
* @return Array of enchantment.
|
* @return Array of enchantment.
|
||||||
*/
|
*/
|
||||||
static @Nullable CAEnchantment getByKey(@NotNull NamespacedKey key){
|
static @Nullable CAEnchantment getByKey(@Nullable NamespacedKey key){
|
||||||
return CAEnchantmentRegistry.getInstance().getByKey(key);
|
return CAEnchantmentRegistry.getInstance().getByKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,7 @@ public class CAEnchantmentRegistry {
|
||||||
if ((!hasWarnedRegistering) && byNameMap.containsKey(enchantment.getName())) {
|
if ((!hasWarnedRegistering) && byNameMap.containsKey(enchantment.getName())) {
|
||||||
hasWarnedRegistering = true;
|
hasWarnedRegistering = true;
|
||||||
|
|
||||||
CustomAnvil.instance.getLogger().log(Level.WARNING,
|
CustomAnvil.Companion.log("Duplicate registered enchantment name. Please check that configuration is using namespace.");
|
||||||
"Duplicate registered enchantment name. Please check that configuration is using namespace.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
byKeyMap.put(enchantment.getKey(), enchantment);
|
byKeyMap.put(enchantment.getKey(), enchantment);
|
||||||
|
|
@ -151,7 +150,7 @@ public class CAEnchantmentRegistry {
|
||||||
* @return Registered enchantment. null if absent.
|
* @return Registered enchantment. null if absent.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public CAEnchantment getByKey(@NotNull NamespacedKey key) {
|
public CAEnchantment getByKey(@Nullable NamespacedKey key) {
|
||||||
return byKeyMap.get(key);
|
return byKeyMap.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package xyz.alexcrea.cuanvil.gui.config;
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import com.github.stefvanschie.inventoryframework.pane.PatternPane;
|
import com.github.stefvanschie.inventoryframework.pane.PatternPane;
|
||||||
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
|
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
|
||||||
import io.delilaheve.CustomAnvil;
|
import io.delilaheve.CustomAnvil;
|
||||||
|
|
@ -39,116 +40,142 @@ public class MainConfigGui extends ChestGui {
|
||||||
GuiGlobalItems.addBackgroundItem(pane);
|
GuiGlobalItems.addBackgroundItem(pane);
|
||||||
|
|
||||||
// Basic config item
|
// Basic config item
|
||||||
ItemStack basicConfigItemstack = new ItemStack(Material.COMMAND_BLOCK);
|
var basicConfigItem = basicConfigItem(new BasicConfigGui(packetManager));
|
||||||
ItemMeta basicConfigMeta = basicConfigItemstack.getItemMeta();
|
|
||||||
assert basicConfigMeta != null;
|
|
||||||
|
|
||||||
basicConfigMeta.setDisplayName("§aBasic Config Menu");
|
|
||||||
basicConfigMeta.setLore(Collections.singletonList("§7Click here to open basic config menu"));
|
|
||||||
basicConfigItemstack.setItemMeta(basicConfigMeta);
|
|
||||||
|
|
||||||
GuiItem basicConfigItem = GuiGlobalItems.goToGuiItem(basicConfigItemstack, new BasicConfigGui(packetManager));
|
|
||||||
pane.bindItem('1', basicConfigItem);
|
pane.bindItem('1', basicConfigItem);
|
||||||
|
|
||||||
// enchant level limit item
|
// enchant level limit item
|
||||||
ItemStack enchantLimitItemstack = new ItemStack(Material.ENCHANTED_BOOK);
|
var enchantLimitItem = enchantLimitItem(new EnchantLimitConfigGui());
|
||||||
ItemMeta enchantLimitMeta = enchantLimitItemstack.getItemMeta();
|
|
||||||
assert enchantLimitMeta != null;
|
|
||||||
|
|
||||||
enchantLimitMeta.setDisplayName("§aEnchantment Level Limit");
|
|
||||||
enchantLimitMeta.setLore(Collections.singletonList("§7Click here to open enchantment level limit menu"));
|
|
||||||
enchantLimitItemstack.setItemMeta(enchantLimitMeta);
|
|
||||||
|
|
||||||
GuiItem enchantLimitItem = GuiGlobalItems.goToGuiItem(enchantLimitItemstack, new EnchantLimitConfigGui());
|
|
||||||
pane.bindItem('2', enchantLimitItem);
|
pane.bindItem('2', enchantLimitItem);
|
||||||
|
|
||||||
// enchant level limit item
|
// enchant level limit item
|
||||||
ItemStack enchantMergeLimitItemstack = new ItemStack(Material.ENCHANTED_BOOK);
|
var enchantMergeLimitItem = enchantMergeLimitItem(new EnchantMergeLimitConfigGui());
|
||||||
ItemMeta enchantMergeLimitMeta = enchantMergeLimitItemstack.getItemMeta();
|
|
||||||
assert enchantMergeLimitMeta != null;
|
|
||||||
|
|
||||||
enchantMergeLimitMeta.setDisplayName("§aEnchantment Merge Limit");
|
|
||||||
enchantMergeLimitMeta.setLore(Collections.singletonList("§7Click here to open enchantment merge limit menu"));
|
|
||||||
enchantMergeLimitItemstack.setItemMeta(enchantMergeLimitMeta);
|
|
||||||
|
|
||||||
GuiItem enchantMergeLimitItem = GuiGlobalItems.goToGuiItem(enchantMergeLimitItemstack, new EnchantMergeLimitConfigGui());
|
|
||||||
pane.bindItem('3', enchantMergeLimitItem);
|
pane.bindItem('3', enchantMergeLimitItem);
|
||||||
|
|
||||||
// enchant cost item
|
// enchant cost item
|
||||||
ItemStack enchantCostItemstack = new ItemStack(Material.EXPERIENCE_BOTTLE);
|
var enchantCostItem = enchantCostItem(new EnchantCostConfigGui());
|
||||||
ItemMeta enchantCostMeta = enchantCostItemstack.getItemMeta();
|
|
||||||
assert enchantCostMeta != null;
|
|
||||||
|
|
||||||
enchantCostMeta.setDisplayName("§aEnchantment Cost");
|
|
||||||
enchantCostMeta.setLore(Collections.singletonList("§7Click here to open enchantment costs menu"));
|
|
||||||
enchantCostItemstack.setItemMeta(enchantCostMeta);
|
|
||||||
|
|
||||||
GuiItem enchantCostItem = GuiGlobalItems.goToGuiItem(enchantCostItemstack, new EnchantCostConfigGui());
|
|
||||||
pane.bindItem('4', enchantCostItem);
|
pane.bindItem('4', enchantCostItem);
|
||||||
|
|
||||||
// Enchantment Conflicts item
|
// Enchantment Conflicts item
|
||||||
ItemStack enchantConflictItemstack = new ItemStack(Material.OAK_FENCE);
|
var enchantConflictItem = enchantConflictItem(EnchantConflictGui.getInstance());
|
||||||
ItemMeta enchantConflictMeta = enchantConflictItemstack.getItemMeta();
|
|
||||||
assert enchantConflictMeta != null;
|
|
||||||
|
|
||||||
enchantConflictMeta.setDisplayName("§aEnchantment Conflict");
|
|
||||||
enchantConflictMeta.setLore(Collections.singletonList("§7Click here to open enchantment conflict menu"));
|
|
||||||
enchantConflictItemstack.setItemMeta(enchantConflictMeta);
|
|
||||||
|
|
||||||
GuiItem enchantConflictItem = GuiGlobalItems.goToGuiItem(enchantConflictItemstack, EnchantConflictGui.getInstance());
|
|
||||||
pane.bindItem('5', enchantConflictItem);
|
pane.bindItem('5', enchantConflictItem);
|
||||||
|
|
||||||
// Group config items
|
// Group config items
|
||||||
ItemStack groupItemstack = new ItemStack(Material.CHEST);
|
var groupConfigItem = groupConfigItem(GroupConfigGui.getInstance());
|
||||||
ItemMeta groupMeta = groupItemstack.getItemMeta();
|
|
||||||
assert groupMeta != null;
|
|
||||||
|
|
||||||
groupMeta.setDisplayName("§aItem Groups");
|
|
||||||
groupMeta.setLore(Collections.singletonList("§7Click here to open item group menu"));
|
|
||||||
groupItemstack.setItemMeta(groupMeta);
|
|
||||||
|
|
||||||
GuiItem groupConfigItem = GuiGlobalItems.goToGuiItem(groupItemstack, GroupConfigGui.getInstance());
|
|
||||||
|
|
||||||
pane.bindItem('6', groupConfigItem);
|
pane.bindItem('6', groupConfigItem);
|
||||||
|
|
||||||
// Unit repair item
|
// Unit repair item
|
||||||
ItemStack unirRepairItemstack = new ItemStack(Material.DIAMOND);
|
var unitRepairItem = unitRepairItem(UnitRepairConfigGui.getInstance());
|
||||||
ItemMeta unitRepairMeta = unirRepairItemstack.getItemMeta();
|
|
||||||
assert unitRepairMeta != null;
|
|
||||||
|
|
||||||
unitRepairMeta.setDisplayName("§aUnit Repair");
|
|
||||||
unitRepairMeta.setLore(Collections.singletonList("§7Click here to open anvil unit repair menu"));
|
|
||||||
unirRepairItemstack.setItemMeta(unitRepairMeta);
|
|
||||||
|
|
||||||
GuiItem unitRepairItem = GuiGlobalItems.goToGuiItem(unirRepairItemstack, UnitRepairConfigGui.getInstance());
|
|
||||||
pane.bindItem('7', unitRepairItem);
|
pane.bindItem('7', unitRepairItem);
|
||||||
|
|
||||||
// Custom recipe item
|
// Custom recipe item
|
||||||
ItemStack customRecipeItemstack = new ItemStack(Material.CRAFTING_TABLE);
|
var customRecipeItem = customRecipeItem(CustomRecipeConfigGui.getInstance());
|
||||||
ItemMeta customRecipeMeta = customRecipeItemstack.getItemMeta();
|
|
||||||
assert customRecipeMeta != null;
|
|
||||||
|
|
||||||
customRecipeMeta.setDisplayName("§aCustom recipes");
|
|
||||||
customRecipeMeta.setLore(Collections.singletonList("§7Click here to open anvil custom recipe menu"));
|
|
||||||
customRecipeItemstack.setItemMeta(customRecipeMeta);
|
|
||||||
|
|
||||||
GuiItem customRecipeItem = GuiGlobalItems.goToGuiItem(customRecipeItemstack, CustomRecipeConfigGui.getInstance());
|
|
||||||
pane.bindItem('8', customRecipeItem);
|
pane.bindItem('8', customRecipeItem);
|
||||||
|
|
||||||
// quit item
|
// quit item
|
||||||
ItemStack quitItemstack = new ItemStack(Material.BARRIER);
|
pane.bindItem('Q', quitItem());
|
||||||
ItemMeta quitMeta = quitItemstack.getItemMeta();
|
}
|
||||||
assert quitMeta != null;
|
|
||||||
|
|
||||||
quitMeta.setDisplayName("§cQuit");
|
public static GuiItem basicConfigItem(Gui target) {
|
||||||
quitItemstack.setItemMeta(quitMeta);
|
var item = new ItemStack(Material.COMMAND_BLOCK);
|
||||||
|
var meta = item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
GuiItem quitItem = new GuiItem(quitItemstack, event -> {
|
meta.setDisplayName("§aBasic Config Menu");
|
||||||
|
meta.setLore(Collections.singletonList("§7Click here to open basic config menu"));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
return GuiGlobalItems.goToGuiItem(item, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuiItem enchantLimitItem(Gui target) {
|
||||||
|
var item = new ItemStack(Material.ENCHANTED_BOOK);
|
||||||
|
var meta = item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("§aEnchantment Level Limit");
|
||||||
|
meta.setLore(Collections.singletonList("§7Click here to open enchantment level limit menu"));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
return GuiGlobalItems.goToGuiItem(item, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuiItem enchantMergeLimitItem(Gui target) {
|
||||||
|
ItemStack item = new ItemStack(Material.ENCHANTED_BOOK);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("§aEnchantment Merge Limit");
|
||||||
|
meta.setLore(Collections.singletonList("§7Click here to open enchantment merge limit menu"));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
return GuiGlobalItems.goToGuiItem(item, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuiItem enchantCostItem(Gui target) {
|
||||||
|
ItemStack item = new ItemStack(Material.EXPERIENCE_BOTTLE);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("§aEnchantment Cost");
|
||||||
|
meta.setLore(Collections.singletonList("§7Click here to open enchantment costs menu"));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
return GuiGlobalItems.goToGuiItem(item, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuiItem enchantConflictItem(Gui target) {
|
||||||
|
var item = new ItemStack(Material.OAK_FENCE);
|
||||||
|
var meta = item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("§aEnchantment Conflict");
|
||||||
|
meta.setLore(Collections.singletonList("§7Click here to open enchantment conflict menu"));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
return GuiGlobalItems.goToGuiItem(item, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuiItem groupConfigItem(Gui target) {
|
||||||
|
var item = new ItemStack(Material.CHEST);
|
||||||
|
var meta = item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("§aItem Groups");
|
||||||
|
meta.setLore(Collections.singletonList("§7Click here to open item group menu"));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
return GuiGlobalItems.goToGuiItem(item, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuiItem unitRepairItem(Gui target) {
|
||||||
|
var item = new ItemStack(Material.DIAMOND);
|
||||||
|
var meta = item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("§aUnit Repair");
|
||||||
|
meta.setLore(Collections.singletonList("§7Click here to open anvil unit repair menu"));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
|
return GuiGlobalItems.goToGuiItem(item, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuiItem customRecipeItem(Gui target) {
|
||||||
|
var item = new ItemStack(Material.CRAFTING_TABLE);
|
||||||
|
var meta = item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("§aCustom recipes");
|
||||||
|
meta.setLore(Collections.singletonList("§7Click here to open anvil custom recipe menu"));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
return GuiGlobalItems.goToGuiItem(item, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuiItem quitItem() {
|
||||||
|
var item = new ItemStack(Material.BARRIER);
|
||||||
|
var meta = item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("§cQuit");
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
|
return new GuiItem(item, event -> {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getWhoClicked().closeInventory();
|
event.getWhoClicked().closeInventory();
|
||||||
}, CustomAnvil.instance);
|
}, CustomAnvil.instance);
|
||||||
pane.bindItem('Q', quitItem);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
package xyz.alexcrea.cuanvil.gui.config.global;
|
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
|
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
||||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry;
|
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry;
|
||||||
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
|
||||||
import xyz.alexcrea.cuanvil.gui.config.list.SettingGuiListConfigGui;
|
import xyz.alexcrea.cuanvil.gui.config.list.SettingGuiListConfigGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.SettingGui;
|
import xyz.alexcrea.cuanvil.gui.config.settings.SettingGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||||
|
|
@ -31,13 +31,17 @@ public abstract class AbstractEnchantConfigGui<T extends SettingGui.SettingGuiFa
|
||||||
super(title);
|
super(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected AbstractEnchantConfigGui(String title, Gui parent) {
|
||||||
|
super(title, parent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateGuiValues() { //TODO maybe optimise it.
|
public void updateGuiValues() { //TODO maybe optimise it.
|
||||||
reloadValues();
|
reloadValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<CAEnchantment> getEveryDisplayableInstanceOfGeneric() {
|
protected Collection<CAEnchantment> getEveryInstanceOfGeneric() {
|
||||||
return CAEnchantmentRegistry.getInstance().getNameSortedEnchantments();
|
return CAEnchantmentRegistry.getInstance().getNameSortedEnchantments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,7 +77,7 @@ public abstract class AbstractEnchantConfigGui<T extends SettingGui.SettingGuiFa
|
||||||
this.pages.clear();
|
this.pages.clear();
|
||||||
this.pages.add(this.firstPage);
|
this.pages.add(this.firstPage);
|
||||||
|
|
||||||
for (CAEnchantment enchantment : getEveryDisplayableInstanceOfGeneric()) {
|
for (CAEnchantment enchantment : getDisplayableInstanceOfGeneric()) {
|
||||||
GuiItem item = this.guiItemMap.get(enchantment);
|
GuiItem item = this.guiItemMap.get(enchantment);
|
||||||
|
|
||||||
if(item == null) {
|
if(item == null) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package xyz.alexcrea.cuanvil.gui.config.global;
|
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
@ -40,6 +41,10 @@ public class CustomRecipeConfigGui extends MappedGuiListConfigGui<AnvilCustomRec
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CustomRecipeConfigGui(Gui parent) {
|
||||||
|
super("Custom Recipe Config", parent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack createItemForGeneric(AnvilCustomRecipe recipe) {
|
protected ItemStack createItemForGeneric(AnvilCustomRecipe recipe) {
|
||||||
// Get base item to display
|
// Get base item to display
|
||||||
|
|
@ -113,7 +118,7 @@ public class CustomRecipeConfigGui extends MappedGuiListConfigGui<AnvilCustomRec
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<AnvilCustomRecipe> getEveryDisplayableInstanceOfGeneric() {
|
protected Collection<AnvilCustomRecipe> getEveryInstanceOfGeneric() {
|
||||||
return ConfigHolder.CUSTOM_RECIPE_HOLDER.getRecipeManager().getRecipeList();
|
return ConfigHolder.CUSTOM_RECIPE_HOLDER.getRecipeManager().getRecipeList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,196 @@
|
||||||
|
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||||
|
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
|
import com.github.stefvanschie.inventoryframework.pane.PatternPane;
|
||||||
|
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
|
||||||
|
import io.delilaheve.CustomAnvil;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import xyz.alexcrea.cuanvil.api.EnchantmentApi;
|
||||||
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
|
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
||||||
|
import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
|
||||||
|
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
||||||
|
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui;
|
||||||
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||||
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class EnchantConfigGui extends ChestGui implements ValueUpdatableGui {
|
||||||
|
|
||||||
|
private final Set<CAEnchantment> enchantments;
|
||||||
|
private final PatternPane pane;
|
||||||
|
|
||||||
|
private EnchantLimitConfigGui enchantLimitConfigGui;
|
||||||
|
private EnchantMergeLimitConfigGui enchantMergeLimitConfigGui;
|
||||||
|
private EnchantCostConfigGui enchantCostConfigGui;
|
||||||
|
|
||||||
|
private EnchantConflictGui enchantConflictGui;
|
||||||
|
private GroupConfigGui groupConfigGui;
|
||||||
|
|
||||||
|
public EnchantConfigGui(@NotNull Set<CAEnchantment> enchantments) {
|
||||||
|
super(3,
|
||||||
|
"Configuring Enchantments",
|
||||||
|
CustomAnvil.instance);
|
||||||
|
this.enchantments = enchantments;
|
||||||
|
|
||||||
|
Pattern pattern = new Pattern(
|
||||||
|
"0000D0000",
|
||||||
|
"023405600",
|
||||||
|
"Q00000000"
|
||||||
|
);
|
||||||
|
pane = new PatternPane(0, 0, 9, 3, pattern);
|
||||||
|
addPane(pane);
|
||||||
|
|
||||||
|
GuiGlobalItems.addBackgroundItem(pane);
|
||||||
|
|
||||||
|
ItemStack displayItemstack = new ItemStack(Material.ENCHANTED_BOOK);
|
||||||
|
ItemMeta displayMeta = displayItemstack.getItemMeta();
|
||||||
|
assert displayMeta != null;
|
||||||
|
|
||||||
|
displayMeta.setDisplayName("§aConfiguring Enchantments:");
|
||||||
|
displayItemstack.setItemMeta(displayMeta);
|
||||||
|
|
||||||
|
// Set enchantments
|
||||||
|
HashMap<CAEnchantment, Integer> enchantmentMap = new HashMap<>();
|
||||||
|
for (CAEnchantment enchantment : enchantments) {
|
||||||
|
enchantmentMap.put(enchantment, 1);
|
||||||
|
}
|
||||||
|
EnchantmentApi.setEnchantments(displayItemstack, enchantmentMap);
|
||||||
|
|
||||||
|
pane.bindItem('D', new GuiItem(displayItemstack, GuiGlobalActions.stayInPlace, CustomAnvil.instance));
|
||||||
|
|
||||||
|
updateGuiValues();
|
||||||
|
|
||||||
|
// Enchantment Conflicts item
|
||||||
|
var enchantConflictItem = MainConfigGui.enchantConflictItem(getEnchantConflictGui());
|
||||||
|
pane.bindItem('5', enchantConflictItem);
|
||||||
|
|
||||||
|
// Group config items
|
||||||
|
var groupConfigItem = MainConfigGui.groupConfigItem(getGroupConfigGui());
|
||||||
|
pane.bindItem('6', groupConfigItem);
|
||||||
|
|
||||||
|
// quit item
|
||||||
|
pane.bindItem('Q', MainConfigGui.quitItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
private GuiItem enchantLimitConfigGui() {
|
||||||
|
if (enchantLimitConfigGui == null) {
|
||||||
|
enchantLimitConfigGui = new EnchantLimitConfigGui(this);
|
||||||
|
enchantLimitConfigGui.setFilter(enchantments::contains);
|
||||||
|
enchantLimitConfigGui.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bypass
|
||||||
|
if(enchantments.size() == 1) {
|
||||||
|
var enchant = enchantments.iterator().next();
|
||||||
|
var factory = EnchantLimitConfigGui.createFactory(enchant, this);
|
||||||
|
|
||||||
|
return enchantLimitConfigGui.itemFromFactory(enchant, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MainConfigGui.enchantLimitItem(enchantLimitConfigGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
private GuiItem enchantMergeLimitConfigGui() {
|
||||||
|
if (enchantMergeLimitConfigGui == null) {
|
||||||
|
enchantMergeLimitConfigGui = new EnchantMergeLimitConfigGui(this);
|
||||||
|
enchantMergeLimitConfigGui.setFilter(enchantments::contains);
|
||||||
|
enchantMergeLimitConfigGui.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bypass
|
||||||
|
if(enchantments.size() == 1) {
|
||||||
|
var enchant = enchantments.iterator().next();
|
||||||
|
var factory = EnchantMergeLimitConfigGui.createFactory(enchant, this);
|
||||||
|
|
||||||
|
return enchantMergeLimitConfigGui.itemFromFactory(enchant, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MainConfigGui.enchantMergeLimitItem(enchantMergeLimitConfigGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
private GuiItem enchantCostConfigGui() {
|
||||||
|
if (enchantCostConfigGui == null) {
|
||||||
|
enchantCostConfigGui = new EnchantCostConfigGui(this);
|
||||||
|
enchantCostConfigGui.setFilter(enchantments::contains);
|
||||||
|
enchantCostConfigGui.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bypass
|
||||||
|
if(enchantments.size() == 1) {
|
||||||
|
var enchant = enchantments.iterator().next();
|
||||||
|
var factory = EnchantCostConfigGui.createFactory(enchant, this);
|
||||||
|
|
||||||
|
return enchantCostConfigGui.itemFromFactory(enchant, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MainConfigGui.enchantCostItem(enchantCostConfigGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Contract(pure = true)
|
||||||
|
private Predicate<EnchantConflictGroup> getGroupFilter() {
|
||||||
|
return group -> group.getEnchants()
|
||||||
|
.stream()
|
||||||
|
.anyMatch(enchantments::contains);
|
||||||
|
}
|
||||||
|
|
||||||
|
private EnchantConflictGui getEnchantConflictGui() {
|
||||||
|
if (enchantConflictGui == null) {
|
||||||
|
enchantConflictGui = new EnchantConflictGui(this);
|
||||||
|
enchantConflictGui.setFilter(getGroupFilter());
|
||||||
|
enchantConflictGui.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
return enchantConflictGui;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GroupConfigGui getGroupConfigGui() {
|
||||||
|
if (groupConfigGui == null) {
|
||||||
|
groupConfigGui = new GroupConfigGui(this);
|
||||||
|
|
||||||
|
// Get all the conflict related to this enchantment
|
||||||
|
var groups = ConfigHolder.CONFLICT_HOLDER
|
||||||
|
.getConflictManager()
|
||||||
|
.getConflictList()
|
||||||
|
.stream()
|
||||||
|
.filter(getGroupFilter())
|
||||||
|
.map(EnchantConflictGroup::getCantConflictGroup)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
groupConfigGui.setFilter(group ->
|
||||||
|
groups.stream().anyMatch(other -> other.isReferencing(group))
|
||||||
|
);
|
||||||
|
groupConfigGui.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
return groupConfigGui;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateGuiValues() {
|
||||||
|
// enchant level limit item
|
||||||
|
pane.bindItem('2', enchantLimitConfigGui());
|
||||||
|
|
||||||
|
// enchant level limit item
|
||||||
|
pane.bindItem('3', enchantMergeLimitConfigGui());
|
||||||
|
|
||||||
|
// enchant cost item
|
||||||
|
pane.bindItem('4', enchantCostConfigGui());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Gui getConnectedGui() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package xyz.alexcrea.cuanvil.gui.config.global;
|
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
@ -35,6 +36,10 @@ public class EnchantConflictGui extends MappedGuiListConfigGui<EnchantConflictGr
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Need to init myself
|
||||||
|
public EnchantConflictGui(Gui parent) {
|
||||||
|
super("Conflict Config", parent);
|
||||||
|
}
|
||||||
|
|
||||||
private EnchantConflictGui() {
|
private EnchantConflictGui() {
|
||||||
super("Conflict Config");
|
super("Conflict Config");
|
||||||
|
|
@ -97,7 +102,7 @@ public class EnchantConflictGui extends MappedGuiListConfigGui<EnchantConflictGr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<EnchantConflictGroup> getEveryDisplayableInstanceOfGeneric() {
|
protected Collection<EnchantConflictGroup> getEveryInstanceOfGeneric() {
|
||||||
return ConfigHolder.CONFLICT_HOLDER.getConflictManager().getConflictList();
|
return ConfigHolder.CONFLICT_HOLDER.getConflictManager().getConflictList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
package xyz.alexcrea.cuanvil.gui.config.global;
|
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
||||||
import xyz.alexcrea.cuanvil.enchant.EnchantmentProperties;
|
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
||||||
import xyz.alexcrea.cuanvil.enchant.EnchantmentRarity;
|
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.EnchantCostSettingsGui;
|
import xyz.alexcrea.cuanvil.gui.config.settings.EnchantCostSettingsGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
|
|
@ -18,13 +18,13 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import static io.delilaheve.util.ConfigOptions.ENCHANT_VALUES_ROOT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global Config gui for enchantment cost settings.
|
* Global Config gui for enchantment cost settings.
|
||||||
*/
|
*/
|
||||||
public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSettingsGui.EnchantCostSettingFactory> {
|
public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSettingsGui.EnchantCostSettingFactory> {
|
||||||
|
|
||||||
private static final String SECTION_NAME = "enchant_values";
|
|
||||||
|
|
||||||
private static EnchantCostConfigGui INSTANCE = null;
|
private static EnchantCostConfigGui INSTANCE = null;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
@ -42,13 +42,24 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor of this Global gui for enchantment cost settings.
|
||||||
|
*/
|
||||||
|
public EnchantCostConfigGui(Gui parent) {
|
||||||
|
super("§8Enchantment Level Cost", parent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnchantCostSettingsGui.EnchantCostSettingFactory createFactory(CAEnchantment enchant) {
|
public EnchantCostSettingsGui.EnchantCostSettingFactory createFactory(CAEnchantment enchant) {
|
||||||
|
return createFactory(enchant, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnchantCostSettingsGui.EnchantCostSettingFactory createFactory(CAEnchantment enchant, ValueUpdatableGui parent) {
|
||||||
String key = enchant.getKey().toString().toLowerCase(Locale.ENGLISH);
|
String key = enchant.getKey().toString().toLowerCase(Locale.ENGLISH);
|
||||||
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
|
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
|
||||||
|
|
||||||
return new EnchantCostSettingsGui.EnchantCostSettingFactory(prettyKey + " Cost", this,
|
return new EnchantCostSettingsGui.EnchantCostSettingFactory(prettyKey + " Cost", parent,
|
||||||
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
|
ENCHANT_VALUES_ROOT + '.' + key, ConfigHolder.DEFAULT_CONFIG,
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"§7How many level should " + prettyKey,
|
"§7How many level should " + prettyKey,
|
||||||
"§7cost when applied by book or by another item."
|
"§7cost when applied by book or by another item."
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
package xyz.alexcrea.cuanvil.gui.config.global;
|
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import io.delilaheve.util.ConfigOptions;
|
import io.delilaheve.util.ConfigOptions;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
||||||
|
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.IntSettingsGui;
|
import xyz.alexcrea.cuanvil.gui.config.settings.IntSettingsGui;
|
||||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
|
|
||||||
|
|
@ -36,14 +38,22 @@ public class EnchantLimitConfigGui extends AbstractEnchantConfigGui<IntSettingsG
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EnchantLimitConfigGui(Gui parent) {
|
||||||
|
super("§8Enchantment Level Limit", parent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant) {
|
public IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant) {
|
||||||
|
return createFactory(enchant, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant, ValueUpdatableGui parent) {
|
||||||
String key = enchant.getKey().toString().toLowerCase(Locale.ROOT);
|
String key = enchant.getKey().toString().toLowerCase(Locale.ROOT);
|
||||||
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
|
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
|
||||||
|
|
||||||
var defaultValue = enchant.defaultMaxLevel();
|
var defaultValue = enchant.defaultMaxLevel();
|
||||||
|
|
||||||
return new IntSettingsGui.IntSettingFactory(prettyKey + " Limit", this,
|
return new IntSettingsGui.IntSettingFactory(prettyKey + " Limit", parent,
|
||||||
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
|
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
|
||||||
Collections.singletonList(
|
Collections.singletonList(
|
||||||
"§7Maximum applied level of " + prettyKey
|
"§7Maximum applied level of " + prettyKey
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
package xyz.alexcrea.cuanvil.gui.config.global;
|
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import io.delilaheve.util.ConfigOptions;
|
import io.delilaheve.util.ConfigOptions;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
||||||
|
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.IntSettingsGui;
|
import xyz.alexcrea.cuanvil.gui.config.settings.IntSettingsGui;
|
||||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
|
|
||||||
|
|
@ -33,12 +35,24 @@ public class EnchantMergeLimitConfigGui extends AbstractEnchantConfigGui<IntSett
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor of this Global gui for enchantment level limit settings.
|
||||||
|
*/
|
||||||
|
public EnchantMergeLimitConfigGui(Gui parent) {
|
||||||
|
super("§8Enchantment Maximum Merge Level", parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant) {
|
public IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant) {
|
||||||
|
return createFactory(enchant, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant, ValueUpdatableGui parent) {
|
||||||
String key = enchant.getKey().toString().toLowerCase(Locale.ROOT);
|
String key = enchant.getKey().toString().toLowerCase(Locale.ROOT);
|
||||||
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
|
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
|
||||||
|
|
||||||
return new IntSettingsGui.IntSettingFactory(prettyKey + " Merge Limit", this,
|
return new IntSettingsGui.IntSettingFactory(prettyKey + " Merge Limit", parent,
|
||||||
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
|
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"§7Maximum merge level for for " + prettyKey,
|
"§7Maximum merge level for for " + prettyKey,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package xyz.alexcrea.cuanvil.gui.config.global;
|
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
@ -43,6 +44,10 @@ public class GroupConfigGui extends MappedGuiListConfigGui<IncludeGroup, MappedG
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GroupConfigGui(Gui parent) {
|
||||||
|
super("Group Config", parent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack createItemForGeneric(IncludeGroup group) {
|
protected ItemStack createItemForGeneric(IncludeGroup group) {
|
||||||
ItemStack item = new ItemStack(group.getRepresentativeMaterial());
|
ItemStack item = new ItemStack(group.getRepresentativeMaterial());
|
||||||
|
|
@ -62,7 +67,7 @@ public class GroupConfigGui extends MappedGuiListConfigGui<IncludeGroup, MappedG
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<IncludeGroup> getEveryDisplayableInstanceOfGeneric() {
|
protected Collection<IncludeGroup> getEveryInstanceOfGeneric() {
|
||||||
ArrayList<IncludeGroup> includeGroups = new ArrayList<>();
|
ArrayList<IncludeGroup> includeGroups = new ArrayList<>();
|
||||||
|
|
||||||
for (AbstractMaterialGroup group : ConfigHolder.ITEM_GROUP_HOLDER.getItemGroupsManager().getGroupMap().values()) {
|
for (AbstractMaterialGroup group : ConfigHolder.ITEM_GROUP_HOLDER.getItemGroupsManager().getGroupMap().values()) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,132 @@
|
||||||
|
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||||
|
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
||||||
|
import com.github.stefvanschie.inventoryframework.pane.PatternPane;
|
||||||
|
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
|
||||||
|
import io.delilaheve.CustomAnvil;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
|
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui;
|
||||||
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||||
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||||
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
|
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
||||||
|
import xyz.alexcrea.cuanvil.util.UnitRepairUtil;
|
||||||
|
|
||||||
|
public class ItemConfigGui extends ChestGui {
|
||||||
|
|
||||||
|
private EnchantConflictGui enchantConflictGui;
|
||||||
|
private GroupConfigGui groupConfigGui;
|
||||||
|
private UnitRepairConfigGui unitRepairConfigGui;
|
||||||
|
private CustomRecipeConfigGui customRecipeConfigGui;
|
||||||
|
|
||||||
|
public ItemConfigGui(@NotNull Material display, @NotNull NamespacedKey material) {
|
||||||
|
super(3,
|
||||||
|
CasedStringUtil.snakeToUpperSpacedCase(
|
||||||
|
material.getKey().toLowerCase()
|
||||||
|
) + " Config",
|
||||||
|
CustomAnvil.instance);
|
||||||
|
|
||||||
|
Pattern pattern = new Pattern(
|
||||||
|
"0000D0000",
|
||||||
|
"056000780",
|
||||||
|
"Q00000000"
|
||||||
|
);
|
||||||
|
PatternPane pane = new PatternPane(0, 0, 9, 3, pattern);
|
||||||
|
addPane(pane);
|
||||||
|
|
||||||
|
GuiGlobalItems.addBackgroundItem(pane);
|
||||||
|
|
||||||
|
ItemStack displayItemstack = new ItemStack(display);
|
||||||
|
ItemMeta displayMeta = displayItemstack.getItemMeta();
|
||||||
|
assert displayMeta != null;
|
||||||
|
|
||||||
|
displayMeta.setDisplayName("§aConfiguring " + material);
|
||||||
|
displayItemstack.setItemMeta(displayMeta);
|
||||||
|
pane.bindItem('D', new GuiItem(displayItemstack, GuiGlobalActions.stayInPlace, CustomAnvil.instance));
|
||||||
|
|
||||||
|
// Enchantment Conflicts item
|
||||||
|
GuiItem enchantConflictItem = MainConfigGui.enchantConflictItem(getEnchantConflictGui(material));
|
||||||
|
pane.bindItem('5', enchantConflictItem);
|
||||||
|
|
||||||
|
// Group config items
|
||||||
|
GuiItem groupConfigItem = MainConfigGui.groupConfigItem(getGroupConfigGui(material));
|
||||||
|
pane.bindItem('6', groupConfigItem);
|
||||||
|
|
||||||
|
// Unit repair item
|
||||||
|
GuiItem unitRepairItem = MainConfigGui.unitRepairItem(getUnitRepairConfigGui(material));
|
||||||
|
pane.bindItem('7', unitRepairItem);
|
||||||
|
|
||||||
|
// Custom recipe item
|
||||||
|
GuiItem customRecipeItem = MainConfigGui.customRecipeItem(getCustomRecipeConfigGui(material));
|
||||||
|
pane.bindItem('8', customRecipeItem);
|
||||||
|
|
||||||
|
// quit item
|
||||||
|
pane.bindItem('Q', MainConfigGui.quitItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
private EnchantConflictGui getEnchantConflictGui(@NotNull NamespacedKey material) {
|
||||||
|
if (enchantConflictGui == null) {
|
||||||
|
enchantConflictGui = new EnchantConflictGui(this);
|
||||||
|
enchantConflictGui.setFilter(group ->
|
||||||
|
group.getCantConflictGroup().contain(material)
|
||||||
|
);
|
||||||
|
enchantConflictGui.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
return enchantConflictGui;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GroupConfigGui getGroupConfigGui(@NotNull NamespacedKey material) {
|
||||||
|
if (groupConfigGui == null) {
|
||||||
|
groupConfigGui = new GroupConfigGui(this);
|
||||||
|
groupConfigGui.setFilter(group ->
|
||||||
|
group.contain(material)
|
||||||
|
);
|
||||||
|
groupConfigGui.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
return groupConfigGui;
|
||||||
|
}
|
||||||
|
|
||||||
|
private UnitRepairConfigGui getUnitRepairConfigGui(@NotNull NamespacedKey material) {
|
||||||
|
if (unitRepairConfigGui == null) {
|
||||||
|
unitRepairConfigGui = new UnitRepairConfigGui(this);
|
||||||
|
unitRepairConfigGui.setFilter(otherMat ->
|
||||||
|
otherMat.equals(material) || UnitRepairUtil.INSTANCE.findRawRepairValue(
|
||||||
|
material, otherMat, ConfigHolder.UNIT_REPAIR_HOLDER.getConfig()) != null
|
||||||
|
);
|
||||||
|
unitRepairConfigGui.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
return unitRepairConfigGui;
|
||||||
|
}
|
||||||
|
|
||||||
|
private CustomRecipeConfigGui getCustomRecipeConfigGui(@NotNull NamespacedKey material) {
|
||||||
|
if (customRecipeConfigGui == null) {
|
||||||
|
customRecipeConfigGui = new CustomRecipeConfigGui(this);
|
||||||
|
customRecipeConfigGui.setFilter(recipe -> {
|
||||||
|
if (isMaterial(recipe.getLeftItem(), material)) return true;
|
||||||
|
if (isMaterial(recipe.getRightItem(), material)) return true;
|
||||||
|
return isMaterial(recipe.getResultItem(), material);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
customRecipeConfigGui.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
return customRecipeConfigGui;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isMaterial(@Nullable ItemStack item, @NotNull NamespacedKey material) {
|
||||||
|
if (item == null) return false;
|
||||||
|
|
||||||
|
return material.equals(MaterialUtil.INSTANCE.getCustomType(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package xyz.alexcrea.cuanvil.gui.config.global;
|
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import io.delilaheve.CustomAnvil;
|
import io.delilaheve.CustomAnvil;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
@ -13,13 +14,14 @@ import xyz.alexcrea.cuanvil.gui.config.ask.SelectItemTypeGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.list.MappedGuiListConfigGui;
|
import xyz.alexcrea.cuanvil.gui.config.list.MappedGuiListConfigGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.list.UnitRepairElementListGui;
|
import xyz.alexcrea.cuanvil.gui.config.list.UnitRepairElementListGui;
|
||||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
|
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class UnitRepairConfigGui extends
|
public class UnitRepairConfigGui extends
|
||||||
MappedGuiListConfigGui<Material, MappedGuiListConfigGui.LazyElement<UnitRepairElementListGui>> {
|
MappedGuiListConfigGui<NamespacedKey, MappedGuiListConfigGui.LazyElement<UnitRepairElementListGui>> {
|
||||||
|
|
||||||
private static UnitRepairConfigGui INSTANCE;
|
private static UnitRepairConfigGui INSTANCE;
|
||||||
|
|
||||||
|
|
@ -41,8 +43,12 @@ public class UnitRepairConfigGui extends
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UnitRepairConfigGui(Gui parent) {
|
||||||
|
super("Unit Repair Config", parent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LazyElement<UnitRepairElementListGui> newInstanceOfGui(Material material, GuiItem item) {
|
protected LazyElement<UnitRepairElementListGui> newInstanceOfGui(NamespacedKey material, GuiItem item) {
|
||||||
return new LazyElement<>(item, () -> {
|
return new LazyElement<>(item, () -> {
|
||||||
UnitRepairElementListGui element = new UnitRepairElementListGui(material, this);
|
UnitRepairElementListGui element = new UnitRepairElementListGui(material, this);
|
||||||
element.init();
|
element.init();
|
||||||
|
|
@ -51,17 +57,28 @@ public class UnitRepairConfigGui extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack createItemForGeneric(Material material) {
|
protected ItemStack createItemForGeneric(@NotNull NamespacedKey material) {
|
||||||
ConfigurationSection materialSection = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().getConfigurationSection(material.name().toLowerCase());
|
var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
||||||
String materialName = CasedStringUtil.snakeToUpperSpacedCase(material.name().toLowerCase());
|
var section = unitConfig.getConfigurationSection(material.toString().toLowerCase());
|
||||||
|
var legacySection = unitConfig.getConfigurationSection(material.getKey().toLowerCase());
|
||||||
|
|
||||||
if(material.isAir()){
|
String materialName = CasedStringUtil.snakeToUpperSpacedCase(material.getKey().toLowerCase());
|
||||||
material = Material.BARRIER;
|
|
||||||
|
var display = MaterialUtil.INSTANCE.getMatFromKey(material);
|
||||||
|
|
||||||
|
if (display == null || display.isAir()) {
|
||||||
|
display = Material.BARRIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int reparableItemCount = materialSection == null ? 0 : materialSection.getKeys(false).size(); // Probably an expensive call but... why not
|
var reparable = new HashSet<String>();
|
||||||
|
if (section != null)
|
||||||
|
reparable.addAll(section.getKeys(false));
|
||||||
|
if (legacySection != null)
|
||||||
|
reparable.addAll(legacySection.getKeys(false));
|
||||||
|
|
||||||
ItemStack item = new ItemStack(material);
|
var reparableItemCount = reparable.size();
|
||||||
|
|
||||||
|
ItemStack item = new ItemStack(display);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
|
|
||||||
|
|
@ -77,13 +94,16 @@ public class UnitRepairConfigGui extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<Material> getEveryDisplayableInstanceOfGeneric() {
|
protected Collection<NamespacedKey> getEveryInstanceOfGeneric() {
|
||||||
ArrayList<Material> materials = new ArrayList<>();
|
var materials = new HashSet<NamespacedKey>();
|
||||||
|
var config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
||||||
|
|
||||||
for (String matName : ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().getKeys(false)) {
|
for (String matName : config.getKeys(false)) {
|
||||||
Material mat = Material.getMaterial(matName.toUpperCase());
|
if(!config.isConfigurationSection(matName)) continue;
|
||||||
if(mat != null){
|
|
||||||
materials.add(mat);
|
NamespacedKey material = NamespacedKey.fromString(matName.toLowerCase());
|
||||||
|
if (material != null) {
|
||||||
|
materials.add(material);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return materials;
|
return materials;
|
||||||
|
|
@ -113,7 +133,7 @@ public class UnitRepairConfigGui extends
|
||||||
"§7You like to be an unit repair item",
|
"§7You like to be an unit repair item",
|
||||||
this,
|
this,
|
||||||
(itemStack, player) -> {
|
(itemStack, player) -> {
|
||||||
Material type = itemStack.getType();
|
NamespacedKey type = MaterialUtil.INSTANCE.getCustomType(itemStack);
|
||||||
// Add new material
|
// Add new material
|
||||||
updateValueForGeneric(type, true);
|
updateValueForGeneric(type, true);
|
||||||
|
|
||||||
|
|
@ -126,7 +146,7 @@ public class UnitRepairConfigGui extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public LazyElement<UnitRepairElementListGui> getInstanceOrCreate(Material mat){
|
public LazyElement<UnitRepairElementListGui> getInstanceOrCreate(NamespacedKey mat) {
|
||||||
LazyElement<UnitRepairElementListGui> element = this.elementGuiMap.get(mat);
|
LazyElement<UnitRepairElementListGui> element = this.elementGuiMap.get(mat);
|
||||||
if (element == null) {
|
if (element == null) {
|
||||||
updateValueForGeneric(mat, false);
|
updateValueForGeneric(mat, false);
|
||||||
|
|
@ -141,8 +161,10 @@ public class UnitRepairConfigGui extends
|
||||||
protected String genericDisplayedName() {
|
protected String genericDisplayedName() {
|
||||||
return "this function Should not be used.";
|
return "this function Should not be used.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Not used in this implementation.
|
@Override // Not used in this implementation.
|
||||||
protected Material createAndSaveNewEmptyGeneric(String name) {
|
protected NamespacedKey createAndSaveNewEmptyGeneric(String name) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,18 +23,22 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public abstract class ElementListConfigGui<T> extends ChestGui implements ValueUpdatableGui {
|
public abstract class ElementListConfigGui<T> extends ChestGui implements ValueUpdatableGui {
|
||||||
|
|
||||||
private final String namePrefix;
|
|
||||||
|
|
||||||
protected PatternPane backgroundPane;
|
|
||||||
|
|
||||||
public static final int LIST_FILLER_START_X = 1;
|
public static final int LIST_FILLER_START_X = 1;
|
||||||
public static final int LIST_FILLER_START_Y = 1;
|
public static final int LIST_FILLER_START_Y = 1;
|
||||||
public static final int LIST_FILLER_LENGTH = 7;
|
public static final int LIST_FILLER_LENGTH = 7;
|
||||||
public static final int LIST_FILLER_HEIGHT = 4;
|
public static final int LIST_FILLER_HEIGHT = 4;
|
||||||
|
|
||||||
|
private final String namePrefix;
|
||||||
|
|
||||||
|
protected PatternPane backgroundPane;
|
||||||
|
|
||||||
|
private Predicate<T> filter = (t) -> true;
|
||||||
|
private boolean hasDefaultFilter = true;
|
||||||
|
|
||||||
protected ElementListConfigGui(@NotNull String title, Gui parent) {
|
protected ElementListConfigGui(@NotNull String title, Gui parent) {
|
||||||
super(6, title, CustomAnvil.instance);
|
super(6, title, CustomAnvil.instance);
|
||||||
this.namePrefix = title;
|
this.namePrefix = title;
|
||||||
|
|
@ -46,6 +50,11 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFilter(Predicate<T> filter) {
|
||||||
|
this.filter = filter;
|
||||||
|
this.hasDefaultFilter = false;
|
||||||
|
}
|
||||||
|
|
||||||
protected Pattern getBackgroundPattern() {
|
protected Pattern getBackgroundPattern() {
|
||||||
return new Pattern(
|
return new Pattern(
|
||||||
GuiSharedConstant.UPPER_FILLER_FULL_PLANE,
|
GuiSharedConstant.UPPER_FILLER_FULL_PLANE,
|
||||||
|
|
@ -61,7 +70,7 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
|
||||||
protected ArrayList<OutlinePane> pages;
|
protected ArrayList<OutlinePane> pages;
|
||||||
protected HashMap<UUID, Integer> pageMap;
|
protected HashMap<UUID, Integer> pageMap;
|
||||||
|
|
||||||
public void init() { // Why I'm using an init function ? //TODO determine why is it using a init function and not used on constructor.
|
public void init() {
|
||||||
GuiGlobalItems.addBackgroundItem(this.backgroundPane);
|
GuiGlobalItems.addBackgroundItem(this.backgroundPane);
|
||||||
this.backgroundPane.bindItem('1', GuiSharedConstant.SECONDARY_BACKGROUND_ITEM);
|
this.backgroundPane.bindItem('1', GuiSharedConstant.SECONDARY_BACKGROUND_ITEM);
|
||||||
addPane(this.backgroundPane);
|
addPane(this.backgroundPane);
|
||||||
|
|
@ -112,17 +121,23 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
|
||||||
viewer.setItemOnCursor(cursor);
|
viewer.setItemOnCursor(cursor);
|
||||||
}, CustomAnvil.instance);
|
}, CustomAnvil.instance);
|
||||||
|
|
||||||
GuiItem createNew = prepareCreateNewItem();
|
GuiItem createNew;
|
||||||
|
if(hasDefaultFilter)
|
||||||
|
createNew = prepareCreateNewItem();
|
||||||
|
else
|
||||||
|
createNew = GuiSharedConstant.SECONDARY_BACKGROUND_ITEM;
|
||||||
|
|
||||||
if (createNew != null) {
|
if (createNew != null) {
|
||||||
this.backgroundPane.bindItem('C', createNew);
|
this.backgroundPane.bindItem('C', createNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void reloadValues() {
|
protected void reloadValues() {
|
||||||
this.firstPage.clear();
|
this.firstPage.clear();
|
||||||
this.pages.clear();
|
this.pages.clear();
|
||||||
this.pages.add(this.firstPage);
|
this.pages.add(this.firstPage);
|
||||||
|
|
||||||
for (T generic : getEveryDisplayableInstanceOfGeneric()) {
|
for (T generic : getDisplayableInstanceOfGeneric()) {
|
||||||
updateValueForGeneric(generic, false);
|
updateValueForGeneric(generic, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -300,7 +315,11 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
|
||||||
|
|
||||||
protected abstract void updateGeneric(T generic, ItemStack usedItem);
|
protected abstract void updateGeneric(T generic, ItemStack usedItem);
|
||||||
|
|
||||||
protected abstract Collection<T> getEveryDisplayableInstanceOfGeneric();
|
protected abstract Collection<T> getEveryInstanceOfGeneric();
|
||||||
|
|
||||||
|
protected Collection<T> getDisplayableInstanceOfGeneric() {
|
||||||
|
return getEveryInstanceOfGeneric().stream().filter(filter).toList();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateGuiValues() {
|
public void updateGuiValues() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package xyz.alexcrea.cuanvil.gui.config.list;
|
package xyz.alexcrea.cuanvil.gui.config.list;
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import io.delilaheve.CustomAnvil;
|
import io.delilaheve.CustomAnvil;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
|
@ -17,12 +18,17 @@ import java.util.function.Consumer;
|
||||||
public abstract class MappedElementListConfigGui<T, S> extends ElementListConfigGui<T> {
|
public abstract class MappedElementListConfigGui<T, S> extends ElementListConfigGui<T> {
|
||||||
|
|
||||||
protected final HashMap<T, S> elementGuiMap;
|
protected final HashMap<T, S> elementGuiMap;
|
||||||
protected MappedElementListConfigGui(@NotNull String title) {
|
|
||||||
super(title, MainConfigGui.getInstance());
|
protected MappedElementListConfigGui(@NotNull String title, @NotNull Gui parent) {
|
||||||
|
super(title, parent);
|
||||||
this.elementGuiMap = new HashMap<>();
|
this.elementGuiMap = new HashMap<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected MappedElementListConfigGui(@NotNull String title) {
|
||||||
|
this(title, MainConfigGui.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GuiItem prepareCreateNewItem() {
|
protected GuiItem prepareCreateNewItem() {
|
||||||
// Create new conflict item
|
// Create new conflict item
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package xyz.alexcrea.cuanvil.gui.config.list;
|
package xyz.alexcrea.cuanvil.gui.config.list;
|
||||||
|
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import io.delilaheve.CustomAnvil;
|
import io.delilaheve.CustomAnvil;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
@ -19,7 +20,10 @@ public abstract class MappedGuiListConfigGui< T, S extends MappedGuiListConfigGu
|
||||||
|
|
||||||
protected MappedGuiListConfigGui(@NotNull String title) {
|
protected MappedGuiListConfigGui(@NotNull String title) {
|
||||||
super(title);
|
super(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MappedGuiListConfigGui(@NotNull String title, @NotNull Gui parent) {
|
||||||
|
super(title, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -80,7 +84,7 @@ public abstract class MappedGuiListConfigGui< T, S extends MappedGuiListConfigGu
|
||||||
|
|
||||||
// Try to find if it already exists in a for loop
|
// Try to find if it already exists in a for loop
|
||||||
// Not the most efficient on large number of conflict, but it should not run often.
|
// Not the most efficient on large number of conflict, but it should not run often.
|
||||||
for (T generic : getEveryDisplayableInstanceOfGeneric()) {
|
for (T generic : getDisplayableInstanceOfGeneric()) {
|
||||||
if (generic.toString().equalsIgnoreCase(message)) {
|
if (generic.toString().equalsIgnoreCase(message)) {
|
||||||
player.sendMessage("§cPlease enter a " + genericDisplayedName() + " name that do not already exist...");
|
player.sendMessage("§cPlease enter a " + genericDisplayedName() + " name that do not already exist...");
|
||||||
// wait next message.
|
// wait next message.
|
||||||
|
|
@ -117,6 +121,7 @@ public abstract class MappedGuiListConfigGui< T, S extends MappedGuiListConfigGu
|
||||||
|
|
||||||
private final GuiItem parentItem;
|
private final GuiItem parentItem;
|
||||||
private final LazyValue<Consumer<InventoryClickEvent>> lazyOpenConsumer;
|
private final LazyValue<Consumer<InventoryClickEvent>> lazyOpenConsumer;
|
||||||
|
|
||||||
public LazyElement(GuiItem parentItem, Supplier<T> valueSupplier) {
|
public LazyElement(GuiItem parentItem, Supplier<T> valueSupplier) {
|
||||||
super(valueSupplier);
|
super(valueSupplier);
|
||||||
this.parentItem = parentItem;
|
this.parentItem = parentItem;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ public abstract class SettingGuiListConfigGui< T, S extends SettingGui.SettingGu
|
||||||
|
|
||||||
protected HashMap<T, GuiItem> guiItemMap;
|
protected HashMap<T, GuiItem> guiItemMap;
|
||||||
protected HashMap<T, S> factoryMap;
|
protected HashMap<T, S> factoryMap;
|
||||||
|
|
||||||
protected SettingGuiListConfigGui(@NotNull String title, Gui parent) {
|
protected SettingGuiListConfigGui(@NotNull String title, Gui parent) {
|
||||||
super(title, parent);
|
super(title, parent);
|
||||||
this.guiItemMap = new HashMap<>();
|
this.guiItemMap = new HashMap<>();
|
||||||
|
|
@ -86,17 +87,22 @@ public abstract class SettingGuiListConfigGui< T, S extends SettingGui.SettingGu
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Not used
|
@Override // Not used
|
||||||
protected void updateGeneric(T generic, ItemStack usedItem) {}
|
protected void updateGeneric(T generic, ItemStack usedItem) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override // Not used
|
@Override // Not used
|
||||||
protected ItemStack createItemForGeneric(T generic) {
|
protected ItemStack createItemForGeneric(T generic) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract List<String> getCreateItemLore();
|
protected abstract List<String> getCreateItemLore();
|
||||||
|
|
||||||
protected abstract Consumer<InventoryClickEvent> getCreateClickConsumer();
|
protected abstract Consumer<InventoryClickEvent> getCreateClickConsumer();
|
||||||
|
|
||||||
protected abstract String createItemName();
|
protected abstract String createItemName();
|
||||||
|
|
||||||
protected abstract S createFactory(T generic);
|
protected abstract S createFactory(T generic);
|
||||||
|
|
||||||
protected abstract GuiItem itemFromFactory(T generic, S factory);
|
protected abstract GuiItem itemFromFactory(T generic, S factory);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,14 @@ package xyz.alexcrea.cuanvil.gui.config.list;
|
||||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||||
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.meta.Damageable;
|
import org.bukkit.inventory.meta.Damageable;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.ask.SelectItemTypeGui;
|
import xyz.alexcrea.cuanvil.gui.config.ask.SelectItemTypeGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.global.UnitRepairConfigGui;
|
import xyz.alexcrea.cuanvil.gui.config.global.UnitRepairConfigGui;
|
||||||
|
|
@ -17,26 +19,25 @@ import xyz.alexcrea.cuanvil.gui.config.settings.DoubleSettingGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
|
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, DoubleSettingGui.DoubleSettingFactory> implements ElementMappedToListGui {
|
public class UnitRepairElementListGui extends SettingGuiListConfigGui<NamespacedKey, DoubleSettingGui.DoubleSettingFactory> implements ElementMappedToListGui {
|
||||||
|
|
||||||
private final Material parentMaterial;
|
private final NamespacedKey parentMaterial;
|
||||||
private final UnitRepairConfigGui parentGui;
|
private final UnitRepairConfigGui parentGui;
|
||||||
private final String materialName;
|
private final String materialName;
|
||||||
|
|
||||||
private boolean shouldWork = true;
|
private boolean shouldWork = true;
|
||||||
public UnitRepairElementListGui(@NotNull Material parentMaterial,
|
|
||||||
|
public UnitRepairElementListGui(@NotNull NamespacedKey parentMaterial,
|
||||||
@NotNull UnitRepairConfigGui parentGui) {
|
@NotNull UnitRepairConfigGui parentGui) {
|
||||||
super("§e" + CasedStringUtil.snakeToUpperSpacedCase(parentMaterial.name().toLowerCase()) + " §rUnit repair");
|
super("§e" + CasedStringUtil.snakeToUpperSpacedCase(parentMaterial.getKey().toLowerCase()) + " §rUnit repair");
|
||||||
this.parentMaterial = parentMaterial;
|
this.parentMaterial = parentMaterial;
|
||||||
this.parentGui = parentGui;
|
this.parentGui = parentGui;
|
||||||
this.materialName = CasedStringUtil.snakeToUpperSpacedCase(parentMaterial.name().toLowerCase());
|
this.materialName = CasedStringUtil.snakeToUpperSpacedCase(parentMaterial.getKey().toLowerCase());
|
||||||
|
|
||||||
GuiGlobalItems.addBackItem(this.backgroundPane, parentGui);
|
GuiGlobalItems.addBackItem(this.backgroundPane, parentGui);
|
||||||
}
|
}
|
||||||
|
|
@ -66,28 +67,28 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
|
||||||
this,
|
this,
|
||||||
(itemStack, player) -> {
|
(itemStack, player) -> {
|
||||||
ItemMeta meta = itemStack.getItemMeta();
|
ItemMeta meta = itemStack.getItemMeta();
|
||||||
Material type = itemStack.getType();
|
NamespacedKey type = MaterialUtil.INSTANCE.getCustomType(itemStack);
|
||||||
|
|
||||||
if(!(meta instanceof Damageable) || (type.getMaxDurability() <= 0)) {
|
if (!(meta instanceof Damageable)) {
|
||||||
player.sendMessage("§cThis item can't be damaged, so it can't be repaired.");
|
player.sendMessage("§cThis item can't be damaged, so it can't be repaired.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(type == this.parentMaterial){
|
if (type.equals(this.parentMaterial)) {
|
||||||
player.sendMessage("§cItem can't repair something of the same type.");
|
player.sendMessage("§cItem can't repair something of the same type.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String materialName = type.name().toLowerCase();
|
String materialName = type.toString();
|
||||||
|
|
||||||
// Add new material
|
// Add new material
|
||||||
ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().set(parentMaterial.name().toLowerCase() + "." + materialName,0.25);
|
ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().set(parentMaterial.toString().toLowerCase() + "." + materialName, 0.25);
|
||||||
|
|
||||||
if (GuiSharedConstant.TEMPORARY_DO_SAVE_TO_DISK_EVERY_CHANGE) {
|
if (GuiSharedConstant.TEMPORARY_DO_SAVE_TO_DISK_EVERY_CHANGE) {
|
||||||
ConfigHolder.UNIT_REPAIR_HOLDER.saveToDisk(GuiSharedConstant.TEMPORARY_DO_BACKUP_EVERY_SAVE);
|
ConfigHolder.UNIT_REPAIR_HOLDER.saveToDisk(GuiSharedConstant.TEMPORARY_DO_BACKUP_EVERY_SAVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update gui
|
// Update gui
|
||||||
updateValueForGeneric(materialName, true);
|
updateValueForGeneric(type, true);
|
||||||
this.parentGui.updateValueForGeneric(this.parentMaterial, true);
|
this.parentGui.updateValueForGeneric(this.parentMaterial, true);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -106,14 +107,14 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DoubleSettingGui.DoubleSettingFactory createFactory(String materialName) {
|
protected DoubleSettingGui.DoubleSettingFactory createFactory(NamespacedKey materialName) {
|
||||||
String materialDisplayName = CasedStringUtil.snakeToUpperSpacedCase(materialName);
|
String materialDisplayName = CasedStringUtil.snakeToUpperSpacedCase(materialName.getKey());
|
||||||
|
|
||||||
return new DoubleSettingGui.DoubleSettingFactory(
|
return new DoubleSettingGui.DoubleSettingFactory(
|
||||||
"§0%§8" + materialDisplayName + " Repair",
|
"§0%§8" + materialDisplayName + " Repair",
|
||||||
this,
|
this,
|
||||||
ConfigHolder.UNIT_REPAIR_HOLDER,
|
ConfigHolder.UNIT_REPAIR_HOLDER,
|
||||||
this.parentMaterial.name().toLowerCase()+"."+materialName,
|
this.parentMaterial.toString().toLowerCase() + "." + materialName,
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"§7Click here to change how many §e% §7of §a" + materialDisplayName,
|
"§7Click here to change how many §e% §7of §a" + materialDisplayName,
|
||||||
"§7Should get repaired by §e" + this.materialName
|
"§7Should get repaired by §e" + this.materialName
|
||||||
|
|
@ -128,28 +129,39 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GuiItem itemFromFactory(String materialName, DoubleSettingGui.DoubleSettingFactory factory) {
|
protected GuiItem itemFromFactory(NamespacedKey materialName, DoubleSettingGui.DoubleSettingFactory factory) {
|
||||||
return factory.getItem(materialFromName(materialName),
|
return factory.getItem(materialFromName(materialName),
|
||||||
"§7%§a" + CasedStringUtil.snakeToUpperSpacedCase(materialName)+ " §erepaired by §a" + this.materialName);
|
"§7%§a" + CasedStringUtil.snakeToUpperSpacedCase(materialName.getKey()) + " §erepaired by §a" + this.materialName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<String> getEveryDisplayableInstanceOfGeneric() {
|
protected Collection<NamespacedKey> getEveryInstanceOfGeneric() {
|
||||||
ArrayList<String> keys = new ArrayList<>();
|
Set<NamespacedKey> keys = new HashSet<>();
|
||||||
if (!this.shouldWork) {
|
if (!this.shouldWork) {
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationSection materialSection = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().getConfigurationSection(parentMaterial.name().toLowerCase());
|
ConfigurationSection legacySection = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().getConfigurationSection(parentMaterial.getKey().toLowerCase());
|
||||||
if(materialSection == null){
|
ConfigurationSection materialSection = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().getConfigurationSection(parentMaterial.toString().toLowerCase());
|
||||||
return keys;
|
|
||||||
}
|
addAllKeys(legacySection, keys);
|
||||||
keys.addAll(materialSection.getKeys(false));
|
addAllKeys(materialSection, keys);
|
||||||
|
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Material materialFromName(String materialName){
|
private void addAllKeys(@Nullable ConfigurationSection section, @NotNull Set<NamespacedKey> keys) {
|
||||||
Material mat = Material.getMaterial(materialName.toUpperCase());
|
if (section == null) return;
|
||||||
|
for (var key : section.getKeys(false)) {
|
||||||
|
var material = NamespacedKey.fromString(key);
|
||||||
|
if (material == null) continue;
|
||||||
|
|
||||||
|
keys.add(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Material materialFromName(NamespacedKey material) {
|
||||||
|
Material mat = MaterialUtil.INSTANCE.getMatFromKey(material);
|
||||||
if (mat == null || mat.isAir()) return Material.BARRIER;
|
if (mat == null || mat.isAir()) return Material.BARRIER;
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
@ -163,7 +175,8 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
|
||||||
// ElementMappedToListGui methods
|
// ElementMappedToListGui methods
|
||||||
|
|
||||||
@Override // Not used in this implementation
|
@Override // Not used in this implementation
|
||||||
public void updateLocal() {}
|
public void updateLocal() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanAndBeUnusable() {
|
public void cleanAndBeUnusable() {
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,6 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
|
||||||
}
|
}
|
||||||
pane.bindItem('D', returnToDefault);
|
pane.bindItem('D', returnToDefault);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -285,14 +284,14 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getConfiguredValue() {
|
public int getConfiguredValue() {
|
||||||
return ConfigOptions.INSTANCE.enchantmentValue(enchantment, false);
|
return ConfigOptions.INSTANCE.enchantmentValue(enchantment, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The configured value for the enchant setting book value.
|
* @return The configured value for the enchant setting book value.
|
||||||
*/
|
*/
|
||||||
public int getConfiguredBookValue() {
|
public int getConfiguredBookValue() {
|
||||||
return ConfigOptions.INSTANCE.enchantmentValue(enchantment, true);
|
return ConfigOptions.INSTANCE.enchantmentValue(enchantment, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class EnchantSelectSettingGui extends SettingGuiListConfigGui<CAEnchantme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<CAEnchantment> getEveryDisplayableInstanceOfGeneric() {
|
protected Collection<CAEnchantment> getEveryInstanceOfGeneric() {
|
||||||
Stream<CAEnchantment> toDisplayStream;
|
Stream<CAEnchantment> toDisplayStream;
|
||||||
if(this.displayUnselected){
|
if(this.displayUnselected){
|
||||||
toDisplayStream = CAEnchantmentRegistry.getInstance().getNameSortedEnchantments().stream();
|
toDisplayStream = CAEnchantmentRegistry.getInstance().getNameSortedEnchantments().stream();
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Namespa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<NamespacedKey> getEveryDisplayableInstanceOfGeneric() {
|
protected Collection<NamespacedKey> getEveryInstanceOfGeneric() {
|
||||||
return this.defaultMaterials;
|
return this.defaultMaterials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,7 @@ package xyz.alexcrea.cuanvil.update;
|
||||||
|
|
||||||
import io.delilaheve.CustomAnvil;
|
import io.delilaheve.CustomAnvil;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.update.minecraft.MCUpdate;
|
import xyz.alexcrea.cuanvil.update.minecraft.*;
|
||||||
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_21;
|
|
||||||
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_21_11;
|
|
||||||
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_21_9;
|
|
||||||
import xyz.alexcrea.cuanvil.update.plugin.*;
|
import xyz.alexcrea.cuanvil.update.plugin.*;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
@ -32,10 +29,13 @@ public class UpdateHandler {
|
||||||
new Version(1, 8, 0), PUpdate_1_8_0::handleUpdate,
|
new Version(1, 8, 0), PUpdate_1_8_0::handleUpdate,
|
||||||
new Version(1, 11, 0), PUpdate_1_11_0::handleUpdate,
|
new Version(1, 11, 0), PUpdate_1_11_0::handleUpdate,
|
||||||
new Version(1, 15, 5), PUpdate_1_15_5::handleUpdate,
|
new Version(1, 15, 5), PUpdate_1_15_5::handleUpdate,
|
||||||
new Version(1, 15, 6), PUpdate_1_15_6::handleUpdate
|
new Version(1, 15, 6), PUpdate_1_15_6::handleUpdate,
|
||||||
|
new Version(1, 18, 0), PUpdate_1_18::handleUpdate
|
||||||
);
|
);
|
||||||
|
|
||||||
private static final List<MCUpdate> mcUpdateMap = List.of(
|
private static final List<MCUpdate> mcUpdateMap = List.of(
|
||||||
|
new Update_1_19(),
|
||||||
|
new Update_1_20_5(),
|
||||||
new Update_1_21(),
|
new Update_1_21(),
|
||||||
new Update_1_21_9(),
|
new Update_1_21_9(),
|
||||||
new Update_1_21_11()
|
new Update_1_21_11()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package xyz.alexcrea.cuanvil.update;
|
package xyz.alexcrea.cuanvil.update;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -33,4 +34,20 @@ public class UpdateUtils {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean removeFromList(FileConfiguration config, String path, String toRemove) {
|
||||||
|
List<String> groups = new ArrayList<>(config.getStringList(path));
|
||||||
|
if (!groups.remove(toRemove)) return false;
|
||||||
|
|
||||||
|
config.set(path, groups);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void mergeSections(ConfigurationSection source, ConfigurationSection target) {
|
||||||
|
for (String key : source.getKeys(false)) {
|
||||||
|
if(target.contains(key)) continue;
|
||||||
|
target.set(key, source.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package xyz.alexcrea.cuanvil.update.minecraft;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
|
import xyz.alexcrea.cuanvil.update.Version;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static xyz.alexcrea.cuanvil.update.UpdateUtils.addAbsentToList;
|
||||||
|
|
||||||
|
public class Update_1_19 extends MCUpdate {
|
||||||
|
|
||||||
|
public Update_1_19() {
|
||||||
|
super(new Version(1, 19));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doUpdate() {
|
||||||
|
var tosave = new HashSet<ConfigHolder>();
|
||||||
|
updateName(tosave);
|
||||||
|
|
||||||
|
for (ConfigHolder holder : tosave) {
|
||||||
|
holder.saveToDisk(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void updateName(@NotNull Set<ConfigHolder> tosave) {
|
||||||
|
var conflict = ConfigHolder.CONFLICT_HOLDER.getConfig();
|
||||||
|
|
||||||
|
addAbsentToList(conflict, "restriction_swift_sneak.enchantments", "minecraft:swift_sneak");
|
||||||
|
addAbsentToList(conflict, "restriction_swift_sneak.notAffectedGroups", "leggings", "enchanted_book");
|
||||||
|
|
||||||
|
ConfigHolder.ITEM_GROUP_HOLDER.reload();
|
||||||
|
|
||||||
|
tosave.add(ConfigHolder.DEFAULT_CONFIG);
|
||||||
|
tosave.add(ConfigHolder.CONFLICT_HOLDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
package xyz.alexcrea.cuanvil.update.minecraft;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
|
import xyz.alexcrea.cuanvil.update.Version;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static xyz.alexcrea.cuanvil.update.UpdateUtils.*;
|
||||||
|
|
||||||
|
public class Update_1_20_5 extends MCUpdate {
|
||||||
|
|
||||||
|
public Update_1_20_5() {
|
||||||
|
super(new Version(1, 20, 5));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doUpdate() {
|
||||||
|
var tosave = new HashSet<ConfigHolder>();
|
||||||
|
updateName(tosave);
|
||||||
|
|
||||||
|
for (ConfigHolder holder : tosave) {
|
||||||
|
holder.saveToDisk(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String SWEEPING_ENCHANTS = "restriction_sweeping_edge.enchantments";
|
||||||
|
|
||||||
|
public static void updateName(@NotNull Set<ConfigHolder> tosave) {
|
||||||
|
var config = ConfigHolder.DEFAULT_CONFIG.getConfig();
|
||||||
|
var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
||||||
|
var conflict = ConfigHolder.CONFLICT_HOLDER.getConfig();
|
||||||
|
|
||||||
|
// Rename sweeping to sweeping_edge
|
||||||
|
migrateEnchantLimit(config, "minecraft:sweeping");
|
||||||
|
migrateEnchantLimit(config, "sweeping");
|
||||||
|
|
||||||
|
migrateEnchantValues(config, "minecraft:sweeping");
|
||||||
|
migrateEnchantValues(config, "sweeping");
|
||||||
|
|
||||||
|
if (removeFromList(conflict, SWEEPING_ENCHANTS, "minecraft:sweeping"))
|
||||||
|
addAbsentToList(conflict, SWEEPING_ENCHANTS, "minecraft:sweeping_edge");
|
||||||
|
if (removeFromList(conflict, SWEEPING_ENCHANTS, "sweeping"))
|
||||||
|
addAbsentToList(conflict, SWEEPING_ENCHANTS, "minecraft:sweeping_edge");
|
||||||
|
|
||||||
|
// Rename scute to turtle_scute
|
||||||
|
migrateUnitRepair(unitConfig, "minecraft:scute");
|
||||||
|
migrateUnitRepair(unitConfig, "scute");
|
||||||
|
|
||||||
|
ConfigHolder.ITEM_GROUP_HOLDER.reload();
|
||||||
|
|
||||||
|
tosave.add(ConfigHolder.DEFAULT_CONFIG);
|
||||||
|
tosave.add(ConfigHolder.UNIT_REPAIR_HOLDER);
|
||||||
|
tosave.add(ConfigHolder.CONFLICT_HOLDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void migrateEnchantLimit(FileConfiguration config, String path) {
|
||||||
|
var finalPath = "enchant_limits." + path;
|
||||||
|
if (!config.isInt(finalPath)) return;
|
||||||
|
var value = config.getInt(finalPath);
|
||||||
|
|
||||||
|
config.set(finalPath, null);
|
||||||
|
if (!config.contains("enchant_limits.minecraft:sweeping_edge")) return;
|
||||||
|
if (!config.contains("enchant_limits.sweeping_edge")) return;
|
||||||
|
|
||||||
|
config.set("enchant_limits.minecraft:sweeping_edge", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void migrateEnchantValues(FileConfiguration config, String path) {
|
||||||
|
migrateEnchantValues(config, path, "item");
|
||||||
|
migrateEnchantValues(config, path, "book");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void migrateEnchantValues(FileConfiguration config, String path, String child) {
|
||||||
|
var finalPath = "enchant_values." + path + "." + child;
|
||||||
|
if (config.isInt(finalPath)) return;
|
||||||
|
var value = config.getInt(finalPath);
|
||||||
|
|
||||||
|
config.set(finalPath, null);
|
||||||
|
if (!config.contains("enchant_values.minecraft:sweeping_edge." + child)) return;
|
||||||
|
if (!config.contains("enchant_values.sweeping_edge." + child)) return;
|
||||||
|
|
||||||
|
config.set("enchant_values.minecraft:sweeping_edge." + child, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void migrateUnitRepair(FileConfiguration config, String path) {
|
||||||
|
var section = config.getConfigurationSection(path);
|
||||||
|
if (section == null) return;
|
||||||
|
|
||||||
|
config.set(path, null);
|
||||||
|
var turtle_scute = config.getConfigurationSection("minecraft:turtle_scute");
|
||||||
|
if (turtle_scute == null) config.set("minecraft:turtle_scute", section);
|
||||||
|
else mergeSections(section, turtle_scute);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package xyz.alexcrea.cuanvil.update.minecraft;
|
package xyz.alexcrea.cuanvil.update.minecraft;
|
||||||
|
|
||||||
import io.delilaheve.CustomAnvil;
|
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.update.UpdateUtils;
|
import xyz.alexcrea.cuanvil.update.UpdateUtils;
|
||||||
import xyz.alexcrea.cuanvil.update.Version;
|
import xyz.alexcrea.cuanvil.update.Version;
|
||||||
|
|
|
||||||
|
|
@ -38,26 +38,26 @@ public class Update_1_21_11 extends MCUpdate{
|
||||||
addAbsentToList(conflictConfig, "restriction_fire_aspect.notAffectedGroups", "spears");
|
addAbsentToList(conflictConfig, "restriction_fire_aspect.notAffectedGroups", "spears");
|
||||||
|
|
||||||
// Unit repair for spears
|
// Unit repair for spears
|
||||||
unitConfig.set("gold_ingot.golden_spear", 0.25);
|
unitConfig.set("minecraft:gold_ingot.minecraft:golden_spear", 0.25);
|
||||||
unitConfig.set("copper_ingot.copper_spear", 0.25);
|
unitConfig.set("minecraft:copper_ingot.minecraft:copper_spear", 0.25);
|
||||||
unitConfig.set("iron_ingot.iron_spear", 0.25);
|
unitConfig.set("minecraft:iron_ingot.minecraft:iron_spear", 0.25);
|
||||||
unitConfig.set("diamond.diamond_spear", 0.25);
|
unitConfig.set("minecraft:diamond.minecraft:diamond_spear", 0.25);
|
||||||
unitConfig.set("netherite_ingot.netherite_spear", 0.25);
|
unitConfig.set("minecraft:netherite_ingot.minecraft:netherite_spear", 0.25);
|
||||||
|
|
||||||
unitConfig.set("cobblestone.stone_spear", 0.25);
|
unitConfig.set("minecraft:cobblestone.stone_spear", 0.25);
|
||||||
unitConfig.set("cobbled_deepslate.stone_spear", 0.25);
|
unitConfig.set("minecraft:cobbled_deepslate.stone_spear", 0.25);
|
||||||
|
|
||||||
unitConfig.set("oak_planks.wooden_spear", 0.25);
|
unitConfig.set("minecraft:oak_planks.minecraft:wooden_spear", 0.25);
|
||||||
unitConfig.set("spruce_planks.wooden_spear", 0.25);
|
unitConfig.set("minecraft:spruce_planks.minecraft:wooden_spear", 0.25);
|
||||||
unitConfig.set("birch_planks.wooden_spear", 0.25);
|
unitConfig.set("minecraft:birch_planks.minecraft:wooden_spear", 0.25);
|
||||||
unitConfig.set("jungle_planks.wooden_spear", 0.25);
|
unitConfig.set("minecraft:jungle_planks.minecraft:wooden_spear", 0.25);
|
||||||
unitConfig.set("acacia_planks.wooden_spear", 0.25);
|
unitConfig.set("minecraft:acacia_planks.minecraft:wooden_spear", 0.25);
|
||||||
unitConfig.set("dark_oak_planks.wooden_spear", 0.25);
|
unitConfig.set("minecraft:dark_oak_planks.minecraft:wooden_spear", 0.25);
|
||||||
unitConfig.set("mangrove_planks.wooden_spear", 0.25);
|
unitConfig.set("minecraft:mangrove_planks.minecraft:wooden_spear", 0.25);
|
||||||
unitConfig.set("cherry_planks.wooden_spear", 0.25);
|
unitConfig.set("minecraft:cherry_planks.minecraft:wooden_spear", 0.25);
|
||||||
unitConfig.set("bamboo_planks.wooden_spear", 0.25);
|
unitConfig.set("minecraft:bamboo_planks.minecraft:wooden_spear", 0.25);
|
||||||
unitConfig.set("crimson_planks.wooden_spear", 0.25);
|
unitConfig.set("minecraft:crimson_planks.minecraft:wooden_spear", 0.25);
|
||||||
unitConfig.set("warped_planks.wooden_spear", 0.25);
|
unitConfig.set("minecraft:warped_planks.minecraft:wooden_spear", 0.25);
|
||||||
|
|
||||||
// Create lunge enchant value and group
|
// Create lunge enchant value and group
|
||||||
baseConfig.set("enchant_limits.minecraft:lunge", 3);
|
baseConfig.set("enchant_limits.minecraft:lunge", 3);
|
||||||
|
|
|
||||||
|
|
@ -49,16 +49,16 @@ public class Update_1_21_9 extends MCUpdate{
|
||||||
|
|
||||||
public static void addCopperUnitRepair(FileConfiguration unitConfig) {
|
public static void addCopperUnitRepair(FileConfiguration unitConfig) {
|
||||||
// Add unit repair
|
// Add unit repair
|
||||||
unitConfig.set("copper_ingot.copper_helmet", 0.25);
|
unitConfig.set("minecraft:copper_ingot.minecraft:copper_helmet", 0.25);
|
||||||
unitConfig.set("copper_ingot.copper_chestplate", 0.25);
|
unitConfig.set("minecraft:copper_ingot.minecraft:copper_chestplate", 0.25);
|
||||||
unitConfig.set("copper_ingot.copper_leggings", 0.25);
|
unitConfig.set("minecraft:copper_ingot.minecraft:copper_leggings", 0.25);
|
||||||
unitConfig.set("copper_ingot.copper_boots", 0.25);
|
unitConfig.set("minecraft:copper_ingot.minecraft:copper_boots", 0.25);
|
||||||
|
|
||||||
unitConfig.set("copper_ingot.copper_pickaxe", 0.25);
|
unitConfig.set("minecraft:copper_ingot.minecraft:copper_pickaxe", 0.25);
|
||||||
unitConfig.set("copper_ingot.copper_shovel", 0.25);
|
unitConfig.set("minecraft:copper_ingot.minecraft:copper_shovel", 0.25);
|
||||||
unitConfig.set("copper_ingot.copper_hoe", 0.25);
|
unitConfig.set("minecraft:copper_ingot.minecraft:copper_hoe", 0.25);
|
||||||
unitConfig.set("copper_ingot.copper_axe", 0.25);
|
unitConfig.set("minecraft:copper_ingot.minecraft:copper_axe", 0.25);
|
||||||
unitConfig.set("copper_ingot.copper_sword", 0.25);
|
unitConfig.set("minecraft:copper_ingot.minecraft:copper_sword", 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package xyz.alexcrea.cuanvil.update.plugin;
|
||||||
|
|
||||||
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
|
import xyz.alexcrea.cuanvil.update.UpdateUtils;
|
||||||
|
import xyz.alexcrea.cuanvil.update.Version;
|
||||||
|
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_19;
|
||||||
|
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_20_5;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class PUpdate_1_18 {
|
||||||
|
|
||||||
|
public static void handleUpdate(@Nonnull Set<ConfigHolder> toSave) {
|
||||||
|
Version current = UpdateUtils.currentMinecraftVersion();
|
||||||
|
if (new Version(1, 19, 0).greaterThan(current)) return;
|
||||||
|
Update_1_19.updateName(toSave);
|
||||||
|
|
||||||
|
if (new Version(1, 20, 5).greaterThan(current)) return;
|
||||||
|
Update_1_20_5.updateName(toSave);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,7 +11,6 @@ import xyz.alexcrea.cuanvil.command.EditConfigExecutor
|
||||||
import xyz.alexcrea.cuanvil.command.ReloadExecutor
|
import xyz.alexcrea.cuanvil.command.ReloadExecutor
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
||||||
import xyz.alexcrea.cuanvil.dependency.MinecraftVersionUtil
|
|
||||||
import xyz.alexcrea.cuanvil.dependency.economy.EconomyManager
|
import xyz.alexcrea.cuanvil.dependency.economy.EconomyManager
|
||||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
|
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
|
||||||
|
|
@ -24,6 +23,8 @@ import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener
|
||||||
import xyz.alexcrea.cuanvil.update.ModrinthUpdateChecker
|
import xyz.alexcrea.cuanvil.update.ModrinthUpdateChecker
|
||||||
import xyz.alexcrea.cuanvil.update.PluginSetDefault
|
import xyz.alexcrea.cuanvil.update.PluginSetDefault
|
||||||
import xyz.alexcrea.cuanvil.update.UpdateHandler
|
import xyz.alexcrea.cuanvil.update.UpdateHandler
|
||||||
|
import xyz.alexcrea.cuanvil.update.UpdateUtils
|
||||||
|
import xyz.alexcrea.cuanvil.update.Version
|
||||||
import xyz.alexcrea.cuanvil.util.MetricsUtil
|
import xyz.alexcrea.cuanvil.util.MetricsUtil
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileReader
|
import java.io.FileReader
|
||||||
|
|
@ -56,6 +57,8 @@ open class CustomAnvil : JavaPlugin() {
|
||||||
// Permission string required to edit the plugin's config
|
// Permission string required to edit the plugin's config
|
||||||
const val editConfigPermission = "ca.config.edit"
|
const val editConfigPermission = "ca.config.edit"
|
||||||
|
|
||||||
|
// Permission string required to edit the plugin's config
|
||||||
|
const val giveEnchantmentPermission = "ca.command.enchantment"
|
||||||
|
|
||||||
// Command Name to reload the config
|
// Command Name to reload the config
|
||||||
const val commandReloadName = "anvilconfigreload"
|
const val commandReloadName = "anvilconfigreload"
|
||||||
|
|
@ -133,7 +136,7 @@ open class CustomAnvil : JavaPlugin() {
|
||||||
override fun onEnable() {
|
override fun onEnable() {
|
||||||
instance = this
|
instance = this
|
||||||
try {
|
try {
|
||||||
legacyCheck()
|
if(legacyCheck()) return
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.log(Level.SEVERE, "error trying to check for legacy system", e)
|
logger.log(Level.SEVERE, "error trying to check for legacy system", e)
|
||||||
MetricsUtil.trackError(e)
|
MetricsUtil.trackError(e)
|
||||||
|
|
@ -199,7 +202,16 @@ open class CustomAnvil : JavaPlugin() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun legacyCheck() {
|
private fun legacyCheck(): Boolean {
|
||||||
|
val currentVersion = UpdateUtils.currentMinecraftVersion()
|
||||||
|
if (currentVersion.greaterEqual(Version(1, 21, 0))
|
||||||
|
&& !DependencyManager.inTesting
|
||||||
|
&& !"true".equals(System.getenv("CUSTOM_ANVIL_BYPASS_LEGACY_CHECK"), true)) {
|
||||||
|
logger.warning("You are running a Minecraft version above or equal to 1.21.0")
|
||||||
|
logger.warning("Please use CustomAnvil v2 instead if you wish to use the plugin with this version.")
|
||||||
|
Bukkit.getPluginManager().disablePlugin(this)
|
||||||
|
return true
|
||||||
|
}
|
||||||
// Disable old plugin name if exist
|
// Disable old plugin name if exist
|
||||||
val potentialPlugin = Bukkit.getPluginManager().getPlugin("UnsafeEnchantsPlus")
|
val potentialPlugin = Bukkit.getPluginManager().getPlugin("UnsafeEnchantsPlus")
|
||||||
if (potentialPlugin != null) {
|
if (potentialPlugin != null) {
|
||||||
|
|
@ -212,10 +224,6 @@ open class CustomAnvil : JavaPlugin() {
|
||||||
if(!isPaper) {
|
if(!isPaper) {
|
||||||
logger.warning("It seems you are using spigot")
|
logger.warning("It seems you are using spigot")
|
||||||
logger.warning("Please take notice that spigot is less supported than paper and derivatives")
|
logger.warning("Please take notice that spigot is less supported than paper and derivatives")
|
||||||
if(MinecraftVersionUtil.isTooNewForSpigot) {
|
|
||||||
logger.warning("If replace too expensive is not working this is likely because of spigot")
|
|
||||||
logger.warning("As native nms is not supported for spigot starting 26.1")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val loader = if(isPaper) "paper" else "spigot"
|
val loader = if(isPaper) "paper" else "spigot"
|
||||||
|
|
@ -223,7 +231,8 @@ open class CustomAnvil : JavaPlugin() {
|
||||||
val version = description.version
|
val version = description.version
|
||||||
val featured = if(version.contains("dev")) null else true
|
val featured = if(version.contains("dev")) null else true
|
||||||
|
|
||||||
ModrinthUpdateChecker(modrinthPluginID, loader, null)
|
ModrinthUpdateChecker(modrinthPluginID, loader,
|
||||||
|
UpdateUtils.currentMinecraftVersion().toString())
|
||||||
.setFeatured(featured)
|
.setFeatured(featured)
|
||||||
.setOnError {
|
.setOnError {
|
||||||
logger.log(Level.WARNING, "error trying to fetch latest update", it)
|
logger.log(Level.WARNING, "error trying to fetch latest update", it)
|
||||||
|
|
@ -234,6 +243,7 @@ open class CustomAnvil : JavaPlugin() {
|
||||||
|
|
||||||
logger.warning("An update may be available: $latestVer")
|
logger.warning("An update may be available: $latestVer")
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun registerListeners() {
|
private fun registerListeners() {
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ object ConfigOptions {
|
||||||
|
|
||||||
// Keys for specific enchantment values
|
// Keys for specific enchantment values
|
||||||
private const val KEY_BOOK = "book"
|
private const val KEY_BOOK = "book"
|
||||||
|
private const val KEY_BOOK_ON_BOOK = "book_on_book"
|
||||||
private const val KEY_ITEM = "item"
|
private const val KEY_ITEM = "item"
|
||||||
|
|
||||||
// Debug flag
|
// Debug flag
|
||||||
|
|
@ -578,14 +579,15 @@ object ConfigOptions {
|
||||||
*/
|
*/
|
||||||
fun enchantmentValue(
|
fun enchantmentValue(
|
||||||
enchantment: CAEnchantment,
|
enchantment: CAEnchantment,
|
||||||
isFromBook: Boolean
|
isToBook: Boolean,
|
||||||
|
isFromBook: Boolean,
|
||||||
): Int {
|
): Int {
|
||||||
// Test namespace
|
// Test namespace
|
||||||
var limit = enchantmentValue(enchantment.key.toString(), isFromBook)
|
var limit = enchantmentValue(enchantment.key.toString(), isToBook, isFromBook)
|
||||||
if (limit != null) return limit
|
if (limit != null) return limit
|
||||||
|
|
||||||
// Test legacy (name only)
|
// Test legacy (name only)
|
||||||
limit = enchantmentValue(enchantment.enchantmentName, isFromBook)
|
limit = enchantmentValue(enchantment.enchantmentName, isToBook, isFromBook)
|
||||||
if (limit != null) return limit
|
if (limit != null) return limit
|
||||||
|
|
||||||
// get default (and test old legacy if present)
|
// get default (and test old legacy if present)
|
||||||
|
|
@ -599,13 +601,22 @@ object ConfigOptions {
|
||||||
*/
|
*/
|
||||||
private fun enchantmentValue(
|
private fun enchantmentValue(
|
||||||
enchantmentName: String,
|
enchantmentName: String,
|
||||||
isFromBook: Boolean
|
isToBook: Boolean,
|
||||||
|
isFromBook: Boolean,
|
||||||
): Int? {
|
): Int? {
|
||||||
val typeKey = if (isFromBook) KEY_BOOK else KEY_ITEM
|
val typeKey = if (isFromBook) KEY_BOOK else KEY_ITEM
|
||||||
val path = "${ENCHANT_VALUES_ROOT}.${enchantmentName}.$typeKey"
|
val path = "${ENCHANT_VALUES_ROOT}.${enchantmentName}.$typeKey"
|
||||||
return CustomAnvil.instance
|
|
||||||
.config
|
val config = ConfigHolder.DEFAULT_CONFIG.config
|
||||||
.getInt(path, DEFAULT_ENCHANT_VALUE - 1)
|
if(isFromBook && isToBook) {
|
||||||
|
val specialPath = "${ENCHANT_VALUES_ROOT}.${enchantmentName}.$KEY_BOOK_ON_BOOK"
|
||||||
|
|
||||||
|
if(config.isInt(specialPath))
|
||||||
|
return config.getInt(specialPath)
|
||||||
|
.takeIf { it >= DEFAULT_ENCHANT_VALUE }
|
||||||
|
}
|
||||||
|
|
||||||
|
return config.getInt(path, DEFAULT_ENCHANT_VALUE - 1)
|
||||||
.takeIf { it >= DEFAULT_ENCHANT_VALUE }
|
.takeIf { it >= DEFAULT_ENCHANT_VALUE }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -613,20 +624,9 @@ object ConfigOptions {
|
||||||
* Get default value if enchantment do not exist on config
|
* Get default value if enchantment do not exist on config
|
||||||
*/
|
*/
|
||||||
private fun getDefaultValue(
|
private fun getDefaultValue(
|
||||||
enchantment: CAEnchantment, // compatibility with 1.20.5. TODO better update system
|
enchantment: CAEnchantment,
|
||||||
isFromBook: Boolean
|
isFromBook: Boolean
|
||||||
): Int {
|
): Int {
|
||||||
|
|
||||||
val enchantmentName = enchantment.key.toString()
|
|
||||||
if (enchantmentName == "minecraft:sweeping_edge") {
|
|
||||||
var limit = enchantmentValue("minecraft:sweeping", isFromBook)
|
|
||||||
if (limit != null) return limit
|
|
||||||
|
|
||||||
// legacy name
|
|
||||||
limit = enchantmentValue("sweeping", isFromBook)
|
|
||||||
if (limit != null) return limit
|
|
||||||
}
|
|
||||||
|
|
||||||
val rarity = enchantment.defaultRarity()
|
val rarity = enchantment.defaultRarity()
|
||||||
return if (isFromBook)
|
return if (isFromBook)
|
||||||
rarity.bookValue
|
rarity.bookValue
|
||||||
|
|
@ -648,15 +648,6 @@ object ConfigOptions {
|
||||||
value = maxBeforeMergeDisabled(legacy)
|
value = maxBeforeMergeDisabled(legacy)
|
||||||
if (value >= 0) return value
|
if (value >= 0) return value
|
||||||
|
|
||||||
if (key == "minecraft:sweeping_edge") {
|
|
||||||
value = maxBeforeMergeDisabled("minecraft:sweeping")
|
|
||||||
if (value >= 0) return value
|
|
||||||
|
|
||||||
// legacy name of legacy enchantment name
|
|
||||||
value = maxBeforeMergeDisabled("sweeping")
|
|
||||||
if (value >= 0) return value
|
|
||||||
}
|
|
||||||
|
|
||||||
return DEFAULT_MAX_BEFORE_MERGE_DISABLED
|
return DEFAULT_MAX_BEFORE_MERGE_DISABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
package io.delilaheve.util
|
package io.delilaheve.util
|
||||||
|
|
||||||
|
import org.bukkit.Material
|
||||||
import org.bukkit.Material.ENCHANTED_BOOK
|
import org.bukkit.Material.ENCHANTED_BOOK
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.meta.Damageable
|
import org.bukkit.inventory.meta.Damageable
|
||||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment
|
|
||||||
import xyz.alexcrea.cuanvil.update.UpdateUtils
|
import xyz.alexcrea.cuanvil.update.UpdateUtils
|
||||||
import xyz.alexcrea.cuanvil.util.MaterialUtil.customType
|
import xyz.alexcrea.cuanvil.util.MaterialUtil.customType
|
||||||
import xyz.alexcrea.cuanvil.util.MaxDamageCheckerUtil
|
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
@ -21,13 +20,6 @@ object ItemUtil {
|
||||||
*/
|
*/
|
||||||
fun ItemStack.isEnchantedBook() = type == ENCHANTED_BOOK
|
fun ItemStack.isEnchantedBook() = type == ENCHANTED_BOOK
|
||||||
|
|
||||||
private fun maxDamage(damageable: Damageable): Int {
|
|
||||||
val ver = UpdateUtils.currentMinecraftVersion()
|
|
||||||
if(ver.major <= 1 && ver.minor <= 20 && ver.patch < 5) return Integer.MAX_VALUE
|
|
||||||
|
|
||||||
return MaxDamageCheckerUtil.getMaxDamage(damageable)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set this [ItemStack]s durability from a combination of the
|
* Set this [ItemStack]s durability from a combination of the
|
||||||
* [first] and [second] item's durability values
|
* [first] and [second] item's durability values
|
||||||
|
|
@ -37,24 +29,23 @@ object ItemUtil {
|
||||||
first: ItemStack,
|
first: ItemStack,
|
||||||
second: ItemStack
|
second: ItemStack
|
||||||
): Boolean {
|
): Boolean {
|
||||||
(itemMeta as? Damageable)?.let {
|
val meta = itemMeta
|
||||||
val durability = type.maxDurability.toInt()
|
if(meta !is Damageable) return false
|
||||||
val firstDamage = (first.itemMeta as? Damageable)?.damage ?: 0
|
|
||||||
if (firstDamage == 0) return false
|
|
||||||
|
|
||||||
val firstDurability = durability - firstDamage
|
val maxDamage = type.maxDurability.toInt()
|
||||||
|
val damage = (first.itemMeta as? Damageable)?.damage ?: 0
|
||||||
|
if (damage == 0) return false
|
||||||
|
|
||||||
|
val firstDurability = maxDamage - damage
|
||||||
val secondDamage = (second.itemMeta as? Damageable)?.damage ?: 0
|
val secondDamage = (second.itemMeta as? Damageable)?.damage ?: 0
|
||||||
val secondDurability = durability - secondDamage
|
val secondDurability = maxDamage - secondDamage
|
||||||
val combinedDurability = firstDurability + secondDurability
|
val combinedDurability = firstDurability + secondDurability
|
||||||
val newDurability = min(combinedDurability, durability)
|
val newDurability = min(combinedDurability, maxDamage)
|
||||||
|
|
||||||
val maxDamage = maxDamage(it)
|
meta.damage = min(maxDamage - newDurability, maxDamage)
|
||||||
it.damage = min(durability - newDurability, maxDamage)
|
this.itemMeta = meta
|
||||||
itemMeta = it
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ItemStack.unitRepair(
|
fun ItemStack.unitRepair(
|
||||||
unitAmount: Int,
|
unitAmount: Int,
|
||||||
|
|
@ -84,6 +75,6 @@ object ItemUtil {
|
||||||
* The two items should either be the same type, or, the [other] is a book
|
* The two items should either be the same type, or, the [other] is a book
|
||||||
*/
|
*/
|
||||||
fun ItemStack.canMergeWith(
|
fun ItemStack.canMergeWith(
|
||||||
other: ItemStack?
|
other: ItemStack
|
||||||
) = (other != null) && (customType == other.customType || (other.isEnchantedBook()))
|
) = customType == other.customType || (other.isEnchantedBook())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue