Make "PluginInstance" available internally

This commit is contained in:
Jakob K
2021-08-24 01:47:38 +02:00
parent 4d3e25af32
commit fa71b0cc0e
11 changed files with 48 additions and 43 deletions

View File

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