Fixed /ecopets givexp
This commit is contained in:
@@ -4,6 +4,7 @@ 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.givePetExperience
|
||||
import com.willfp.ecopets.pets.hasPet
|
||||
@@ -50,15 +51,22 @@ class CommandGiveXP(plugin: EcoPlugin) : Subcommand(plugin, "givexp", "ecopets.c
|
||||
return
|
||||
}
|
||||
|
||||
val amount = args[2].toDoubleOrNull()
|
||||
|
||||
if (amount == null) {
|
||||
sender.sendMessage(plugin.langYml.getMessage("invalid-amount"))
|
||||
return
|
||||
}
|
||||
|
||||
player.givePetExperience(
|
||||
pet,
|
||||
args[1].toDouble()
|
||||
amount
|
||||
)
|
||||
|
||||
sender.sendMessage(
|
||||
plugin.langYml.getMessage("gave-xp", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
|
||||
.replace("%player%", player.savedDisplayName)
|
||||
.replace("%xp%", args[1])
|
||||
.replace("%xp%", amount.toNiceString())
|
||||
.replace("%pet%", pet.name)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -311,7 +311,14 @@ class Pet(
|
||||
.map {
|
||||
it.replace("%percentage_progress%", (player.getPetProgress(this) * 100).toNiceString())
|
||||
.replace("%current_xp%", player.getPetXP(this).toNiceString())
|
||||
.replace("%required_xp%", this.getExpForLevel(player.getPetLevel(this) + 1).toNiceString())
|
||||
.replace("%required_xp%", this.getExpForLevel(player.getPetLevel(this) + 1).let { req ->
|
||||
if (req == Int.MAX_VALUE) {
|
||||
plugin.langYml.getFormattedString("infinity")
|
||||
} else {
|
||||
req.toNiceString()
|
||||
}
|
||||
}
|
||||
)
|
||||
.replace("%description%", this.description)
|
||||
.replace("%pet%", this.name)
|
||||
.replace("%level%", (forceLevel ?: player.getPetLevel(this)).toString())
|
||||
|
||||
@@ -216,7 +216,7 @@ level-up:
|
||||
enabled: true
|
||||
message:
|
||||
- "&f"
|
||||
- " &#d977c2You levelled up your %pet%&#d977c2 petW to &eLevel %level%&#d977c2!"
|
||||
- " &#d977c2You levelled up your %pet%&#d977c2 pet to &eLevel %level%&#d977c2!"
|
||||
- "&f"
|
||||
- " &#d977c2&lREWARDS:"
|
||||
- " %level_up_messages%"
|
||||
|
||||
@@ -11,14 +11,17 @@ messages:
|
||||
needs-player: "&cYou must specify a player!"
|
||||
gave-xp: "&fYou have given &a%xp% &fXP to %player%'s %pet%&f!"
|
||||
needs-pet: "&cYou must specify a pet!"
|
||||
need-amount: "&cYou must specify a amount"
|
||||
need-amount: "&cYou must specify a amount!"
|
||||
invalid-player: "&cInvalid player!"
|
||||
invalid-pet: "&cInvalid pet!"
|
||||
already-has-pet: "&cPlayer already has this pet!"
|
||||
doesnt-have-pet: "&cPlayer doesn't have this pet"
|
||||
doesnt-have-pet: "&cPlayer doesn't have this pet!"
|
||||
gave-pet: "&fSuccessfully gave %player%&f the %pet%&f pet!"
|
||||
gave-pet-egg: "&fSuccessfully gave %player%&f the %pet%&f pet egg!"
|
||||
cannot-spawn-pet: "&cYou already have this pet unlocked!"
|
||||
invalid-amount: "&cInvalid amount!"
|
||||
|
||||
menu:
|
||||
title: "Pets"
|
||||
|
||||
infinity: "∞"
|
||||
|
||||
Reference in New Issue
Block a user