mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
add edit config tab completer
This commit is contained in:
parent
2147384823
commit
1d59f033b8
1 changed files with 26 additions and 0 deletions
|
|
@ -1,10 +1,12 @@
|
||||||
package xyz.alexcrea.cuanvil.command
|
package xyz.alexcrea.cuanvil.command
|
||||||
|
|
||||||
|
import com.willfp.eco.core.lookup.matches
|
||||||
import io.delilaheve.CustomAnvil
|
import io.delilaheve.CustomAnvil
|
||||||
import org.bukkit.command.Command
|
import org.bukkit.command.Command
|
||||||
import org.bukkit.command.CommandSender
|
import org.bukkit.command.CommandSender
|
||||||
import org.bukkit.entity.HumanEntity
|
import org.bukkit.entity.HumanEntity
|
||||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||||
|
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
|
||||||
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
|
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions
|
||||||
|
|
||||||
|
|
@ -46,4 +48,28 @@ class EditConfigExecutor: CASubCommand() {
|
||||||
return "Gui to edit the plugin's config"
|
return "Gui to edit the plugin's config"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun allEnchantmentsByName(): Collection<String>{
|
||||||
|
val names = mutableSetOf<String>()
|
||||||
|
for (enchantment in CAEnchantmentRegistry.getInstance().values()) {
|
||||||
|
names.add(enchantment.name)
|
||||||
|
names.add(enchantment.key.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
return names
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun tabCompleter(sender: CommandSender, args: Array<out String>, list: MutableList<String>) {
|
||||||
|
list.addAll(when (args.size) {
|
||||||
|
1 -> listOf("item", "enchant", "open")
|
||||||
|
2 -> {
|
||||||
|
when(args[0].lowercase()) {
|
||||||
|
"enchant" -> allEnchantmentsByName()
|
||||||
|
else -> listOf()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> listOf()
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue