mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
add test command
This commit is contained in:
parent
e5c222ca0c
commit
4aeaed801c
3 changed files with 36 additions and 4 deletions
|
|
@ -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())
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
19
src/main/kotlin/xyz/alexcrea/command/TestExecutor.kt
Normal file
19
src/main/kotlin/xyz/alexcrea/command/TestExecutor.kt
Normal 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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue