Added registerable implementations of CommandExecutor and Listener
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
package net.axay.kspigot.utils
|
||||||
|
|
||||||
|
import net.axay.kspigot.main.KSpigot
|
||||||
|
import org.bukkit.command.CommandExecutor
|
||||||
|
import org.bukkit.command.TabCompleter
|
||||||
|
|
||||||
|
interface RegisterableCommand : CommandExecutor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers this executor for the given command
|
||||||
|
* and for the given instance of [kSpigot].
|
||||||
|
*
|
||||||
|
* @return true if the command was found -
|
||||||
|
* false if not
|
||||||
|
*/
|
||||||
|
fun registerCommand(commandName: String, kSpigot: KSpigot): Boolean {
|
||||||
|
kSpigot.plugin.getCommand(commandName)?.let {
|
||||||
|
it.setExecutor(this)
|
||||||
|
if (this is TabCompleter)
|
||||||
|
it.tabCompleter = this
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,15 @@
|
|||||||
|
package net.axay.kspigot.utils
|
||||||
|
|
||||||
|
import net.axay.kspigot.main.KSpigot
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
|
||||||
|
interface RegisterableListener : Listener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers this listener
|
||||||
|
* for the given instance of [kSpigot].
|
||||||
|
*/
|
||||||
|
fun registerListener(kSpigot: KSpigot) = Bukkit.getPluginManager().registerEvents(this, kSpigot.plugin)
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user