From 02372160a1909e5f1a38d1c5e9947a4d6747f650 Mon Sep 17 00:00:00 2001 From: bluefireoly Date: Thu, 29 Oct 2020 20:36:59 +0100 Subject: [PATCH] Added constructor for rect space compound --- .../kotlin/net/axay/kspigot/gui/GUIBuilder.kt | 1 - .../gui/elements/GUISpaceCompoundScrollButton.kt | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/axay/kspigot/gui/GUIBuilder.kt b/src/main/kotlin/net/axay/kspigot/gui/GUIBuilder.kt index 7dadf8a7..d34a2be1 100644 --- a/src/main/kotlin/net/axay/kspigot/gui/GUIBuilder.kt +++ b/src/main/kotlin/net/axay/kspigot/gui/GUIBuilder.kt @@ -267,7 +267,6 @@ class GUIPageBuilder( GUISpaceCompoundScrollButton( icon, compound, - compound.compoundWidth, scrollTimes, reverse ) diff --git a/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompoundScrollButton.kt b/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompoundScrollButton.kt index fbb44b40..e4d7717e 100644 --- a/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompoundScrollButton.kt +++ b/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompoundScrollButton.kt @@ -5,12 +5,16 @@ import net.axay.kspigot.runnables.task import org.bukkit.inventory.ItemStack class GUISpaceCompoundScrollButton( + icon: ItemStack, + private val compound: AbstractGUISpaceCompound, private val scrollDistance: Int, private val scrollTimes: Int, private val reverse: Boolean = false + ) : GUIButton(icon, { + if (scrollTimes > 1) { task( period = 1, @@ -21,4 +25,14 @@ class GUISpaceCompoundScrollButton( } } else if (scrollTimes == 1) if (reverse) compound.scroll(-scrollDistance) else compound.scroll(scrollDistance) -}) \ No newline at end of file + +}) { + + constructor( + icon: ItemStack, + compound: GUIRectSpaceCompound, + scrollTimes: Int = 1, + reverse: Boolean = false + ) : this(icon, compound, compound.compoundWidth, scrollTimes, reverse) + +} \ No newline at end of file