Completed v4 migration
This commit is contained in:
@@ -3,8 +3,8 @@ version = rootProject.version
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT")
|
||||
compileOnly("com.ticxo.modelengine:api:R3.1.4")
|
||||
compileOnly("com.benmanes.caffeine:caffeine:3.0.2")
|
||||
compileOnly("com.ticxo.modelengine:api:R3.1.5")
|
||||
compileOnly("com.github.ben-manes.caffeine:caffeine:3.0.2")
|
||||
|
||||
implementation("com.willfp:ecomponent:1.3.0")
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.willfp.ecopets.commands.CommandPets
|
||||
import com.willfp.ecopets.pets.DiscoverRecipeListener
|
||||
import com.willfp.ecopets.pets.PetDisplay
|
||||
import com.willfp.ecopets.pets.PetLevelListener
|
||||
import com.willfp.ecopets.pets.PetTriggerXPGainListener
|
||||
import com.willfp.ecopets.pets.Pets
|
||||
import com.willfp.ecopets.pets.SpawnEggHandler
|
||||
import com.willfp.ecopets.pets.activePet
|
||||
import com.willfp.ecopets.pets.activePetLevel
|
||||
@@ -16,6 +16,7 @@ import com.willfp.ecopets.pets.entity.ModelEnginePetEntity
|
||||
import com.willfp.ecopets.pets.entity.PetEntity
|
||||
import com.willfp.libreforge.SimpleProvidedHolder
|
||||
import com.willfp.libreforge.loader.LibreforgePlugin
|
||||
import com.willfp.libreforge.loader.configs.ConfigCategory
|
||||
import com.willfp.libreforge.registerHolderProvider
|
||||
import org.bukkit.event.Listener
|
||||
|
||||
@@ -31,6 +32,12 @@ class EcoPetsPlugin : LibreforgePlugin() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun loadConfigCategories(): List<ConfigCategory> {
|
||||
return listOf(
|
||||
Pets
|
||||
)
|
||||
}
|
||||
|
||||
override fun handleEnable() {
|
||||
PlayerPlaceholder(
|
||||
this,
|
||||
@@ -77,7 +84,6 @@ class EcoPetsPlugin : LibreforgePlugin() {
|
||||
override fun loadListeners(): List<Listener> {
|
||||
return listOf(
|
||||
PetLevelListener(this),
|
||||
PetTriggerXPGainListener,
|
||||
SpawnEggHandler(this),
|
||||
petDisplay,
|
||||
DiscoverRecipeListener(this)
|
||||
@@ -89,4 +95,3 @@ class EcoPetsPlugin : LibreforgePlugin() {
|
||||
lateinit var instance: EcoPetsPlugin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.willfp.eco.core.placeholder.PlayerStaticPlaceholder
|
||||
import com.willfp.eco.core.placeholder.PlayerlessPlaceholder
|
||||
import com.willfp.eco.core.recipe.Recipes
|
||||
import com.willfp.eco.core.recipe.parts.EmptyTestableItem
|
||||
import com.willfp.eco.core.registry.Registrable
|
||||
import com.willfp.eco.util.NumberUtils
|
||||
import com.willfp.eco.util.formatEco
|
||||
import com.willfp.eco.util.toNiceString
|
||||
@@ -27,7 +28,6 @@ import com.willfp.libreforge.conditions.Conditions
|
||||
import com.willfp.libreforge.counters.Counters
|
||||
import com.willfp.libreforge.effects.EffectList
|
||||
import com.willfp.libreforge.effects.Effects
|
||||
import com.willfp.libreforge.triggers.Trigger
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.OfflinePlayer
|
||||
import org.bukkit.entity.Player
|
||||
@@ -349,6 +349,14 @@ class Pet(
|
||||
return processed.flatten().formatEco(player)
|
||||
}
|
||||
|
||||
override fun onRegister() {
|
||||
petXpGains.forEach { it.bind(PetXPAccumulator(this)) }
|
||||
}
|
||||
|
||||
override fun onRemove() {
|
||||
petXpGains.forEach { it.unbind() }
|
||||
}
|
||||
|
||||
fun getIcon(player: Player): ItemStack {
|
||||
val base = baseItem.clone()
|
||||
|
||||
@@ -399,6 +407,10 @@ class Pet(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getID(): String {
|
||||
return this.id
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is Pet) {
|
||||
return false
|
||||
@@ -486,7 +498,7 @@ private val expMultiplierCache = Caffeine.newBuilder()
|
||||
}
|
||||
|
||||
val Player.petExperienceMultiplier: Double
|
||||
get() = expMultiplierCache.get(this)
|
||||
get() = expMultiplierCache.get(this)!!
|
||||
|
||||
private fun Player.cacheSkillExperienceMultiplier(): Double {
|
||||
if (this.hasPermission("ecopets.xpmultiplier.quadruple")) {
|
||||
|
||||
@@ -36,6 +36,7 @@ class PetDisplay(
|
||||
val pet = player.activePet
|
||||
|
||||
if (pet != null) {
|
||||
@Suppress("DEPRECATION")
|
||||
stand.customName = plugin.configYml.getString("pet-entity.name")
|
||||
.replace("%player%", player.displayName)
|
||||
.replace("%pet%", pet.name)
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.willfp.ecopets.pets
|
||||
|
||||
import com.willfp.libreforge.counters.Accumulator
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class PetXPAccumulator(
|
||||
private val pet: Pet
|
||||
) : Accumulator {
|
||||
override fun accept(count: Double) {
|
||||
override fun accept(player: Player, count: Double) {
|
||||
player.givePetExperience(pet, count)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ internal fun emptyArmorStandAt(location: Location, pet: Pet): ArmorStand {
|
||||
}
|
||||
|
||||
stand.isCustomNameVisible = true
|
||||
@Suppress("DEPRECATION")
|
||||
stand.customName = pet.name
|
||||
|
||||
return stand
|
||||
|
||||
@@ -14,6 +14,7 @@ class SkullPetEntity(pet: Pet) : PetEntity(pet) {
|
||||
.setSkullTexture(pet.entityTexture)
|
||||
.build()
|
||||
|
||||
@Suppress("UNNECESSARY_SAFE_CALL") // Can be null.
|
||||
stand.equipment?.helmet = skull
|
||||
|
||||
return stand
|
||||
|
||||
Reference in New Issue
Block a user