Compare commits
158 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36195e16ce | ||
|
|
bae0ab6150 | ||
|
|
4445c7f681 | ||
|
|
8285613d15 | ||
|
|
855aa29e4b | ||
|
|
92f47d1c87 | ||
|
|
5b817fed20 | ||
|
|
b6b523b1f8 | ||
|
|
8c016b94ef | ||
|
|
9c87498045 | ||
|
|
cbb48fa888 | ||
|
|
58ecfbe112 | ||
|
|
93e24a6f25 | ||
|
|
d8dfe6fd7c | ||
|
|
4551ddad08 | ||
|
|
e47533f03c | ||
|
|
5c9f792780 | ||
|
|
bde074bd7c | ||
|
|
5d143f6dec | ||
|
|
8abdcd6d33 | ||
|
|
210f618dc9 | ||
|
|
0514220390 | ||
|
|
2135293799 | ||
|
|
14e3d8fdf5 | ||
|
|
db4fb84160 | ||
|
|
6b0541646f | ||
|
|
72f826a57c | ||
|
|
04b0816e72 | ||
|
|
09980fc895 | ||
|
|
c737256349 | ||
|
|
ff4900da4d | ||
|
|
570f1b1213 | ||
|
|
1f8714bb57 | ||
|
|
08e964986b | ||
|
|
2dcf954101 | ||
|
|
d3d25290fd | ||
|
|
b9939057a0 | ||
|
|
26624faf98 | ||
|
|
23997922ed | ||
|
|
b2120c59e3 | ||
|
|
c04d6eca01 | ||
|
|
5d18b5953a | ||
|
|
5345394d14 | ||
|
|
0c765272df | ||
|
|
f17d4af664 | ||
|
|
f57db1cd74 | ||
|
|
188cac252f | ||
|
|
8fd8f6237e | ||
|
|
6abf50b009 | ||
|
|
8a750b5824 | ||
|
|
1fd45ccd75 | ||
|
|
1fdb3f65df | ||
|
|
a6fe3b095c | ||
|
|
86c0c4d391 | ||
|
|
b42dfe9be2 | ||
|
|
ea66d98df8 | ||
|
|
2cc0d6b3c2 | ||
|
|
8e2006fa2c | ||
|
|
e8c387e85c | ||
|
|
7a82b73b96 | ||
|
|
4049a429d6 | ||
|
|
5895c12c6b | ||
|
|
0b6112408f | ||
|
|
8ee3852ad8 | ||
|
|
5aab3af9ea | ||
|
|
e83d8d4b14 | ||
|
|
0241b2fb2a | ||
|
|
ac9147463a | ||
|
|
d2928ee59f | ||
|
|
315d8f0954 | ||
|
|
7f616da0ce | ||
|
|
eeada10ef8 | ||
|
|
230eb9b87f | ||
|
|
803324c5c9 | ||
|
|
6aaf494b73 | ||
|
|
d34ad33c7d | ||
|
|
e0c1c27ea5 | ||
|
|
a31b6a2a4c | ||
|
|
82decbb2cb | ||
|
|
f143a90dd7 | ||
|
|
58a16a33ec | ||
|
|
8626869a0f | ||
|
|
88eea3c768 | ||
|
|
0271c16357 | ||
|
|
2dc88624dd | ||
|
|
20d7e3abf7 | ||
|
|
2d1d423f83 | ||
|
|
2064bcc9f2 | ||
|
|
95b7bdc3db | ||
|
|
619d5fdde5 | ||
|
|
4226d544e9 | ||
|
|
cf8de5a182 | ||
|
|
26ef893d2c | ||
|
|
1e5836203a | ||
|
|
dcb06f6e25 | ||
|
|
493d419e2c | ||
|
|
435160f626 | ||
|
|
dfe7af1e1b | ||
|
|
25fe58d2ab | ||
|
|
a538947fb8 | ||
|
|
345c8e9049 | ||
|
|
87e3a15d01 | ||
|
|
1ea152058c | ||
|
|
a1a08f750a | ||
|
|
0ec4e566b3 | ||
|
|
98c71e938c | ||
|
|
2e3db38e67 | ||
|
|
d3438a0db1 | ||
|
|
69b8179672 | ||
|
|
ffe6f47e22 | ||
|
|
759f921287 | ||
|
|
2a0e27d7e1 | ||
|
|
ad1e639d00 | ||
|
|
9f1f6b206c | ||
|
|
2a465013d4 | ||
|
|
6b2ea93e3b | ||
|
|
9f55826f5e | ||
|
|
ff9e2cbcba | ||
|
|
8e90f57364 | ||
|
|
682cfe6c8e | ||
|
|
a4983ffea0 | ||
|
|
ebda2dd3c9 | ||
|
|
75794f4af7 | ||
|
|
53d7688436 | ||
|
|
e145b21cb8 | ||
|
|
bf436b239f | ||
|
|
4707291704 | ||
|
|
321d3ed92c | ||
|
|
88b25f93ce | ||
|
|
244626682e | ||
|
|
af6b811458 | ||
|
|
e5064aabef | ||
|
|
558431d39c | ||
|
|
eca0980869 | ||
|
|
5645698d3f | ||
|
|
d4cf108d52 | ||
|
|
95c8fe5277 | ||
|
|
0975391c9c | ||
|
|
3d4666f7e0 | ||
|
|
ae2c9680f3 | ||
|
|
ad3892fc90 | ||
|
|
658aeee2cc | ||
|
|
d09ebfa779 | ||
|
|
826d9c6300 | ||
|
|
508e5d32f5 | ||
|
|
16604aba7f | ||
|
|
84d0e025c3 | ||
|
|
9ad09ecec0 | ||
|
|
c725db06bd | ||
|
|
480cd9da49 | ||
|
|
797235c0a5 | ||
|
|
10cc3e07c8 | ||
|
|
c3825fb16c | ||
|
|
ac7c2eccc3 | ||
|
|
a274d0f6b8 | ||
|
|
7a2a6accea | ||
|
|
1a8c42f40a | ||
|
|
043f70aa05 |
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* @WillFP
|
||||||
4
.github/workflows/publish-release.yml
vendored
4
.github/workflows/publish-release.yml
vendored
@@ -15,11 +15,11 @@ jobs:
|
|||||||
- name: Checkout latest code
|
- name: Checkout latest code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 21
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: 17
|
java-version: 21
|
||||||
|
|
||||||
- name: Change wrapper permissions
|
- name: Change wrapper permissions
|
||||||
run: chmod +x ./gradlew
|
run: chmod +x ./gradlew
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
`java-library`
|
`java-library`
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
kotlin("jvm") version "1.7.10"
|
kotlin("jvm") version "2.1.0"
|
||||||
id("com.github.johnrengelman.shadow") version "8.0.0"
|
id("com.gradleup.shadow") version "8.3.0"
|
||||||
id("com.willfp.libreforge-gradle-plugin") version "1.0.0"
|
id("com.willfp.libreforge-gradle-plugin") version "1.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +27,7 @@ allprojects {
|
|||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
apply(plugin = "kotlin")
|
apply(plugin = "kotlin")
|
||||||
apply(plugin = "maven-publish")
|
apply(plugin = "maven-publish")
|
||||||
apply(plugin = "com.github.johnrengelman.shadow")
|
apply(plugin = "com.gradleup.shadow")
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
@@ -40,7 +42,7 @@ allprojects {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("com.willfp:eco:6.55.0")
|
compileOnly("com.willfp:eco:6.55.0")
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:1.7.10")
|
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:2.1.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
@@ -52,11 +54,12 @@ allprojects {
|
|||||||
shadowJar {
|
shadowJar {
|
||||||
relocate("com.willfp.libreforge.loader", "com.willfp.ecopets.libreforge.loader")
|
relocate("com.willfp.libreforge.loader", "com.willfp.ecopets.libreforge.loader")
|
||||||
relocate("com.willfp.ecomponent", "com.willfp.ecopets.ecomponent")
|
relocate("com.willfp.ecomponent", "com.willfp.ecopets.ecomponent")
|
||||||
|
relocate("com.willfp.modelenginebridge", "com.willfp.ecopets.modelenginebridge")
|
||||||
}
|
}
|
||||||
|
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
kotlinOptions {
|
compilerOptions {
|
||||||
jvmTarget = "17"
|
jvmTarget.set(JvmTarget.JVM_17)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,20 @@ version = rootProject.version
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT")
|
||||||
compileOnly("com.ticxo.modelengine:api:R3.1.5")
|
|
||||||
compileOnly("com.github.ben-manes.caffeine:caffeine:3.0.2")
|
compileOnly("com.github.ben-manes.caffeine:caffeine:3.0.2")
|
||||||
|
|
||||||
implementation("com.willfp:ecomponent:1.3.0")
|
implementation("com.willfp:ecomponent:1.3.0")
|
||||||
|
implementation("com.willfp:ModelEngineBridge:1.2.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
register("maven", MavenPublication::class) {
|
register<MavenPublication>("maven") {
|
||||||
from(components["java"])
|
groupId = project.group.toString()
|
||||||
|
version = project.version.toString()
|
||||||
artifactId = rootProject.name
|
artifactId = rootProject.name
|
||||||
|
|
||||||
|
artifact(rootProject.tasks.shadowJar.get().archiveFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.willfp.eco.core.placeholder.PlayerPlaceholder
|
|||||||
import com.willfp.ecopets.commands.CommandEcoPets
|
import com.willfp.ecopets.commands.CommandEcoPets
|
||||||
import com.willfp.ecopets.commands.CommandPets
|
import com.willfp.ecopets.commands.CommandPets
|
||||||
import com.willfp.ecopets.libreforge.ConditionHasActivePet
|
import com.willfp.ecopets.libreforge.ConditionHasActivePet
|
||||||
|
import com.willfp.ecopets.libreforge.ConditionHasPet
|
||||||
import com.willfp.ecopets.libreforge.ConditionHasPetLevel
|
import com.willfp.ecopets.libreforge.ConditionHasPetLevel
|
||||||
import com.willfp.ecopets.libreforge.EffectGivePetXp
|
import com.willfp.ecopets.libreforge.EffectGivePetXp
|
||||||
import com.willfp.ecopets.libreforge.EffectPetXpMultiplier
|
import com.willfp.ecopets.libreforge.EffectPetXpMultiplier
|
||||||
@@ -19,6 +20,7 @@ import com.willfp.ecopets.pets.Pets
|
|||||||
import com.willfp.ecopets.pets.SpawnEggHandler
|
import com.willfp.ecopets.pets.SpawnEggHandler
|
||||||
import com.willfp.ecopets.pets.activePet
|
import com.willfp.ecopets.pets.activePet
|
||||||
import com.willfp.ecopets.pets.activePetLevel
|
import com.willfp.ecopets.pets.activePetLevel
|
||||||
|
import com.willfp.ecopets.pets.hasPet
|
||||||
import com.willfp.ecopets.pets.entity.ModelEnginePetEntity
|
import com.willfp.ecopets.pets.entity.ModelEnginePetEntity
|
||||||
import com.willfp.ecopets.pets.entity.PetEntity
|
import com.willfp.ecopets.pets.entity.PetEntity
|
||||||
import com.willfp.libreforge.SimpleProvidedHolder
|
import com.willfp.libreforge.SimpleProvidedHolder
|
||||||
@@ -28,7 +30,9 @@ import com.willfp.libreforge.filters.Filters
|
|||||||
import com.willfp.libreforge.loader.LibreforgePlugin
|
import com.willfp.libreforge.loader.LibreforgePlugin
|
||||||
import com.willfp.libreforge.loader.configs.ConfigCategory
|
import com.willfp.libreforge.loader.configs.ConfigCategory
|
||||||
import com.willfp.libreforge.registerHolderProvider
|
import com.willfp.libreforge.registerHolderProvider
|
||||||
|
import com.willfp.libreforge.registerSpecificHolderProvider
|
||||||
import com.willfp.libreforge.triggers.Triggers
|
import com.willfp.libreforge.triggers.Triggers
|
||||||
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.Listener
|
import org.bukkit.event.Listener
|
||||||
|
|
||||||
class EcoPetsPlugin : LibreforgePlugin() {
|
class EcoPetsPlugin : LibreforgePlugin() {
|
||||||
@@ -47,15 +51,16 @@ class EcoPetsPlugin : LibreforgePlugin() {
|
|||||||
override fun handleEnable() {
|
override fun handleEnable() {
|
||||||
Conditions.register(ConditionHasPetLevel)
|
Conditions.register(ConditionHasPetLevel)
|
||||||
Conditions.register(ConditionHasActivePet)
|
Conditions.register(ConditionHasActivePet)
|
||||||
|
Conditions.register(ConditionHasPet)
|
||||||
Effects.register(EffectPetXpMultiplier)
|
Effects.register(EffectPetXpMultiplier)
|
||||||
Effects.register(EffectGivePetXp)
|
Effects.register(EffectGivePetXp)
|
||||||
Triggers.register(TriggerGainPetXp)
|
Triggers.register(TriggerGainPetXp)
|
||||||
Triggers.register(TriggerLevelUpPet)
|
Triggers.register(TriggerLevelUpPet)
|
||||||
Filters.register(FilterPet)
|
Filters.register(FilterPet)
|
||||||
|
|
||||||
registerHolderProvider {
|
registerSpecificHolderProvider<Player> {
|
||||||
it.activePetLevel?.let { l ->
|
it.activePetLevel?.let { p ->
|
||||||
listOf(SimpleProvidedHolder(l))
|
listOf(SimpleProvidedHolder(p))
|
||||||
} ?: emptyList()
|
} ?: emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +73,18 @@ class EcoPetsPlugin : LibreforgePlugin() {
|
|||||||
this,
|
this,
|
||||||
"pet_id"
|
"pet_id"
|
||||||
) { it.activePet?.id ?: "" }.register()
|
) { it.activePet?.id ?: "" }.register()
|
||||||
|
|
||||||
|
PlayerPlaceholder(
|
||||||
|
this,
|
||||||
|
"total_pets"
|
||||||
|
) {
|
||||||
|
var pets = 0
|
||||||
|
for (pet in Pets.values()) {
|
||||||
|
if (it.hasPet(pet))
|
||||||
|
pets++
|
||||||
|
}
|
||||||
|
pets.toString()
|
||||||
|
}.register()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleReload() {
|
override fun handleReload() {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class CommandEcoPets(plugin: EcoPlugin) : PluginCommand(plugin, "ecopets", "ecop
|
|||||||
.addSubcommand(CommandGiveEgg(plugin))
|
.addSubcommand(CommandGiveEgg(plugin))
|
||||||
.addSubcommand(CommandGiveXP(plugin))
|
.addSubcommand(CommandGiveXP(plugin))
|
||||||
.addSubcommand(CommandReset(plugin))
|
.addSubcommand(CommandReset(plugin))
|
||||||
|
.addSubcommand(CommandGiveCurrentXP(plugin))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onExecute(sender: CommandSender, args: List<String>) {
|
override fun onExecute(sender: CommandSender, args: List<String>) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.willfp.ecopets.pets.hasPet
|
|||||||
import com.willfp.ecopets.pets.setPetLevel
|
import com.willfp.ecopets.pets.setPetLevel
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
import org.bukkit.command.CommandSender
|
import org.bukkit.command.CommandSender
|
||||||
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.util.StringUtil
|
import org.bukkit.util.StringUtil
|
||||||
|
|
||||||
class CommandGive(plugin: EcoPlugin) : Subcommand(plugin, "give", "ecopets.command.give", false) {
|
class CommandGive(plugin: EcoPlugin) : Subcommand(plugin, "give", "ecopets.command.give", false) {
|
||||||
@@ -28,7 +29,7 @@ class CommandGive(plugin: EcoPlugin) : Subcommand(plugin, "give", "ecopets.comma
|
|||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
val player = Bukkit.getOfflinePlayer(playerName)
|
val player = Bukkit.getOfflinePlayer(playerName)
|
||||||
|
|
||||||
if (!player.hasPlayedBefore()) {
|
if (!player.hasPlayedBefore() && player !is Player) {
|
||||||
sender.sendMessage(plugin.langYml.getMessage("invalid-player"))
|
sender.sendMessage(plugin.langYml.getMessage("invalid-player"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package com.willfp.ecopets.commands
|
||||||
|
|
||||||
|
import com.willfp.eco.core.EcoPlugin
|
||||||
|
import com.willfp.eco.core.command.impl.Subcommand
|
||||||
|
import com.willfp.eco.util.StringUtils
|
||||||
|
import com.willfp.eco.util.savedDisplayName
|
||||||
|
import com.willfp.eco.util.toNiceString
|
||||||
|
import com.willfp.ecopets.pets.Pets
|
||||||
|
import com.willfp.ecopets.pets.activePet
|
||||||
|
import com.willfp.ecopets.pets.givePetExperience
|
||||||
|
import com.willfp.ecopets.pets.hasPet
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.command.CommandSender
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.util.StringUtil
|
||||||
|
|
||||||
|
class CommandGiveCurrentXP(plugin: EcoPlugin) : Subcommand(plugin, "givecurrentxp", "ecopets.command.givecurrentxp", false) {
|
||||||
|
override fun onExecute(sender: CommandSender, args: List<String>) {
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
sender.sendMessage(plugin.langYml.getMessage("needs-player"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.size == 1) {
|
||||||
|
sender.sendMessage(plugin.langYml.getMessage("needs-amount"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val playerName = args[0]
|
||||||
|
|
||||||
|
val player = Bukkit.getPlayer(playerName)
|
||||||
|
|
||||||
|
if (player == null) {
|
||||||
|
sender.sendMessage(plugin.langYml.getMessage("invalid-player"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val pet = player.activePet
|
||||||
|
|
||||||
|
if (pet == null) {
|
||||||
|
sender.sendMessage(plugin.langYml.getMessage("no-pet"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!player.hasPet(pet)) {
|
||||||
|
sender.sendMessage(plugin.langYml.getMessage("doesnt-have-pet"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val amount = args[1].toDoubleOrNull()
|
||||||
|
|
||||||
|
if (amount == null) {
|
||||||
|
sender.sendMessage(plugin.langYml.getMessage("invalid-amount"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
player.givePetExperience(
|
||||||
|
pet,
|
||||||
|
amount
|
||||||
|
)
|
||||||
|
|
||||||
|
sender.sendMessage(
|
||||||
|
plugin.langYml.getMessage("gave-current-xp", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
|
||||||
|
.replace("%player%", player.savedDisplayName)
|
||||||
|
.replace("%xp%", amount.toNiceString())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun tabComplete(sender: CommandSender, args: List<String>): List<String> {
|
||||||
|
if (args.size == 1) {
|
||||||
|
return Bukkit.getOnlinePlayers().map { it.name }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.size == 2) {
|
||||||
|
return listOf("10", "100", "1000", "10000")
|
||||||
|
}
|
||||||
|
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,9 +3,12 @@ package com.willfp.ecopets.libreforge
|
|||||||
import com.willfp.eco.core.config.interfaces.Config
|
import com.willfp.eco.core.config.interfaces.Config
|
||||||
import com.willfp.ecopets.api.EcoPetsAPI
|
import com.willfp.ecopets.api.EcoPetsAPI
|
||||||
import com.willfp.ecopets.pets.Pets
|
import com.willfp.ecopets.pets.Pets
|
||||||
|
import com.willfp.libreforge.Dispatcher
|
||||||
import com.willfp.libreforge.NoCompileData
|
import com.willfp.libreforge.NoCompileData
|
||||||
|
import com.willfp.libreforge.ProvidedHolder
|
||||||
import com.willfp.libreforge.arguments
|
import com.willfp.libreforge.arguments
|
||||||
import com.willfp.libreforge.conditions.Condition
|
import com.willfp.libreforge.conditions.Condition
|
||||||
|
import com.willfp.libreforge.get
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
object ConditionHasActivePet : Condition<NoCompileData>("has_active_pet") {
|
object ConditionHasActivePet : Condition<NoCompileData>("has_active_pet") {
|
||||||
@@ -13,10 +16,14 @@ object ConditionHasActivePet : Condition<NoCompileData>("has_active_pet") {
|
|||||||
require("pet", "You must specify the pet!")
|
require("pet", "You must specify the pet!")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean {
|
override fun isMet(
|
||||||
return EcoPetsAPI.instance.hasPet(
|
dispatcher: Dispatcher<*>,
|
||||||
player,
|
config: Config,
|
||||||
Pets.getByID(config.getString("pet").lowercase()) ?: return false
|
holder: ProvidedHolder,
|
||||||
)
|
compileData: NoCompileData
|
||||||
|
): Boolean {
|
||||||
|
val player = dispatcher.get<Player>() ?: return false
|
||||||
|
|
||||||
|
return EcoPetsAPI.instance.getActivePet(player) == Pets.getByID(config.getString("pet").lowercase())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.willfp.ecopets.libreforge
|
||||||
|
|
||||||
|
import com.willfp.eco.core.config.interfaces.Config
|
||||||
|
import com.willfp.ecopets.api.EcoPetsAPI
|
||||||
|
import com.willfp.ecopets.pets.Pets
|
||||||
|
import com.willfp.libreforge.Dispatcher
|
||||||
|
import com.willfp.libreforge.NoCompileData
|
||||||
|
import com.willfp.libreforge.ProvidedHolder
|
||||||
|
import com.willfp.libreforge.conditions.Condition
|
||||||
|
import com.willfp.libreforge.get
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
|
object ConditionHasPet : Condition<NoCompileData>("has_pet") {
|
||||||
|
override fun isMet(
|
||||||
|
dispatcher: Dispatcher<*>,
|
||||||
|
config: Config,
|
||||||
|
holder: ProvidedHolder,
|
||||||
|
compileData: NoCompileData
|
||||||
|
): Boolean {
|
||||||
|
val player = dispatcher.get<Player>() ?: return false
|
||||||
|
|
||||||
|
return EcoPetsAPI.instance.hasPet(
|
||||||
|
player,
|
||||||
|
Pets.getByID(config.getString("pet").lowercase()) ?: return false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,9 +4,13 @@ import com.willfp.eco.core.config.interfaces.Config
|
|||||||
import com.willfp.ecopets.api.EcoPetsAPI
|
import com.willfp.ecopets.api.EcoPetsAPI
|
||||||
import com.willfp.ecopets.api.event.PlayerPetLevelUpEvent
|
import com.willfp.ecopets.api.event.PlayerPetLevelUpEvent
|
||||||
import com.willfp.ecopets.pets.Pets
|
import com.willfp.ecopets.pets.Pets
|
||||||
|
import com.willfp.libreforge.Dispatcher
|
||||||
import com.willfp.libreforge.NoCompileData
|
import com.willfp.libreforge.NoCompileData
|
||||||
|
import com.willfp.libreforge.ProvidedHolder
|
||||||
import com.willfp.libreforge.arguments
|
import com.willfp.libreforge.arguments
|
||||||
import com.willfp.libreforge.conditions.Condition
|
import com.willfp.libreforge.conditions.Condition
|
||||||
|
import com.willfp.libreforge.get
|
||||||
|
import com.willfp.libreforge.toDispatcher
|
||||||
import com.willfp.libreforge.updateEffects
|
import com.willfp.libreforge.updateEffects
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
@@ -20,10 +24,17 @@ object ConditionHasPetLevel : Condition<NoCompileData>("has_pet_level") {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
fun handle(event: PlayerPetLevelUpEvent) {
|
fun handle(event: PlayerPetLevelUpEvent) {
|
||||||
event.player.updateEffects()
|
event.player.toDispatcher().updateEffects()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean {
|
override fun isMet(
|
||||||
|
dispatcher: Dispatcher<*>,
|
||||||
|
config: Config,
|
||||||
|
holder: ProvidedHolder,
|
||||||
|
compileData: NoCompileData
|
||||||
|
): Boolean {
|
||||||
|
val player = dispatcher.get<Player>() ?: return false
|
||||||
|
|
||||||
return EcoPetsAPI.instance.getPetLevel(
|
return EcoPetsAPI.instance.getPetLevel(
|
||||||
player,
|
player,
|
||||||
Pets.getByID(config.getString("pet").lowercase()) ?: return false
|
Pets.getByID(config.getString("pet").lowercase()) ?: return false
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.willfp.ecopets.api.event.PlayerPetExpGainEvent
|
|||||||
import com.willfp.ecopets.pets.Pet
|
import com.willfp.ecopets.pets.Pet
|
||||||
import com.willfp.ecopets.pets.Pets
|
import com.willfp.ecopets.pets.Pets
|
||||||
import com.willfp.libreforge.effects.templates.MultiMultiplierEffect
|
import com.willfp.libreforge.effects.templates.MultiMultiplierEffect
|
||||||
|
import com.willfp.libreforge.toDispatcher
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
|
|
||||||
object EffectPetXpMultiplier : MultiMultiplierEffect<Pet>("pet_xp_multiplier") {
|
object EffectPetXpMultiplier : MultiMultiplierEffect<Pet>("pet_xp_multiplier") {
|
||||||
@@ -21,6 +22,6 @@ object EffectPetXpMultiplier : MultiMultiplierEffect<Pet>("pet_xp_multiplier") {
|
|||||||
fun handle(event: PlayerPetExpGainEvent) {
|
fun handle(event: PlayerPetExpGainEvent) {
|
||||||
val player = event.player
|
val player = event.player
|
||||||
|
|
||||||
event.amount *= getMultiplier(player, event.pet)
|
event.amount *= getMultiplier(player.toDispatcher(), event.pet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.willfp.ecopets.libreforge
|
package com.willfp.ecopets.libreforge
|
||||||
|
|
||||||
import com.willfp.ecopets.api.event.PlayerPetExpGainEvent
|
import com.willfp.ecopets.api.event.PlayerPetExpGainEvent
|
||||||
|
import com.willfp.libreforge.toDispatcher
|
||||||
import com.willfp.libreforge.triggers.Trigger
|
import com.willfp.libreforge.triggers.Trigger
|
||||||
import com.willfp.libreforge.triggers.TriggerData
|
import com.willfp.libreforge.triggers.TriggerData
|
||||||
import com.willfp.libreforge.triggers.TriggerParameter
|
import com.willfp.libreforge.triggers.TriggerParameter
|
||||||
@@ -18,7 +19,7 @@ object TriggerGainPetXp : Trigger("gain_pet_xp") {
|
|||||||
val player = event.player
|
val player = event.player
|
||||||
|
|
||||||
this.dispatch(
|
this.dispatch(
|
||||||
player,
|
player.toDispatcher(),
|
||||||
TriggerData(
|
TriggerData(
|
||||||
player = player,
|
player = player,
|
||||||
location = player.location,
|
location = player.location,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.willfp.ecopets.libreforge
|
package com.willfp.ecopets.libreforge
|
||||||
|
|
||||||
import com.willfp.ecopets.api.event.PlayerPetLevelUpEvent
|
import com.willfp.ecopets.api.event.PlayerPetLevelUpEvent
|
||||||
|
import com.willfp.libreforge.toDispatcher
|
||||||
import com.willfp.libreforge.triggers.Trigger
|
import com.willfp.libreforge.triggers.Trigger
|
||||||
import com.willfp.libreforge.triggers.TriggerData
|
import com.willfp.libreforge.triggers.TriggerData
|
||||||
import com.willfp.libreforge.triggers.TriggerParameter
|
import com.willfp.libreforge.triggers.TriggerParameter
|
||||||
@@ -18,7 +19,7 @@ object TriggerLevelUpPet : Trigger("level_up_pet") {
|
|||||||
val player = event.player
|
val player = event.player
|
||||||
|
|
||||||
this.dispatch(
|
this.dispatch(
|
||||||
player,
|
player.toDispatcher(),
|
||||||
TriggerData(
|
TriggerData(
|
||||||
player = player,
|
player = player,
|
||||||
location = player.location,
|
location = player.location,
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ class Pet(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val entityTexture = config.getString("entity-texture")
|
val entityTexture = config.getString("entity-texture")
|
||||||
val modelEngineAnimation = config.getStringOrNull("modelengine-animation")
|
|
||||||
|
|
||||||
private val levelXpRequirements = listOf(0) + config.getInts("level-xp-requirements")
|
private val levelXpRequirements = listOf(0) + config.getInts("level-xp-requirements")
|
||||||
|
|
||||||
@@ -363,6 +362,8 @@ class Pet(
|
|||||||
val level = player.getPetLevel(this)
|
val level = player.getPetLevel(this)
|
||||||
val isActive = player.activePet == this
|
val isActive = player.activePet == this
|
||||||
|
|
||||||
|
val baseLoreLocation = if (level == this.maxLevel) "max-level-lore" else "lore"
|
||||||
|
|
||||||
return ItemStackBuilder(base)
|
return ItemStackBuilder(base)
|
||||||
.setDisplayName(
|
.setDisplayName(
|
||||||
plugin.configYml.getFormattedString("gui.pet-icon.name")
|
plugin.configYml.getFormattedString("gui.pet-icon.name")
|
||||||
@@ -370,7 +371,7 @@ class Pet(
|
|||||||
.replace("%pet%", this.name)
|
.replace("%pet%", this.name)
|
||||||
)
|
)
|
||||||
.addLoreLines {
|
.addLoreLines {
|
||||||
injectPlaceholdersInto(plugin.configYml.getStrings("gui.pet-icon.lore"), player) +
|
injectPlaceholdersInto(plugin.configYml.getStrings("gui.pet-icon.$baseLoreLocation"), player) +
|
||||||
if (isActive) plugin.configYml.getStrings("gui.pet-icon.active-lore") else
|
if (isActive) plugin.configYml.getStrings("gui.pet-icon.active-lore") else
|
||||||
plugin.configYml.getStrings("gui.pet-icon.not-active-lore")
|
plugin.configYml.getStrings("gui.pet-icon.not-active-lore")
|
||||||
}
|
}
|
||||||
@@ -379,6 +380,9 @@ class Pet(
|
|||||||
|
|
||||||
fun getPetInfoIcon(player: Player): ItemStack {
|
fun getPetInfoIcon(player: Player): ItemStack {
|
||||||
val base = baseItem.clone()
|
val base = baseItem.clone()
|
||||||
|
|
||||||
|
val prefix = if (player.getPetLevel(this) == this.maxLevel) "max-level-" else ""
|
||||||
|
|
||||||
return ItemStackBuilder(base)
|
return ItemStackBuilder(base)
|
||||||
.setDisplayName(
|
.setDisplayName(
|
||||||
plugin.configYml.getFormattedString("gui.pet-info.active.name")
|
plugin.configYml.getFormattedString("gui.pet-info.active.name")
|
||||||
@@ -386,7 +390,7 @@ class Pet(
|
|||||||
.replace("%pet%", this.name)
|
.replace("%pet%", this.name)
|
||||||
)
|
)
|
||||||
.addLoreLines {
|
.addLoreLines {
|
||||||
injectPlaceholdersInto(plugin.configYml.getStrings("gui.pet-info.active.lore"), player)
|
injectPlaceholdersInto(plugin.configYml.getStrings("gui.pet-info.active.${prefix}lore"), player)
|
||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ class PetDisplay(
|
|||||||
val pet = player.activePet
|
val pet = player.activePet
|
||||||
|
|
||||||
if (pet != null) {
|
if (pet != null) {
|
||||||
|
if (player.isInvisible) {
|
||||||
|
remove(player)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
stand.customName = plugin.configYml.getString("pet-entity.name")
|
stand.customName = plugin.configYml.getString("pet-entity.name")
|
||||||
.replace("%player%", player.displayName)
|
.replace("%player%", player.displayName)
|
||||||
@@ -77,6 +82,10 @@ class PetDisplay(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getOrNew(player: Player): ArmorStand? {
|
private fun getOrNew(player: Player): ArmorStand? {
|
||||||
|
if (player.isInvisible) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
val tracked = trackedEntities[player.uniqueId]
|
val tracked = trackedEntities[player.uniqueId]
|
||||||
val existing = tracked?.stand
|
val existing = tracked?.stand
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ class PetLevelGUI(
|
|||||||
override fun getLevelItem(player: Player, menu: Menu, level: Int, levelState: LevelState): ItemStack {
|
override fun getLevelItem(player: Player, menu: Menu, level: Int, levelState: LevelState): ItemStack {
|
||||||
val key = levelState.name.lowercase().replace("_", "-")
|
val key = levelState.name.lowercase().replace("_", "-")
|
||||||
|
|
||||||
|
val prefix = if (player.getPetLevel(pet) == pet.maxLevel) "max-level-" else ""
|
||||||
|
|
||||||
return ItemStackBuilder(Items.lookup(plugin.configYml.getString("level-gui.progression-slots.$key.item")))
|
return ItemStackBuilder(Items.lookup(plugin.configYml.getString("level-gui.progression-slots.$key.item")))
|
||||||
.setDisplayName(
|
.setDisplayName(
|
||||||
plugin.configYml.getFormattedString("level-gui.progression-slots.$key.name")
|
plugin.configYml.getFormattedString("level-gui.progression-slots.$key.name")
|
||||||
@@ -44,7 +46,7 @@ class PetLevelGUI(
|
|||||||
)
|
)
|
||||||
.addLoreLines(
|
.addLoreLines(
|
||||||
pet.injectPlaceholdersInto(
|
pet.injectPlaceholdersInto(
|
||||||
plugin.configYml.getFormattedStrings("level-gui.progression-slots.$key.lore"),
|
plugin.configYml.getFormattedStrings("level-gui.progression-slots.$key.${prefix}lore"),
|
||||||
player,
|
player,
|
||||||
forceLevel = level
|
forceLevel = level
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.willfp.ecopets.pets
|
|||||||
import com.willfp.eco.core.config.updating.ConfigUpdater
|
import com.willfp.eco.core.config.updating.ConfigUpdater
|
||||||
import com.willfp.eco.core.gui.menu
|
import com.willfp.eco.core.gui.menu
|
||||||
import com.willfp.eco.core.gui.menu.Menu
|
import com.willfp.eco.core.gui.menu.Menu
|
||||||
|
import com.willfp.eco.core.gui.page.Page
|
||||||
|
import com.willfp.eco.core.gui.page.PageChangeEvent
|
||||||
import com.willfp.eco.core.gui.slot
|
import com.willfp.eco.core.gui.slot
|
||||||
import com.willfp.eco.core.gui.slot.ConfigSlot
|
import com.willfp.eco.core.gui.slot.ConfigSlot
|
||||||
import com.willfp.eco.core.gui.slot.FillerMask
|
import com.willfp.eco.core.gui.slot.FillerMask
|
||||||
@@ -21,17 +23,6 @@ import kotlin.math.min
|
|||||||
object PetsGUI {
|
object PetsGUI {
|
||||||
private lateinit var menu: Menu
|
private lateinit var menu: Menu
|
||||||
private val petAreaSlots = mutableListOf<Pair<Int, Int>>()
|
private val petAreaSlots = mutableListOf<Pair<Int, Int>>()
|
||||||
private const val pageKey = "page"
|
|
||||||
|
|
||||||
private fun getPage(menu: Menu, player: Player): Int {
|
|
||||||
val pages = ceil(Pets.values()
|
|
||||||
.filter { player.getPetLevel(it) > 0 }
|
|
||||||
.size.toDouble() / petAreaSlots.size).toInt()
|
|
||||||
|
|
||||||
val page = menu.getState(player, pageKey) ?: 1
|
|
||||||
|
|
||||||
return max(min(pages, page + 1), 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ConfigUpdater
|
@ConfigUpdater
|
||||||
@@ -42,8 +33,8 @@ object PetsGUI {
|
|||||||
val bottomRightColumn = plugin.configYml.getInt("gui.pet-area.bottom-right.column")
|
val bottomRightColumn = plugin.configYml.getInt("gui.pet-area.bottom-right.column")
|
||||||
|
|
||||||
petAreaSlots.clear()
|
petAreaSlots.clear()
|
||||||
for (row in topLeftRow..bottomRightRow) {
|
for (row in topLeftRow .. bottomRightRow) {
|
||||||
for (column in topLeftColumn..bottomRightColumn) {
|
for (column in topLeftColumn .. bottomRightColumn) {
|
||||||
petAreaSlots.add(Pair(row, column))
|
petAreaSlots.add(Pair(row, column))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,31 +46,28 @@ object PetsGUI {
|
|||||||
val petInfoItemBuilder = { player: Player, _: Menu ->
|
val petInfoItemBuilder = { player: Player, _: Menu ->
|
||||||
val pet = player.activePet
|
val pet = player.activePet
|
||||||
|
|
||||||
if (pet == null) {
|
pet?.getPetInfoIcon(player)
|
||||||
ItemStackBuilder(Items.lookup(plugin.configYml.getString("gui.pet-info.no-active.item")))
|
?: ItemStackBuilder(Items.lookup(plugin.configYml.getString("gui.pet-info.no-active.item")))
|
||||||
.setDisplayName(plugin.configYml.getFormattedString("gui.pet-info.no-active.name"))
|
.setDisplayName(plugin.configYml.getFormattedString("gui.pet-info.no-active.name"))
|
||||||
.addLoreLines(plugin.configYml.getFormattedStrings("gui.pet-info.no-active.lore"))
|
.addLoreLines(plugin.configYml.getFormattedStrings("gui.pet-info.no-active.lore"))
|
||||||
.build()
|
.build()
|
||||||
} else {
|
|
||||||
pet.getPetInfoIcon(player)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val petIconBuilder = { player: Player, menu: Menu, index: Int ->
|
val petIconBuilder = { player: Player, menu: Menu, index: Int ->
|
||||||
val page = getPage(menu, player)
|
val page = menu.getPage(player)
|
||||||
|
|
||||||
val unlockedPets = Pets.values()
|
val unlockedPets = Pets.values()
|
||||||
.sortedByDescending { player.getPetLevel(it) }
|
.sortedByDescending { player.getPetLevel(it) }
|
||||||
.filter { player.getPetLevel(it) > 0 }
|
.filter { player.getPetLevel(it) > 0 }
|
||||||
|
|
||||||
val pagedIndex = ((page - 1) * petAreaSlots.size) + index
|
val pagedIndex = page * petAreaSlots.size - petAreaSlots.size + index
|
||||||
|
|
||||||
val pet = unlockedPets.getOrNull(pagedIndex)
|
val pet = unlockedPets.getOrNull(pagedIndex)
|
||||||
pet?.getIcon(player) ?: ItemStack(Material.AIR)
|
pet?.getIcon(player) ?: ItemStack(Material.AIR)
|
||||||
}
|
}
|
||||||
|
|
||||||
return menu(plugin.configYml.getInt("gui.rows")) {
|
return menu(plugin.configYml.getInt("gui.rows")) {
|
||||||
setTitle(plugin.langYml.getString("menu.title"))
|
title = plugin.langYml.getString("menu.title")
|
||||||
|
|
||||||
setMask(
|
setMask(
|
||||||
FillerMask(
|
FillerMask(
|
||||||
@@ -88,35 +76,30 @@ object PetsGUI {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
setSlot(
|
onRender { player, menu ->
|
||||||
plugin.configYml.getInt("gui.pet-info.row"),
|
menu.setState(player, "ecopets", true)
|
||||||
plugin.configYml.getInt("gui.pet-info.column"),
|
|
||||||
slot(petInfoItemBuilder) {
|
if (menu.getPage(player) > menu.getMaxPage(player)) {
|
||||||
onLeftClick { event, _, _ ->
|
menu.setState(player, Page.PAGE_KEY, 1)
|
||||||
val player = event.whoClicked as Player
|
|
||||||
player.activePet?.levelGUI?.open(player)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
|
||||||
for ((index, pair) in petAreaSlots.withIndex()) {
|
for ((index, pair) in petAreaSlots.withIndex()) {
|
||||||
val (row, column) = pair
|
val (row, column) = pair
|
||||||
|
setSlot(row, column, slot({ player, menu -> petIconBuilder(player, menu, index) }) {
|
||||||
setSlot(row, column, slot({ p, m -> petIconBuilder(p, m, index) }) {
|
setUpdater { player, menu, _ ->
|
||||||
setUpdater { p, m, _ ->
|
petIconBuilder(player, menu, index)
|
||||||
petIconBuilder(p, m, index)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onLeftClick { event, _, _ ->
|
onLeftClick { event, _, _ ->
|
||||||
val player = event.whoClicked as Player
|
val player = event.whoClicked as Player
|
||||||
|
val page = menu.getPage(player)
|
||||||
val page = getPage(menu, player)
|
|
||||||
|
|
||||||
val unlockedPets = Pets.values()
|
val unlockedPets = Pets.values()
|
||||||
.sortedByDescending { player.getPetLevel(it) }
|
.sortedByDescending { player.getPetLevel(it) }
|
||||||
.filter { player.getPetLevel(it) > 0 }
|
.filter { player.getPetLevel(it) > 0 }
|
||||||
|
|
||||||
val pagedIndex = ((page - 1) * petAreaSlots.size) + index
|
val pagedIndex = page * petAreaSlots.size - petAreaSlots.size + index
|
||||||
|
|
||||||
val pet = unlockedPets.getOrNull(pagedIndex) ?: return@onLeftClick
|
val pet = unlockedPets.getOrNull(pagedIndex) ?: return@onLeftClick
|
||||||
|
|
||||||
@@ -134,6 +117,8 @@ object PetsGUI {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// I do this for backwards compatibility because with PageChanger if you don't have any more pages, the item will disappear and this would require an update of the config for all users
|
||||||
|
// This is terrible imo, but everything for compatibility!
|
||||||
setSlot(
|
setSlot(
|
||||||
plugin.configYml.getInt("gui.prev-page.location.row"),
|
plugin.configYml.getInt("gui.prev-page.location.row"),
|
||||||
plugin.configYml.getInt("gui.prev-page.location.column"),
|
plugin.configYml.getInt("gui.prev-page.location.column"),
|
||||||
@@ -141,14 +126,19 @@ object PetsGUI {
|
|||||||
ItemStackBuilder(Items.lookup(plugin.configYml.getString("gui.prev-page.item")))
|
ItemStackBuilder(Items.lookup(plugin.configYml.getString("gui.prev-page.item")))
|
||||||
.setDisplayName(plugin.configYml.getString("gui.prev-page.name"))
|
.setDisplayName(plugin.configYml.getString("gui.prev-page.name"))
|
||||||
.build()
|
.build()
|
||||||
) {
|
)
|
||||||
onLeftClick { event, _, menu ->
|
{
|
||||||
|
onLeftClick { event, _, _ ->
|
||||||
val player = event.whoClicked as Player
|
val player = event.whoClicked as Player
|
||||||
val page = getPage(menu, player)
|
val page = menu.getPage(player)
|
||||||
|
val newPage = max(1, min(page + -1, menu.getMaxPage(player)))
|
||||||
|
|
||||||
val newPage = max(1, page - 1)
|
if (newPage == page) {
|
||||||
|
return@onLeftClick
|
||||||
|
}
|
||||||
|
|
||||||
menu.setState(player, pageKey, newPage)
|
menu.setState(player, Page.PAGE_KEY, newPage)
|
||||||
|
menu.callEvent(player, PageChangeEvent(newPage, page))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -160,19 +150,30 @@ object PetsGUI {
|
|||||||
ItemStackBuilder(Items.lookup(plugin.configYml.getString("gui.next-page.item")))
|
ItemStackBuilder(Items.lookup(plugin.configYml.getString("gui.next-page.item")))
|
||||||
.setDisplayName(plugin.configYml.getString("gui.next-page.name"))
|
.setDisplayName(plugin.configYml.getString("gui.next-page.name"))
|
||||||
.build()
|
.build()
|
||||||
) {
|
)
|
||||||
onLeftClick { event, _, menu ->
|
{
|
||||||
|
onLeftClick { event, _, _ ->
|
||||||
val player = event.whoClicked as Player
|
val player = event.whoClicked as Player
|
||||||
|
val page = menu.getPage(player)
|
||||||
|
val newPage = max(1, min(page + 1, menu.getMaxPage(player)))
|
||||||
|
|
||||||
val pages = ceil(Pets.values()
|
if (newPage == page) {
|
||||||
.filter { player.getPetLevel(it) > 0 }
|
return@onLeftClick
|
||||||
.size.toDouble() / petAreaSlots.size).toInt()
|
}
|
||||||
|
|
||||||
val page = getPage(menu, player)
|
menu.setState(player, Page.PAGE_KEY, newPage)
|
||||||
|
menu.callEvent(player, PageChangeEvent(newPage, page))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
val newPage = min(pages, page + 1)
|
setSlot(
|
||||||
|
plugin.configYml.getInt("gui.pet-info.row"),
|
||||||
menu.setState(player, pageKey, newPage)
|
plugin.configYml.getInt("gui.pet-info.column"),
|
||||||
|
slot(petInfoItemBuilder) {
|
||||||
|
onLeftClick { event, _, _ ->
|
||||||
|
val player = event.whoClicked as Player
|
||||||
|
player.activePet?.levelGUI?.open(player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -209,6 +210,21 @@ object PetsGUI {
|
|||||||
ConfigSlot(config)
|
ConfigSlot(config)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxPages { player ->
|
||||||
|
val unlockedPets = Pets.values()
|
||||||
|
.sortedByDescending { player.getPetLevel(it) }
|
||||||
|
.filter { player.getPetLevel(it) > 0 }
|
||||||
|
|
||||||
|
val perPage = petAreaSlots.size
|
||||||
|
|
||||||
|
val pages = if (unlockedPets.isEmpty()) {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
ceil((unlockedPets.size.toDouble() / perPage)).toInt()
|
||||||
|
}
|
||||||
|
pages
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.willfp.ecopets.pets.entity
|
package com.willfp.ecopets.pets.entity
|
||||||
|
|
||||||
import com.ticxo.modelengine.api.ModelEngineAPI
|
|
||||||
import com.willfp.ecopets.EcoPetsPlugin
|
import com.willfp.ecopets.EcoPetsPlugin
|
||||||
import com.willfp.ecopets.pets.Pet
|
import com.willfp.ecopets.pets.Pet
|
||||||
|
import com.willfp.modelenginebridge.ModelEngineBridge
|
||||||
import org.bukkit.Location
|
import org.bukkit.Location
|
||||||
import org.bukkit.entity.ArmorStand
|
import org.bukkit.entity.ArmorStand
|
||||||
|
|
||||||
@@ -13,29 +13,11 @@ class ModelEnginePetEntity(
|
|||||||
) : PetEntity(pet) {
|
) : PetEntity(pet) {
|
||||||
override fun spawn(location: Location): ArmorStand {
|
override fun spawn(location: Location): ArmorStand {
|
||||||
val stand = emptyArmorStandAt(location, pet)
|
val stand = emptyArmorStandAt(location, pet)
|
||||||
val meAnimation = pet.modelEngineAnimation
|
|
||||||
|
|
||||||
val model = ModelEngineAPI.createActiveModel(modelID)
|
val model = ModelEngineBridge.instance.createActiveModel(modelID) ?: return stand
|
||||||
|
|
||||||
if (meAnimation != null) {
|
val modelled = ModelEngineBridge.instance.createModeledEntity(stand)
|
||||||
val animationHandler = model.animationHandler
|
modelled.addModel(model)
|
||||||
val animationProperty = animationHandler.getAnimation(meAnimation)
|
|
||||||
|
|
||||||
if (animationProperty != null) {
|
|
||||||
animationHandler.playAnimation(animationProperty, true)
|
|
||||||
} else {
|
|
||||||
plugin.logger.warning("Animation $meAnimation not found in model $modelID, defaulting to walk!")
|
|
||||||
val animationPropertyWalk = animationHandler.getAnimation("walk")
|
|
||||||
if (animationPropertyWalk != null) {
|
|
||||||
animationHandler.playAnimation(animationPropertyWalk, true)
|
|
||||||
} else {
|
|
||||||
plugin.logger.warning("Walk animation not found in $modelID!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val modelled = ModelEngineAPI.createModeledEntity(stand)
|
|
||||||
modelled.addModel(model, true)
|
|
||||||
|
|
||||||
return stand
|
return stand
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,11 @@
|
|||||||
# by Auxilor
|
# by Auxilor
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Even if eco is set up to use a database, you can
|
||||||
|
# force EcoPets to save to local storage to disable
|
||||||
|
# cross-server sync.
|
||||||
|
use-local-storage: false
|
||||||
|
|
||||||
discover-recipes: true
|
discover-recipes: true
|
||||||
|
|
||||||
gui:
|
gui:
|
||||||
@@ -64,6 +69,20 @@ gui:
|
|||||||
- ""
|
- ""
|
||||||
- "&eClick to view Level Progression!"
|
- "&eClick to view Level Progression!"
|
||||||
|
|
||||||
|
# By default, the lore for the max level is the same,
|
||||||
|
# but you can change this if you want.
|
||||||
|
max-level-lore:
|
||||||
|
- "%description%"
|
||||||
|
- "&f"
|
||||||
|
- "&fEffects:"
|
||||||
|
- "%effects%"
|
||||||
|
- ""
|
||||||
|
- "&fProgress:"
|
||||||
|
- "&8» &e%percentage_progress%%"
|
||||||
|
- "&8» &e%current_xp%&8/&7%required_xp% &fXP"
|
||||||
|
- ""
|
||||||
|
- "&eClick to view Level Progression!"
|
||||||
|
|
||||||
pet-icon:
|
pet-icon:
|
||||||
name: "%pet% &fLvl. &a%level%"
|
name: "%pet% &fLvl. &a%level%"
|
||||||
lore:
|
lore:
|
||||||
@@ -76,6 +95,18 @@ gui:
|
|||||||
- "&8» &e%percentage_progress%%"
|
- "&8» &e%percentage_progress%%"
|
||||||
- "&8» &e%current_xp%&8/&7%required_xp% &fXP"
|
- "&8» &e%current_xp%&8/&7%required_xp% &fXP"
|
||||||
|
|
||||||
|
# By default, the lore for the max level is the same,
|
||||||
|
# but you can change this if you want.
|
||||||
|
max-level-lore:
|
||||||
|
- "%description%"
|
||||||
|
- "&f"
|
||||||
|
- "&fEffects:"
|
||||||
|
- "%effects%"
|
||||||
|
- ""
|
||||||
|
- "&fProgress:"
|
||||||
|
- "&8» &e%percentage_progress%%"
|
||||||
|
- "&8» &e%current_xp%&8/&7%required_xp% &fXP"
|
||||||
|
|
||||||
active-lore:
|
active-lore:
|
||||||
- ""
|
- ""
|
||||||
- "&cThis pet is already active!"
|
- "&cThis pet is already active!"
|
||||||
@@ -198,6 +229,17 @@ level-gui:
|
|||||||
- "&fProgress:"
|
- "&fProgress:"
|
||||||
- "&8» &e%percentage_progress%%"
|
- "&8» &e%percentage_progress%%"
|
||||||
- "&8» &e%current_xp%&8/&7%required_xp% &fXP"
|
- "&8» &e%current_xp%&8/&7%required_xp% &fXP"
|
||||||
|
|
||||||
|
# By default, the lore for the max level is the same,
|
||||||
|
# but you can change this if you want.
|
||||||
|
max-level-lore:
|
||||||
|
- "&f"
|
||||||
|
- "&fRewards:"
|
||||||
|
- "%rewards%"
|
||||||
|
- "&f"
|
||||||
|
- "&fProgress:"
|
||||||
|
- "&8» &e%percentage_progress%%"
|
||||||
|
- "&8» &e%current_xp%&8/&7%required_xp% &fXP"
|
||||||
locked:
|
locked:
|
||||||
item: red_stained_glass_pane
|
item: red_stained_glass_pane
|
||||||
name: "%pet% &fLvl. &a%level%"
|
name: "%pet% &fLvl. &a%level%"
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ messages:
|
|||||||
|
|
||||||
needs-player: "&cYou must specify a player!"
|
needs-player: "&cYou must specify a player!"
|
||||||
gave-xp: "&fYou have given &a%xp% &fXP to %player%&f's %pet%&f!"
|
gave-xp: "&fYou have given &a%xp% &fXP to %player%&f's %pet%&f!"
|
||||||
|
gave-current-xp: "&fYou have given &a%xp% &fXP to %player%&f's currently active pet!"
|
||||||
|
no-pet: "&cThe player doesn't have a pet active!"
|
||||||
reset-xp: "&fYou have reset %player%&f's %pet%&f XP!"
|
reset-xp: "&fYou have reset %player%&f's %pet%&f XP!"
|
||||||
needs-pet: "&cYou must specify a pet!"
|
needs-pet: "&cYou must specify a pet!"
|
||||||
need-amount: "&cYou must specify a amount!"
|
need-amount: "&cYou must specify a amount!"
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
name: ${pluginName}
|
|
||||||
version: ${version}
|
|
||||||
main: com.willfp.ecopets.EcoPetsPlugin
|
|
||||||
api-version: 1.19
|
|
||||||
|
|
||||||
dependencies:
|
|
||||||
- name: eco
|
|
||||||
required: true
|
|
||||||
bootstrap: false
|
|
||||||
|
|
||||||
- name: libreforge
|
|
||||||
required: false
|
|
||||||
bootstrap: false
|
|
||||||
|
|
||||||
load-after:
|
|
||||||
- name: eco
|
|
||||||
bootstrap: false
|
|
||||||
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
ecopets.*:
|
|
||||||
description: All ecopets permissions
|
|
||||||
default: op
|
|
||||||
children:
|
|
||||||
ecopets.command.*: true
|
|
||||||
ecopets.command.*:
|
|
||||||
description: All commands
|
|
||||||
default: op
|
|
||||||
children:
|
|
||||||
ecopets.command.ecopets: true
|
|
||||||
ecopets.command.reload: true
|
|
||||||
ecopets.command.pets: true
|
|
||||||
ecopets.command.give: true
|
|
||||||
ecopets.command.giveegg: true
|
|
||||||
ecopets.command.givexp: true
|
|
||||||
ecopets.command.reset: true
|
|
||||||
ecopets.command.activate: true
|
|
||||||
ecopets.command.deactivate: true
|
|
||||||
|
|
||||||
ecopets.command.reload:
|
|
||||||
description: Allows reloading the config
|
|
||||||
default: op
|
|
||||||
ecopets.command.ecopets:
|
|
||||||
description: Allows the use of /ecopets.
|
|
||||||
default: true
|
|
||||||
ecopets.command.pets:
|
|
||||||
description: Allows the use of /pets.
|
|
||||||
default: true
|
|
||||||
ecopets.command.give:
|
|
||||||
description: Allows the use of /ecopets give.
|
|
||||||
default: op
|
|
||||||
ecopets.command.giveegg:
|
|
||||||
description: Allows the use of /ecopets giveegg.
|
|
||||||
default: op
|
|
||||||
ecopets.command.givexp:
|
|
||||||
description: Allows the use of /ecopets givexp.
|
|
||||||
default: op
|
|
||||||
ecopets.command.reset:
|
|
||||||
description: Allows the use of /ecopets reset.
|
|
||||||
default: op
|
|
||||||
ecopets.command.activate:
|
|
||||||
description: Allows the use of /pets activate.
|
|
||||||
default: true
|
|
||||||
ecopets.command.deactivate:
|
|
||||||
description: Allows the use of /pets deactivate.
|
|
||||||
default: true
|
|
||||||
|
|
||||||
ecopets.xpmultiplier.50percent:
|
|
||||||
description: Gives the player 50% more skill experience
|
|
||||||
default: false
|
|
||||||
ecopets.xpmultiplier.double:
|
|
||||||
description: Gives the player 2x skill experience
|
|
||||||
default: false
|
|
||||||
ecopets.xpmultiplier.triple:
|
|
||||||
description: Gives the player 3x skill experience
|
|
||||||
default: false
|
|
||||||
ecopets.xpmultiplier.quadruple:
|
|
||||||
description: Gives the player 4x skill experience
|
|
||||||
default: false
|
|
||||||
@@ -116,7 +116,6 @@ conditions: [ ]
|
|||||||
# The texture of the pet entity in game
|
# The texture of the pet entity in game
|
||||||
# If you're using modelengine, use modelengine:id as the texture
|
# If you're using modelengine, use modelengine:id as the texture
|
||||||
entity-texture: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTA5NWZjYzFlM2Q3Y2JkMzUwZjE5YjM4OTQ5OGFiOGJiOTZjNjVhZDE4NWQzNDU5MjA2N2E3ZDAzM2FjNDhkZSJ9fX0="
|
entity-texture: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTA5NWZjYzFlM2Q3Y2JkMzUwZjE5YjM4OTQ5OGFiOGJiOTZjNjVhZDE4NWQzNDU5MjA2N2E3ZDAzM2FjNDhkZSJ9fX0="
|
||||||
modelengine-animation: "fly" # If you're using ModelEngine, you can specify an animation here
|
|
||||||
|
|
||||||
# The icon in GUIs
|
# The icon in GUIs
|
||||||
icon: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTA5NWZjYzFlM2Q3Y2JkMzUwZjE5YjM4OTQ5OGFiOGJiOTZjNjVhZDE4NWQzNDU5MjA2N2E3ZDAzM2FjNDhkZSJ9fX0=
|
icon: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTA5NWZjYzFlM2Q3Y2JkMzUwZjE5YjM4OTQ5OGFiOGJiOTZjNjVhZDE4NWQzNDU5MjA2N2E3ZDAzM2FjNDhkZSJ9fX0=
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ permissions:
|
|||||||
ecopets.command.give: true
|
ecopets.command.give: true
|
||||||
ecopets.command.giveegg: true
|
ecopets.command.giveegg: true
|
||||||
ecopets.command.givexp: true
|
ecopets.command.givexp: true
|
||||||
|
ecopets.command.givecurrentxp: true
|
||||||
ecopets.command.reset: true
|
ecopets.command.reset: true
|
||||||
ecopets.command.activate: true
|
ecopets.command.activate: true
|
||||||
ecopets.command.deactivate: true
|
ecopets.command.deactivate: true
|
||||||
@@ -57,6 +58,9 @@ permissions:
|
|||||||
ecopets.command.givexp:
|
ecopets.command.givexp:
|
||||||
description: Allows the use of /ecopets givexp.
|
description: Allows the use of /ecopets givexp.
|
||||||
default: op
|
default: op
|
||||||
|
ecopets.command.givecurrentxp:
|
||||||
|
description: Allows the use of /ecopets givecurrentxp.
|
||||||
|
default: op
|
||||||
ecopets.command.reset:
|
ecopets.command.reset:
|
||||||
description: Allows the use of /ecopets reset.
|
description: Allows the use of /ecopets reset.
|
||||||
default: op
|
default: op
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#libreforge-updater
|
#libreforge-updater
|
||||||
#Wed May 03 14:48:12 BST 2023
|
#Sat Mar 29 14:22:31 GMT 2025
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
libreforge-version=4.8.0
|
libreforge-version=4.75.0
|
||||||
version=2.8.0
|
version=2.74.0
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
jdk: openjdk17
|
|
||||||
before_install:
|
|
||||||
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
|
||||||
- sdk update
|
|
||||||
- sdk install java 17.0.1-tem
|
|
||||||
- sdk use java 17.0.1-tem
|
|
||||||
@@ -2,11 +2,15 @@ pluginManagement {
|
|||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
maven("https://repo.jpenilla.xyz/snapshots/")
|
|
||||||
maven("https://repo.auxilor.io/repository/maven-public/")
|
maven("https://repo.auxilor.io/repository/maven-public/")
|
||||||
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
||||||
|
}
|
||||||
|
|
||||||
rootProject.name = "EcoPets"
|
rootProject.name = "EcoPets"
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
|
|||||||
Reference in New Issue
Block a user