diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt index 2e027d2..d88006f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt @@ -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() @@ -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? { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandReset.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandReset.kt index 7cd1632..1aa7bdc 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandReset.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandReset.kt @@ -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 }