diff --git a/src/main/kotlin/io/delilaheve/CustomAnvil.kt b/src/main/kotlin/io/delilaheve/CustomAnvil.kt index 8535ae7..73f34f2 100644 --- a/src/main/kotlin/io/delilaheve/CustomAnvil.kt +++ b/src/main/kotlin/io/delilaheve/CustomAnvil.kt @@ -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()) + } + } diff --git a/src/main/kotlin/xyz/alexcrea/command/TestExecutor.kt b/src/main/kotlin/xyz/alexcrea/command/TestExecutor.kt new file mode 100644 index 0000000..aa80055 --- /dev/null +++ b/src/main/kotlin/xyz/alexcrea/command/TestExecutor.kt @@ -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): Boolean { + + if(sender !is HumanEntity) return false + MainConfigGui.INSTANCE.show(sender) + + return true + } + +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 639910e..ccce05b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -18,6 +18,9 @@ commands: #- acreload # anvil config reload #- careload # custom anvil reload - carl # custom anvil reload + test: + description: test cmd + permissions: ca.affected: default: true