mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2025-12-31 21:06:40 +00:00
Fixed /ecoskills reset not working on offline players
This commit is contained in:
@@ -13,7 +13,7 @@ import org.bukkit.OfflinePlayer
|
||||
import org.bukkit.entity.Entity
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.entity.Projectile
|
||||
import java.util.*
|
||||
import java.util.UUID
|
||||
import kotlin.math.abs
|
||||
|
||||
private val expMultiplierCache = mutableMapOf<UUID, Double>()
|
||||
@@ -169,9 +169,11 @@ fun OfflinePlayer.getBaseStatLevel(stat: Stat): Int {
|
||||
return PlayerProfile.load(this).read(stat.dataKey)
|
||||
}
|
||||
|
||||
fun Player.setStatLevel(stat: Stat, level: Int) {
|
||||
fun OfflinePlayer.setStatLevel(stat: Stat, level: Int) {
|
||||
PlayerProfile.load(this).write(stat.dataKey, level)
|
||||
stat.updateStatLevel(this)
|
||||
if (this is Player) {
|
||||
stat.updateStatLevel(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun Entity.tryAsPlayer(): Player? {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package com.willfp.ecoskills.commands
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
@@ -13,7 +15,6 @@ import org.bukkit.Bukkit
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.util.StringUtil
|
||||
|
||||
|
||||
class CommandReset(plugin: EcoPlugin) :
|
||||
Subcommand(
|
||||
plugin,
|
||||
@@ -28,8 +29,8 @@ class CommandReset(plugin: EcoPlugin) :
|
||||
return
|
||||
}
|
||||
|
||||
val player = Bukkit.getPlayer(args[0])
|
||||
if (player == null) {
|
||||
val player = Bukkit.getOfflinePlayer(args[0])
|
||||
if (!player.hasPlayedBefore()) {
|
||||
sender.sendMessage(plugin.langYml.getMessage("invalid-player"))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user