Skip to content

Commit

Permalink
chore: code improvements and better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFruxz committed Oct 22, 2022
1 parent 51ad2ca commit f9406cf
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@ data class ComplexEffect(
effects += effect
}



}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.fruxz.sparkle.framework.event.canvas

import de.fruxz.sparkle.framework.visual.canvas.Canvas
import de.fruxz.sparkle.framework.visual.canvas.Canvas.ExperimentalCanvasApi
import net.kyori.adventure.key.Key
import org.bukkit.entity.Player
import org.bukkit.event.HandlerList
Expand All @@ -26,7 +27,9 @@ class CanvasUpdateEvent(
}

enum class UpdateReason {
PLUGIN, SCROLL, PAGE_TURN;
PLUGIN,
@ExperimentalCanvasApi SCROLL,
@ExperimentalCanvasApi PAGE_TURN;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,6 @@ open class Canvas(

@MustBeDocumented
@RequiresOptIn(message = "This api is still in development and may not work like expected and may change in the future")
annotation class CanvasPrototypeAPI
annotation class ExperimentalCanvasApi

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ data class MutableCanvas(
fun base(inventoryType: InventoryType) = base(Companion.ofType(inventoryType))

@CanvasDsl
@CanvasPrototypeAPI
@ExperimentalCanvasApi
fun pagination(pagination: PaginationType<*>) {
this.pagination = pagination
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import de.fruxz.sparkle.framework.extension.subNamespacedKey
import de.fruxz.sparkle.framework.extension.sparkle
import de.fruxz.sparkle.framework.extension.visual.ui.item
import de.fruxz.sparkle.framework.extension.visual.ui.skull
import de.fruxz.sparkle.framework.visual.canvas.Canvas.CanvasPrototypeAPI
import de.fruxz.sparkle.framework.visual.canvas.Canvas.ExperimentalCanvasApi
import de.fruxz.sparkle.framework.visual.canvas.PaginationType.Companion.PaginationBase.PAGED
import de.fruxz.sparkle.framework.visual.canvas.PaginationType.Companion.PaginationBase.SCROLL
import de.fruxz.sparkle.framework.visual.item.Item
Expand Down Expand Up @@ -36,7 +36,7 @@ interface PaginationType<C> {
override fun contentRendering(scrollState: Int, lines: Int, contents: Map<Int, ItemLike>) = contents
}

@CanvasPrototypeAPI
@ExperimentalCanvasApi
fun scroll(configuration: ScrollControlSetup = ScrollControlSetup()) =
object : PaginationType<ScrollControlSetup> {
override val base: PaginationBase = SCROLL
Expand Down Expand Up @@ -83,7 +83,7 @@ interface PaginationType<C> {
}
}

@CanvasPrototypeAPI
@ExperimentalCanvasApi
fun paged(configuration: PageControlSetup = PageControlSetup()) =
object : PaginationType<PageControlSetup> {
override val base: PaginationBase = PAGED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import de.fruxz.sparkle.framework.extension.visual.ui.skull
import de.fruxz.sparkle.framework.infrastructure.command.completion.buildInterchangeStructure
import de.fruxz.sparkle.framework.infrastructure.command.completion.content.CompletionAsset
import de.fruxz.sparkle.framework.infrastructure.command.structured.StructuredInterchange
import de.fruxz.sparkle.framework.visual.canvas.Canvas.CanvasPrototypeAPI
import de.fruxz.sparkle.framework.visual.canvas.Canvas.ExperimentalCanvasApi
import de.fruxz.sparkle.framework.visual.canvas.PaginationType
import de.fruxz.sparkle.framework.visual.canvas.buildCanvas
import de.fruxz.sparkle.framework.visual.color.ColorType
Expand Down Expand Up @@ -96,7 +96,7 @@ internal class PlaygroundInterchange : StructuredInterchange("playground", build

}

val canvasScrollable = @OptIn(CanvasPrototypeAPI::class)
val canvasScrollable = @OptIn(ExperimentalCanvasApi::class)
buildCanvas {
label("<i>Hello!")
pagination(PaginationType.scroll())
Expand Down

0 comments on commit f9406cf

Please sign in to comment.