diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java index de53b41..2b9efc7 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java @@ -51,7 +51,7 @@ public class EcoSkillsPlugin extends EcoPlugin { * Internal constructor called by bukkit on plugin load. */ public EcoSkillsPlugin() { - super(1351, 12205, "&#ff00ae", true); + super(1351, 13052, "&#ff00ae", true); instance = this; effectsYml = new EffectsYml(this); dataHandler = this.getConfigYml().getBool("mysql.enabled") diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/util/TabCompleteHelper.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/util/TabCompleteHelper.java index 4490b5c..01b46dd 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/util/TabCompleteHelper.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/util/TabCompleteHelper.java @@ -34,6 +34,17 @@ public class TabCompleteHelper { "10" ); + /** + * Numbers. + */ + public static final List NUMBERS = Arrays.asList( + "1", + "2", + "3", + "4", + "5" + ); + /** * Update lists. */ diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandRank.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandRank.kt index 236469a..b315896 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandRank.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/commands/CommandRank.kt @@ -86,6 +86,15 @@ class CommandRank(plugin: EcoPlugin) : return@TabCompleteHandler completions } + if (args.size == 2) { + StringUtil.copyPartialMatches( + args[1], + TabCompleteHelper.NUMBERS, + completions + ) + return@TabCompleteHandler completions + } + return@TabCompleteHandler emptyList() } } 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 4b6dfd7..6169af7 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 @@ -2,12 +2,15 @@ package com.willfp.ecoskills.commands import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.command.CommandHandler +import com.willfp.eco.core.command.TabCompleteHandler import com.willfp.eco.core.command.impl.Subcommand import com.willfp.eco.util.StringUtils import com.willfp.ecoskills.data.LeaderboardHandler import com.willfp.ecoskills.data.savedDisplayName import com.willfp.ecoskills.getTotalSkillLevel +import com.willfp.ecoskills.util.TabCompleteHelper import org.bukkit.command.CommandSender +import org.bukkit.util.StringUtil class CommandTop(plugin: EcoPlugin) : @@ -54,4 +57,21 @@ class CommandTop(plugin: EcoPlugin) : } } } + + override fun getTabCompleter(): TabCompleteHandler { + return TabCompleteHandler { _, args -> + val completions = mutableListOf() + + if (args.size == 1) { + StringUtil.copyPartialMatches( + args[0], + TabCompleteHelper.NUMBERS, + completions + ) + return@TabCompleteHandler completions + } + + return@TabCompleteHandler emptyList() + } + } } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/DataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/DataHandler.kt index b08befa..590ede7 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/DataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/DataHandler.kt @@ -6,5 +6,8 @@ interface DataHandler { fun save() fun write(uuid: UUID, key: String, value: T) - fun read(uuid: UUID, key: String, default: T): T + fun read(uuid: UUID, key: String): T? + fun read(uuid: UUID, key: String, default: T): T { + return read(uuid, key) ?: default + } } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/MySQLDataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/MySQLDataHandler.kt index 1a8e420..bc41056 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/MySQLDataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/MySQLDataHandler.kt @@ -67,11 +67,11 @@ class MySQLDataHandler( } } - override fun read(uuid: UUID, key: String, default: T): T { - var value = default + override fun read(uuid: UUID, key: String): T? { + var value: T? = null transaction { val player = Players.select { Players.id eq uuid }.firstOrNull() ?: return@transaction - value = player[Players.columns.stream().filter { it.name == key }.findFirst().get()] as T? ?: default + value = player[Players.columns.stream().filter { it.name == key }.findFirst().get()] as T? } return value } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/YamlDataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/YamlDataHandler.kt index 2f1b6ab..20f7858 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/YamlDataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/YamlDataHandler.kt @@ -18,12 +18,8 @@ class YamlDataHandler( dataYml.set("player.$uuid.$key", value) } - override fun read(uuid: UUID, key: String, default: T): T { - return if (dataYml.has("player.$uuid.$key")) { - dataYml.get("player.$uuid.$key") as T - } else { - default - } + override fun read(uuid: UUID, key: String): T? { + return dataYml.get("player.$uuid.$key") as T? } class DataYml( diff --git a/gradle.properties b/gradle.properties index 4a35961..f04dfd8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 1.7.2 +version = 1.7.4 plugin-name = EcoSkills \ No newline at end of file