9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2025-12-19 15:09:23 +00:00

Merge branch 'master' into config-fixes

This commit is contained in:
Will FP
2025-01-31 11:47:12 +00:00
committed by GitHub
12 changed files with 119 additions and 50 deletions

View File

@@ -2,7 +2,7 @@ plugins {
java
`java-library`
`maven-publish`
kotlin("jvm") version "1.9.20"
kotlin("jvm") version "2.1.0"
id("io.github.goooler.shadow") version "8.1.7"
id("com.willfp.libreforge-gradle-plugin") version "1.0.0"
}
@@ -40,7 +40,7 @@ allprojects {
dependencies {
compileOnly("com.willfp:eco:6.58.0")
compileOnly("org.jetbrains:annotations:23.0.0")
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:1.9.20")
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:2.1.0")
}
java {

View File

@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = "com.willfp"
version = rootProject.version
@@ -19,8 +21,8 @@ tasks {
}
compileKotlin {
kotlinOptions {
jvmTarget = "21"
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
}
}
}

View File

@@ -0,0 +1,28 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = "com.willfp"
version = rootProject.version
val spigotVersion = "1.21.4-R0.1-SNAPSHOT"
dependencies {
compileOnly("org.spigotmc:spigot:$spigotVersion")
}
configurations.compileOnly {
resolutionStrategy {
force("org.spigotmc:spigot:$spigotVersion")
}
}
tasks {
compileJava {
options.release = 21
}
compileKotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
}
}
}

View File

@@ -0,0 +1,22 @@
package com.willfp.ecoskills.proxy.v1_21_4
import com.willfp.eco.core.packet.PacketEvent
import com.willfp.ecoskills.actionbar.ActionBarCompatibilityProxy
import com.willfp.ecoskills.actionbar.pausePersistentActionBar
import net.minecraft.network.protocol.game.ClientboundSystemChatPacket
class ActionBarCompatibility : ActionBarCompatibilityProxy {
private val ClientboundSystemChatPacket.isActionBar: Boolean
get() = this::class.java.declaredFields
.first { it.type == Boolean::class.java }
.apply { isAccessible = true }
.get(this) as Boolean
override fun onSend(event: PacketEvent) {
val player = event.player
when (val packet = event.packet.handle) {
is ClientboundSystemChatPacket -> if (packet.isActionBar) player.pausePersistentActionBar()
}
}
}

View File

@@ -37,7 +37,7 @@ class CommandTop(plugin: EcoPlugin) :
val offset = (page - 1) * 10
val positions = ((offset + page)..(offset + page + 9)).toList()
val positions = ((offset + 1)..(offset + 10)).toList()
val top = if (skill == null) {
positions.mapNotNull { Skills.getTop(it) }
@@ -52,7 +52,7 @@ class CommandTop(plugin: EcoPlugin) :
val (player, level) = entry
val line = plugin.langYml.getString("top-line-format")
.replace("%rank%", positions[index].toString())
.replace("%rank%", (offset + index + 1).toString())
.replace("%level%", level.toString())
.replace("%player%", player.savedDisplayName)

View File

@@ -23,47 +23,48 @@ class PlayerInfoIcon(
config: Config,
opensStatMenu: Boolean
) : PositionedComponent {
private val slot = slot({ player, _ ->
skullCache.get(player.uniqueId) {
val skullBuilder = SkullBuilder()
.setDisplayName(
config.getString("name")
.replace("%player%", player.savedDisplayName)
.formatEco(player, true)
)
.addLoreLines(
config.getFormattedStrings(
"lore",
placeholderContext(
player = player
override val isEnabled = config.getBoolOrNull("enabled") ?: true
private val slot = if (isEnabled) {
slot({ player, _ ->
skullCache.get(player.uniqueId) {
val skullBuilder = SkullBuilder()
.setDisplayName(
config.getString("name")
.replace("%player%", player.savedDisplayName)
.formatEco(player, true)
)
.addLoreLines(
config.getFormattedStrings(
"lore", // Ensure correct path for lore
placeholderContext(player = player)
)
)
)
.apply {
if (opensStatMenu) {
addLoreLines(
config.getFormattedStrings(
"view-more",
placeholderContext(
player = player
.apply {
if (opensStatMenu) {
addLoreLines(
config.getFormattedStrings(
"view-more",
placeholderContext(player = player)
)
)
)
}
}
}
skullBuilder.build().apply {
val meta = itemMeta as SkullMeta
meta.owningPlayer = player
itemMeta = meta
}
}
}) {
if (opensStatMenu) {
onLeftClick { player, _, _, _ ->
StatsGUI.open(player)
skullBuilder.build().apply {
val meta = itemMeta as SkullMeta
meta.owningPlayer = player
itemMeta = meta
}
}
}) {
if (opensStatMenu) {
onLeftClick { player, _, _, _ ->
StatsGUI.open(player)
}
}
}
} else {
null
}
override val row: Int = config.getInt("row")

View File

@@ -18,13 +18,14 @@ import com.willfp.ecoskills.api.getFormattedRequiredXP
import com.willfp.ecoskills.api.getSkillLevel
import com.willfp.ecoskills.api.getSkillProgress
import com.willfp.ecoskills.api.getSkillXP
import com.willfp.ecoskills.skills.Skill
import org.bukkit.boss.BarColor
import org.bukkit.boss.BarStyle
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import java.time.Duration
import java.util.UUID
private val xpGainSoundEnabledKey = PersistentDataKey(
namespacedKeyOf("ecoskills", "gain_sound_enabled"),
@@ -36,13 +37,22 @@ fun Player.toggleXPGainSound() {
this.profile.write(xpGainSoundEnabledKey, !this.profile.read(xpGainSoundEnabledKey))
}
data class PlayerSkill(
val player: UUID,
val skill: String
)
private fun playerSkill(player: Player, skill: Skill): PlayerSkill {
return PlayerSkill(player.uniqueId, skill.id)
}
val Player.isXPGainSoundEnabled: Boolean
get() = this.profile.read(xpGainSoundEnabledKey)
class GainXPDisplay(
private val plugin: EcoPlugin
) : Listener {
private val gainCache: Cache<Skill, Double> = Caffeine.newBuilder().expireAfterWrite(Duration.ofSeconds(3))
private val gainCache: Cache<PlayerSkill, Double> = Caffeine.newBuilder().expireAfterWrite(Duration.ofSeconds(3))
.build()
private val sound = if (plugin.configYml.getBool("skills.gain-xp.sound.enabled")) {
@@ -51,11 +61,11 @@ class GainXPDisplay(
)
} else null
@EventHandler
@EventHandler(priority = EventPriority.MONITOR)
fun handle(event: PlayerSkillXPGainEvent) {
val player = event.player
val current = gainCache.get(event.skill) { 0.0 }
gainCache.put(event.skill, current + event.gainedXP)
val current = gainCache.get(playerSkill(player, event.skill)) { 0.0 }
gainCache.put(playerSkill(player, event.skill), current + event.gainedXP)
// Run next tick because level up calls before xp is added
plugin.scheduler.run {
@@ -111,7 +121,7 @@ class GainXPDisplay(
)
.replace("%current_xp%", event.player.getSkillXP(event.skill).toNiceString())
.replace("%required_xp%", event.player.getFormattedRequiredXP(event.skill))
.replace("%gained_xp%", gainCache.get(event.skill) { 0.0 }.toNiceString())
.replace("%gained_xp%", gainCache.get(playerSkill(event.player, event.skill)) { 0.0 }.toNiceString())
.formatEco(
placeholderContext(
event.player,

View File

@@ -123,6 +123,7 @@ stats-gui:
- "211101112"
player-info:
enabled: true
row: 1
column: 5

View File

@@ -147,7 +147,6 @@ xp-gain-methods:
blocks:
- wheat
- carrots
- melon
- nether_wart
- trigger: mine_block
@@ -163,6 +162,7 @@ xp-gain-methods:
player_placed: false
blocks:
- pumpkin
- melon
- trigger: mine_block
multiplier: 5

View File

@@ -114,6 +114,7 @@ xp-gain-methods:
- dark_oak_log
- mangrove_log
- cherry_log
- pale_oak_log
- oak_wood
- birch_wood
- spruce_wood
@@ -121,7 +122,8 @@ xp-gain-methods:
- acacia_wood
- dark_oak_wood
- mangrove_wood
- chery_wood
- cherry_wood
- pale_oak_wood
- trigger: mine_block
multiplier: 14

View File

@@ -1,5 +1,7 @@
#libreforge-updater
#Wed Nov 06 18:32:41 GMT 2024
#Sat Jan 25 13:49:47 GMT 2025
kotlin.code.style=official
libreforge-version=4.72.2
version=3.60.4
kotlin.daemon.jvmargs=-Xmx2g -XX\:+UseG1GC -XX\:MaxMetaspaceSize\=512m
libreforge-version=4.73.0
org.gradle.parallel=true
version=3.62.0

View File

@@ -28,3 +28,4 @@ include(":eco-core:core-nms:v1_20_R2")
include(":eco-core:core-nms:v1_20_R3")
include(":eco-core:core-nms:v1_21")
include(":eco-core:core-nms:v1_21_3")
include(":eco-core:core-nms:v1_21_4")