diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandTop.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandTop.kt index ede9db4..1efaf9d 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandTop.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandTop.kt @@ -9,6 +9,7 @@ import com.willfp.ecoskills.getTotalSkillLevel import org.bukkit.Bukkit import org.bukkit.OfflinePlayer import org.bukkit.command.CommandSender +import org.bukkit.entity.Player import java.util.* import java.util.stream.Collectors import kotlin.collections.set @@ -72,14 +73,23 @@ class CommandTop(plugin: EcoPlugin) : val messages = plugin.langYml.getStrings("top", false) val lines = ArrayList() + val useDisplayName = plugin.configYml.getBool("commands.top.use-display-name"); var rank = start + 1 for (entry in pagePlayers.entries) { - val line = plugin.langYml.getString("top-line-format", false) + var line = plugin.langYml.getString("top-line-format", false) .replace("%rank%", rank.toString()) - .replace("%player%", entry.key.name!!) .replace("%level%", entry.value.toString()) + val player = entry.key + var name = player.name!! + + if (useDisplayName && player is Player) { + name = player.displayName + } + + line = line.replace("%player%", name) + lines.add(line) rank++ diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index 4463672..068d36e 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -297,4 +297,9 @@ damage-indicators: crit: "&f✧ %damage% &f✧" max-x-offset: 0.6 max-y-offset: 0.6 - max-z-offset: 0.6 \ No newline at end of file + max-z-offset: 0.6 + +commands: + top: + # If displayname (including rank) should be used + use-display-name: true \ No newline at end of file