Eliminated plugin and kSpigot parameters

This commit is contained in:
bluefireoly
2020-10-12 17:01:01 +02:00
parent 6b2f95c7fa
commit 29bd82803d
11 changed files with 63 additions and 69 deletions

View File

@@ -1,16 +1,16 @@
package net.axay.kspigot.event package net.axay.kspigot.event
import net.axay.kspigot.extensions.pluginManager import net.axay.kspigot.extensions.pluginManager
import net.axay.kspigot.main.KSpigotMainInstance
import org.bukkit.event.Event import org.bukkit.event.Event
import org.bukkit.event.EventPriority import org.bukkit.event.EventPriority
import org.bukkit.event.HandlerList import org.bukkit.event.HandlerList
import org.bukkit.event.Listener import org.bukkit.event.Listener
import org.bukkit.plugin.Plugin
/** /**
* Shortcut for registering this listener on the given plugin. * Shortcut for registering this listener on the given plugin.
*/ */
fun Listener.register(plugin: Plugin) = pluginManager.registerEvents(this, plugin) fun Listener.register() = pluginManager.registerEvents(this, KSpigotMainInstance)
/** /**
* Shortcut for unregistering all events in this listener. * Shortcut for unregistering all events in this listener.
@@ -26,12 +26,11 @@ fun Listener.unregister() = HandlerList.unregisterAll(this)
* @param executor handles incoming events * @param executor handles incoming events
*/ */
inline fun <reified T : Event> Listener.register( inline fun <reified T : Event> Listener.register(
plugin: Plugin,
priority: EventPriority = EventPriority.NORMAL, priority: EventPriority = EventPriority.NORMAL,
ignoreCancelled: Boolean = false, ignoreCancelled: Boolean = false,
noinline executor: (Listener, Event) -> Unit noinline executor: (Listener, Event) -> Unit
) { ) {
pluginManager.registerEvent(T::class.java, this, priority, executor, plugin, ignoreCancelled) pluginManager.registerEvent(T::class.java, this, priority, executor, KSpigotMainInstance, ignoreCancelled)
} }
/** /**
@@ -50,11 +49,10 @@ interface SingleListener<T : Event> : Listener {
* @param ignoreCancelled if manual cancellation should be ignored * @param ignoreCancelled if manual cancellation should be ignored
*/ */
inline fun <reified T : Event> SingleListener<T>.register( inline fun <reified T : Event> SingleListener<T>.register(
plugin: Plugin,
priority: EventPriority = EventPriority.NORMAL, priority: EventPriority = EventPriority.NORMAL,
ignoreCancelled: Boolean = false ignoreCancelled: Boolean = false
) { ) {
register<T>(plugin, priority, ignoreCancelled) { _, event -> register<T>(priority, ignoreCancelled) { _, event ->
(event as? T)?.let { this.onEvent(it) } (event as? T)?.let { this.onEvent(it) }
} }
} }
@@ -65,7 +63,7 @@ inline fun <reified T : Event> SingleListener<T>.register(
* @param ignoreCancelled if manual cancellation should be ignored * @param ignoreCancelled if manual cancellation should be ignored
* @param onEvent the event callback * @param onEvent the event callback
*/ */
inline fun <reified T : Event> Plugin.listen( inline fun <reified T : Event> listen(
priority: EventPriority = EventPriority.NORMAL, priority: EventPriority = EventPriority.NORMAL,
ignoreCancelled: Boolean = false, ignoreCancelled: Boolean = false,
crossinline onEvent: (T) -> Unit crossinline onEvent: (T) -> Unit
@@ -73,6 +71,6 @@ inline fun <reified T : Event> Plugin.listen(
val listener = object : SingleListener<T> { val listener = object : SingleListener<T> {
override fun onEvent(event: T) = onEvent.invoke(event) override fun onEvent(event: T) = onEvent.invoke(event)
} }
listener.register(this, priority, ignoreCancelled) listener.register(priority, ignoreCancelled)
return listener return listener
} }

View File

@@ -1,27 +1,28 @@
package net.axay.kspigot.extensions.bukkit package net.axay.kspigot.extensions.bukkit
import net.axay.kspigot.main.KSpigotMainInstance
import net.md_5.bungee.api.ChatColor import net.md_5.bungee.api.ChatColor
import org.bukkit.command.CommandSender import org.bukkit.command.CommandSender
import org.bukkit.plugin.Plugin import org.bukkit.plugin.Plugin
/** @see printColoredPrefix */ /** @see printColoredPrefix */
fun CommandSender.print(text: String, plugin: Plugin? = null) fun CommandSender.print(text: String, plugin: Plugin? = KSpigotMainInstance)
= printColoredPrefix(text, ChatColor.RESET, plugin?.name ?: "INFO", ChatColor.GRAY) = printColoredPrefix(text, ChatColor.RESET, plugin?.name ?: "INFO", ChatColor.GRAY)
/** @see printColoredPrefix */ /** @see printColoredPrefix */
fun CommandSender.info(text: String, plugin: Plugin? = null) fun CommandSender.info(text: String, plugin: Plugin? = KSpigotMainInstance)
= printColoredPrefix(text, ChatColor.WHITE, plugin?.name ?: "INFO", ChatColor.DARK_AQUA) = printColoredPrefix(text, ChatColor.WHITE, plugin?.name ?: "INFO", ChatColor.DARK_AQUA)
/** @see printColoredPrefix */ /** @see printColoredPrefix */
fun CommandSender.success(text: String, plugin: Plugin? = null) fun CommandSender.success(text: String, plugin: Plugin? = KSpigotMainInstance)
= printColoredPrefix(text, ChatColor.GREEN, plugin?.name ?: "SUCCESS", ChatColor.DARK_AQUA) = printColoredPrefix(text, ChatColor.GREEN, plugin?.name ?: "SUCCESS", ChatColor.DARK_AQUA)
/** @see printColoredPrefix */ /** @see printColoredPrefix */
fun CommandSender.warn(text: String, plugin: Plugin? = null) fun CommandSender.warn(text: String, plugin: Plugin? = KSpigotMainInstance)
= printColoredPrefix(text, ChatColor.WHITE, plugin?.name?.plus(" - WARN") ?: "WARN", ChatColor.YELLOW) = printColoredPrefix(text, ChatColor.WHITE, plugin?.name?.plus(" - WARN") ?: "WARN", ChatColor.YELLOW)
/** @see printColoredPrefix */ /** @see printColoredPrefix */
fun CommandSender.error(text: String, plugin: Plugin? = null) fun CommandSender.error(text: String, plugin: Plugin? = KSpigotMainInstance)
= printColoredPrefix(text, ChatColor.RED, plugin?.name?.plus(" - ERROR") ?: "ERROR", ChatColor.DARK_RED) = printColoredPrefix(text, ChatColor.RED, plugin?.name?.plus(" - ERROR") ?: "ERROR", ChatColor.DARK_RED)
/** /**

View File

@@ -2,12 +2,12 @@ package net.axay.kspigot.extensions.bukkit
import net.axay.kspigot.annotations.NMS_General import net.axay.kspigot.annotations.NMS_General
import net.axay.kspigot.extensions.onlinePlayers import net.axay.kspigot.extensions.onlinePlayers
import net.axay.kspigot.main.KSpigotMainInstance
import org.bukkit.Location import org.bukkit.Location
import org.bukkit.Material import org.bukkit.Material
import org.bukkit.attribute.Attribute import org.bukkit.attribute.Attribute
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld import org.bukkit.craftbukkit.v1_16_R2.CraftWorld
import org.bukkit.entity.* import org.bukkit.entity.*
import org.bukkit.plugin.Plugin
/** /**
* Checks if the entity is completely in water. * Checks if the entity is completely in water.
@@ -72,15 +72,15 @@ fun Player.feedSaturate() {
/** /**
* Hides the player for all [onlinePlayers]. * Hides the player for all [onlinePlayers].
*/ */
fun Player.disappear(plugin: Plugin) { fun Player.disappear() {
onlinePlayers.filter { it != this }.forEach { it.hidePlayer(plugin, this) } onlinePlayers.filter { it != this }.forEach { it.hidePlayer(KSpigotMainInstance, this) }
} }
/** /**
* Shows the player for all [onlinePlayers]. * Shows the player for all [onlinePlayers].
*/ */
fun Player.appear(plugin: Plugin) { fun Player.appear() {
onlinePlayers.filter { it != this }.forEach { it.showPlayer(plugin, this) } onlinePlayers.filter { it != this }.forEach { it.showPlayer(KSpigotMainInstance, this) }
} }
/** /**

View File

@@ -3,13 +3,12 @@
package net.axay.kspigot.game package net.axay.kspigot.game
import net.axay.kspigot.extensions.broadcast import net.axay.kspigot.extensions.broadcast
import net.axay.kspigot.main.KSpigot import net.axay.kspigot.main.KSpigotMainInstance
import net.axay.kspigot.runnables.task
import net.md_5.bungee.api.ChatColor import net.md_5.bungee.api.ChatColor
class GamePhaseSystem(vararg gamePhases: GamePhase) { class GamePhaseSystem(vararg gamePhases: GamePhase) {
val gamePhases = gamePhases.toMutableList() val gamePhases = gamePhases.toMutableList()
fun begin(kSpigot: KSpigot) = gamePhases.removeAt(0).startIt(kSpigot, gamePhases) fun begin() = gamePhases.removeAt(0).startIt(gamePhases)
} }
fun counterMessage( fun counterMessage(
@@ -36,9 +35,9 @@ class GamePhase(
val end: (() -> Unit)?, val end: (() -> Unit)?,
val counterMessage: ((secondsLeft: Long) -> String)? val counterMessage: ((secondsLeft: Long) -> String)?
) { ) {
fun startIt(kSpigot: KSpigot, phaseQueue: MutableList<GamePhase>) { fun startIt(phaseQueue: MutableList<GamePhase>) {
start?.invoke() start?.invoke()
kSpigot.task( KSpigotMainInstance.task(
period = 20, period = 20,
howOften = (length / 20) + 1, howOften = (length / 20) + 1,
endCallback = { endCallback = {
@@ -46,7 +45,7 @@ class GamePhase(
end?.invoke() end?.invoke()
if (phaseQueue.isNotEmpty()) if (phaseQueue.isNotEmpty())
phaseQueue.removeAt(0).startIt(kSpigot, phaseQueue) phaseQueue.removeAt(0).startIt(phaseQueue)
} }
) { ) {

View File

@@ -3,7 +3,7 @@
package net.axay.kspigot.inventory package net.axay.kspigot.inventory
import net.axay.kspigot.event.listen import net.axay.kspigot.event.listen
import net.axay.kspigot.main.KSpigot import net.axay.kspigot.main.KSpigotMainInstance
import org.bukkit.entity.HumanEntity import org.bukkit.entity.HumanEntity
import org.bukkit.event.inventory.InventoryClickEvent import org.bukkit.event.inventory.InventoryClickEvent
import org.bukkit.inventory.Inventory import org.bukkit.inventory.Inventory
@@ -25,7 +25,7 @@ fun HumanEntity.openGUI(gui: InventoryGUI<*>, page: Int? = null): InventoryView?
// GUI HOLDER // GUI HOLDER
class InventoryGUIHolder(kSpigot: KSpigot) : AutoCloseable { class InventoryGUIHolder : AutoCloseable {
private val registered = HashSet<InventoryGUI<ForInventory>>() private val registered = HashSet<InventoryGUI<ForInventory>>()
@@ -39,7 +39,7 @@ class InventoryGUIHolder(kSpigot: KSpigot) : AutoCloseable {
init { init {
kSpigot.listen<InventoryClickEvent> { listen<InventoryClickEvent> {
val clickedInv = it.clickedInventory ?: return@listen val clickedInv = it.clickedInventory ?: return@listen
@@ -76,7 +76,6 @@ class InventoryGUIClickEvent<T : ForInventory>(
private const val DEFAULT_PAGE = 1 private const val DEFAULT_PAGE = 1
class InventoryGUIData<T : ForInventory>( class InventoryGUIData<T : ForInventory>(
val plugin: KSpigot,
val inventoryType: InventoryType<T>, val inventoryType: InventoryType<T>,
val title: String?, val title: String?,
internal val pages: Map<Int, InventoryGUIPage<T>>, internal val pages: Map<Int, InventoryGUIPage<T>>,
@@ -108,14 +107,14 @@ abstract class InventoryGUI<T : ForInventory>(
* (KSpigot will listen for actions in the inventory.) * (KSpigot will listen for actions in the inventory.)
*/ */
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
fun register() = data.plugin.inventoryGUIHolder.register(this as InventoryGUI<ForInventory>) fun register() = KSpigotMainInstance.inventoryGUIHolder.register(this as InventoryGUI<ForInventory>)
/** /**
* Stops KSpigot from listening to actions in this * Stops KSpigot from listening to actions in this
* InventoryGUI anymore. * InventoryGUI anymore.
*/ */
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
fun unregister() = data.plugin.inventoryGUIHolder.unregister(this as InventoryGUI<ForInventory>) fun unregister() = KSpigotMainInstance.inventoryGUIHolder.unregister(this as InventoryGUI<ForInventory>)
/** /**
* Loads the specified page in order to display it in the GUI. * Loads the specified page in order to display it in the GUI.

View File

@@ -2,16 +2,14 @@
package net.axay.kspigot.inventory package net.axay.kspigot.inventory
import net.axay.kspigot.main.KSpigot
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
fun <T : ForInventory> KSpigot.inventoryGUI( fun <T : ForInventory> inventoryGUI(
type: InventoryType<T>, type: InventoryType<T>,
builder: InventoryGUIBuilder<T>.() -> Unit, builder: InventoryGUIBuilder<T>.() -> Unit,
) = InventoryGUIBuilder(this, type).apply(builder).build() ) = InventoryGUIBuilder(type).apply(builder).build()
class InventoryGUIBuilder<T : ForInventory>( class InventoryGUIBuilder<T : ForInventory>(
private val kSpigot: KSpigot,
val type: InventoryType<T> val type: InventoryType<T>
) { ) {
@@ -38,7 +36,7 @@ class InventoryGUIBuilder<T : ForInventory>(
} }
internal fun build() = InventoryGUIShared( internal fun build() = InventoryGUIShared(
InventoryGUIData(kSpigot, type, title, guiSlots, transitionTo, transitionFrom, onClickElement) InventoryGUIData(type, title, guiSlots, transitionTo, transitionFrom, onClickElement)
).apply { register() } ).apply { register() }
} }

View File

@@ -1,7 +1,6 @@
package net.axay.kspigot.inventory package net.axay.kspigot.inventory
import net.axay.kspigot.main.KSpigot import net.axay.kspigot.main.KSpigotMainInstance
import net.axay.kspigot.runnables.task
abstract class InventoryGUIPageChangeCalculator { abstract class InventoryGUIPageChangeCalculator {
@@ -54,7 +53,7 @@ internal fun InventoryGUI<*>.changePage(
val width = data.inventoryType.dimensions.width val width = data.inventoryType.dimensions.width
changePageEffect(data.plugin, fromPageInt, toPageInt, width) { currentOffset, ifInverted -> changePageEffect(fromPageInt, toPageInt, width) { currentOffset, ifInverted ->
if (ifInverted) { if (ifInverted) {
loadPageUnsafe(fromPage, offsetHorizontally = currentOffset) loadPageUnsafe(fromPage, offsetHorizontally = currentOffset)
loadPageUnsafe(toPage, offsetHorizontally = -(width - currentOffset)) loadPageUnsafe(toPage, offsetHorizontally = -(width - currentOffset))
@@ -70,7 +69,7 @@ internal fun InventoryGUI<*>.changePage(
val height = data.inventoryType.dimensions.heigth val height = data.inventoryType.dimensions.heigth
changePageEffect(data.plugin, fromPageInt, toPageInt, height) { currentOffset, ifInverted -> changePageEffect(fromPageInt, toPageInt, height) { currentOffset, ifInverted ->
if (ifInverted) { if (ifInverted) {
loadPageUnsafe(fromPage, offsetVertically = currentOffset) loadPageUnsafe(fromPage, offsetVertically = currentOffset)
loadPageUnsafe(toPage, offsetVertically = -(height - currentOffset)) loadPageUnsafe(toPage, offsetVertically = -(height - currentOffset))
@@ -86,7 +85,7 @@ internal fun InventoryGUI<*>.changePage(
val width = data.inventoryType.dimensions.width val width = data.inventoryType.dimensions.width
changePageEffect(data.plugin, fromPageInt, toPageInt, width) { currentOffset, ifInverted -> changePageEffect(fromPageInt, toPageInt, width) { currentOffset, ifInverted ->
if (ifInverted) { if (ifInverted) {
loadPageUnsafe(toPage, offsetHorizontally = -(width - currentOffset)) loadPageUnsafe(toPage, offsetHorizontally = -(width - currentOffset))
} else { } else {
@@ -100,7 +99,7 @@ internal fun InventoryGUI<*>.changePage(
val height = data.inventoryType.dimensions.heigth val height = data.inventoryType.dimensions.heigth
changePageEffect(data.plugin, fromPageInt, toPageInt, height) { currentOffset, ifInverted -> changePageEffect(fromPageInt, toPageInt, height) { currentOffset, ifInverted ->
if (ifInverted) { if (ifInverted) {
loadPageUnsafe(toPage, offsetVertically = -(height - currentOffset)) loadPageUnsafe(toPage, offsetVertically = -(height - currentOffset))
} else { } else {
@@ -120,7 +119,6 @@ internal fun InventoryGUI<*>.changeGUI(
) = changePage(effect.effect, fromPage, toPage) ) = changePage(effect.effect, fromPage, toPage)
private inline fun changePageEffect( private inline fun changePageEffect(
kSpigot: KSpigot,
fromPage: Int, fromPage: Int,
toPage: Int, toPage: Int,
doFor: Int, doFor: Int,
@@ -130,7 +128,7 @@ private inline fun changePageEffect(
val ifInverted = fromPage >= toPage val ifInverted = fromPage >= toPage
var currentOffset = 1 var currentOffset = 1
kSpigot.task( KSpigotMainInstance.task(
sync = true, sync = true,
period = 1, period = 1,
howOften = doFor.toLong() howOften = doFor.toLong()

View File

@@ -22,7 +22,7 @@ abstract class KSpigot : JavaPlugin() {
// lazy properties // lazy properties
private val kRunnableHolderProperty = lazy { KRunnableHolder() } private val kRunnableHolderProperty = lazy { KRunnableHolder() }
private val inventoryGUIHolderProperty = lazy { InventoryGUIHolder(this) } private val inventoryGUIHolderProperty = lazy { InventoryGUIHolder() }
internal val kRunnableHolder by kRunnableHolderProperty internal val kRunnableHolder by kRunnableHolderProperty
internal val inventoryGUIHolder by inventoryGUIHolderProperty internal val inventoryGUIHolder by inventoryGUIHolderProperty
@@ -43,6 +43,7 @@ abstract class KSpigot : JavaPlugin() {
open fun shutdown() { } open fun shutdown() { }
final override fun onLoad() { final override fun onLoad() {
KSpigotMainInstance = this
load() load()
} }
@@ -60,4 +61,6 @@ abstract class KSpigot : JavaPlugin() {
} }
} }
lateinit var KSpigotMainInstance: KSpigot private set

View File

@@ -2,15 +2,14 @@
package net.axay.kspigot.runnables package net.axay.kspigot.runnables
import net.axay.kspigot.main.KSpigotMainInstance
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.plugin.Plugin
/* /*
* Chainable bukkit runnable. * Chainable bukkit runnable.
*/ */
class ChainedRunnablePart<T, R>( class ChainedRunnablePart<T, R>(
val plugin: Plugin,
val runnable: (T?) -> R, val runnable: (T?) -> R,
val sync: Boolean, val sync: Boolean,
var previous: ChainedRunnablePart<*, T>? = null, var previous: ChainedRunnablePart<*, T>? = null,
@@ -27,22 +26,22 @@ class ChainedRunnablePart<T, R>(
next?.start(result) next?.start(result)
} }
if (sync) if (sync)
Bukkit.getScheduler().runTask(plugin, realRunnable) Bukkit.getScheduler().runTask(KSpigotMainInstance, realRunnable)
else else
Bukkit.getScheduler().runTaskAsynchronously(plugin, realRunnable) Bukkit.getScheduler().runTaskAsynchronously(KSpigotMainInstance, realRunnable)
} }
} }
// FIRST // FIRST
fun <R> Plugin.firstDo(sync: Boolean, runnable: (Unit?) -> R) fun <R> firstDo(sync: Boolean, runnable: (Unit?) -> R)
= ChainedRunnablePart<Unit, R>(this, runnable, sync) = ChainedRunnablePart<Unit, R>(runnable, sync)
fun <R> Plugin.firstSync(runnable: (Unit?) -> R) = firstDo(true, runnable) fun <R> firstSync(runnable: (Unit?) -> R) = firstDo(true, runnable)
fun <R> Plugin.firstAsync(runnable: (Unit?) -> R) = firstDo(false, runnable) fun <R> firstAsync(runnable: (Unit?) -> R) = firstDo(false, runnable)
// THEN // THEN
fun <T, R, U> ChainedRunnablePart<T, R>.thenDo(sync: Boolean, runnable: (R?) -> U): ChainedRunnablePart<R, U> { fun <T, R, U> ChainedRunnablePart<T, R>.thenDo(sync: Boolean, runnable: (R?) -> U): ChainedRunnablePart<R, U> {
ChainedRunnablePart<R, U>(plugin, runnable, sync).apply { ChainedRunnablePart<R, U>(runnable, sync).apply {
previous = this@thenDo previous = this@thenDo
this@thenDo.next = this this@thenDo.next = this
return this return this

View File

@@ -2,9 +2,8 @@
package net.axay.kspigot.runnables package net.axay.kspigot.runnables
import net.axay.kspigot.main.KSpigot import net.axay.kspigot.main.KSpigotMainInstance
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.plugin.Plugin
import org.bukkit.scheduler.BukkitRunnable import org.bukkit.scheduler.BukkitRunnable
class KRunnableHolder : AutoCloseable { class KRunnableHolder : AutoCloseable {
@@ -49,7 +48,7 @@ abstract class KSpigotRunnable(
* @param endCallback code that should always be executed when the runnable ends * @param endCallback code that should always be executed when the runnable ends
* @param runnable the runnable which should be executed each repetition * @param runnable the runnable which should be executed each repetition
*/ */
fun KSpigot.task( fun task(
sync: Boolean = true, sync: Boolean = true,
delay: Long = 0, delay: Long = 0,
period: Long? = null, period: Long? = null,
@@ -87,32 +86,32 @@ fun KSpigot.task(
if (isCancelled) { if (isCancelled) {
if (safe || ranOut) if (safe || ranOut)
kRunnableHolder.activate(this) KSpigotMainInstance.kRunnableHolder.activate(this)
else else
kRunnableHolder.remove(this) KSpigotMainInstance.kRunnableHolder.remove(this)
} }
} }
} }
if (endCallback != null) kRunnableHolder.add(bukkitRunnable, endCallback, safe) if (endCallback != null) KSpigotMainInstance.kRunnableHolder.add(bukkitRunnable, endCallback, safe)
if (sync) if (sync)
bukkitRunnable.runTaskTimer(this, delay, period ?: 20) bukkitRunnable.runTaskTimer(KSpigotMainInstance, delay, period ?: 20)
else else
bukkitRunnable.runTaskTimerAsynchronously(this, delay, period ?: 20) bukkitRunnable.runTaskTimerAsynchronously(KSpigotMainInstance, delay, period ?: 20)
} }
/** /**
* Starts a synchronous task. * Starts a synchronous task.
*/ */
fun Plugin.sync(runnable: () -> Unit) fun sync(runnable: () -> Unit)
= Bukkit.getScheduler().runTask(this, runnable) = Bukkit.getScheduler().runTask(KSpigotMainInstance, runnable)
/** /**
* Starts an asynchronous task. * Starts an asynchronous task.
*/ */
fun Plugin.async(runnable: () -> Unit) fun async(runnable: () -> Unit)
= Bukkit.getScheduler().runTaskAsynchronously(this, runnable) = Bukkit.getScheduler().runTaskAsynchronously(KSpigotMainInstance, runnable)

View File

@@ -1,6 +1,6 @@
package net.axay.kspigot.utils package net.axay.kspigot.utils
import net.axay.kspigot.main.KSpigot import net.axay.kspigot.main.KSpigotMainInstance
import org.bukkit.command.CommandExecutor import org.bukkit.command.CommandExecutor
import org.bukkit.command.TabCompleter import org.bukkit.command.TabCompleter
@@ -13,8 +13,8 @@ interface RegisterableCommand : CommandExecutor {
* @return true if the command was found - * @return true if the command was found -
* false if not * false if not
*/ */
fun registerCommand(commandName: String, kSpigot: KSpigot): Boolean { fun registerAs(commandName: String): Boolean {
kSpigot.getCommand(commandName)?.let { KSpigotMainInstance.getCommand(commandName)?.let {
it.setExecutor(this) it.setExecutor(this)
if (this is TabCompleter) if (this is TabCompleter)
it.tabCompleter = this it.tabCompleter = this