add test command

This commit is contained in:
alexcrea 2024-02-27 18:56:37 +01:00 committed by alexcrea
parent 6259eaa2cd
commit 379eb12940
3 changed files with 36 additions and 4 deletions

View file

@ -5,9 +5,10 @@ import org.bukkit.Bukkit
import org.bukkit.configuration.file.YamlConfiguration
import org.bukkit.plugin.java.JavaPlugin
import xyz.alexcrea.command.ReloadExecutor
import xyz.alexcrea.command.TestExecutor
import xyz.alexcrea.cuanvil.util.Metrics
import xyz.alexcrea.group.EnchantConflictManager
import xyz.alexcrea.group.ItemGroupManager
import xyz.alexcrea.cuanvil.util.Metrics
import xyz.alexcrea.util.MetricsUtil
import java.io.File
import java.io.FileReader
@ -33,6 +34,8 @@ class CustomAnvil : JavaPlugin() {
// Command Name to reload the config
const val commandReloadName = "anvilconfigreload"
// Test command name
const val commandTestName = "test"
// Item Grouping Configuration file name
const val itemGroupingConfigFilePath = "item_groups.yml"
@ -80,9 +83,8 @@ class CustomAnvil : JavaPlugin() {
val metric = Metrics(this, bstatsPluginId)
MetricsUtil.addCustomMetric(metric)
// Add command to reload the plugin
val command = getCommand(commandReloadName)
command?.setExecutor(ReloadExecutor())
// Add commands to reload the plugin
prepareCommand()
server.pluginManager.registerEvents(
AnvilEventListener(),
@ -145,4 +147,12 @@ class CustomAnvil : JavaPlugin() {
return yamlConfig
}
fun prepareCommand(): Unit {
var command = getCommand(commandReloadName)
command?.setExecutor(ReloadExecutor())
command = getCommand(commandTestName)
command?.setExecutor(TestExecutor())
}
}

View file

@ -0,0 +1,19 @@
package xyz.alexcrea.command
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.entity.HumanEntity
import xyz.alexcrea.cuanvil.gui.gui.MainConfigGui
class TestExecutor : CommandExecutor {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
if(sender !is HumanEntity) return false
MainConfigGui.INSTANCE.show(sender)
return true
}
}