9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2026-01-03 06:12:21 +00:00

Added page number tab completion

This commit is contained in:
Auxilor
2021-10-16 15:51:03 +01:00
parent 58e54f7ec6
commit f58ea2396a
3 changed files with 40 additions and 0 deletions

View File

@@ -34,6 +34,17 @@ public class TabCompleteHelper {
"10"
);
/**
* Numbers.
*/
public static final List<String> NUMBERS = Arrays.asList(
"1",
"2",
"3",
"4",
"5"
);
/**
* Update lists.
*/

View File

@@ -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()
}
}

View File

@@ -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<String>()
if (args.size == 1) {
StringUtil.copyPartialMatches(
args[0],
TabCompleteHelper.NUMBERS,
completions
)
return@TabCompleteHandler completions
}
return@TabCompleteHandler emptyList()
}
}
}