Use holders from KSpigotMainInstance
This commit is contained in:
@@ -4,6 +4,7 @@ package net.axay.kspigot.gui
|
|||||||
|
|
||||||
import net.axay.kspigot.event.listen
|
import net.axay.kspigot.event.listen
|
||||||
import net.axay.kspigot.extensions.bukkit.closeForViewers
|
import net.axay.kspigot.extensions.bukkit.closeForViewers
|
||||||
|
import net.axay.kspigot.main.KSpigotMainInstance
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent
|
import org.bukkit.event.inventory.InventoryCloseEvent
|
||||||
import org.bukkit.event.player.PlayerQuitEvent
|
import org.bukkit.event.player.PlayerQuitEvent
|
||||||
@@ -186,7 +187,7 @@ class GUIInstance<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() = GUIHolder.register(this as GUIInstance<ForInventory>)
|
fun register() = KSpigotMainInstance.guiHolder.register(this as GUIInstance<ForInventory>)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops KSpigot from listening to actions in this
|
* Stops KSpigot from listening to actions in this
|
||||||
@@ -194,7 +195,7 @@ class GUIInstance<T : ForInventory>(
|
|||||||
*/
|
*/
|
||||||
fun unregister() {
|
fun unregister() {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
GUIHolder.unregister(this as GUIInstance<ForInventory>)
|
KSpigotMainInstance.guiHolder.unregister(this as GUIInstance<ForInventory>)
|
||||||
// unregister this inv from all elements
|
// unregister this inv from all elements
|
||||||
currentElements.forEach { it.stopUsing(this) }
|
currentElements.forEach { it.stopUsing(this) }
|
||||||
currentElements.clear()
|
currentElements.clear()
|
||||||
|
@@ -77,14 +77,14 @@ fun 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 (period != null)
|
if (period != null)
|
||||||
if (sync) bukkitRunnable.runTaskTimer(KSpigotMainInstance, delay, period)
|
if (sync) bukkitRunnable.runTaskTimer(KSpigotMainInstance, delay, period)
|
||||||
|
Reference in New Issue
Block a user