Use holders from KSpigotMainInstance

This commit is contained in:
Jakob K
2021-06-15 20:07:19 +02:00
parent 8ffaee3d51
commit d66fbd7979
2 changed files with 6 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ package net.axay.kspigot.gui
import net.axay.kspigot.event.listen
import net.axay.kspigot.extensions.bukkit.closeForViewers
import net.axay.kspigot.main.KSpigotMainInstance
import org.bukkit.entity.Player
import org.bukkit.event.inventory.InventoryCloseEvent
import org.bukkit.event.player.PlayerQuitEvent
@@ -186,7 +187,7 @@ class GUIInstance<T : ForInventory>(
* (KSpigot will listen for actions in the inventory.)
*/
@Suppress("UNCHECKED_CAST")
fun register() = GUIHolder.register(this as GUIInstance<ForInventory>)
fun register() = KSpigotMainInstance.guiHolder.register(this as GUIInstance<ForInventory>)
/**
* Stops KSpigot from listening to actions in this
@@ -194,7 +195,7 @@ class GUIInstance<T : ForInventory>(
*/
fun unregister() {
@Suppress("UNCHECKED_CAST")
GUIHolder.unregister(this as GUIInstance<ForInventory>)
KSpigotMainInstance.guiHolder.unregister(this as GUIInstance<ForInventory>)
// unregister this inv from all elements
currentElements.forEach { it.stopUsing(this) }
currentElements.clear()

View File

@@ -77,14 +77,14 @@ fun task(
if (isCancelled) {
if (safe || ranOut)
KRunnableHolder.activate(this)
KSpigotMainInstance.kRunnableHolder.activate(this)
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 (period != null)
if (sync) bukkitRunnable.runTaskTimer(KSpigotMainInstance, delay, period)