mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
Compare commits
6 commits
fda211fe5b
...
162b171a89
| Author | SHA1 | Date | |
|---|---|---|---|
| 162b171a89 | |||
| ded892f2ec | |||
| 703bf40449 | |||
| 640bd1bfd8 | |||
| 1e0e8d5f6d | |||
| bef2dfdc2f |
36 changed files with 116 additions and 187 deletions
|
|
@ -5,23 +5,24 @@ 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.4.0"
|
kotlin("jvm") version "2.3.0"
|
||||||
java
|
java
|
||||||
id("org.jetbrains.dokka").version("2.2.0")
|
id("org.jetbrains.dokka").version("1.9.20")
|
||||||
id("com.gradleup.shadow").version("9.6.1")
|
id("com.gradleup.shadow").version("9.3.0")
|
||||||
// Maven publish
|
// Maven publish
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
signing
|
signing
|
||||||
id("cn.lalaki.central").version("2.0.8")
|
id("cn.lalaki.central").version("1.2.8")
|
||||||
// Paper
|
// Paper
|
||||||
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21" apply false
|
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17" apply false
|
||||||
id("io.papermc.hangar-publish-plugin") version "0.1.4"
|
id("io.papermc.hangar-publish-plugin") version "0.1.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "xyz.alexcrea"
|
group = "xyz.alexcrea"
|
||||||
version = "2.0.2"
|
version = "2.0.0"
|
||||||
|
|
||||||
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"
|
||||||
|
|
@ -157,16 +158,16 @@ allprojects {
|
||||||
// Set target version
|
// Set target version
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
tasks.withType<JavaCompile>().configureEach {
|
||||||
sourceCompatibility =
|
sourceCompatibility =
|
||||||
"21" // We aim for java 21 for minecraft 1.21.0
|
"16" // We aim for java 16 for minecraft 1.16.5. even if it not really supported by custom anvil.
|
||||||
targetCompatibility = "21"
|
targetCompatibility = "16"
|
||||||
|
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,10 +178,7 @@ 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 version = effectiveVersion
|
val name = "${rootProject.name}-${effectiveVersion}${processedSuffix}.jar"
|
||||||
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 +187,8 @@ tasks {
|
||||||
|
|
||||||
filesMatching("plugin.yml") {
|
filesMatching("plugin.yml") {
|
||||||
expand(
|
expand(
|
||||||
"version" to version + processedSuffix,
|
"version" to effectiveVersion + processedSuffix,
|
||||||
"libraries" to librariesExpendTo,
|
"libraries" to libraries.joinToString(transform = { "\"$it\"" }),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,7 +200,7 @@ tasks {
|
||||||
shadowJar {
|
shadowJar {
|
||||||
configureBaseShadow("",
|
configureBaseShadow("",
|
||||||
arrayOf(
|
arrayOf(
|
||||||
"org.jetbrains.kotlin:kotlin-stdlib:2.4.0",
|
"org.jetbrains.kotlin:kotlin-stdlib:2.3.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 +212,7 @@ tasks {
|
||||||
exclude("net/kyori/**")
|
exclude("net/kyori/**")
|
||||||
}
|
}
|
||||||
|
|
||||||
val offlineJar = register<ShadowJar>("offlineJar") {
|
val offlineJar by registering(ShadowJar::class) {
|
||||||
configureBaseShadow("offline", emptyArray())
|
configureBaseShadow("offline", emptyArray())
|
||||||
|
|
||||||
from(sourceSets.main.get().output)
|
from(sourceSets.main.get().output)
|
||||||
|
|
@ -228,12 +226,12 @@ tasks {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourcesJar = tasks.register<Jar>("sourcesJar") {
|
val sourcesJar by tasks.registering(Jar::class) {
|
||||||
archiveClassifier.set("sources")
|
archiveClassifier.set("sources")
|
||||||
from(kotlin.sourceSets.main.get().kotlin)
|
from(kotlin.sourceSets.main.get().kotlin)
|
||||||
}
|
}
|
||||||
|
|
||||||
val javadocJar = tasks.register<Jar>("javadocJar", fun Jar.() {
|
val javadocJar by tasks.registering(Jar::class, 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,25 +355,36 @@ publishing {
|
||||||
}
|
}
|
||||||
|
|
||||||
// hangar publish
|
// hangar publish
|
||||||
fun latestCommitMessage(): Provider<String> {
|
|
||||||
return providers.exec {
|
fun executeGitCommand(vararg command: String): String {
|
||||||
commandLine("git", "log", "-1", "--pretty=%B")
|
val byteOut = ByteArrayOutputStream()
|
||||||
}.standardOutput.asText.map(String::trim)
|
exec {
|
||||||
|
commandLine = listOf("git", *command)
|
||||||
|
standardOutput = byteOut
|
||||||
|
}
|
||||||
|
return byteOut.toString(Charsets.UTF_8.name()).trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun changelog(isOnline: Boolean): Provider<String> {
|
|
||||||
val changelog = if(isDevBuild) latestCommitMessage()
|
fun latestCommitMessage(): String {
|
||||||
else providers.environmentVariable("RELEASE_CHANGELOG")
|
return executeGitCommand("log", "-1", "--pretty=%B")
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
|
@ -386,12 +395,11 @@ hangarPublish {
|
||||||
if(!isOnline) versionName+= "-offline"
|
if(!isOnline) versionName+= "-offline"
|
||||||
|
|
||||||
version.set(versionName)
|
version.set(versionName)
|
||||||
var finalReleaseChannel = if (isDevBuild || isPreRelease) devChannel else releaseChannel
|
var releaseChannel = if (isDevBuild || isPreRelease) devChannel else releaseChannel
|
||||||
if(finalReleaseChannel == null) return
|
if(releaseChannel == null) return
|
||||||
channel.set(finalReleaseChannel)
|
channel.set(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,5 +1,4 @@
|
||||||
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
|
||||||
|
|
|
||||||
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-9.7.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-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.4.0"
|
kotlin("jvm") version "2.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ group = rootProject.group
|
||||||
version = rootProject.version
|
version = rootProject.version
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.4.0"
|
kotlin("jvm") version "2.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Imitate needed class and method to support legacy version of EcoEnchant
|
// Imitate needed class and method to support legacy version of EcoEnchant
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,20 @@
|
||||||
@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
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
import org.bukkit.packs.DataPack
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object DataPackTester {
|
object DataPackTester {
|
||||||
val legacyNames: List<String>
|
|
||||||
get() = Bukkit.getDataPackManager().dataPacks
|
|
||||||
.stream().filter { obj -> obj.isEnabled }
|
|
||||||
.map { pack -> pack.key.key }
|
|
||||||
.toList()
|
|
||||||
|
|
||||||
val enabledPacks: List<String>
|
val enabledPacks: List<String>
|
||||||
get() {
|
get() {
|
||||||
try {
|
return try {
|
||||||
// will throw error if do not exist
|
Bukkit.getDatapackManager().enabledPacks
|
||||||
Bukkit::class.java.getDeclaredMethod("getDatapackManager")
|
|
||||||
|
|
||||||
return Bukkit.getDatapackManager().enabledPacks
|
|
||||||
.stream().map { obj: Datapack -> obj.name }
|
.stream().map { obj: Datapack -> obj.name }
|
||||||
.toList()
|
.toList()
|
||||||
} catch(_: NoSuchMethodException) {
|
} catch (_: Exception){
|
||||||
try {
|
|
||||||
DataPack::class.java.getDeclaredMethod("getKey")
|
|
||||||
} catch(_: NoSuchMethodException) {
|
|
||||||
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...")
|
|
||||||
return emptyList()
|
|
||||||
}
|
|
||||||
return legacyNames
|
|
||||||
} catch(_: Exception) {
|
|
||||||
// Assume cause UnimplementedOperationException on mock server
|
// Assume cause UnimplementedOperationException on mock server
|
||||||
return Collections.emptyList()
|
Collections.emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ object AnvilTitleUtil {
|
||||||
|
|
||||||
private val runTaskMap = HashMap<UUID, ScheduledTask>()
|
private val runTaskMap = HashMap<UUID, ScheduledTask>()
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
private fun actualRename(view: AnvilView, name: String, player: HumanEntity, anvilDialog: AnvilRenameDialog) {
|
private fun actualRename(view: AnvilView, 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_4)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_4)
|
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
|
||||||
jvmTarget.set(JvmTarget.JVM_21)
|
jvmTarget.set(JvmTarget.JVM_21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
|
||||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -34,7 +33,7 @@ public class ConfirmActionGui extends AbstractAskGui {
|
||||||
|
|
||||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,7 +47,7 @@ public class ConfirmActionGui extends AbstractAskGui {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
MsgUI.INSTANCE.getCONFIRM_ACTION_FAILED().send(player);
|
event.getWhoClicked().sendMessage("§cAction could not be completed. ");
|
||||||
}
|
}
|
||||||
backOnConfirm.show(player);
|
backOnConfirm.show(player);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||||
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.lang.MsgUI;
|
|
||||||
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -37,7 +36,7 @@ public class SelectItemTypeGui extends AbstractAskGui {
|
||||||
|
|
||||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui;
|
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -53,12 +52,13 @@ public abstract class MappedElementListConfigGui<T, S> extends ElementListConfig
|
||||||
// check permission
|
// check permission
|
||||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
|
||||||
MsgUI.INSTANCE.getELEMENT_LIST_INSTRUCTION_NEW().send(player, genericDisplayedName());
|
player.sendMessage("§eWrite the " + genericDisplayedName() + " name you want to create in the chat.\n" +
|
||||||
|
"§eOr write §ccancel §eto go back to " + genericDisplayedName() + " config menu");
|
||||||
|
|
||||||
CustomAnvil.Companion.getChatListener().setListenedCallback(player, prepareCreateItemConsumer(player));
|
CustomAnvil.Companion.getChatListener().setListenedCallback(player, prepareCreateItemConsumer(player));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.list.elements.ElementMappedToListGui;
|
import xyz.alexcrea.cuanvil.gui.config.list.elements.ElementMappedToListGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
|
||||||
import xyz.alexcrea.cuanvil.util.LazyValue;
|
import xyz.alexcrea.cuanvil.util.LazyValue;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
@ -70,13 +69,13 @@ public abstract class MappedGuiListConfigGui<T, S extends MappedGuiListConfigGui
|
||||||
|
|
||||||
// check permission
|
// check permission
|
||||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
message = message.toLowerCase(Locale.ROOT);
|
message = message.toLowerCase(Locale.ROOT);
|
||||||
if ("cancel".equalsIgnoreCase(message)) {
|
if ("cancel".equalsIgnoreCase(message)) {
|
||||||
MsgUI.INSTANCE.getELEMENT_LIST_CANCELLED_NEW().send(player, genericDisplayedName());
|
player.sendMessage(genericDisplayedName() + " creation cancelled...");
|
||||||
show(player);
|
show(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -87,7 +86,7 @@ public abstract class MappedGuiListConfigGui<T, S extends MappedGuiListConfigGui
|
||||||
// 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 : getDisplayableInstanceOfGeneric()) {
|
for (T generic : getDisplayableInstanceOfGeneric()) {
|
||||||
if (generic.toString().equalsIgnoreCase(message)) {
|
if (generic.toString().equalsIgnoreCase(message)) {
|
||||||
MsgUI.INSTANCE.getELEMENT_LIST_DUPLICATED_NEW().send(player, genericDisplayedName());
|
player.sendMessage("§cPlease enter a " + genericDisplayedName() + " name that do not already exist...");
|
||||||
// wait next message.
|
// wait next message.
|
||||||
CustomAnvil.Companion.getChatListener().setListenedCallback(player, selfRef.get());
|
CustomAnvil.Companion.getChatListener().setListenedCallback(player, selfRef.get());
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import xyz.alexcrea.cuanvil.gui.config.list.elements.ElementMappedToListGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.DoubleSettingGui;
|
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.lang.MsgUI;
|
|
||||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
||||||
|
|
||||||
|
|
@ -71,11 +70,11 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<Namespaced
|
||||||
NamespacedKey type = MaterialUtil.INSTANCE.getCustomType(itemStack);
|
NamespacedKey type = MaterialUtil.INSTANCE.getCustomType(itemStack);
|
||||||
|
|
||||||
if (!(meta instanceof Damageable)) {
|
if (!(meta instanceof Damageable)) {
|
||||||
MsgUI.INSTANCE.getUNIT_REPAIR_ELEMENT_CANNOT_REPAIR_NEW().send(player);
|
player.sendMessage("§cThis item can't be damaged, so it can't be repaired.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type.equals(this.parentMaterial)) {
|
if (type.equals(this.parentMaterial)) {
|
||||||
MsgUI.INSTANCE.getUNIT_REPAIR_ELEMENT_SAME_TYPE_NEW().send(player);
|
player.sendMessage("§cItem can't repair something of the same type.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import xyz.alexcrea.cuanvil.gui.config.settings.MaterialSelectSettingGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||||
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.lang.MsgUI;
|
|
||||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -114,7 +113,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
|
||||||
// Do not allow to open inventory if player do not have edit configuration permission
|
// Do not allow to open inventory if player do not have edit configuration permission
|
||||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// test if group is used & cancel & warn user if so
|
// test if group is used & cancel & warn user if so
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import xyz.alexcrea.cuanvil.gui.config.list.MappedElementListConfigGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||||
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.lang.MsgUI;
|
|
||||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
||||||
|
|
||||||
|
|
@ -157,7 +156,7 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Namespa
|
||||||
// Do not allow to save configuration if player do not have edit configuration permission
|
// Do not allow to save configuration if player do not have edit configuration permission
|
||||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(testCantSave()) return;
|
if(testCantSave()) return;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.config.WorkPenaltyType;
|
import xyz.alexcrea.cuanvil.config.WorkPenaltyType;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.global.BasicConfigGui;
|
import xyz.alexcrea.cuanvil.gui.config.global.BasicConfigGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
|
@ -74,7 +73,7 @@ public class WorkPenaltyTypeSettingGui extends AbstractSettingGui {
|
||||||
// Do not allow to open inventory if player do not have edit configuration permission
|
// Do not allow to open inventory if player do not have edit configuration permission
|
||||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
player.sendMessage(GuiGlobalActions.NO_EDIT_PERM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new WorkPenaltyTypeSettingGui(parent).show(player);
|
new WorkPenaltyTypeSettingGui(parent).show(player);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.SettingGui;
|
import xyz.alexcrea.cuanvil.gui.config.settings.SettingGui;
|
||||||
import xyz.alexcrea.cuanvil.lang.MsgUI;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
@ -18,6 +17,8 @@ import java.util.function.Consumer;
|
||||||
*/
|
*/
|
||||||
public class GuiGlobalActions {
|
public class GuiGlobalActions {
|
||||||
|
|
||||||
|
public static final String NO_EDIT_PERM = "§cYou do not have permission to edit the config";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Consumer that should be used if the item goal is to do nothing on click.
|
* A Consumer that should be used if the item goal is to do nothing on click.
|
||||||
*/
|
*/
|
||||||
|
|
@ -43,7 +44,7 @@ public class GuiGlobalActions {
|
||||||
// Do not allow to open inventory if player do not have edit configuration permission
|
// Do not allow to open inventory if player do not have edit configuration permission
|
||||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
player.sendMessage(NO_EDIT_PERM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
@ -101,7 +102,7 @@ public class GuiGlobalActions {
|
||||||
// Do not allow to open inventory if player do not have edit configuration permission
|
// Do not allow to open inventory if player do not have edit configuration permission
|
||||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
player.sendMessage(NO_EDIT_PERM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
goal.show(player);
|
goal.show(player);
|
||||||
|
|
@ -126,7 +127,7 @@ public class GuiGlobalActions {
|
||||||
// Do not allow to save configuration if player do not have edit configuration permission
|
// Do not allow to save configuration if player do not have edit configuration permission
|
||||||
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
if (!player.hasPermission(CustomAnvil.editConfigPermission)) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
MsgUI.INSTANCE.getSHARED_CONFIG_NO_EDIT_PERM().send(player);
|
player.sendMessage(NO_EDIT_PERM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandExecutor
|
||||||
import org.bukkit.command.CommandSender
|
import org.bukkit.command.CommandSender
|
||||||
import org.bukkit.command.TabCompleter
|
import org.bukkit.command.TabCompleter
|
||||||
import xyz.alexcrea.cuanvil.lang.MsgCommand
|
import xyz.alexcrea.cuanvil.lang.MsgCommand
|
||||||
|
import xyz.alexcrea.cuanvil.util.MetricsUtil
|
||||||
|
|
||||||
class CustomAnvilCommand(plugin: CustomAnvil) : CommandExecutor, TabCompleter {
|
class CustomAnvilCommand(plugin: CustomAnvil) : CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ import xyz.alexcrea.cuanvil.enchant.CAEnchantment
|
||||||
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
|
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
|
||||||
import xyz.alexcrea.cuanvil.gui.config.global.EnchantConfigGui
|
import xyz.alexcrea.cuanvil.gui.config.global.EnchantConfigGui
|
||||||
import xyz.alexcrea.cuanvil.gui.config.global.ItemConfigGui
|
import xyz.alexcrea.cuanvil.gui.config.global.ItemConfigGui
|
||||||
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions
|
||||||
import xyz.alexcrea.cuanvil.lang.Message
|
import xyz.alexcrea.cuanvil.lang.Message
|
||||||
import xyz.alexcrea.cuanvil.lang.MsgCommand
|
import xyz.alexcrea.cuanvil.lang.MsgCommand
|
||||||
import xyz.alexcrea.cuanvil.lang.MsgUI
|
|
||||||
import xyz.alexcrea.cuanvil.util.MaterialUtil.customType
|
import xyz.alexcrea.cuanvil.util.MaterialUtil.customType
|
||||||
import xyz.alexcrea.cuanvil.util.MaterialUtil.isAir
|
import xyz.alexcrea.cuanvil.util.MaterialUtil.isAir
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ class EditConfigExecutor : CASubCommand {
|
||||||
if(sender !is HumanEntity) return false
|
if(sender !is HumanEntity) return false
|
||||||
|
|
||||||
if(!allowed(sender)) {
|
if(!allowed(sender)) {
|
||||||
MsgUI.SHARED_CONFIG_NO_EDIT_PERM.send(sender)
|
sender.sendMessage(GuiGlobalActions.NO_EDIT_PERM)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if(PlatformUtil.isFolia) {
|
if(PlatformUtil.isFolia) {
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,9 @@ import xyz.alexcrea.cuanvil.dependency.scheduler.FoliaScheduler
|
||||||
import xyz.alexcrea.cuanvil.dependency.scheduler.TaskScheduler
|
import xyz.alexcrea.cuanvil.dependency.scheduler.TaskScheduler
|
||||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil.componentLore
|
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil.componentLore
|
||||||
import xyz.alexcrea.cuanvil.lang.MsgWarning
|
|
||||||
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT
|
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT
|
||||||
import xyz.alexcrea.cuanvil.util.MetricsUtil.trackError
|
import xyz.alexcrea.cuanvil.util.MetricsUtil.trackError
|
||||||
import java.lang.IllegalStateException
|
import java.lang.reflect.Constructor
|
||||||
import java.util.logging.Level
|
import java.util.logging.Level
|
||||||
|
|
||||||
@Suppress("UnstableApiUsage")
|
@Suppress("UnstableApiUsage")
|
||||||
|
|
@ -159,14 +158,18 @@ object DependencyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun logException(target: CommandSender, e: Exception) {
|
private fun logException(target: CommandSender, e: Exception) {
|
||||||
CustomAnvil.logError(
|
CustomAnvil.instance.logger.log(
|
||||||
|
Level.SEVERE,
|
||||||
"Error while trying to handle custom anvil supported plugin: ",
|
"Error while trying to handle custom anvil supported plugin: ",
|
||||||
e
|
e
|
||||||
)
|
)
|
||||||
trackError(e)
|
trackError(e)
|
||||||
|
|
||||||
// Finally, warn the player
|
// Finally, warn the player
|
||||||
MsgWarning.DEPENDENCY_GENERIC_EXCEPTION.send(target)
|
target.sendMessage(
|
||||||
|
"[" + ChatColor.YELLOW.toString() + "CustomAnvil" + ChatColor.WHITE.toString() + "] " +
|
||||||
|
ChatColor.RED.toString() + "Error while handling the anvil."
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun logExceptionAndClear(view: AnvilView, e: Exception) {
|
private fun logExceptionAndClear(view: AnvilView, e: Exception) {
|
||||||
|
|
@ -334,14 +337,10 @@ object DependencyManager {
|
||||||
|
|
||||||
|
|
||||||
private val prepareAnvilConstructor =
|
private val prepareAnvilConstructor =
|
||||||
PrepareAnvilEvent::class.java.constructors.first()
|
PrepareAnvilEvent::class.java.constructors.first() as Constructor<PrepareAnvilEvent>
|
||||||
|
|
||||||
fun createFakeEvent(view: AnvilView, result: ItemStack?): PrepareAnvilEvent {
|
fun createFakeEvent(view: AnvilView, result: ItemStack?): PrepareAnvilEvent {
|
||||||
val result = prepareAnvilConstructor.newInstance(view, result)
|
return prepareAnvilConstructor.newInstance(view, result)
|
||||||
if(result !is PrepareAnvilEvent)
|
|
||||||
throw IllegalStateException("Could not create a PrepareAnvilEvent ?")
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import com.willfp.ecoenchants.enchant.EcoEnchant
|
||||||
import com.willfp.ecoenchants.enchant.EcoEnchants
|
import com.willfp.ecoenchants.enchant.EcoEnchants
|
||||||
import com.willfp.ecoenchants.enchant.UtilKt
|
import com.willfp.ecoenchants.enchant.UtilKt
|
||||||
import io.delilaheve.CustomAnvil
|
import io.delilaheve.CustomAnvil
|
||||||
import org.bukkit.Bukkit
|
|
||||||
import org.bukkit.event.inventory.PrepareAnvilEvent
|
import org.bukkit.event.inventory.PrepareAnvilEvent
|
||||||
import org.bukkit.plugin.Plugin
|
import org.bukkit.plugin.Plugin
|
||||||
import xyz.alexcrea.cuanvil.api.EnchantmentApi
|
import xyz.alexcrea.cuanvil.api.EnchantmentApi
|
||||||
|
|
@ -23,11 +22,11 @@ class EcoEnchantDependency(private val ecoEnchantPlugin: Plugin) {
|
||||||
try {
|
try {
|
||||||
Class.forName("com.willfp.ecoenchants.enchant.EcoEnchants")
|
Class.forName("com.willfp.ecoenchants.enchant.EcoEnchants")
|
||||||
isLegacy = false
|
isLegacy = false
|
||||||
} catch(_: ClassNotFoundException) {
|
} catch (_: ClassNotFoundException) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isLegacy = isLegacy;
|
this.isLegacy = isLegacy;
|
||||||
if(isLegacy) {
|
if (isLegacy) {
|
||||||
this.legacyDependency = LegacyEcoEnchantDependency()
|
this.legacyDependency = LegacyEcoEnchantDependency()
|
||||||
} else {
|
} else {
|
||||||
this.legacyDependency = null
|
this.legacyDependency = null
|
||||||
|
|
@ -35,27 +34,25 @@ class EcoEnchantDependency(private val ecoEnchantPlugin: Plugin) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getEcoLevelLimit(): Int {
|
public fun getEcoLevelLimit(): Int {
|
||||||
return UtilKt.infiniteIfNegative((ecoEnchantPlugin as EcoPlugin).configYml.getInt("anvil.enchant-limit"))
|
return UtilKt.infiniteIfNegative((ecoEnchantPlugin as EcoPlugin).configYml.getInt("anvil.enchant-limit"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun disableAnvilListener() {
|
fun disableAnvilListener() {
|
||||||
PrepareAnvilEvent.getHandlerList().unregister(this.ecoEnchantPlugin)
|
PrepareAnvilEvent.getHandlerList().unregister(this.ecoEnchantPlugin)
|
||||||
// I don't like that but modern ee use eco prepare anvil event
|
|
||||||
PrepareAnvilEvent.getHandlerList().unregister(Bukkit.getPluginManager().getPlugin("eco")!!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var ecoEnchantOldEnchantments: MutableSet<EcoEnchant>? = null
|
private var ecoEnchantOldEnchantments: MutableSet<EcoEnchant>? = null
|
||||||
fun registerEnchantments() {
|
fun registerEnchantments() {
|
||||||
CustomAnvil.instance.logger.info("Preparing Eco Enchant compatibility...")
|
CustomAnvil.instance.logger.info("Preparing Eco Enchant compatibility...")
|
||||||
|
|
||||||
if(isLegacy) {
|
if (isLegacy) {
|
||||||
legacyDependency!!.registerEnchantments();
|
legacyDependency!!.registerEnchantments();
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val enchantments = EcoEnchants.INSTANCE.values()
|
val enchantments = EcoEnchants.INSTANCE.values()
|
||||||
for(ecoEnchant in enchantments) {
|
for (ecoEnchant in enchantments) {
|
||||||
EnchantmentApi.unregisterEnchantment(ecoEnchant.enchantment) // As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant.
|
EnchantmentApi.unregisterEnchantment(ecoEnchant.enchantment) // As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant.
|
||||||
EnchantmentApi.registerEnchantment(CAEcoEnchant(ecoEnchant))
|
EnchantmentApi.registerEnchantment(CAEcoEnchant(ecoEnchant))
|
||||||
}
|
}
|
||||||
|
|
@ -66,24 +63,24 @@ class EcoEnchantDependency(private val ecoEnchantPlugin: Plugin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleConfigReload() {
|
fun handleConfigReload() {
|
||||||
if(isLegacy) {
|
if (isLegacy) {
|
||||||
legacyDependency!!.handleConfigReload()
|
legacyDependency!!.handleConfigReload()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should not happen in known case.
|
// Should not happen in known case.
|
||||||
if(this.ecoEnchantOldEnchantments == null) return
|
if (this.ecoEnchantOldEnchantments == null) return
|
||||||
|
|
||||||
val newEnchantments = EcoEnchants.INSTANCE.values()
|
val newEnchantments = EcoEnchants.INSTANCE.values()
|
||||||
|
|
||||||
// Add new enchantments
|
// Add new enchantments
|
||||||
for(ecoEnchant in newEnchantments)
|
for (ecoEnchant in newEnchantments)
|
||||||
if(!this.ecoEnchantOldEnchantments!!.contains(ecoEnchant))
|
if (!this.ecoEnchantOldEnchantments!!.contains(ecoEnchant))
|
||||||
EnchantmentApi.registerEnchantment(CAEcoEnchant(ecoEnchant))
|
EnchantmentApi.registerEnchantment(CAEcoEnchant(ecoEnchant))
|
||||||
|
|
||||||
// Remove old enchantments that not now currently used
|
// Remove old enchantments that not now currently used
|
||||||
this.ecoEnchantOldEnchantments!!.removeAll(newEnchantments)
|
this.ecoEnchantOldEnchantments!!.removeAll(newEnchantments)
|
||||||
for(oldEnchantment in this.ecoEnchantOldEnchantments!!) {
|
for (oldEnchantment in this.ecoEnchantOldEnchantments!!) {
|
||||||
EnchantmentApi.unregisterEnchantment(oldEnchantment.enchantment)
|
EnchantmentApi.unregisterEnchantment(oldEnchantment.enchantment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import org.bukkit.NamespacedKey
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.plugin.Plugin
|
import org.bukkit.plugin.Plugin
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
class ItemsAdderDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
class ItemsAdderDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
||||||
var isLoaded: Boolean = false
|
var isLoaded: Boolean = false
|
||||||
get() {
|
get() {
|
||||||
|
|
|
||||||
|
|
@ -10,20 +10,13 @@ class LegacyEcoEnchantDependency {
|
||||||
|
|
||||||
|
|
||||||
private var ecoEnchantOldEnchantments: MutableSet<EcoEnchant>? = null
|
private var ecoEnchantOldEnchantments: MutableSet<EcoEnchant>? = null
|
||||||
private fun unregisterEnchantment(enchant: Any) {
|
|
||||||
EnchantmentApi.unregisterEnchantment((enchant as Enchantment).key)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun registerEnchantment(ecoEnchant: EcoEnchant, enchant: Any) {
|
|
||||||
EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, enchant as Enchantment))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun registerEnchantments() {
|
fun registerEnchantments() {
|
||||||
val enchantments = EcoEnchants.values()
|
val enchantments = EcoEnchants.values()
|
||||||
for (ecoEnchant in enchantments) {
|
for (ecoEnchant in enchantments) {
|
||||||
// As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant.
|
ecoEnchant as Enchantment
|
||||||
unregisterEnchantment(ecoEnchant)
|
|
||||||
registerEnchantment(ecoEnchant, ecoEnchant)
|
EnchantmentApi.unregisterEnchantment(ecoEnchant) // As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant.
|
||||||
|
EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, ecoEnchant))
|
||||||
}
|
}
|
||||||
|
|
||||||
ecoEnchantOldEnchantments = HashSet(enchantments)
|
ecoEnchantOldEnchantments = HashSet(enchantments)
|
||||||
|
|
@ -38,13 +31,13 @@ class LegacyEcoEnchantDependency {
|
||||||
// Add new enchantments
|
// Add new enchantments
|
||||||
for (ecoEnchant in newEnchantments)
|
for (ecoEnchant in newEnchantments)
|
||||||
if (!this.ecoEnchantOldEnchantments!!.contains(ecoEnchant))
|
if (!this.ecoEnchantOldEnchantments!!.contains(ecoEnchant))
|
||||||
registerEnchantment(ecoEnchant, ecoEnchant)
|
EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, ecoEnchant as Enchantment))
|
||||||
|
|
||||||
|
|
||||||
// Remove old enchantments that not now currently used
|
// Remove old enchantments that not now currently used
|
||||||
this.ecoEnchantOldEnchantments!!.removeAll(newEnchantments)
|
this.ecoEnchantOldEnchantments!!.removeAll(newEnchantments)
|
||||||
for (oldEnchantment in this.ecoEnchantOldEnchantments!!) {
|
for (oldEnchantment in this.ecoEnchantOldEnchantments!!) {
|
||||||
unregisterEnchantment(oldEnchantment)
|
EnchantmentApi.unregisterEnchantment(oldEnchantment as Enchantment)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ecoEnchantOldEnchantments = HashSet(newEnchantments)
|
this.ecoEnchantOldEnchantments = HashSet(newEnchantments)
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,9 @@ class ToolStatsDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
||||||
getTokenMethod.trySetAccessible()
|
getTokenMethod.trySetAccessible()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ItemChecker.getTokenSafe(item: ItemStack?): Array<*> {
|
private fun ItemChecker.getTokenSafe(item: ItemStack?): Array<String> {
|
||||||
if (item == null) return arrayOf<Any>()
|
if (item == null) return arrayOf()
|
||||||
val result = getTokenMethod.invoke(this, item)
|
return getTokenMethod.invoke(this, item) as Array<String>
|
||||||
if(result !is Array<*>)
|
|
||||||
throw IllegalStateException("Could not get token from ToolStats")
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun testAnvilResult(event: InventoryClickEvent): Boolean {
|
override fun testAnvilResult(event: InventoryClickEvent): Boolean {
|
||||||
|
|
|
||||||
|
|
@ -144,4 +144,4 @@ class ErrorMessage(key: String, vararg params: String) : Message("error.$key", *
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommandMessage(key: String, vararg params: String) : Message("command.$key", *params)
|
class CommandMessage(key: String, vararg params: String) : Message("command.$key", *params)
|
||||||
class UIMessage(key: String, vararg params: String) : Message("config-ui.$key", *params)
|
class UIMessage(key: String, vararg params: String) : Message("ui.$key", *params)
|
||||||
|
|
@ -1,21 +1,6 @@
|
||||||
package xyz.alexcrea.cuanvil.lang
|
package xyz.alexcrea.cuanvil.lang
|
||||||
|
|
||||||
import xyz.alexcrea.cuanvil.lang.UIMessage as Message
|
|
||||||
|
|
||||||
object MsgUI {
|
object MsgUI {
|
||||||
|
|
||||||
val SHARED_CONFIG_NO_EDIT_PERM = Message("shared.no-permission")
|
|
||||||
|
|
||||||
val CONFIRM_ACTION_FAILED = Message("confirm-action.fail")
|
|
||||||
|
|
||||||
val ELEMENT_LIST_INSTRUCTION_NEW = Message("element-list.instruction-new", "type")
|
|
||||||
val ELEMENT_LIST_CANCELLED_NEW = Message("element-list.cancelled-new", "type")
|
|
||||||
val ELEMENT_LIST_DUPLICATED_NEW = Message("element-list.duplicated-new", "type")
|
|
||||||
|
|
||||||
val UNIT_REPAIR_ELEMENT_TITLE = Message("unit-repair.element.title")
|
|
||||||
val UNIT_REPAIR_ELEMENT_DESCRIPTION = Message("unit-repair.element.description")
|
|
||||||
val UNIT_REPAIR_ELEMENT_CANNOT_REPAIR_NEW = Message("unit-repair.element.cannot-damage-new")
|
|
||||||
val UNIT_REPAIR_ELEMENT_SAME_TYPE_NEW = Message("unit-repair.element.same-type-new")
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -15,6 +15,4 @@ object MsgWarning {
|
||||||
val LOAD_LEGACY_SPIGOT = Message("load.legacy.spigot")
|
val LOAD_LEGACY_SPIGOT = Message("load.legacy.spigot")
|
||||||
val LOAD_LEGACY_SPIGOT_OLD = Message("load.legacy.spigot-old")
|
val LOAD_LEGACY_SPIGOT_OLD = Message("load.legacy.spigot-old")
|
||||||
|
|
||||||
val DEPENDENCY_GENERIC_EXCEPTION = Message("config-ui.shared.no-permission")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -90,23 +90,3 @@ command:
|
||||||
success: "<green>Config reloaded !"
|
success: "<green>Config reloaded !"
|
||||||
fail: "<red>Config was not able to be reloaded..."
|
fail: "<red>Config was not able to be reloaded..."
|
||||||
hard-fail: "<red>Hard fail, plugin disabled"
|
hard-fail: "<red>Hard fail, plugin disabled"
|
||||||
|
|
||||||
config-ui:
|
|
||||||
shared:
|
|
||||||
no-permission: "<red>You do not have permission to edit the config"
|
|
||||||
confirm-action:
|
|
||||||
fail: "<red>Action could not be completed."
|
|
||||||
element-list:
|
|
||||||
instruction-new:
|
|
||||||
1: "<yellow>Write the %type name you want to create in the chat."
|
|
||||||
2: "<yellow>Or write <red>cancel <yellow>to go back to %type config menu"
|
|
||||||
cancelled-new: "%type creation cancelled..."
|
|
||||||
duplicated-new: "<red>Please enter a %type name that do not already exist..."
|
|
||||||
unit-repair:
|
|
||||||
element:
|
|
||||||
title: "Select item to be repaired."
|
|
||||||
description:
|
|
||||||
1: "<gray>Click here with an item to set the item"
|
|
||||||
2: "<gray>You like to be repaired by %name"
|
|
||||||
cannot-damage-new: "<red>This item can't be damaged, so it can't be repaired."
|
|
||||||
same-type-new: "<red>Item can't repair something of the same type."
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue