partialy remove protocolib dependency (#22)

Remove necessity of protocolib for some version (1.17 to 1.21.1)
Can still set `force_protocolib=true` to use protocolib instead of the
build-in packet sender.
This commit is contained in:
alexcrea 2024-08-11 03:58:39 +02:00 committed by GitHub
commit 1746cdfbde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
70 changed files with 1360 additions and 353 deletions

6
.gitignore vendored
View file

@ -3,3 +3,9 @@
/build/ /build/
/out/ /out/
.lastDeploymentsId .lastDeploymentsId
#nms submodule build directory ignored
/nms/build
/nms/.gradle
/nms/*/build
/nms/*/.gradle

View file

@ -10,39 +10,25 @@ plugins {
`maven-publish` `maven-publish`
signing signing
id("cn.lalaki.central").version("1.2.5") id("cn.lalaki.central").version("1.2.5")
id("io.papermc.paperweight.userdev") version "1.7.1" apply false
} }
group = "xyz.alexcrea" group = "xyz.alexcrea"
version = "1.5.4-fix" version = "1.5.4-fix"
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(20))
}
repositories { repositories {
mavenCentral()
maven(url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
// ProtocoLib
maven (url = "https://repo.dmulloy2.net/repository/public/" )
// EcoEnchants // EcoEnchants
maven(url = "https://repo.auxilor.io/repository/maven-public/") maven(url = "https://repo.auxilor.io/repository/maven-public/")
} }
dependencies { dependencies {
// Spigot api
compileOnly(kotlin("stdlib"))
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT") compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
// Gui library // Gui library
implementation("com.github.stefvanschie.inventoryframework:IF:0.10.14") implementation("com.github.stefvanschie.inventoryframework:IF:0.10.14")
// Protocolib
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
// EnchantsSquaredRewritten // EnchantsSquaredRewritten
compileOnly(files("libs/EnchantsSquared.jar")) compileOnly(files("libs/EnchantsSquared.jar"))
@ -50,29 +36,69 @@ dependencies {
compileOnly("com.willfp:EcoEnchants:12.5.1") compileOnly("com.willfp:EcoEnchants:12.5.1")
compileOnly("com.willfp:eco:6.70.1") compileOnly("com.willfp:eco:6.70.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0") // Include nms
implementation(project(":nms:nms-common"))
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") implementation(project(":nms:v1_17R1", configuration = "reobf"))
implementation(project(":nms:v1_18R1", configuration = "reobf"))
implementation(project(":nms:v1_18R2", configuration = "reobf"))
implementation(project(":nms:v1_19R1", configuration = "reobf"))
implementation(project(":nms:v1_19R2", configuration = "reobf"))
implementation(project(":nms:v1_19R3", configuration = "reobf"))
implementation(project(":nms:v1_20R1", configuration = "reobf"))
implementation(project(":nms:v1_20R2", configuration = "reobf"))
implementation(project(":nms:v1_20R3", configuration = "reobf"))
implementation(project(":nms:v1_20R4", configuration = "reobf"))
implementation(project(":nms:v1_21R1", configuration = "reobf"))
} }
tasks.getByName<Test>("test") { allprojects {
apply(plugin = "java")
apply(plugin = "kotlin")
repositories {
mavenCentral()
// Spigot repository
maven(url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
// Paper repository
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies {
compileOnly(kotlin("stdlib"))
// Currently not used. but it would be useful to test.
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
tasks.getByName<Test>("test") {
useJUnitPlatform() useJUnitPlatform()
} }
// Set target version // Configure used version of kotlin and java
tasks.withType<JavaCompile>().configureEach { java {
sourceCompatibility = "16" // We aim for java 16 for minecraft 1.16.5. even if it not really suported. disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(20))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "16" // We aim for java 16 for minecraft 1.16.5. even if it not really suported by custom anvil.
targetCompatibility = "16" targetCompatibility = "16"
}
kotlin { options.encoding = "UTF-8"
}
kotlin {
compilerOptions { compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0) apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_16) jvmTarget.set(JvmTarget.JVM_16)
} }
} }
}
// Fat-jar builder // Fat-jar builder
val fatJar = tasks.register<Jar>("fatJar") { val fatJar = tasks.register<Jar>("fatJar") {

View file

@ -0,0 +1,16 @@
group = rootProject.group
version = rootProject.version
repositories {
// ProtocoLib
maven (url = "https://repo.dmulloy2.net/repository/public/" )
}
dependencies {
// Spigot api
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
// Protocolib
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
}

View file

@ -0,0 +1,14 @@
package xyz.alexcrea.cuanvil.dependency.packet
import org.bukkit.entity.Player
class NoPacketManager: PacketManager {
override val canSetInstantBuild: Boolean
get() = false
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
// ProtocoLib not installed and not in a supported version: We do nothing
}
}

View file

@ -0,0 +1,17 @@
package xyz.alexcrea.cuanvil.dependency.packet
import org.bukkit.entity.Player
interface PacketManager {
/**
* If the provided packet manager if able to set instant build.
*/
val canSetInstantBuild: Boolean
/**
* Try to set instant build properties
*/
fun setInstantBuild(player: Player, instantBuild: Boolean)
}

View file

@ -0,0 +1,16 @@
package xyz.alexcrea.cuanvil.dependency.packet
import org.bukkit.entity.Player
import org.bukkit.event.Listener
abstract class PacketManagerBase() : PacketManager, Listener {
override val canSetInstantBuild: Boolean
get() = false
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
// Default implementation is empty.
}
}

View file

@ -1,4 +1,4 @@
package xyz.alexcrea.cuanvil.dependency.protocolib package xyz.alexcrea.cuanvil.dependency.packet
import com.comphenix.protocol.PacketType import com.comphenix.protocol.PacketType
import com.comphenix.protocol.ProtocolLibrary import com.comphenix.protocol.ProtocolLibrary
@ -11,7 +11,7 @@ class ProtocoLibWrapper: PacketManager {
private val protocolManager: ProtocolManager = ProtocolLibrary.getProtocolManager(); private val protocolManager: ProtocolManager = ProtocolLibrary.getProtocolManager();
override val isProtocoLibInstalled: Boolean override val canSetInstantBuild: Boolean
get() = true get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) { override fun setInstantBuild(player: Player, instantBuild: Boolean) {

View file

@ -0,0 +1,43 @@
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.17.1-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// As minecraft 1.17 recommended java version is 1.16. we set language version to 1.16
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(16))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "16"
targetCompatibility = "16"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_16)
}
}

View file

@ -0,0 +1,33 @@
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.v1_17_R1.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_17R1_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)
}
}

View file

@ -0,0 +1,43 @@
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.18.1-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// As minecraft 1.18 work with java 1.17 or above. we set language version to 1.17
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -0,0 +1,33 @@
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.v1_18_R1.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_18R1_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)
}
}

View file

@ -0,0 +1,43 @@
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.18.2-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// As minecraft 1.18 work with java 1.17 or above. we set language version to 1.17
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -0,0 +1,33 @@
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.v1_18_R2.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_18R2_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)
}
}

View file

@ -0,0 +1,43 @@
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.19.2-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// I do not know minecraft 1.19 recommended java version. assumed 17 is good enough
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -0,0 +1,33 @@
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.v1_19_R1.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_19R1_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)
}
}

View file

@ -0,0 +1,43 @@
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.19.3-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// I do not know minecraft 1.19 recommended java version. assumed 17 is good enough
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -0,0 +1,33 @@
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.v1_19_R2.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_19R2_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)
}
}

View file

@ -0,0 +1,43 @@
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.19.4-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// I do not know minecraft 1.19 recommended java version. assumed 17 is good enough
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -0,0 +1,33 @@
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.v1_19_R3.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_19R3_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)
}
}

View file

@ -0,0 +1,43 @@
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.20.1-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// minecraft 1.20 recommended java version is 18. but we assume 17 is good enough as lts
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -0,0 +1,33 @@
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.v1_20_R1.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_20R1_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)
}
}

View file

@ -0,0 +1,43 @@
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.20.2-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// minecraft 1.20 recommended java version is 18. but we assume 17 is good enough as lts
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -0,0 +1,33 @@
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.v1_20_R2.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_20R2_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)
}
}

View file

@ -0,0 +1,43 @@
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.20.4-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// minecraft 1.20 recommended java version is 18. but we assume 17 is good enough as lts
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -0,0 +1,33 @@
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.v1_20_R3.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_20R3_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)
}
}

View file

@ -0,0 +1,43 @@
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.20.6-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// minecraft 1.20 recommended java version is 18. but we assume 17 is good enough as lts
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -0,0 +1,33 @@
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_20R4_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)
}
}

View file

@ -0,0 +1,43 @@
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-R0.1-SNAPSHOT") // 1.21.1 userdev did not release yet but still use R1
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// minecraft 1.21 java version is 21.
// Configure used version of kotlin and java
java {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
// 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_0)
jvmTarget.set(JvmTarget.JVM_21)
}
}

View file

@ -0,0 +1,33 @@
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)
}
}

View file

@ -1,2 +1,27 @@
rootProject.name = "CustomAnvil" rootProject.name = "CustomAnvil"
// NMS subproject
include("nms:nms-common")
findProject(":nms:nms-common")?.name = "nms-common"
include("nms:v1_17R1")
findProject(":nms:v1_17R1")?.name = "v1_17R1"
include("nms:v1_18R1")
findProject(":nms:v1_18R1")?.name = "v1_18R1"
include("nms:v1_18R2")
findProject(":nms:v1_18R2")?.name = "v1_18R2"
include("nms:v1_19R1")
findProject(":nms:v1_19R1")?.name = "v1_19R1"
include("nms:v1_19R2")
findProject(":nms:v1_19R2")?.name = "v1_19R2"
include("nms:v1_19R3")
findProject(":nms:v1_19R3")?.name = "v1_19R3"
include("nms:v1_20R1")
findProject(":nms:v1_20R1")?.name = "v1_20R1"
include("nms:v1_20R2")
findProject(":nms:v1_20R2")?.name = "v1_20R2"
include("nms:v1_20R3")
findProject(":nms:v1_20R3")?.name = "v1_20R3"
include("nms:v1_20R4")
findProject(":nms:v1_20R4")?.name = "v1_20R4"
include("nms:v1_21R1")
findProject(":nms:v1_21R1")?.name = "v1_21R1"

View file

@ -8,7 +8,7 @@ import io.delilaheve.CustomAnvil;
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 xyz.alexcrea.cuanvil.dependency.protocolib.PacketManager; import xyz.alexcrea.cuanvil.dependency.packet.PacketManager;
import xyz.alexcrea.cuanvil.gui.config.global.*; import xyz.alexcrea.cuanvil.gui.config.global.*;
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems; import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
@ -23,7 +23,7 @@ public class MainConfigGui extends ChestGui {
} }
private MainConfigGui() { private MainConfigGui() {
super(3, "\u00A78Anvil Config", CustomAnvil.instance); super(3, "§8Anvil Config", CustomAnvil.instance);
} }
public void init(PacketManager packetManager) { public void init(PacketManager packetManager) {
@ -42,8 +42,8 @@ public class MainConfigGui extends ChestGui {
ItemMeta basicConfigMeta = basicConfigItemstack.getItemMeta(); ItemMeta basicConfigMeta = basicConfigItemstack.getItemMeta();
assert basicConfigMeta != null; assert basicConfigMeta != null;
basicConfigMeta.setDisplayName("\u00A7aBasic Config Menu"); basicConfigMeta.setDisplayName("§aBasic Config Menu");
basicConfigMeta.setLore(Collections.singletonList("\u00A77Click here to open basic config menu")); basicConfigMeta.setLore(Collections.singletonList("§7Click here to open basic config menu"));
basicConfigItemstack.setItemMeta(basicConfigMeta); basicConfigItemstack.setItemMeta(basicConfigMeta);
GuiItem basicConfigItem = GuiGlobalItems.goToGuiItem(basicConfigItemstack, new BasicConfigGui(packetManager)); GuiItem basicConfigItem = GuiGlobalItems.goToGuiItem(basicConfigItemstack, new BasicConfigGui(packetManager));
@ -54,8 +54,8 @@ public class MainConfigGui extends ChestGui {
ItemMeta enchantLimitMeta = enchantLimitItemstack.getItemMeta(); ItemMeta enchantLimitMeta = enchantLimitItemstack.getItemMeta();
assert enchantLimitMeta != null; assert enchantLimitMeta != null;
enchantLimitMeta.setDisplayName("\u00A7aEnchantment Level Limit"); enchantLimitMeta.setDisplayName("§aEnchantment Level Limit");
enchantLimitMeta.setLore(Collections.singletonList("\u00A77Click here to open enchantment level limit menu")); enchantLimitMeta.setLore(Collections.singletonList("§7Click here to open enchantment level limit menu"));
enchantLimitItemstack.setItemMeta(enchantLimitMeta); enchantLimitItemstack.setItemMeta(enchantLimitMeta);
GuiItem enchantLimitItem = GuiGlobalItems.goToGuiItem(enchantLimitItemstack, new EnchantLimitConfigGui()); GuiItem enchantLimitItem = GuiGlobalItems.goToGuiItem(enchantLimitItemstack, new EnchantLimitConfigGui());
@ -66,8 +66,8 @@ public class MainConfigGui extends ChestGui {
ItemMeta enchantCostMeta = enchantCostItemstack.getItemMeta(); ItemMeta enchantCostMeta = enchantCostItemstack.getItemMeta();
assert enchantCostMeta != null; assert enchantCostMeta != null;
enchantCostMeta.setDisplayName("\u00A7aEnchantment Cost"); enchantCostMeta.setDisplayName("§aEnchantment Cost");
enchantCostMeta.setLore(Collections.singletonList("\u00A77Click here to open enchantment costs menu")); enchantCostMeta.setLore(Collections.singletonList("§7Click here to open enchantment costs menu"));
enchantCostItemstack.setItemMeta(enchantCostMeta); enchantCostItemstack.setItemMeta(enchantCostMeta);
GuiItem enchantCostItem = GuiGlobalItems.goToGuiItem(enchantCostItemstack, new EnchantCostConfigGui()); GuiItem enchantCostItem = GuiGlobalItems.goToGuiItem(enchantCostItemstack, new EnchantCostConfigGui());
@ -78,8 +78,8 @@ public class MainConfigGui extends ChestGui {
ItemMeta enchantConflictMeta = enchantConflictItemstack.getItemMeta(); ItemMeta enchantConflictMeta = enchantConflictItemstack.getItemMeta();
assert enchantConflictMeta != null; assert enchantConflictMeta != null;
enchantConflictMeta.setDisplayName("\u00A7aEnchantment Conflict"); enchantConflictMeta.setDisplayName("§aEnchantment Conflict");
enchantConflictMeta.setLore(Collections.singletonList("\u00A77Click here to open enchantment conflict menu")); enchantConflictMeta.setLore(Collections.singletonList("§7Click here to open enchantment conflict menu"));
enchantConflictItemstack.setItemMeta(enchantConflictMeta); enchantConflictItemstack.setItemMeta(enchantConflictMeta);
GuiItem enchantConflictItem = GuiGlobalItems.goToGuiItem(enchantConflictItemstack, EnchantConflictGui.getInstance()); GuiItem enchantConflictItem = GuiGlobalItems.goToGuiItem(enchantConflictItemstack, EnchantConflictGui.getInstance());
@ -90,8 +90,8 @@ public class MainConfigGui extends ChestGui {
ItemMeta groupMeta = groupItemstack.getItemMeta(); ItemMeta groupMeta = groupItemstack.getItemMeta();
assert groupMeta != null; assert groupMeta != null;
groupMeta.setDisplayName("\u00A7aGroups"); groupMeta.setDisplayName("§aGroups");
groupMeta.setLore(Collections.singletonList("\u00A77Click here to open material group menu")); groupMeta.setLore(Collections.singletonList("§7Click here to open material group menu"));
groupItemstack.setItemMeta(groupMeta); groupItemstack.setItemMeta(groupMeta);
GuiItem groupConfigItem = GuiGlobalItems.goToGuiItem(groupItemstack, GroupConfigGui.getInstance()); GuiItem groupConfigItem = GuiGlobalItems.goToGuiItem(groupItemstack, GroupConfigGui.getInstance());
@ -103,8 +103,8 @@ public class MainConfigGui extends ChestGui {
ItemMeta unitRepairMeta = unirRepairItemstack.getItemMeta(); ItemMeta unitRepairMeta = unirRepairItemstack.getItemMeta();
assert unitRepairMeta != null; assert unitRepairMeta != null;
unitRepairMeta.setDisplayName("\u00A7aUnit Repair"); unitRepairMeta.setDisplayName("§aUnit Repair");
unitRepairMeta.setLore(Collections.singletonList("\u00A77Click here to open anvil unit repair menu")); unitRepairMeta.setLore(Collections.singletonList("§7Click here to open anvil unit repair menu"));
unirRepairItemstack.setItemMeta(unitRepairMeta); unirRepairItemstack.setItemMeta(unitRepairMeta);
GuiItem unitRepairItem = GuiGlobalItems.goToGuiItem(unirRepairItemstack, UnitRepairConfigGui.getInstance()); GuiItem unitRepairItem = GuiGlobalItems.goToGuiItem(unirRepairItemstack, UnitRepairConfigGui.getInstance());
@ -115,8 +115,8 @@ public class MainConfigGui extends ChestGui {
ItemMeta customRecipeMeta = customRecipeItemstack.getItemMeta(); ItemMeta customRecipeMeta = customRecipeItemstack.getItemMeta();
assert customRecipeMeta != null; assert customRecipeMeta != null;
customRecipeMeta.setDisplayName("\u00A7aCustom recipes"); customRecipeMeta.setDisplayName("§aCustom recipes");
customRecipeMeta.setLore(Collections.singletonList("\u00A77Click here to open anvil custom recipe menu")); customRecipeMeta.setLore(Collections.singletonList("§7Click here to open anvil custom recipe menu"));
customRecipeItemstack.setItemMeta(customRecipeMeta); customRecipeItemstack.setItemMeta(customRecipeMeta);
GuiItem customRecipeItem = GuiGlobalItems.goToGuiItem(customRecipeItemstack, CustomRecipeConfigGui.getInstance()); GuiItem customRecipeItem = GuiGlobalItems.goToGuiItem(customRecipeItemstack, CustomRecipeConfigGui.getInstance());
@ -127,7 +127,7 @@ public class MainConfigGui extends ChestGui {
ItemMeta quitMeta = quitItemstack.getItemMeta(); ItemMeta quitMeta = quitItemstack.getItemMeta();
assert quitMeta != null; assert quitMeta != null;
quitMeta.setDisplayName("\u00A7cQuit"); quitMeta.setDisplayName("§cQuit");
quitItemstack.setItemMeta(quitMeta); quitItemstack.setItemMeta(quitMeta);
GuiItem quitItem = new GuiItem(quitItemstack, event -> { GuiItem quitItem = new GuiItem(quitItemstack, event -> {

View file

@ -19,12 +19,12 @@ public interface SelectGroupContainer {
static List<String> getGroupLore(SelectGroupContainer container, String containerType, String groupAction){ static List<String> getGroupLore(SelectGroupContainer container, String containerType, String groupAction){
// Prepare group lore // Prepare group lore
ArrayList<String> groupLore = new ArrayList<>(); ArrayList<String> groupLore = new ArrayList<>();
groupLore.add("\u00A77Allow you to select a list of \u00A73Groups \u00A77that this " + containerType + " should " + groupAction); groupLore.add("§7Allow you to select a list of §3Groups §7that this " + containerType + " should " + groupAction);
Set<AbstractMaterialGroup> grouos = container.getSelectedGroups(); Set<AbstractMaterialGroup> grouos = container.getSelectedGroups();
if (grouos.isEmpty()) { if (grouos.isEmpty()) {
groupLore.add("\u00A77There is no "+groupAction+"d group for this "+containerType+"."); groupLore.add("§7There is no "+groupAction+"d group for this "+containerType+".");
} else { } else {
groupLore.add("\u00A77List of "+groupAction+"d groups for this "+containerType+":"); groupLore.add("§7List of "+groupAction+"d groups for this "+containerType+":");
Iterator<AbstractMaterialGroup> groupIterator = grouos.iterator(); Iterator<AbstractMaterialGroup> groupIterator = grouos.iterator();
boolean greaterThanMax = grouos.size() > 5; boolean greaterThanMax = grouos.size() > 5;
@ -32,11 +32,11 @@ public interface SelectGroupContainer {
for (int i = 0; i < maxindex; i++) { for (int i = 0; i < maxindex; i++) {
// format string like "- Melee Weapons" // format string like "- Melee Weapons"
String formattedName = CasedStringUtil.snakeToUpperSpacedCase(groupIterator.next().getName()); String formattedName = CasedStringUtil.snakeToUpperSpacedCase(groupIterator.next().getName());
groupLore.add("\u00A77- \u00A73" + formattedName); groupLore.add("§7- §3" + formattedName);
} }
if (greaterThanMax) { if (greaterThanMax) {
groupLore.add("\u00A77And " + (grouos.size() - 4) + " more..."); groupLore.add("§7And " + (grouos.size() - 4) + " more...");
} }
} }
return groupLore; return groupLore;

View file

@ -16,12 +16,12 @@ public interface SelectMaterialContainer {
static List<String> getMaterialLore(SelectMaterialContainer container, String containerType, String action){ static List<String> getMaterialLore(SelectMaterialContainer container, String containerType, String action){
// Prepare material lore // Prepare material lore
ArrayList<String> groupLore = new ArrayList<>(); ArrayList<String> groupLore = new ArrayList<>();
groupLore.add("\u00A77Allow you to select a list of \u00A7ematerials \u00A77that this " + containerType + " should " + action); groupLore.add("§7Allow you to select a list of §ematerials §7that this " + containerType + " should " + action);
Set<Material> materialSet = container.getSelectedMaterials(); Set<Material> materialSet = container.getSelectedMaterials();
if (materialSet.isEmpty()) { if (materialSet.isEmpty()) {
groupLore.add("\u00A77There is no "+action+"d material for this "+containerType+"."); groupLore.add("§7There is no "+action+"d material for this "+containerType+".");
} else { } else {
groupLore.add("\u00A77List of "+action+"d materials for this "+containerType+":"); groupLore.add("§7List of "+action+"d materials for this "+containerType+":");
Iterator<Material> materialIterator = materialSet.iterator(); Iterator<Material> materialIterator = materialSet.iterator();
boolean greaterThanMax = materialSet.size() > 5; boolean greaterThanMax = materialSet.size() > 5;
@ -29,11 +29,11 @@ public interface SelectMaterialContainer {
for (int i = 0; i < maxindex; i++) { for (int i = 0; i < maxindex; i++) {
// format string like "- Stone Sword" // format string like "- Stone Sword"
String formattedName = CasedStringUtil.snakeToUpperSpacedCase(materialIterator.next().name().toLowerCase()); String formattedName = CasedStringUtil.snakeToUpperSpacedCase(materialIterator.next().name().toLowerCase());
groupLore.add("\u00A77- \u00A7e" + formattedName); groupLore.add("§7- §e" + formattedName);
} }
if (greaterThanMax) { if (greaterThanMax) {
groupLore.add("\u00A77And " + (materialSet.size() - 4) + " more..."); groupLore.add("§7And " + (materialSet.size() - 4) + " more...");
} }
} }
return groupLore; return groupLore;

View file

@ -45,7 +45,7 @@ public class ConfirmActionGui extends AbstractAskGui {
} }
if (!success) { if (!success) {
event.getWhoClicked().sendMessage("\u00A7cAction could not be completed. "); event.getWhoClicked().sendMessage("§cAction could not be completed. ");
} }
backOnConfirm.show(player); backOnConfirm.show(player);
@ -55,7 +55,7 @@ public class ConfirmActionGui extends AbstractAskGui {
ItemStack infoItem = new ItemStack(Material.PAPER); ItemStack infoItem = new ItemStack(Material.PAPER);
ItemMeta infoMeta = infoItem.getItemMeta(); ItemMeta infoMeta = infoItem.getItemMeta();
infoMeta.setDisplayName("\u00A7eAre you sure ?"); infoMeta.setDisplayName("§eAre you sure ?");
if(actionDescription != null){ if(actionDescription != null){
infoMeta.setLore(Arrays.asList(actionDescription.split("\n"))); infoMeta.setLore(Arrays.asList(actionDescription.split("\n")));
} }

View file

@ -80,7 +80,7 @@ public class SelectItemTypeGui extends AbstractAskGui {
private ItemStack setDisplayMeta(ItemStack item, String actionDescription){ private ItemStack setDisplayMeta(ItemStack item, String actionDescription){
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName("\u00A7ePlace an item here"); meta.setDisplayName("§ePlace an item here");
meta.setLore(Arrays.asList(actionDescription.split("\n"))); meta.setLore(Arrays.asList(actionDescription.split("\n")));
item.setItemMeta(meta); item.setItemMeta(meta);

View file

@ -14,7 +14,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
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.dependency.protocolib.PacketManager; import xyz.alexcrea.cuanvil.dependency.packet.PacketManager;
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui; import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui; import xyz.alexcrea.cuanvil.gui.config.MainConfigGui;
import xyz.alexcrea.cuanvil.gui.config.settings.BoolSettingsGui; import xyz.alexcrea.cuanvil.gui.config.settings.BoolSettingsGui;
@ -44,7 +44,7 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
* Constructor of this Global gui for basic settings. * Constructor of this Global gui for basic settings.
*/ */
public BasicConfigGui(PacketManager packetManager) { public BasicConfigGui(PacketManager packetManager) {
super(4, "\u00A78Basic Config", CustomAnvil.instance); super(4, "§8Basic Config", CustomAnvil.instance);
if(INSTANCE == null) INSTANCE = this; if(INSTANCE == null) INSTANCE = this;
this.packetManager = packetManager; this.packetManager = packetManager;
@ -99,33 +99,33 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
*/ */
protected void prepareValues() { protected void prepareValues() {
// cap anvil cost // cap anvil cost
this.capAnvilCost = BoolSettingsGui.boolFactory("\u00A78Cap Anvil Cost ?", this, this.capAnvilCost = BoolSettingsGui.boolFactory("§8Cap Anvil Cost ?", this,
ConfigHolder.DEFAULT_CONFIG, ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.CAP_ANVIL_COST, ConfigOptions.DEFAULT_CAP_ANVIL_COST, ConfigOptions.CAP_ANVIL_COST, ConfigOptions.DEFAULT_CAP_ANVIL_COST,
"\u00A77All anvil cost will be capped to \u00A7aMax Anvil Cost\u00A77 if enabled.", "§7All anvil cost will be capped to §aMax Anvil Cost§7 if enabled.",
"\u00A77In other words:", "§7In other words:",
"\u00A77For any anvil cost greater than \u00A7aMax Anvil Cost\u00A77, Cost will be set to \u00A7aMax Anvil Cost\u00A77."); "§7For any anvil cost greater than §aMax Anvil Cost§7, Cost will be set to §aMax Anvil Cost§7.");
// cap anvil cost not needed // cap anvil cost not needed
ItemStack item = new ItemStack(Material.BARRIER); ItemStack item = new ItemStack(Material.BARRIER);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7cCap Anvil Cost ?"); meta.setDisplayName("§cCap Anvil Cost ?");
meta.setLore(Collections.singletonList("\u00A77This config only work if \u00A7cLimit Repair Cost\u00A77 is disabled.")); meta.setLore(Collections.singletonList("§7This config only work if §cLimit Repair Cost§7 is disabled."));
item.setItemMeta(meta); item.setItemMeta(meta);
this.noCapRepairItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance); this.noCapRepairItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
// repair cost item // repair cost item
IntRange range = ConfigOptions.MAX_ANVIL_COST_RANGE; IntRange range = ConfigOptions.MAX_ANVIL_COST_RANGE;
this.maxAnvilCost = IntSettingsGui.intFactory("\u00A78Max Anvil Cost", this, this.maxAnvilCost = IntSettingsGui.intFactory("§8Max Anvil Cost", this,
ConfigOptions.MAX_ANVIL_COST, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.MAX_ANVIL_COST, ConfigHolder.DEFAULT_CONFIG,
Arrays.asList( Arrays.asList(
"\u00A77Max cost the Anvil can get to.", "§7Max cost the Anvil can get to.",
"\u00A77Valid values include \u00A7e0 \u00A77to \u00A7e1000\u00A77.", "§7Valid values include §e0 §7to §e1000§7.",
"\u00A77Cost will be displayed as \u00A7cToo Expensive\u00A77:", "§7Cost will be displayed as §cToo Expensive§7:",
"\u00A77- If Cost is above \u00A7e39", "§7- If Cost is above §e39",
"\u00A77- And \u00A7eReplace Too Expensive\u00A77 is disabled" "§7- And §eReplace Too Expensive§7 is disabled"
), ),
range.getFirst(), range.getLast(), range.getFirst(), range.getLast(),
ConfigOptions.DEFAULT_MAX_ANVIL_COST, ConfigOptions.DEFAULT_MAX_ANVIL_COST,
@ -135,22 +135,22 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
meta = item.getItemMeta(); meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7cMax Anvil Cost"); meta.setDisplayName("§cMax Anvil Cost");
meta.setLore(Collections.singletonList("\u00A77This config only work if \u00A7cLimit Repair Cost\u00A77 is disabled.")); meta.setLore(Collections.singletonList("§7This config only work if §cLimit Repair Cost§7 is disabled."));
item.setItemMeta(meta); item.setItemMeta(meta);
this.noMaxCostItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance); this.noMaxCostItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
// remove repair limit item // remove repair limit item
this.removeAnvilCostLimit = BoolSettingsGui.boolFactory("\u00A78Remove Anvil Cost Limit ?", this, this.removeAnvilCostLimit = BoolSettingsGui.boolFactory("§8Remove Anvil Cost Limit ?", this,
ConfigHolder.DEFAULT_CONFIG, ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.REMOVE_ANVIL_COST_LIMIT, ConfigOptions.DEFAULT_REMOVE_ANVIL_COST_LIMIT, ConfigOptions.REMOVE_ANVIL_COST_LIMIT, ConfigOptions.DEFAULT_REMOVE_ANVIL_COST_LIMIT,
"\u00A77Whether the anvil's cost limit should be removed entirely.", "§7Whether the anvil's cost limit should be removed entirely.",
"\u00A77The anvil will still visually display \u00A7cToo Expensive\u00A77 if \u00A7eReplace Too Expensive\u00A77 is disabled.", "§7The anvil will still visually display §cToo Expensive§7 if §eReplace Too Expensive§7 is disabled.",
"\u00A77However, the action will be completable if xp requirement is meet."); "§7However, the action will be completable if xp requirement is meet.");
// replace too expensive item // replace too expensive item
this.replaceTooExpensive = BoolSettingsGui.boolFactory("\u00A78Replace Too Expensive ?", this, this.replaceTooExpensive = BoolSettingsGui.boolFactory("§8Replace Too Expensive ?", this,
ConfigHolder.DEFAULT_CONFIG, ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.REPLACE_TOO_EXPENSIVE, ConfigOptions.DEFAULT_REPLACE_TOO_EXPENSIVE, ConfigOptions.REPLACE_TOO_EXPENSIVE, ConfigOptions.DEFAULT_REPLACE_TOO_EXPENSIVE,
getReplaceToExpensiveLore()); getReplaceToExpensiveLore());
@ -161,23 +161,23 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
// item repair cost // item repair cost
range = ConfigOptions.REPAIR_COST_RANGE; range = ConfigOptions.REPAIR_COST_RANGE;
this.itemRepairCost = IntSettingsGui.intFactory("\u00A78Item Repair Cost", this, this.itemRepairCost = IntSettingsGui.intFactory("§8Item Repair Cost", this,
ConfigOptions.ITEM_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.ITEM_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG,
Arrays.asList( Arrays.asList(
"\u00A77XP Level amount added to the anvil when the item", "§7XP Level amount added to the anvil when the item",
"\u00A77is repaired by another item of the same type." "§7is repaired by another item of the same type."
), ),
range.getFirst(), range.getLast(), range.getFirst(), range.getLast(),
ConfigOptions.DEFAULT_ITEM_REPAIR_COST, ConfigOptions.DEFAULT_ITEM_REPAIR_COST,
1, 5, 10, 50, 100); 1, 5, 10, 50, 100);
// unit repair cost // unit repair cost
this.unitRepairCost = IntSettingsGui.intFactory("\u00A78Unit Repair Cost", this, this.unitRepairCost = IntSettingsGui.intFactory("§8Unit Repair Cost", this,
ConfigOptions.UNIT_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.UNIT_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG,
Arrays.asList( Arrays.asList(
"\u00A77XP Level amount added to the anvil when the item is repaired by an \u00A7eunit\u00A77.", "§7XP Level amount added to the anvil when the item is repaired by an §eunit§7.",
"\u00A77For example: a Diamond on a Diamond Sword.", "§7For example: a Diamond on a Diamond Sword.",
"\u00A77What's considered unit for what can be edited on the unit repair configuration." "§7What's considered unit for what can be edited on the unit repair configuration."
), ),
range.getFirst(), range.getLast(), range.getFirst(), range.getLast(),
ConfigOptions.DEFAULT_UNIT_REPAIR_COST, ConfigOptions.DEFAULT_UNIT_REPAIR_COST,
@ -185,10 +185,10 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
// item rename cost // item rename cost
range = ConfigOptions.ITEM_RENAME_COST_RANGE; range = ConfigOptions.ITEM_RENAME_COST_RANGE;
this.itemRenameCost = IntSettingsGui.intFactory("\u00A78Rename Cost", this, this.itemRenameCost = IntSettingsGui.intFactory("§8Rename Cost", this,
ConfigOptions.ITEM_RENAME_COST, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.ITEM_RENAME_COST, ConfigHolder.DEFAULT_CONFIG,
Arrays.asList( Arrays.asList(
"\u00A77XP Level amount added to the anvil when the item is renamed." "§7XP Level amount added to the anvil when the item is renamed."
), ),
range.getFirst(), range.getLast(), range.getFirst(), range.getLast(),
ConfigOptions.DEFAULT_ITEM_RENAME_COST, ConfigOptions.DEFAULT_ITEM_RENAME_COST,
@ -196,11 +196,11 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
// sacrifice illegal enchant cost // sacrifice illegal enchant cost
range = ConfigOptions.SACRIFICE_ILLEGAL_COST_RANGE; range = ConfigOptions.SACRIFICE_ILLEGAL_COST_RANGE;
this.sacrificeIllegalEnchantCost = IntSettingsGui.intFactory("\u00A78Sacrifice Illegal Enchant Cost", this, this.sacrificeIllegalEnchantCost = IntSettingsGui.intFactory("§8Sacrifice Illegal Enchant Cost", this,
ConfigOptions.SACRIFICE_ILLEGAL_COST, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.SACRIFICE_ILLEGAL_COST, ConfigHolder.DEFAULT_CONFIG,
Arrays.asList( Arrays.asList(
"\u00A77XP Level amount added to the anvil when a sacrifice enchantment", "§7XP Level amount added to the anvil when a sacrifice enchantment",
"\u00A77conflict With one of the left item enchantment" "§7conflict With one of the left item enchantment"
), ),
range.getFirst(), range.getLast(), range.getFirst(), range.getLast(),
ConfigOptions.DEFAULT_SACRIFICE_ILLEGAL_COST, ConfigOptions.DEFAULT_SACRIFICE_ILLEGAL_COST,
@ -211,48 +211,48 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
// ------------- // -------------
// Allow us of color code // Allow us of color code
this.allowColorCode = BoolSettingsGui.boolFactory("\u00A78Allow Use Of Color Code ?", this, this.allowColorCode = BoolSettingsGui.boolFactory("§8Allow Use Of Color Code ?", this,
ConfigHolder.DEFAULT_CONFIG, ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.ALLOW_COLOR_CODE, ConfigOptions.DEFAULT_ALLOW_COLOR_CODE, ConfigOptions.ALLOW_COLOR_CODE, ConfigOptions.DEFAULT_ALLOW_COLOR_CODE,
"\u00A77Whether players can use color code.", "§7Whether players can use color code.",
"\u00A77Color code a formatted like \u00A7a&a\u00A77 and is used in the rename field of the anvil.", "§7Color code a formatted like §a&a§7 and is used in the rename field of the anvil.",
"\u00A77Player may need permission to use color code if \u00A7ePlayer need permission to use color\u00A77 is enabled."); "§7Player may need permission to use color code if §ePlayer need permission to use color§7 is enabled.");
// Allow us of hexadecimal color // Allow us of hexadecimal color
this.allowHexColor = BoolSettingsGui.boolFactory("\u00A78Allow Use Of Hexadecimal Color ?", this, this.allowHexColor = BoolSettingsGui.boolFactory("§8Allow Use Of Hexadecimal Color ?", this,
ConfigHolder.DEFAULT_CONFIG, ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.ALLOW_HEXADECIMAL_COLOR, ConfigOptions.DEFAULT_ALLOW_HEXADECIMAL_COLOR, ConfigOptions.ALLOW_HEXADECIMAL_COLOR, ConfigOptions.DEFAULT_ALLOW_HEXADECIMAL_COLOR,
"\u00A77Whether players can use hexadecimal color.", "§7Whether players can use hexadecimal color.",
"\u00A77Color code a formatted like \u00A72#012345 \u00A77and is used in the rename field of the anvil.", "§7Color code a formatted like §2#012345 §7and is used in the rename field of the anvil.",
"\u00A77Player may need permission to use color code if \u00A7ePermission Needed For Color\u00A77 is enabled."); "§7Player may need permission to use color code if §ePermission Needed For Color§7 is enabled.");
// Permission needed for color // Permission needed for color
this.permissionNeededForColor = BoolSettingsGui.boolFactory("\u00A78Need Permission To Use Color ?", this, this.permissionNeededForColor = BoolSettingsGui.boolFactory("§8Need Permission To Use Color ?", this,
ConfigHolder.DEFAULT_CONFIG, ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.PERMISSION_NEEDED_FOR_COLOR, ConfigOptions.DEFAULT_PERMISSION_NEEDED_FOR_COLOR, ConfigOptions.PERMISSION_NEEDED_FOR_COLOR, ConfigOptions.DEFAULT_PERMISSION_NEEDED_FOR_COLOR,
"\u00A77Whether players should have permission to be able to use colors.", "§7Whether players should have permission to be able to use colors.",
"\u00A77Give player \u00A7eca.color.code\u00A77 Permission to allow use of color code.", "§7Give player §eca.color.code§7 Permission to allow use of color code.",
"\u00A77Give player \u00A7eca.color.hex\u00A77 Permission to allow use of hexadecimal color."); "§7Give player §eca.color.hex§7 Permission to allow use of hexadecimal color.");
// Permission needed for color not necessary // Permission needed for color not necessary
item = new ItemStack(Material.BARRIER); item = new ItemStack(Material.BARRIER);
meta = item.getItemMeta(); meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7cNeed Permission To Use Color ?"); meta.setDisplayName("§cNeed Permission To Use Color ?");
meta.setLore(Arrays.asList("\u00A77This config can do something only if one of the following config is enabled:", meta.setLore(Arrays.asList("§7This config can do something only if one of the following config is enabled:",
"\u00A77- \u00A7aAllow Use Of Color Code", "§7- §aAllow Use Of Color Code",
"\u00A77- \u00A7aAllow Use Of Hexadecimal Color")); "§7- §aAllow Use Of Hexadecimal Color"));
item.setItemMeta(meta); item.setItemMeta(meta);
this.noPermissionNeededItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance); this.noPermissionNeededItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
// Cost of using color // Cost of using color
range = ConfigOptions.USE_OF_COLOR_COST_RANGE; range = ConfigOptions.USE_OF_COLOR_COST_RANGE;
this.useOfColorCost = IntSettingsGui.intFactory("\u00A78Cost Of Using Color", this, this.useOfColorCost = IntSettingsGui.intFactory("§8Cost Of Using Color", this,
ConfigOptions.USE_OF_COLOR_COST, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.USE_OF_COLOR_COST, ConfigHolder.DEFAULT_CONFIG,
Arrays.asList( Arrays.asList(
"\u00A77XP level cost when using color code or hexadecimal color using the anvil.", "§7XP level cost when using color code or hexadecimal color using the anvil.",
"\u00A77conflict With one of the left item enchantment" "§7conflict With one of the left item enchantment"
), ),
range.getFirst(), range.getLast(), range.getFirst(), range.getLast(),
ConfigOptions.DEFAULT_USE_OF_COLOR_COST, ConfigOptions.DEFAULT_USE_OF_COLOR_COST,
@ -263,10 +263,10 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
meta = item.getItemMeta(); meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7cCost Of Using Color"); meta.setDisplayName("§cCost Of Using Color");
meta.setLore(Arrays.asList("\u00A77This config can do something only if one of the following config is enabled:", meta.setLore(Arrays.asList("§7This config can do something only if one of the following config is enabled:",
"\u00A77- \u00A7aAllow Use Of Color Code", "§7- §aAllow Use Of Color Code",
"\u00A77- \u00A7aAllow Use Of Hexadecimal Color")); "§7- §aAllow Use Of Hexadecimal Color"));
item.setItemMeta(meta); item.setItemMeta(meta);
this.noColorCostItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance); this.noColorCostItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
@ -275,14 +275,15 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
@NotNull @NotNull
private String[] getReplaceToExpensiveLore() { private String[] getReplaceToExpensiveLore() {
ArrayList<String> lore = new ArrayList<>(); ArrayList<String> lore = new ArrayList<>();
lore.add("\u00A77Whenever anvil cost is above \u00A7e39\u00A77 should display the true price and not \u00A7cToo Expensive\u00A77."); lore.add("§7Whenever anvil cost is above §e39§7 should display the true price and not §cToo Expensive§7.");
lore.add("\u00A77However, when bypassing \u00A7cToo Expensive\u00A77, anvil price will be displayed as \u00A7aGreen\u00A77."); lore.add("§7However, when bypassing §cToo Expensive§7, anvil price will be displayed as §aGreen§7.");
lore.add("\u00A77Even if cost is displayed as \u00A7aGreen\u00A77:"); lore.add("§7Even if cost is displayed as §aGreen§7:");
lore.add("\u00A77If the player do not have the required xp level, the action will not be completable."); lore.add("§7If the player do not have the required xp level, the action will not be completable.");
if(!this.packetManager.isProtocoLibInstalled()){ if(!this.packetManager.getCanSetInstantBuild()){
lore.add(""); lore.add("");
lore.add("\u00A74/!\\\u00A7cCaution/!\\ \u00A7cYou need ProtocoLib installed for this to work."); lore.add("§4/!\\§cCaution§4/!\\ §cYou need ProtocoLib installed and working or a newer version of this plugin for this to work.");
lore.add("§cCurrently ProtocoLib is not detected.");
} }
String[] loreAsArray = new String[lore.size()]; String[] loreAsArray = new String[lore.size()];

View file

@ -10,6 +10,7 @@ import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.config.ConfigHolder; import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.gui.config.list.MappedGuiListConfigGui; import xyz.alexcrea.cuanvil.gui.config.list.MappedGuiListConfigGui;
import xyz.alexcrea.cuanvil.gui.config.list.elements.CustomRecipeSubSettingGui; import xyz.alexcrea.cuanvil.gui.config.list.elements.CustomRecipeSubSettingGui;
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe; import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe;
import xyz.alexcrea.cuanvil.util.CasedStringUtil; import xyz.alexcrea.cuanvil.util.CasedStringUtil;
@ -54,15 +55,15 @@ public class CustomRecipeConfigGui extends MappedGuiListConfigGui<AnvilCustomRec
ItemMeta meta = displaydItem.getItemMeta(); ItemMeta meta = displaydItem.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(recipe.toString()) + " \u00A7fCustom recipe"); meta.setDisplayName("§e" + CasedStringUtil.snakeToUpperSpacedCase(recipe.toString()) + " §fCustom recipe");
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());
boolean shouldWork = recipe.validate(); boolean shouldWork = recipe.validate();
meta.setLore(Arrays.asList( meta.setLore(Arrays.asList(
"\u00A77Should work: \u00A7"+(shouldWork ? "aYes" : "cNo"), "§7Should work: §"+(shouldWork ? "aYes" : "cNo"),
"\u00A77Exact count: \u00A7"+(recipe.getExactCount() ? "aYes" : "cNo"), "§7Exact count: §"+(recipe.getExactCount() ? "aYes" : "cNo"),
"\u00A77Recipe Xp Cost: \u00A7e"+recipe.getXpCostPerCraft() "§7Recipe Xp Cost: §e"+recipe.getXpCostPerCraft()
)); ));
@ -94,7 +95,7 @@ public class CustomRecipeConfigGui extends MappedGuiListConfigGui<AnvilCustomRec
ConfigHolder.CUSTOM_RECIPE_HOLDER.getRecipeManager().cleanAddNew(recipe); ConfigHolder.CUSTOM_RECIPE_HOLDER.getRecipeManager().cleanAddNew(recipe);
// Save recipe to file // Save recipe to file
recipe.saveToFile(); recipe.saveToFile(GuiSharedConstant.TEMPORARY_DO_SAVE_TO_DISK_EVERY_CHANGE, GuiSharedConstant.TEMPORARY_DO_BACKUP_EVERY_SAVE);
return recipe; return recipe;
} }

View file

@ -74,11 +74,11 @@ public class EnchantConflictGui extends MappedGuiListConfigGui<EnchantConflictGr
assert meta != null; assert meta != null;
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());
meta.setDisplayName("\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(conflict.toString()) + " \u00A7fConflict"); meta.setDisplayName("§e" + CasedStringUtil.snakeToUpperSpacedCase(conflict.toString()) + " §fConflict");
meta.setLore(Arrays.asList( meta.setLore(Arrays.asList(
"\u00A77Enchantment count: \u00A7e" + conflict.getEnchants().size(), "§7Enchantment count: §e" + conflict.getEnchants().size(),
"\u00A77Group count: \u00A7e" + conflict.getCantConflictGroup().getGroups().size(), "§7Group count: §e" + conflict.getCantConflictGroup().getGroups().size(),
"\u00A77Min enchantments count: \u00A7e" + conflict.getMinBeforeBlock() "§7Min enchantments count: §e" + conflict.getMinBeforeBlock()
)); ));
item.setItemMeta(meta); item.setItemMeta(meta);

View file

@ -36,7 +36,7 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
* Constructor of this Global gui for enchantment cost settings. * Constructor of this Global gui for enchantment cost settings.
*/ */
public EnchantCostConfigGui() { public EnchantCostConfigGui() {
super("\u00A78Enchantment Level Cost"); super("§8Enchantment Level Cost");
if(INSTANCE == null) INSTANCE = this; if(INSTANCE == null) INSTANCE = this;
init(); init();
@ -57,8 +57,8 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
return EnchantCostSettingsGui.enchantCostFactory(prettyKey + " Level Cost", this, return EnchantCostSettingsGui.enchantCostFactory(prettyKey + " Level Cost", this,
ConfigHolder.DEFAULT_CONFIG, SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG, SECTION_NAME + '.' + key,
Arrays.asList( Arrays.asList(
"\u00A77How many level should " + prettyKey, "§7How many level should " + prettyKey,
"\u00A77cost when applied by book or by another item." "§7cost when applied by book or by another item."
), ),
0, 255, 0, 255,
rarity.getItemValue(), rarity.getBookValue(), rarity.getItemValue(), rarity.getBookValue(),
@ -70,7 +70,7 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
// Get item properties // Get item properties
int itemCost = factory.getConfiguredValue(); int itemCost = factory.getConfiguredValue();
int bookCost = factory.getConfiguredBookValue(); int bookCost = factory.getConfiguredBookValue();
String itemName = "\u00A7a" + factory.getTitle(); String itemName = "§a" + factory.getTitle();
// Create item // Create item
ItemStack item = new ItemStack(Material.ENCHANTED_BOOK); ItemStack item = new ItemStack(Material.ENCHANTED_BOOK);
ItemMeta itemMeta = item.getItemMeta(); ItemMeta itemMeta = item.getItemMeta();
@ -78,8 +78,8 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
// Prepare lore // Prepare lore
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
lore.add("\u00A77Item Cost: \u00A7e" + itemCost); lore.add("§7Item Cost: §e" + itemCost);
lore.add("\u00A77Book Cost: \u00A7e" + bookCost); lore.add("§7Book Cost: §e" + bookCost);
List<String> displayLore = factory.getDisplayLore(); List<String> displayLore = factory.getDisplayLore();
if(!displayLore.isEmpty()){ if(!displayLore.isEmpty()){

View file

@ -29,7 +29,7 @@ public class EnchantLimitConfigGui extends AbstractEnchantConfigGui<IntSettingsG
* Constructor of this Global gui for enchantment level limit settings. * Constructor of this Global gui for enchantment level limit settings.
*/ */
public EnchantLimitConfigGui() { public EnchantLimitConfigGui() {
super("\u00A78Enchantment Level Limit"); super("§8Enchantment Level Limit");
if(INSTANCE == null) INSTANCE = this; if(INSTANCE == null) INSTANCE = this;
init(); init();
@ -43,7 +43,7 @@ public class EnchantLimitConfigGui extends AbstractEnchantConfigGui<IntSettingsG
return IntSettingsGui.intFactory(prettyKey + " Level Limit", this, return IntSettingsGui.intFactory(prettyKey + " Level Limit", this,
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG, SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
Collections.singletonList( Collections.singletonList(
"\u00A77Maximum applied level of " + prettyKey "§7Maximum applied level of " + prettyKey
), ),
0, 255, 0, 255,
enchant.defaultMaxLevel(), enchant.defaultMaxLevel(),

View file

@ -49,12 +49,12 @@ public class GroupConfigGui extends MappedGuiListConfigGui<IncludeGroup, GroupCo
assert meta != null; assert meta != null;
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());
meta.setDisplayName("\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(group.getName())+ " \u00A7fGroup"); meta.setDisplayName("§e" + CasedStringUtil.snakeToUpperSpacedCase(group.getName())+ " §fGroup");
meta.setLore(Arrays.asList( meta.setLore(Arrays.asList(
"\u00A77Number of selected groups : " + group.getGroups().size(), "§7Number of selected groups : " + group.getGroups().size(),
"\u00A77Number of included material : " + group.getNonGroupInheritedMaterials().size(), "§7Number of included material : " + group.getNonGroupInheritedMaterials().size(),
"", "",
"\u00A77Total number of included material "+group.getMaterials().size())); "§7Total number of included material "+group.getMaterials().size()));
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;

View file

@ -62,10 +62,10 @@ public class UnitRepairConfigGui extends MappedGuiListConfigGui<Material, UnitRe
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7eRepaired by " +materialName); meta.setDisplayName("§eRepaired by " +materialName);
meta.setLore(Arrays.asList( meta.setLore(Arrays.asList(
"\u00A77There is currently \u00A7e" +reparableItemCount+ " \u00A77reparable item with "+materialName, "§7There is currently §e" +reparableItemCount+ " §7reparable item with "+materialName,
"\u00A77Click here to open the menu to edit reparable item by " + materialName "§7Click here to open the menu to edit reparable item by " + materialName
)); ));
item.setItemMeta(meta); item.setItemMeta(meta);
@ -93,10 +93,10 @@ public class UnitRepairConfigGui extends MappedGuiListConfigGui<Material, UnitRe
ItemMeta createMeta = createItem.getItemMeta(); ItemMeta createMeta = createItem.getItemMeta();
assert createMeta != null; assert createMeta != null;
createMeta.setDisplayName("\u00A7aSelect a new unit material"); createMeta.setDisplayName("§aSelect a new unit material");
createMeta.setLore(Arrays.asList( createMeta.setLore(Arrays.asList(
"\u00A77Select a new unit material to be used.", "§7Select a new unit material to be used.",
"\u00A77You will be asked the material to use." "§7You will be asked the material to use."
)); ));
createItem.setItemMeta(createMeta); createItem.setItemMeta(createMeta);
@ -106,8 +106,8 @@ public class UnitRepairConfigGui extends MappedGuiListConfigGui<Material, UnitRe
new SelectItemTypeGui( new SelectItemTypeGui(
"Select unit repair item.", "Select unit repair item.",
"\u00A77Click here with an item to set the item\n" + "§7Click here with an item to set the item\n" +
"\u00A77You 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(); Material type = itemStack.getType();

View file

@ -199,7 +199,7 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
ItemStack leftItem = this.goLeftItem.getItem(); ItemStack leftItem = this.goLeftItem.getItem();
ItemMeta leftMeta = leftItem.getItemMeta(); ItemMeta leftMeta = leftItem.getItemMeta();
leftMeta.setDisplayName("\u00A7eReturn to page " + (page)); leftMeta.setDisplayName("§eReturn to page " + (page));
leftItem.setItemMeta(leftMeta); leftItem.setItemMeta(leftMeta);
this.goLeftItem.setItem(leftItem); this.goLeftItem.setItem(leftItem);
@ -216,7 +216,7 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
ItemStack rightItem = this.goRightItem.getItem(); ItemStack rightItem = this.goRightItem.getItem();
ItemMeta rightMeta = rightItem.getItemMeta(); ItemMeta rightMeta = rightItem.getItemMeta();
rightMeta.setDisplayName("\u00A7eGo to page " + (page + 2)); rightMeta.setDisplayName("§eGo to page " + (page + 2));
rightItem.setItemMeta(rightMeta); rightItem.setItemMeta(rightMeta);
this.goRightItem.setItem(rightItem); this.goRightItem.setItem(rightItem);

View file

@ -29,11 +29,11 @@ public abstract class MappedElementListConfigGui< T, S > extends ElementListConf
ItemMeta createMeta = createItem.getItemMeta(); ItemMeta createMeta = createItem.getItemMeta();
assert createMeta != null; assert createMeta != null;
createMeta.setDisplayName("\u00A7aCreate new "+genericDisplayedName()); createMeta.setDisplayName("§aCreate new "+genericDisplayedName());
createMeta.setLore(Arrays.asList( createMeta.setLore(Arrays.asList(
"\u00A77Create a new "+genericDisplayedName()+".", "§7Create a new "+genericDisplayedName()+".",
"\u00A77You will be asked to name the "+genericDisplayedName()+" in chat.", "§7You will be asked to name the "+genericDisplayedName()+" in chat.",
"\u00A77Then, you should edit the "+genericDisplayedName()+" config as you need" "§7Then, you should edit the "+genericDisplayedName()+" config as you need"
)); ));
createItem.setItemMeta(createMeta); createItem.setItemMeta(createMeta);
@ -50,8 +50,8 @@ public abstract class MappedElementListConfigGui< T, S > extends ElementListConf
} }
player.closeInventory(); player.closeInventory();
player.sendMessage("\u00A7eWrite the "+genericDisplayedName()+" name you want to create in the chat.\n" + player.sendMessage("§eWrite the "+genericDisplayedName()+" name you want to create in the chat.\n" +
"\u00A7eOr write \u00A7ccancel \u00A7eto go back to "+genericDisplayedName()+" config menu"); "§eOr write §ccancel §eto go back to "+genericDisplayedName()+" config menu");
CustomAnvil.Companion.getChatListener().setListenedCallback(player, prepareCreateItemConsumer(player)); CustomAnvil.Companion.getChatListener().setListenedCallback(player, prepareCreateItemConsumer(player));

View file

@ -74,7 +74,7 @@ public abstract class MappedGuiListConfigGui< T, S extends ElementMappedToListGu
// 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 : getEveryDisplayableInstanceOfGeneric()) {
if (generic.toString().equalsIgnoreCase(message)) { if (generic.toString().equalsIgnoreCase(message)) {
player.sendMessage("\u00A7cPlease 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.
CustomAnvil.Companion.getChatListener().setListenedCallback(player, selfRef.get()); CustomAnvil.Companion.getChatListener().setListenedCallback(player, selfRef.get());
return; return;

View file

@ -35,7 +35,7 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
public UnitRepairElementListGui(@NotNull Material parentMaterial, public UnitRepairElementListGui(@NotNull Material parentMaterial,
@NotNull UnitRepairConfigGui parentGui, @NotNull UnitRepairConfigGui parentGui,
@NotNull GuiItem parentItem) { @NotNull GuiItem parentItem) {
super("\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(parentMaterial.name().toLowerCase()) + " \u00A7rUnit repair"); super("§e" + CasedStringUtil.snakeToUpperSpacedCase(parentMaterial.name().toLowerCase()) + " §rUnit repair");
this.parentItem = parentItem; this.parentItem = parentItem;
this.parentMaterial = parentMaterial; this.parentMaterial = parentMaterial;
this.parentGui = parentGui; this.parentGui = parentGui;
@ -48,8 +48,8 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
@Override @Override
protected List<String> getCreateItemLore() { protected List<String> getCreateItemLore() {
return Arrays.asList( return Arrays.asList(
"\u00A77Select a new item to be repairable.", "§7Select a new item to be repairable.",
"\u00A77You will be asked the material to use." "§7You will be asked the material to use."
); );
} }
@ -64,19 +64,19 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
new SelectItemTypeGui( new SelectItemTypeGui(
"Select item to be repaired.", "Select item to be repaired.",
"\u00A77Click here with an item to set the item\n" + "§7Click here with an item to set the item\n" +
"\u00A77You like to be repaired by " + this.materialName, "§7You like to be repaired by " + this.materialName,
this, this,
(itemStack, player) -> { (itemStack, player) -> {
ItemMeta meta = itemStack.getItemMeta(); ItemMeta meta = itemStack.getItemMeta();
Material type = itemStack.getType(); Material type = itemStack.getType();
if(!(meta instanceof Damageable) || (type.getMaxDurability() <= 0)) { if(!(meta instanceof Damageable) || (type.getMaxDurability() <= 0)) {
player.sendMessage("\u00A7cThis 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 == this.parentMaterial){
player.sendMessage("\u00A7cItem can't repair something of the same type."); player.sendMessage("§cItem can't repair something of the same type.");
return; return;
} }
@ -105,7 +105,7 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
@Override @Override
protected String createItemName() { protected String createItemName() {
return "\u00A7aAdd a new item reparable by " + this.materialName; return "§aAdd a new item reparable by " + this.materialName;
} }
@Override @Override
@ -113,13 +113,13 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
String materialDisplayName = CasedStringUtil.snakeToUpperSpacedCase(materialName); String materialDisplayName = CasedStringUtil.snakeToUpperSpacedCase(materialName);
return DoubleSettingGui.doubleFactory( return DoubleSettingGui.doubleFactory(
"\u00A70%\u00A78" + materialDisplayName +" Repair", "§0%§8" + materialDisplayName +" Repair",
this, this,
ConfigHolder.UNIT_REPAIR_HOLDER, ConfigHolder.UNIT_REPAIR_HOLDER,
this.parentMaterial.name().toLowerCase()+"."+materialName, this.parentMaterial.name().toLowerCase()+"."+materialName,
Arrays.asList( Arrays.asList(
"\u00A77Click here to change how many \u00A7e% \u00A77of \u00A7a" + materialDisplayName, "§7Click here to change how many §e% §7of §a" + materialDisplayName,
"\u00A77Should get repaired by \u00A7e"+this.materialName "§7Should get repaired by §e"+this.materialName
), ),
2, 2,
true, true, true, true,
@ -133,7 +133,7 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
@Override @Override
protected GuiItem itemFromFactory(String materialName, DoubleSettingGui.DoubleSettingFactory factory) { protected GuiItem itemFromFactory(String materialName, DoubleSettingGui.DoubleSettingFactory factory) {
return factory.getItem(materialFromName(materialName), return factory.getItem(materialFromName(materialName),
"\u00A77%\u00A7a" + CasedStringUtil.snakeToUpperSpacedCase(materialName)+ " \u00A7erepaired by \u00A7a" + this.materialName); "§7%§a" + CasedStringUtil.snakeToUpperSpacedCase(materialName)+ " §erepaired by §a" + this.materialName);
} }
@Override @Override

View file

@ -37,7 +37,7 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
@NotNull CustomRecipeConfigGui parent, @NotNull CustomRecipeConfigGui parent,
@NotNull AnvilCustomRecipe anvilRecipe, @NotNull AnvilCustomRecipe anvilRecipe,
@NotNull GuiItem parentItemForThisGui) { @NotNull GuiItem parentItemForThisGui) {
super(parentItemForThisGui, 3, "\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(anvilRecipe.toString()) + " \u00A78Config"); super(parentItemForThisGui, 3, "§e" + CasedStringUtil.snakeToUpperSpacedCase(anvilRecipe.toString()) + " §8Config");
this.parent = parent; this.parent = parent;
this.anvilRecipe = anvilRecipe; this.anvilRecipe = anvilRecipe;
@ -68,8 +68,8 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
ItemMeta deleteMeta = deleteItem.getItemMeta(); ItemMeta deleteMeta = deleteItem.getItemMeta();
assert deleteMeta != null; assert deleteMeta != null;
deleteMeta.setDisplayName("\u00A74DELETE RECIPE"); deleteMeta.setDisplayName("§4DELETE RECIPE");
deleteMeta.setLore(Collections.singletonList("\u00A7cCaution with this button !")); deleteMeta.setLore(Collections.singletonList("§cCaution with this button !"));
deleteItem.setItemMeta(deleteMeta); deleteItem.setItemMeta(deleteMeta);
this.pane.bindItem('D', new GuiItem(deleteItem, GuiGlobalActions.openGuiAction(createDeleteGui()), CustomAnvil.instance)); this.pane.bindItem('D', new GuiItem(deleteItem, GuiGlobalActions.openGuiAction(createDeleteGui()), CustomAnvil.instance));
@ -77,33 +77,33 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
// Displayed item will be updated later // Displayed item will be updated later
IntRange costRange = AnvilCustomRecipe.Companion.getXP_COST_CONFIG_RANGE(); IntRange costRange = AnvilCustomRecipe.Companion.getXP_COST_CONFIG_RANGE();
this.exactCountFactory = BoolSettingsGui.boolFactory("\u00A78Exact count ?", this, this.exactCountFactory = BoolSettingsGui.boolFactory("§8Exact count ?", this,
ConfigHolder.DEFAULT_CONFIG, ConfigHolder.DEFAULT_CONFIG,
this.anvilRecipe + "." + AnvilCustomRecipe.EXACT_COUNT_CONFIG, AnvilCustomRecipe.DEFAULT_EXACT_COUNT_CONFIG); this.anvilRecipe + "." + AnvilCustomRecipe.EXACT_COUNT_CONFIG, AnvilCustomRecipe.DEFAULT_EXACT_COUNT_CONFIG);
this.xpCostFactory = IntSettingsGui.intFactory("\u00A78Recipe Xp Cost", this, this.xpCostFactory = IntSettingsGui.intFactory("§8Recipe Xp Cost", this,
this.anvilRecipe +"."+AnvilCustomRecipe.XP_COST_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER, this.anvilRecipe +"."+AnvilCustomRecipe.XP_COST_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER,
null, null,
costRange.getFirst(), costRange.getLast(), AnvilCustomRecipe.DEFAULT_XP_COST_CONFIG, 1, 5, 10); costRange.getFirst(), costRange.getLast(), AnvilCustomRecipe.DEFAULT_XP_COST_CONFIG, 1, 5, 10);
this.leftItemFactory = ItemSettingGui.itemFactory("\u00A7eRecipe Left \u00A78Item", this, this.leftItemFactory = ItemSettingGui.itemFactory("§eRecipe Left §8Item", this,
this.anvilRecipe + "." + AnvilCustomRecipe.LEFT_ITEM_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER, this.anvilRecipe + "." + AnvilCustomRecipe.LEFT_ITEM_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER,
AnvilCustomRecipe.Companion.getDEFAULT_LEFT_ITEM_CONFIG(), AnvilCustomRecipe.Companion.getDEFAULT_LEFT_ITEM_CONFIG(),
"\u00A77Set the left item of the custom craft", "§7Set the left item of the custom craft",
"\u00A77\u25A0 + \u25A1 = \u25A1"); "§7\u25A0 + \u25A1 = \u25A1");
this.rightItemFactory = ItemSettingGui.itemFactory("\u00A7eRecipe Right \u00A78Item", this, this.rightItemFactory = ItemSettingGui.itemFactory("§eRecipe Right §8Item", this,
this.anvilRecipe + "." + AnvilCustomRecipe.RIGHT_ITEM_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER, this.anvilRecipe + "." + AnvilCustomRecipe.RIGHT_ITEM_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER,
AnvilCustomRecipe.Companion.getDEFAULT_RIGHT_ITEM_CONFIG(), AnvilCustomRecipe.Companion.getDEFAULT_RIGHT_ITEM_CONFIG(),
"\u00A77Set the right item of the custom craft", "§7Set the right item of the custom craft",
"\u00A77\u25A1 + \u25A0 = \u25A1"); "§7\u25A1 + \u25A0 = \u25A1");
this.resultItemFactory = ItemSettingGui.itemFactory("\u00A7aRecipe Result \u00A78Item", this, this.resultItemFactory = ItemSettingGui.itemFactory("§aRecipe Result §8Item", this,
this.anvilRecipe + "." + AnvilCustomRecipe.RESULT_ITEM_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER, this.anvilRecipe + "." + AnvilCustomRecipe.RESULT_ITEM_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER,
AnvilCustomRecipe.Companion.getDEFAULT_RESULT_ITEM_CONFIG(), AnvilCustomRecipe.Companion.getDEFAULT_RESULT_ITEM_CONFIG(),
"\u00A77Set the result item of the custom craft", "§7Set the result item of the custom craft",
"\u00A77\u25A1 + \u25A1 = \u25A0"); "§7\u25A1 + \u25A1 = \u25A0");
} }
private ConfirmActionGui createDeleteGui() { private ConfirmActionGui createDeleteGui() {
@ -131,8 +131,8 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
return success; return success;
}; };
return new ConfirmActionGui("\u00A7cDelete \u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(this.anvilRecipe.toString()) + "\u00A7c?", return new ConfirmActionGui("§cDelete §e" + CasedStringUtil.snakeToUpperSpacedCase(this.anvilRecipe.toString()) + "§c?",
"\u00A77Confirm that you want to delete this conflict.", "§7Confirm that you want to delete this conflict.",
this, this.parent, deleteSupplier this, this.parent, deleteSupplier
); );
} }

View file

@ -43,7 +43,7 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
@NotNull GuiItem parentItemForThisGui) { @NotNull GuiItem parentItemForThisGui) {
super(parentItemForThisGui, super(parentItemForThisGui,
3, 3,
"\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(enchantConflict.toString()) + " \u00A78Config"); "§e" + CasedStringUtil.snakeToUpperSpacedCase(enchantConflict.toString()) + " §8Config");
this.parent = parent; this.parent = parent;
this.enchantConflict = enchantConflict; this.enchantConflict = enchantConflict;
@ -72,8 +72,8 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
ItemMeta deleteMeta = deleteItem.getItemMeta(); ItemMeta deleteMeta = deleteItem.getItemMeta();
assert deleteMeta != null; assert deleteMeta != null;
deleteMeta.setDisplayName("\u00A74DELETE CONFLICT"); deleteMeta.setDisplayName("§4DELETE CONFLICT");
deleteMeta.setLore(Collections.singletonList("\u00A7cCaution with this button !")); deleteMeta.setLore(Collections.singletonList("§cCaution with this button !"));
deleteItem.setItemMeta(deleteMeta); deleteItem.setItemMeta(deleteMeta);
this.pane.bindItem('D', new GuiItem(deleteItem, GuiGlobalActions.openGuiAction(createDeleteGui()), CustomAnvil.instance)); this.pane.bindItem('D', new GuiItem(deleteItem, GuiGlobalActions.openGuiAction(createDeleteGui()), CustomAnvil.instance));
@ -82,7 +82,7 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
this.enchantSettingItem = new GuiItem(new ItemStack(Material.ENCHANTED_BOOK), event -> { this.enchantSettingItem = new GuiItem(new ItemStack(Material.ENCHANTED_BOOK), event -> {
event.setCancelled(true); event.setCancelled(true);
EnchantSelectSettingGui enchantGui = new EnchantSelectSettingGui( EnchantSelectSettingGui enchantGui = new EnchantSelectSettingGui(
"\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(enchantConflict.toString()) + "\u00A75", "§e" + CasedStringUtil.snakeToUpperSpacedCase(enchantConflict.toString()) + "§5",
this, this); this, this);
enchantGui.show(event.getWhoClicked()); enchantGui.show(event.getWhoClicked());
}, CustomAnvil.instance); }, CustomAnvil.instance);
@ -90,17 +90,17 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
this.groupSettingItem = new GuiItem(new ItemStack(Material.PAPER), event -> { this.groupSettingItem = new GuiItem(new ItemStack(Material.PAPER), event -> {
event.setCancelled(true); event.setCancelled(true);
GroupSelectSettingGui enchantGui = new GroupSelectSettingGui( GroupSelectSettingGui enchantGui = new GroupSelectSettingGui(
"\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(this.enchantConflict.toString()) + " \u00A73Groups", "§e" + CasedStringUtil.snakeToUpperSpacedCase(this.enchantConflict.toString()) + " §3Groups",
this, this, 0); this, this, 0);
enchantGui.show(event.getWhoClicked()); enchantGui.show(event.getWhoClicked());
}, CustomAnvil.instance); }, CustomAnvil.instance);
this.minBeforeActiveSettingFactory = IntSettingsGui.intFactory( this.minBeforeActiveSettingFactory = IntSettingsGui.intFactory(
"\u00A78Minimum enchantment count", "§8Minimum enchantment count",
this, this.enchantConflict + ".maxEnchantmentBeforeConflict", ConfigHolder.CONFLICT_HOLDER, this, this.enchantConflict + ".maxEnchantmentBeforeConflict", ConfigHolder.CONFLICT_HOLDER,
Arrays.asList( Arrays.asList(
"\u00A77Minimum enchantment count set to X mean only X enchantment can be put", "§7Minimum enchantment count set to X mean only X enchantment can be put",
"\u00A77on an item before the conflict is active." "§7on an item before the conflict is active."
), ),
0, 255, 0, 1 0, 255, 0, 1
); );
@ -138,8 +138,8 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
return success; return success;
}; };
return new ConfirmActionGui("\u00A7cDelete \u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(this.enchantConflict.toString()) + "\u00A7c?", return new ConfirmActionGui("§cDelete §e" + CasedStringUtil.snakeToUpperSpacedCase(this.enchantConflict.toString()) + "§c?",
"\u00A77Confirm that you want to delete this conflict.", "§7Confirm that you want to delete this conflict.",
this, this.parent, deleteSupplier this, this.parent, deleteSupplier
); );
} }
@ -160,12 +160,12 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
// Prepare enchantment lore // Prepare enchantment lore
ArrayList<String> enchantLore = new ArrayList<>(); ArrayList<String> enchantLore = new ArrayList<>();
enchantLore.add("\u00A77Allow you to select a list of \u00A75Enchantments \u00A77that this conflict should include"); enchantLore.add("§7Allow you to select a list of §5Enchantments §7that this conflict should include");
Set<CAEnchantment> enchants = getSelectedEnchantments(); Set<CAEnchantment> enchants = getSelectedEnchantments();
if (enchants.isEmpty()) { if (enchants.isEmpty()) {
enchantLore.add("\u00A77There is no included enchantment for this conflict."); enchantLore.add("§7There is no included enchantment for this conflict.");
} else { } else {
enchantLore.add("\u00A77List of included enchantment for this conflict:"); enchantLore.add("§7List of included enchantment for this conflict:");
Iterator<CAEnchantment> enchantIterator = enchants.iterator(); Iterator<CAEnchantment> enchantIterator = enchants.iterator();
boolean greaterThanMax = enchants.size() > 5; boolean greaterThanMax = enchants.size() > 5;
@ -173,10 +173,10 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
for (int i = 0; i < maxindex; i++) { for (int i = 0; i < maxindex; i++) {
// format string like "- Fire Protection" // format string like "- Fire Protection"
String formattedName = CasedStringUtil.snakeToUpperSpacedCase(enchantIterator.next().getKey().getKey()); String formattedName = CasedStringUtil.snakeToUpperSpacedCase(enchantIterator.next().getKey().getKey());
enchantLore.add("\u00A77- \u00A75" + formattedName); enchantLore.add("§7- §5" + formattedName);
} }
if (greaterThanMax) { if (greaterThanMax) {
enchantLore.add("\u00A77And " + (enchants.size() - 4) + " more..."); enchantLore.add("§7And " + (enchants.size() - 4) + " more...");
} }
} }
@ -189,7 +189,7 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
ItemMeta enchantMeta = enchantItem.getItemMeta(); ItemMeta enchantMeta = enchantItem.getItemMeta();
assert enchantMeta != null; assert enchantMeta != null;
enchantMeta.setDisplayName("\u00A7aSelect included \u00A75Enchantments \u00A7aSettings"); enchantMeta.setDisplayName("§aSelect included §5Enchantments §aSettings");
enchantMeta.setLore(enchantLore); enchantMeta.setLore(enchantLore);
enchantItem.setItemMeta(enchantMeta); enchantItem.setItemMeta(enchantMeta);
@ -201,7 +201,7 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
ItemMeta groupMeta = groupItem.getItemMeta(); ItemMeta groupMeta = groupItem.getItemMeta();
assert groupMeta != null; assert groupMeta != null;
groupMeta.setDisplayName("\u00A7aSelect Excluded \u00A73Groups \u00A7aSettings"); groupMeta.setDisplayName("§aSelect Excluded §3Groups §aSettings");
groupMeta.setLore(groupLore); groupMeta.setLore(groupLore);
groupItem.setItemMeta(groupMeta); groupItem.setItemMeta(groupMeta);

View file

@ -65,8 +65,8 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
ItemStack deleteItem = new ItemStack(Material.RED_TERRACOTTA); ItemStack deleteItem = new ItemStack(Material.RED_TERRACOTTA);
ItemMeta deleteMeta = deleteItem.getItemMeta(); ItemMeta deleteMeta = deleteItem.getItemMeta();
deleteMeta.setDisplayName("\u00A74DELETE GROUP"); deleteMeta.setDisplayName("§4DELETE GROUP");
deleteMeta.setLore(Collections.singletonList("\u00A7cCaution with this button !")); deleteMeta.setLore(Collections.singletonList("§cCaution with this button !"));
deleteItem.setItemMeta(deleteMeta); deleteItem.setItemMeta(deleteMeta);
this.pane.bindItem('D', new GuiItem(deleteItem, openGuiAndCheckAction(), CustomAnvil.instance)); this.pane.bindItem('D', new GuiItem(deleteItem, openGuiAndCheckAction(), CustomAnvil.instance));
@ -140,8 +140,8 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
return success; return success;
}; };
return new ConfirmActionGui("\u00A7cDelete \u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(this.group.toString()) + "\u00A7c?", return new ConfirmActionGui("§cDelete §e" + CasedStringUtil.snakeToUpperSpacedCase(this.group.toString()) + "§c?",
"\u00A77Confirm that you want to delete this group.", "§7Confirm that you want to delete this group.",
this, this.parent, deleteSupplier this, this.parent, deleteSupplier
); );
} }
@ -151,8 +151,8 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
if(usedLoc.isEmpty()){ if(usedLoc.isEmpty()){
return false; return false;
} }
StringBuilder stb = new StringBuilder("\u00A7cCan't delete group " +this.group.getName()+ StringBuilder stb = new StringBuilder("§cCan't delete group " +this.group.getName()+
"\n\u00A7eUsed by:"); "\n§eUsed by:");
int maxIndex = usedLoc.size(); int maxIndex = usedLoc.size();
int nbMore = 0; int nbMore = 0;
if(maxIndex > 10){ if(maxIndex > 10){
@ -160,10 +160,10 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
maxIndex = 9; maxIndex = 9;
} }
for (int i = 0; i < maxIndex; i++) { for (int i = 0; i < maxIndex; i++) {
stb.append("\n\u00A7r-\u00A7e ").append(usedLoc.get(i)); stb.append("\n§r-§e ").append(usedLoc.get(i));
} }
if(nbMore > 0){ if(nbMore > 0){
stb.append("\u00A7cAnd ").append(nbMore).append(" More..."); stb.append("§cAnd ").append(nbMore).append(" More...");
} }
player.sendMessage(stb.toString()); player.sendMessage(stb.toString());
@ -214,7 +214,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
ItemStack matSelectItem = this.materialSelection.getItem(); ItemStack matSelectItem = this.materialSelection.getItem();
ItemMeta matSelectMeta = matSelectItem.getItemMeta(); ItemMeta matSelectMeta = matSelectItem.getItemMeta();
matSelectMeta.setDisplayName("\u00A7aSelect included \u00A7eMaterials \u00A7aSettings"); matSelectMeta.setDisplayName("§aSelect included §eMaterials §aSettings");
matSelectMeta.setLore(matLore); matSelectMeta.setLore(matLore);
matSelectMeta.addItemFlags(ItemFlag.values()); matSelectMeta.addItemFlags(ItemFlag.values());
@ -226,7 +226,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
ItemStack groupSelectItem = this.groupSelection.getItem(); ItemStack groupSelectItem = this.groupSelection.getItem();
ItemMeta groupSelectMeta = groupSelectItem.getItemMeta(); ItemMeta groupSelectMeta = groupSelectItem.getItemMeta();
groupSelectMeta.setDisplayName("\u00A7aSelect included \u00A73Groups \u00A7aSettings"); groupSelectMeta.setDisplayName("§aSelect included §3Groups §aSettings");
groupSelectMeta.setLore(groupLore); groupSelectMeta.setLore(groupLore);
groupSelectItem.setItemMeta(groupSelectMeta); groupSelectItem.setItemMeta(groupSelectMeta);

View file

@ -17,7 +17,7 @@ import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
*/ */
public abstract class AbstractSettingGui extends ChestGui implements SettingGui { public abstract class AbstractSettingGui extends ChestGui implements SettingGui {
protected static final String CLICK_LORE = "\u00A77Click Here to change the value"; protected static final String CLICK_LORE = "§7Click Here to change the value";
private PatternPane pane; private PatternPane pane;

View file

@ -66,9 +66,9 @@ public class BoolSettingsGui extends AbstractSettingGui {
// Prepare default Value text // Prepare default Value text
String defaultValueLore; String defaultValueLore;
if(holder.defaultVal){ if(holder.defaultVal){
defaultValueLore = "\u00A7aYes \u00A77Is the default value"; defaultValueLore = "§aYes §7Is the default value";
}else{ }else{
defaultValueLore = "\u00A7cNo \u00A77Is the default value"; defaultValueLore = "§cNo §7Is the default value";
} }
// Create reset to default item // Create reset to default item
@ -76,7 +76,7 @@ public class BoolSettingsGui extends AbstractSettingGui {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7eReset to default value"); meta.setDisplayName("§eReset to default value");
meta.setLore(Collections.singletonList(defaultValueLore)); meta.setLore(Collections.singletonList(defaultValueLore));
item.setItemMeta(meta); item.setItemMeta(meta);
returnToDefault = new GuiItem(item, event -> { returnToDefault = new GuiItem(item, event -> {
@ -97,10 +97,10 @@ public class BoolSettingsGui extends AbstractSettingGui {
String displayedName; String displayedName;
Material displayedMat; Material displayedMat;
if (now) { if (now) {
displayedName = "\u00A7aYes"; displayedName = "§aYes";
displayedMat = Material.GREEN_TERRACOTTA; displayedMat = Material.GREEN_TERRACOTTA;
} else { } else {
displayedName = "\u00A7cNo"; displayedName = "§cNo";
displayedMat = Material.RED_TERRACOTTA; displayedMat = Material.RED_TERRACOTTA;
} }
@ -254,14 +254,14 @@ public class BoolSettingsGui extends AbstractSettingGui {
boolean value = getConfiguredValue(); boolean value = getConfiguredValue();
Material itemMat; Material itemMat;
StringBuilder itemName = new StringBuilder("\u00A7e"); StringBuilder itemName = new StringBuilder("§e");
String finalValue; String finalValue;
if (value) { if (value) {
itemMat = Material.GREEN_TERRACOTTA; itemMat = Material.GREEN_TERRACOTTA;
finalValue = "\u00A7aYes"; finalValue = "§aYes";
} else { } else {
itemMat = Material.RED_TERRACOTTA; itemMat = Material.RED_TERRACOTTA;
finalValue = "\u00A7cNo"; finalValue = "§cNo";
} }
itemName.append(name); itemName.append(name);

View file

@ -68,9 +68,9 @@ public class DoubleSettingGui extends AbstractSettingGui {
ItemMeta meta = DELETE_ITEM_STACK.getItemMeta(); ItemMeta meta = DELETE_ITEM_STACK.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7cDisable item being repaired ?"); meta.setDisplayName("§cDisable item being repaired ?");
meta.setLore(Arrays.asList("\u00A77Confirm disabling unit repair for this item..", meta.setLore(Arrays.asList("§7Confirm disabling unit repair for this item..",
"\u00A74Cation: This action can't be canceled.")); "§4Cation: This action can't be canceled."));
DELETE_ITEM_STACK.setItemMeta(meta); DELETE_ITEM_STACK.setItemMeta(meta);
} }
@ -121,8 +121,8 @@ public class DoubleSettingGui extends AbstractSettingGui {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7eReset to default value"); meta.setDisplayName("§eReset to default value");
meta.setLore(Collections.singletonList("\u00A77Default value is \u00A7e" + displayValue(holder.defaultVal))); meta.setLore(Collections.singletonList("§7Default value is §e" + displayValue(holder.defaultVal)));
item.setItemMeta(meta); item.setItemMeta(meta);
returnToDefault = new GuiItem(item, event -> { returnToDefault = new GuiItem(item, event -> {
event.setCancelled(true); event.setCancelled(true);
@ -144,7 +144,7 @@ public class DoubleSettingGui extends AbstractSettingGui {
if (now.compareTo(holder.min) > 0) { if (now.compareTo(holder.min) > 0) {
BigDecimal planned = holder.min.max(now.subtract(step)); BigDecimal planned = holder.min.max(now.subtract(step));
minusItem = getSetValueItem(Material.RED_TERRACOTTA, planned, "\u00A7c-"); minusItem = getSetValueItem(Material.RED_TERRACOTTA, planned, "§c-");
} else { } else {
minusItem = GuiGlobalItems.backgroundItem(Material.BARRIER); minusItem = GuiGlobalItems.backgroundItem(Material.BARRIER);
} }
@ -155,7 +155,7 @@ public class DoubleSettingGui extends AbstractSettingGui {
if (now.compareTo(holder.max) < 0) { if (now.compareTo(holder.max) < 0) {
BigDecimal planned = holder.max.min(now.add(step)); BigDecimal planned = holder.max.min(now.add(step));
plusItem = getSetValueItem(Material.GREEN_TERRACOTTA, planned, "\u00A7a+"); plusItem = getSetValueItem(Material.GREEN_TERRACOTTA, planned, "§a+");
} else { } else {
plusItem = GuiGlobalItems.backgroundItem(Material.BARRIER); plusItem = GuiGlobalItems.backgroundItem(Material.BARRIER);
} }
@ -166,7 +166,7 @@ public class DoubleSettingGui extends AbstractSettingGui {
ItemMeta resultMeta = resultPaper.getItemMeta(); ItemMeta resultMeta = resultPaper.getItemMeta();
assert resultMeta != null; assert resultMeta != null;
resultMeta.setDisplayName("\u00A7fValue: \u00A7e" + displayValue(now)); resultMeta.setDisplayName("§fValue: §e" + displayValue(now));
resultPaper.setItemMeta(resultMeta); resultPaper.setItemMeta(resultMeta);
GuiItem resultItem = new GuiItem(resultPaper, GuiGlobalActions.stayInPlace, CustomAnvil.instance); GuiItem resultItem = new GuiItem(resultPaper, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
@ -197,8 +197,8 @@ public class DoubleSettingGui extends AbstractSettingGui {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7e" + displayValue(now) + " \u00A7f-> \u00A7e" + displayValue(planned) meta.setDisplayName("§e" + displayValue(now) + " §f-> §e" + displayValue(planned)
+ " \u00A7r(" + numberPrefix + (displayValue(planned.subtract(now).abs()) + "\u00A7r)")); + " §r(" + numberPrefix + (displayValue(planned.subtract(now).abs()) + "§r)"));
meta.setLore(setLoreItem); meta.setLore(setLoreItem);
item.setItemMeta(meta); item.setItemMeta(meta);
@ -271,21 +271,21 @@ public class DoubleSettingGui extends AbstractSettingGui {
// Get material properties // Get material properties
Material stepMat; Material stepMat;
StringBuilder stepName = new StringBuilder("\u00A7"); StringBuilder stepName = new StringBuilder("§");
List<String> stepLore; List<String> stepLore;
Consumer<InventoryClickEvent> clickEvent; Consumer<InventoryClickEvent> clickEvent;
if (stepValue.compareTo(step) == 0) { if (stepValue.compareTo(step) == 0) {
stepMat = Material.GREEN_STAINED_GLASS_PANE; stepMat = Material.GREEN_STAINED_GLASS_PANE;
stepName.append('a'); stepName.append('a');
stepLore = Collections.singletonList("\u00A77Value is changing by " + displayValue(stepValue)); stepLore = Collections.singletonList("§7Value is changing by " + displayValue(stepValue));
clickEvent = GuiGlobalActions.stayInPlace; clickEvent = GuiGlobalActions.stayInPlace;
} else { } else {
stepMat = Material.RED_STAINED_GLASS_PANE; stepMat = Material.RED_STAINED_GLASS_PANE;
stepName.append('c'); stepName.append('c');
stepLore = Collections.singletonList("\u00A77Click here to change the value by " + displayValue(stepValue)); stepLore = Collections.singletonList("§7Click here to change the value by " + displayValue(stepValue));
clickEvent = updateStepValue(stepValue); clickEvent = updateStepValue(stepValue);
} }
stepName.append("Step of \u00A7e").append(displayValue(stepValue)); stepName.append("Step of §e").append(displayValue(stepValue));
// Create item stack then gui item // Create item stack then gui item
ItemStack item = new ItemStack(stepMat); ItemStack item = new ItemStack(stepMat);
@ -487,10 +487,10 @@ public class DoubleSettingGui extends AbstractSettingGui {
public GuiItem getItem(Material itemMat, String name){ public GuiItem getItem(Material itemMat, String name){
// Get item properties // Get item properties
BigDecimal value = getConfiguredValue(); BigDecimal value = getConfiguredValue();
StringBuilder itemName = new StringBuilder("\u00A7a").append(name); StringBuilder itemName = new StringBuilder("§a").append(name);
return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName, return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName,
"\u00A7e" + displayValue(value, this.asPercentage), "§e" + displayValue(value, this.asPercentage),
this.displayLore, true); this.displayLore, true);
} }

View file

@ -83,10 +83,10 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
ItemMeta bookMeta = bookItemstack.getItemMeta(); ItemMeta bookMeta = bookItemstack.getItemMeta();
assert bookMeta != null; assert bookMeta != null;
bookMeta.setDisplayName("\u00A7aCost of an Enchantment by Book"); bookMeta.setDisplayName("§aCost of an Enchantment by Book");
bookMeta.setLore(Arrays.asList( bookMeta.setLore(Arrays.asList(
"\u00A77Cost per result item level of an sacrifice enchantment", "§7Cost per result item level of an sacrifice enchantment",
"\u00A77Only apply if sacrificed item \u00A7cis \u00A77a book")); "§7Only apply if sacrificed item §cis §7a book"));
bookItemstack.setItemMeta(bookMeta); bookItemstack.setItemMeta(bookMeta);
// sword display // sword display
@ -95,10 +95,10 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
assert swordMeta != null; assert swordMeta != null;
swordMeta.addItemFlags(ItemFlag.values()); swordMeta.addItemFlags(ItemFlag.values());
swordMeta.setDisplayName("\u00A7aCost of an Enchantment by Item"); swordMeta.setDisplayName("§aCost of an Enchantment by Item");
swordMeta.setLore(Arrays.asList( swordMeta.setLore(Arrays.asList(
"\u00A77Cost per result item level of an sacrifice enchantment", "§7Cost per result item level of an sacrifice enchantment",
"\u00A77Only apply if sacrificed item \u00A7cis not \u00A77a book")); "§7Only apply if sacrificed item §cis not §7a book"));
swordItemstack.setItemMeta(swordMeta); swordItemstack.setItemMeta(swordMeta);
pane.bindItem('1', GuiGlobalItems.backgroundItem(Material.BLACK_STAINED_GLASS_PANE)); pane.bindItem('1', GuiGlobalItems.backgroundItem(Material.BLACK_STAINED_GLASS_PANE));
@ -115,10 +115,10 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
// assume holder is an instance of EnchantCostSettingFactory // assume holder is an instance of EnchantCostSettingFactory
EnchantCostSettingFactory holder = (EnchantCostSettingFactory) this.holder; EnchantCostSettingFactory holder = (EnchantCostSettingFactory) this.holder;
meta.setDisplayName("\u00A7eReset to default value"); meta.setDisplayName("§eReset to default value");
meta.setLore(Arrays.asList( meta.setLore(Arrays.asList(
"\u00A77Default item value is: \u00A7e" + holder.defaultVal, "§7Default item value is: §e" + holder.defaultVal,
"\u00A77Default book value is: \u00A7e" + holder.defaultBookVal)); "§7Default book value is: §e" + holder.defaultBookVal));
item.setItemMeta(meta); item.setItemMeta(meta);
returnToDefault = new GuiItem(item, event -> { returnToDefault = new GuiItem(item, event -> {
event.setCancelled(true); event.setCancelled(true);
@ -147,7 +147,7 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7e" + nowBook + " \u00A7f-> \u00A7e" + planned + " \u00A7r(\u00A7c-" + (nowBook - planned) + "\u00A7r)"); meta.setDisplayName("§e" + nowBook + " §f-> §e" + planned + " §r(§c-" + (nowBook - planned) + "§r)");
meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE)); meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE));
item.setItemMeta(meta); item.setItemMeta(meta);
@ -165,7 +165,7 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7e" + nowBook + " \u00A7f-> \u00A7e" + planned + " \u00A7r(\u00A7a+" + (planned - nowBook) + "\u00A7r)"); meta.setDisplayName("§e" + nowBook + " §f-> §e" + planned + " §r(§a+" + (planned - nowBook) + "§r)");
meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE)); meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE));
item.setItemMeta(meta); item.setItemMeta(meta);
@ -180,7 +180,7 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
ItemMeta nowMeta = nowPaper.getItemMeta(); ItemMeta nowMeta = nowPaper.getItemMeta();
assert nowMeta != null; assert nowMeta != null;
nowMeta.setDisplayName("\u00A7fValue: \u00A7e" + nowBook); nowMeta.setDisplayName("§fValue: §e" + nowBook);
if(!holder.displayLore.isEmpty()){ if(!holder.displayLore.isEmpty()){
nowMeta.setLore(holder.displayLore); nowMeta.setLore(holder.displayLore);
} }

View file

@ -107,9 +107,9 @@ public class EnchantSelectSettingGui extends SettingGuiListConfigGui<CAEnchantme
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName((this.displayUnselected ? "\u00A7aEverything displayed" : "\u00A7eOnly selected displayed")); meta.setDisplayName((this.displayUnselected ? "§aEverything displayed" : "§eOnly selected displayed"));
meta.setLore(Collections.singletonList( meta.setLore(Collections.singletonList(
"\u00A77Click here to see " + "§7Click here to see " +
(this.displayUnselected ? "only selected" : "every") + (this.displayUnselected ? "only selected" : "every") +
" enchantments")); " enchantments"));
@ -124,8 +124,8 @@ public class EnchantSelectSettingGui extends SettingGuiListConfigGui<CAEnchantme
}, CustomAnvil.instance); }, CustomAnvil.instance);
} }
private static final List<String> TRUE_LORE = Collections.singletonList("\u00A77Value: \u00A7aSelected"); private static final List<String> TRUE_LORE = Collections.singletonList("§7Value: §aSelected");
private static final List<String> FALSE_LORE = Collections.singletonList("\u00A77Value: \u00A7cNot Selected"); private static final List<String> FALSE_LORE = Collections.singletonList("§7Value: §cNot Selected");
public void setEnchantItemMeta(ItemStack item, String name, boolean isIn) { public void setEnchantItemMeta(ItemStack item, String name, boolean isIn) {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
@ -138,7 +138,7 @@ public class EnchantSelectSettingGui extends SettingGuiListConfigGui<CAEnchantme
assert meta != null; assert meta != null;
} }
meta.setDisplayName("\u00A7" + (isIn ? 'a' : 'c') + CasedStringUtil.snakeToUpperSpacedCase(name)); meta.setDisplayName("§" + (isIn ? 'a' : 'c') + CasedStringUtil.snakeToUpperSpacedCase(name));
if (isIn) { if (isIn) {
meta.addEnchant(Enchantment.DAMAGE_UNDEAD, 1, true); meta.addEnchant(Enchantment.DAMAGE_UNDEAD, 1, true);
meta.setLore(TRUE_LORE); meta.setLore(TRUE_LORE);

View file

@ -91,8 +91,8 @@ public class GroupSelectSettingGui extends AbstractSettingGui {
return guiItem; return guiItem;
} }
private static final List<String> TRUE_LORE = Collections.singletonList("\u00A77Value: \u00A7aSelected"); private static final List<String> TRUE_LORE = Collections.singletonList("§7Value: §aSelected");
private static final List<String> FALSE_LORE = Collections.singletonList("\u00A77Value: \u00A7cNot Selected"); private static final List<String> FALSE_LORE = Collections.singletonList("§7Value: §cNot Selected");
public void setGroupItemMeta(ItemStack item, String name, boolean isIn) { public void setGroupItemMeta(ItemStack item, String name, boolean isIn) {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
@ -105,7 +105,7 @@ public class GroupSelectSettingGui extends AbstractSettingGui {
assert meta != null; assert meta != null;
} }
meta.setDisplayName("\u00A7" + (isIn ? 'a' : 'c') + CasedStringUtil.snakeToUpperSpacedCase(name)); meta.setDisplayName("§" + (isIn ? 'a' : 'c') + CasedStringUtil.snakeToUpperSpacedCase(name));
if (isIn) { if (isIn) {
meta.addEnchant(Enchantment.DAMAGE_UNDEAD, 1, true); meta.addEnchant(Enchantment.DAMAGE_UNDEAD, 1, true);
meta.setLore(TRUE_LORE); meta.setLore(TRUE_LORE);

View file

@ -71,8 +71,8 @@ public class IntSettingsGui extends AbstractSettingGui {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7eReset to default value"); meta.setDisplayName("§eReset to default value");
meta.setLore(Collections.singletonList("\u00A77Default value is \u00A7e" + holder.defaultVal)); meta.setLore(Collections.singletonList("§7Default value is §e" + holder.defaultVal));
item.setItemMeta(meta); item.setItemMeta(meta);
returnToDefault = new GuiItem(item, event -> { returnToDefault = new GuiItem(item, event -> {
event.setCancelled(true); event.setCancelled(true);
@ -97,7 +97,7 @@ public class IntSettingsGui extends AbstractSettingGui {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7e" + now + " \u00A7f-> \u00A7e" + planned + " \u00A7r(\u00A7c-" + (now - planned) + "\u00A7r)"); meta.setDisplayName("§e" + now + " §f-> §e" + planned + " §r(§c-" + (now - planned) + "§r)");
meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE)); meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE));
item.setItemMeta(meta); item.setItemMeta(meta);
@ -116,7 +116,7 @@ public class IntSettingsGui extends AbstractSettingGui {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7e" + now + " \u00A7f-> \u00A7e" + planned + " \u00A7r(\u00A7a+" + (planned - now) + "\u00A7r)"); meta.setDisplayName("§e" + now + " §f-> §e" + planned + " §r(§a+" + (planned - now) + "§r)");
meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE)); meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE));
item.setItemMeta(meta); item.setItemMeta(meta);
@ -131,7 +131,7 @@ public class IntSettingsGui extends AbstractSettingGui {
ItemMeta resultMeta = resultPaper.getItemMeta(); ItemMeta resultMeta = resultPaper.getItemMeta();
assert resultMeta != null; assert resultMeta != null;
resultMeta.setDisplayName("\u00A7fValue: \u00A7e" + now); resultMeta.setDisplayName("§fValue: §e" + now);
resultMeta.setLore(holder.displayLore); resultMeta.setLore(holder.displayLore);
resultPaper.setItemMeta(resultMeta); resultPaper.setItemMeta(resultMeta);
@ -218,21 +218,21 @@ public class IntSettingsGui extends AbstractSettingGui {
// Get material properties // Get material properties
Material stepMat; Material stepMat;
StringBuilder stepName = new StringBuilder("\u00A7"); StringBuilder stepName = new StringBuilder("§");
List<String> stepLore; List<String> stepLore;
Consumer<InventoryClickEvent> clickEvent; Consumer<InventoryClickEvent> clickEvent;
if (stepValue == step) { if (stepValue == step) {
stepMat = Material.GREEN_STAINED_GLASS_PANE; stepMat = Material.GREEN_STAINED_GLASS_PANE;
stepName.append('a'); stepName.append('a');
stepLore = Collections.singletonList("\u00A77Value is changing by " + stepValue); stepLore = Collections.singletonList("§7Value is changing by " + stepValue);
clickEvent = GuiGlobalActions.stayInPlace; clickEvent = GuiGlobalActions.stayInPlace;
} else { } else {
stepMat = Material.RED_STAINED_GLASS_PANE; stepMat = Material.RED_STAINED_GLASS_PANE;
stepName.append('c'); stepName.append('c');
stepLore = Collections.singletonList("\u00A77Click here to change the value by " + stepValue); stepLore = Collections.singletonList("§7Click here to change the value by " + stepValue);
clickEvent = updateStepValue(stepValue); clickEvent = updateStepValue(stepValue);
} }
stepName.append("Step of: \u00A7e").append(stepValue); stepName.append("Step of: §e").append(stepValue);
// Create item stack then gui item // Create item stack then gui item
ItemStack item = new ItemStack(stepMat); ItemStack item = new ItemStack(stepMat);
@ -393,10 +393,10 @@ public class IntSettingsGui extends AbstractSettingGui {
) { ) {
// Get item properties // Get item properties
int value = getConfiguredValue(); int value = getConfiguredValue();
StringBuilder itemName = new StringBuilder("\u00A7a").append(name); StringBuilder itemName = new StringBuilder("§a").append(name);
return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName, return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName,
"\u00A7e" + value, "§e" + value,
this.displayLore, true); this.displayLore, true);
} }

View file

@ -77,8 +77,8 @@ public class ItemSettingGui extends AbstractSettingGui {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7eReset to default value"); meta.setDisplayName("§eReset to default value");
meta.setLore(Collections.singletonList("\u00A77Default value is \u00A7e" + holder.defaultVal)); meta.setLore(Collections.singletonList("§7Default value is §e" + holder.defaultVal));
item.setItemMeta(meta); item.setItemMeta(meta);
returnToDefault = new GuiItem(item, event -> { returnToDefault = new GuiItem(item, event -> {
event.setCancelled(true); event.setCancelled(true);
@ -88,7 +88,7 @@ public class ItemSettingGui extends AbstractSettingGui {
}, CustomAnvil.instance); }, CustomAnvil.instance);
} }
protected final static List<String> CLICK_LORE = Collections.singletonList("\u00A77Click Here with an item to change the value"); protected final static List<String> CLICK_LORE = Collections.singletonList("§7Click Here with an item to change the value");
/** /**
* Update item using the setting value to match the new value * Update item using the setting value to match the new value
@ -105,7 +105,7 @@ public class ItemSettingGui extends AbstractSettingGui {
ItemMeta valueMeta = displayedItem.getItemMeta(); ItemMeta valueMeta = displayedItem.getItemMeta();
assert valueMeta != null; assert valueMeta != null;
valueMeta.setDisplayName("\u00A74NO ITEM SET"); valueMeta.setDisplayName("§4NO ITEM SET");
valueMeta.setLore(CLICK_LORE); valueMeta.setLore(CLICK_LORE);
displayedItem.setItemMeta(valueMeta); displayedItem.setItemMeta(valueMeta);
@ -266,7 +266,7 @@ public class ItemSettingGui extends AbstractSettingGui {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7a" + name); meta.setDisplayName("§a" + name);
meta.setLore(getDisplayLore()); meta.setLore(getDisplayLore());
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());

View file

@ -85,10 +85,10 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Materia
ItemMeta selectMeta = selectItem.getItemMeta(); ItemMeta selectMeta = selectItem.getItemMeta();
assert selectMeta != null; assert selectMeta != null;
selectMeta.setDisplayName("\u00A7aAdd Item"); selectMeta.setDisplayName("§aAdd Item");
selectMeta.setLore(Arrays.asList( selectMeta.setLore(Arrays.asList(
"\u00A77Click here with an item to add", "§7Click here with an item to add",
"\u00A77it's Material to the list.")); "§7it's Material to the list."));
selectItem.setItemMeta(selectMeta); selectItem.setItemMeta(selectMeta);
@ -105,9 +105,9 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Materia
ItemMeta instantRemoveOnMeta = instantRemoveOnItem.getItemMeta(); ItemMeta instantRemoveOnMeta = instantRemoveOnItem.getItemMeta();
assert instantRemoveOnMeta != null; assert instantRemoveOnMeta != null;
instantRemoveOnMeta.setDisplayName("\u00A7eInstant remove is \u00A7aEnabled \u00A7e!"); instantRemoveOnMeta.setDisplayName("§eInstant remove is §aEnabled §e!");
instantRemoveOnMeta.setLore( instantRemoveOnMeta.setLore(
Collections.singletonList("\u00A77Click here to disable the instant remove")); Collections.singletonList("§7Click here to disable the instant remove"));
instantRemoveOnItem.setItemMeta(instantRemoveOnMeta); instantRemoveOnItem.setItemMeta(instantRemoveOnMeta);
@ -116,9 +116,9 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Materia
ItemMeta instantRemoveOffMeta = instantRemoveOffItem.getItemMeta(); ItemMeta instantRemoveOffMeta = instantRemoveOffItem.getItemMeta();
assert instantRemoveOffMeta != null; assert instantRemoveOffMeta != null;
instantRemoveOffMeta.setDisplayName("\u00A7eInstant remove is \u00A7cDisabled \u00A7e!"); instantRemoveOffMeta.setDisplayName("§eInstant remove is §cDisabled §e!");
instantRemoveOffMeta.setLore( instantRemoveOffMeta.setLore(
Collections.singletonList("\u00A77Click here to enable the instant remove")); Collections.singletonList("§7Click here to enable the instant remove"));
instantRemoveOffItem.setItemMeta(instantRemoveOffMeta); instantRemoveOffItem.setItemMeta(instantRemoveOffMeta);
@ -143,7 +143,7 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Materia
ItemMeta saveMeta = saveItemStack.getItemMeta(); ItemMeta saveMeta = saveItemStack.getItemMeta();
assert saveMeta != null; assert saveMeta != null;
saveMeta.setDisplayName("\u00A7aSave"); saveMeta.setDisplayName("§aSave");
saveItemStack.setItemMeta(saveMeta); saveItemStack.setItemMeta(saveMeta);
@ -165,7 +165,7 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Materia
result.addAll(this.elementGuiMap.keySet()); result.addAll(this.elementGuiMap.keySet());
if(!this.selector.setSelectedMaterials(result)){ if(!this.selector.setSelectedMaterials(result)){
player.sendMessage("\u00A7cSomething went wrong while saving the change of value."); player.sendMessage("§cSomething went wrong while saving the change of value.");
} }
// Return to parent // Return to parent
@ -206,8 +206,8 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Materia
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
if(meta == null) return item; if(meta == null) return item;
meta.setDisplayName("\u00A7a" + CasedStringUtil.snakeToUpperSpacedCase(material.name().toLowerCase())); meta.setDisplayName("§a" + CasedStringUtil.snakeToUpperSpacedCase(material.name().toLowerCase()));
meta.setLore(Collections.singletonList("\u00A77Click here to remove this material from the list")); meta.setLore(Collections.singletonList("§7Click here to remove this material from the list"));
meta.addItemFlags(ItemFlag.values()); meta.addItemFlags(ItemFlag.values());
item.setItemMeta(meta); item.setItemMeta(meta);
@ -236,7 +236,7 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Materia
// Create and show confirm remove gui. // Create and show confirm remove gui.
ConfirmActionGui confirmGui = new ConfirmActionGui( ConfirmActionGui confirmGui = new ConfirmActionGui(
"Remove " + materialName, "Remove " + materialName,
"\u00A77Confirm Remove " + materialName.toLowerCase() + " from this list.", "§7Confirm Remove " + materialName.toLowerCase() + " from this list.",
this, this, this, this,
() -> { () -> {
removeMaterial(material); removeMaterial(material);

View file

@ -133,7 +133,7 @@ public class GuiGlobalActions {
// Save setting // Save setting
if (!setting.onSave()) { if (!setting.onSave()) {
player.sendMessage("\u00A7cSomething went wrong while saving the change of value."); player.sendMessage("§cSomething went wrong while saving the change of value.");
} }
// Update gui for those who have it open. // Update gui for those who have it open.
goal.updateGuiValues(); goal.updateGuiValues();

View file

@ -30,7 +30,7 @@ public class GuiGlobalItems {
ItemMeta meta = BACK_ITEM.getItemMeta(); ItemMeta meta = BACK_ITEM.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7cBack"); meta.setDisplayName("§cBack");
BACK_ITEM.setItemMeta(meta); BACK_ITEM.setItemMeta(meta);
} }
@ -82,7 +82,7 @@ public class GuiGlobalItems {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7c"); meta.setDisplayName("§c");
item.setItemMeta(meta); item.setItemMeta(meta);
return new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance); return new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
} }
@ -139,7 +139,7 @@ public class GuiGlobalItems {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7aSave"); meta.setDisplayName("§aSave");
item.setItemMeta(meta); item.setItemMeta(meta);
return new GuiItem(item, return new GuiItem(item,
GuiGlobalActions.saveSettingAction(setting, goal), GuiGlobalActions.saveSettingAction(setting, goal),
@ -154,7 +154,7 @@ public class GuiGlobalItems {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A77No change. can't save."); meta.setDisplayName("§7No change. can't save.");
item.setItemMeta(meta); item.setItemMeta(meta);
NO_CHANGE_ITEM = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance); NO_CHANGE_ITEM = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
} }
@ -185,7 +185,7 @@ public class GuiGlobalItems {
} }
// Prefix of the one line lore that will be added to setting's item. // Prefix of the one line lore that will be added to setting's item.
public static final String SETTING_ITEM_LORE_PREFIX = "\u00A77value: "; public static final String SETTING_ITEM_LORE_PREFIX = "§7value: ";
/** /**
* Create an arbitrary GuiItem from a unique setting and item's property. * Create an arbitrary GuiItem from a unique setting and item's property.
@ -247,8 +247,8 @@ public class GuiGlobalItems {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7eTemporary close this menu"); meta.setDisplayName("§eTemporary close this menu");
meta.setLore(Collections.singletonList("\u00A77Allow you to chose other item then return here.")); meta.setLore(Collections.singletonList("§7Allow you to chose other item then return here."));
item.setItemMeta(meta); item.setItemMeta(meta);
return new GuiItem(item, event -> { return new GuiItem(item, event -> {
@ -263,7 +263,7 @@ public class GuiGlobalItems {
}); });
player.sendMessage("\u00A7eWrite something in chat to return to the item config menu."); player.sendMessage("§eWrite something in chat to return to the item config menu.");
player.closeInventory(); player.closeInventory();
}, CustomAnvil.instance); }, CustomAnvil.instance);
} }

View file

@ -53,25 +53,25 @@ public class GuiSharedConstant {
ItemMeta meta = CANCEL_ITEM.getItemMeta(); ItemMeta meta = CANCEL_ITEM.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7cCancel"); meta.setDisplayName("§cCancel");
meta.setLore(Collections.singletonList("\u00A77Cancel current action and return to previous menu.")); meta.setLore(Collections.singletonList("§7Cancel current action and return to previous menu."));
CANCEL_ITEM.setItemMeta(meta); CANCEL_ITEM.setItemMeta(meta);
CONFIRM_ITEM = new ItemStack(Material.GREEN_TERRACOTTA); CONFIRM_ITEM = new ItemStack(Material.GREEN_TERRACOTTA);
meta = CONFIRM_ITEM.getItemMeta(); meta = CONFIRM_ITEM.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7aConfirm"); meta.setDisplayName("§aConfirm");
meta.setLore(Collections.singletonList("\u00A77Confirm current action.")); meta.setLore(Collections.singletonList("§7Confirm current action."));
CONFIRM_ITEM.setItemMeta(meta); CONFIRM_ITEM.setItemMeta(meta);
CONFIRM_PERMANENT_ITEM = new ItemStack(Material.GREEN_TERRACOTTA); CONFIRM_PERMANENT_ITEM = new ItemStack(Material.GREEN_TERRACOTTA);
meta = CONFIRM_PERMANENT_ITEM.getItemMeta(); meta = CONFIRM_PERMANENT_ITEM.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7aConfirm"); meta.setDisplayName("§aConfirm");
meta.setLore(Arrays.asList("\u00A77Confirm current action.", meta.setLore(Arrays.asList("§7Confirm current action.",
"\u00A74Cation: This action can't be canceled.")); "§4Cation: This action can't be canceled."));
CONFIRM_PERMANENT_ITEM.setItemMeta(meta); CONFIRM_PERMANENT_ITEM.setItemMeta(meta);
} }

View file

@ -1,5 +1,6 @@
package xyz.alexcrea.cuanvil.update; package xyz.alexcrea.cuanvil.update;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import java.util.ArrayList; import java.util.ArrayList;
@ -7,9 +8,14 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
public class UpdateUtils { public class UpdateUtils {
public final static String MINECRAFT_VERSION_PATH = "lowMinecraftVersion"; public static final String MINECRAFT_VERSION_PATH = "lowMinecraftVersion";
static int[] readVersionFromString(String versionString){ public static int[] currentMinecraftVersion(){
String versionString = Bukkit.getServer().getBukkitVersion().split("-")[0];
return UpdateUtils.readVersionFromString(versionString);
}
public static int[] readVersionFromString(String versionString){
String[] partialVersion = versionString.split("\\."); String[] partialVersion = versionString.split("\\.");
int[] versionParts = new int[]{0, 0, 0}; int[] versionParts = new int[]{0, 0, 0};

View file

@ -1,7 +1,6 @@
package xyz.alexcrea.cuanvil.update; package xyz.alexcrea.cuanvil.update;
import io.delilaheve.CustomAnvil; import io.delilaheve.CustomAnvil;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import xyz.alexcrea.cuanvil.config.ConfigHolder; import xyz.alexcrea.cuanvil.config.ConfigHolder;
@ -23,8 +22,7 @@ public class Update_1_21 {
} }
} }
String versionString = Bukkit.getServer().getBukkitVersion().split("-")[0]; int[] versionParts = UpdateUtils.currentMinecraftVersion();
int[] versionParts = UpdateUtils.readVersionFromString(versionString);
// Test 1.21 // Test 1.21
if((versionParts[0] >= 1) && (versionParts[1] >= 21)){ if((versionParts[0] >= 1) && (versionParts[1] >= 21)){

View file

@ -27,7 +27,7 @@ import org.bukkit.inventory.InventoryView.Property.REPAIR_COST
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.Repairable import org.bukkit.inventory.meta.Repairable
import xyz.alexcrea.cuanvil.config.ConfigHolder import xyz.alexcrea.cuanvil.config.ConfigHolder
import xyz.alexcrea.cuanvil.dependency.protocolib.PacketManager import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.group.ConflictType import xyz.alexcrea.cuanvil.group.ConflictType
import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe
import xyz.alexcrea.cuanvil.util.UnitRepairUtil.getRepair import xyz.alexcrea.cuanvil.util.UnitRepairUtil.getRepair

View file

@ -98,6 +98,12 @@ class CustomAnvil : JavaPlugin() {
chatListener = ChatEventListener() chatListener = ChatEventListener()
server.pluginManager.registerEvents(chatListener, this) server.pluginManager.registerEvents(chatListener, this)
// Load default configuration
if (!ConfigHolder.loadDefaultConfig()) {
logger.log(Level.SEVERE,"could not load default config.")
return
}
// Load dependency // Load dependency
DependencyManager.loadDependency() DependencyManager.loadDependency()
@ -113,12 +119,6 @@ class CustomAnvil : JavaPlugin() {
} }
private fun loadEnchantmentSystem(){ private fun loadEnchantmentSystem(){
// Load default configuration
if (!ConfigHolder.loadDefaultConfig()) {
logger.log(Level.SEVERE,"could not load default config.")
return
}
// Register enchantments // Register enchantments
CAEnchantmentRegistry.getInstance().registerBukkit() CAEnchantmentRegistry.getInstance().registerBukkit()
DependencyManager.registerEnchantments() DependencyManager.registerEnchantments()

View file

@ -1,9 +1,9 @@
package xyz.alexcrea.cuanvil.dependency package xyz.alexcrea.cuanvil.dependency
import org.bukkit.Bukkit import org.bukkit.Bukkit
import xyz.alexcrea.cuanvil.dependency.protocolib.NoProtocoLib import xyz.alexcrea.cuanvil.config.ConfigHolder
import xyz.alexcrea.cuanvil.dependency.protocolib.PacketManager import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.protocolib.ProtocoLibWrapper import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerSelector
object DependencyManager { object DependencyManager {
@ -14,10 +14,9 @@ object DependencyManager {
fun loadDependency(){ fun loadDependency(){
val pluginManager = Bukkit.getPluginManager() val pluginManager = Bukkit.getPluginManager()
// ProtocolLib dependency // Packet Manager
packetManager = val forceProtocolib = ConfigHolder.DEFAULT_CONFIG.config.getBoolean("force_protocolib", false)
if(pluginManager.isPluginEnabled("ProtocolLib")) ProtocoLibWrapper() packetManager = PacketManagerSelector.selectPacketManager(forceProtocolib)
else NoProtocoLib()
// Enchantment Squared dependency // Enchantment Squared dependency
if(pluginManager.isPluginEnabled("EnchantsSquared")){ if(pluginManager.isPluginEnabled("EnchantsSquared")){

View file

@ -0,0 +1,64 @@
package xyz.alexcrea.cuanvil.dependency.packet
import org.bukkit.Bukkit
import xyz.alexcrea.cuanvil.dependency.packet.versions.*
import xyz.alexcrea.cuanvil.update.UpdateUtils
object PacketManagerSelector {
fun selectPacketManager(forceProtocolib: Boolean): PacketManager {
// Try to find version
return if (forceProtocolib)
protocolibIfPresent
else
versionSpecificManager ?: protocolibIfPresent
}
private val protocolibIfPresent: PacketManager
get() =
if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib"))
ProtocoLibWrapper()
else
NoPacketManager()
private val versionSpecificManager: PacketManagerBase?
get() {
val versionParts = UpdateUtils.currentMinecraftVersion()
if (versionParts[0] != 1) return null
return when (versionParts[1]) {
// Can't support 1.16.5 bc 1.16.5 paper userdev do not exist
17 -> when (versionParts[2]) {
0, 1 -> V1_17R1_PacketManager()
else -> null
}
18 -> when (versionParts[2]) {
0, 1 -> V1_18R1_PacketManager()
2 -> V1_18R2_PacketManager()
else -> null
}
19 -> when (versionParts[2]) {
0, 1, 2 -> V1_19R1_PacketManager()
3 -> V1_19R2_PacketManager()
4 -> V1_19R3_PacketManager()
else -> null
}
20 -> when (versionParts[2]) {
0, 1 -> V1_20R1_PacketManager()
2 -> V1_20R2_PacketManager()
3, 4 -> V1_20R3_PacketManager()
5, 6 -> V1_20R4_PacketManager()
else -> null
}
21 -> when (versionParts[2]) {
0, 1 -> V1_21R1_PacketManager()
else -> null
}
else -> null
}
}
}

View file

@ -1,13 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.protocolib
import org.bukkit.entity.Player
class NoProtocoLib: PacketManager {
override val isProtocoLibInstalled: Boolean
get() = false
// ProtocoLib not installed: We do nothing
override fun setInstantBuild(player: Player, instantBuild: Boolean) {}
}

View file

@ -1,11 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.protocolib
import org.bukkit.entity.Player
interface PacketManager {
val isProtocoLibInstalled: Boolean
fun setInstantBuild(player: Player, instantBuild: Boolean)
}

View file

@ -265,4 +265,10 @@ debug_log: false
# Whether to show verbose debug logging # Whether to show verbose debug logging
debug_log_verbose: false debug_log_verbose: false
# In case something when wrong with CustomAnvil packet manager.
# If you see "missing class exception" or similar you may test this.
# If enabled and Protocolib absent or disabled "Replace to expensive" will not work.
# ProtocoLib may also be used if the server is in an "unsupported" version even if this option is disabled.
force_protocolib: false
configVersion: 1.4.5 configVersion: 1.4.5