diff --git a/.idea/misc.xml b/.idea/misc.xml
index 0c1b468..1530664 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,7 +5,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules/ktgui.main.iml b/.idea/modules/ktgui.main.iml
deleted file mode 100644
index a589521..0000000
--- a/.idea/modules/ktgui.main.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
- SPIGOT
-
- 1
-
-
-
-
\ No newline at end of file
diff --git a/api/build.gradle.kts b/api/build.gradle.kts
index 97aaee3..c4cfdd6 100644
--- a/api/build.gradle.kts
+++ b/api/build.gradle.kts
@@ -1,19 +1,14 @@
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
plugins {
- kotlin("jvm") version "1.7.10"
- id("com.github.johnrengelman.shadow") version "7.0.0"
+ alias(libs.plugins.kotlinJvm) apply true
+ alias(libs.plugins.shadow) apply true
`maven-publish`
}
-repositories {
- mavenCentral()
-}
-
dependencies {
-// compileOnly(kotlin("reflect"))
- implementation(kotlin("reflect"))
- implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10")
+ compileOnly(libs.paper.api)
+ compileOnly(libs.placeholder.api)
+ implementation(libs.kotlin.reflect)
+ compileOnly(libs.kotlin.stdlib)
}
tasks.test {
@@ -24,8 +19,8 @@ version = rootProject.version
sourceSets["main"].resources.srcDir("src/resources/")
-tasks.withType {
- kotlinOptions.jvmTarget = "17"
+kotlin {
+ jvmToolchain(JavaVersion.VERSION_17.ordinal)
}
tasks {
@@ -38,15 +33,13 @@ tasks {
//// it.path.startsWith("kotlin") && !it.path.contains("reactive")
// it.name.startsWith("kotlin")
// }
+ archiveBaseName.set("ktgui")
+ mergeServiceFiles()
}
}
-tasks.withType {
- archiveBaseName.set("ktgui")
- mergeServiceFiles()
-}
-
java {
+ toolchain.languageVersion.set(JavaLanguageVersion.of(17))
withJavadocJar()
withSourcesJar()
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/GuiManager.kt b/api/src/main/kotlin/com/mattmx/ktgui/GuiManager.kt
index 47e3766..58727d7 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/GuiManager.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/GuiManager.kt
@@ -60,7 +60,7 @@ object GuiManager : Listener {
if (existingCommand != null) {
Bukkit.getPluginCommand(command.name)?.setExecutor(command)
} else {
- if(!isInitialized()) {
+ if (!isInitialized()) {
throw RuntimeException("Unregistered commands are unsupported when GuiManager not initialised! Call GuiManager.init")
}
@@ -89,7 +89,8 @@ object GuiManager : Listener {
val aliasesField = SimpleCommandMap::class.java.getDeclaredField("aliases")
aliasesField.setAccessible(true)
knownAliases = aliasesField.get(cmdMap) as MutableSet
- } catch (e: NoSuchFieldException) {}
+ } catch (e: NoSuchFieldException) {
+ }
event(cmdPlugin) {
if (this.plugin == cmdPlugin) {
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/bossbar/AnimatedBossBar.kt b/api/src/main/kotlin/com/mattmx/ktgui/bossbar/AnimatedBossBar.kt
index 6c3c70f..5d1520e 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/bossbar/AnimatedBossBar.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/bossbar/AnimatedBossBar.kt
@@ -9,7 +9,7 @@ class AnimatedBossBar(var updateEvery: Long? = null) : LegacyBossBarBuilder() {
private lateinit var task: BukkitTask
var update: ((AnimatedBossBar) -> Unit)? = null
- fun update(builder: AnimatedBossBar.() -> Unit) : AnimatedBossBar {
+ fun update(builder: AnimatedBossBar.() -> Unit): AnimatedBossBar {
this.update = builder
return this
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/bossbar/LegacyBossBarBuilder.kt b/api/src/main/kotlin/com/mattmx/ktgui/bossbar/LegacyBossBarBuilder.kt
index 278c87a..a52a447 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/bossbar/LegacyBossBarBuilder.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/bossbar/LegacyBossBarBuilder.kt
@@ -38,10 +38,11 @@ open class LegacyBossBarBuilder {
inline fun bossBar(builder: LegacyBossBarBuilder.() -> Unit) = bossBarDsl(LegacyBossBarBuilder(), builder)
@Deprecated("Simply use the BossBar class in adventure.", ReplaceWith("net.kyori.adventure.bossbar.BossBar"))
-inline fun animatedBossBar(period: Long? = null, builder: AnimatedBossBar.() -> Unit) = bossBarDsl(AnimatedBossBar(period), builder)
+inline fun animatedBossBar(period: Long? = null, builder: AnimatedBossBar.() -> Unit) =
+ bossBarDsl(AnimatedBossBar(period), builder)
@Deprecated("Simply use the BossBar class in adventure.", ReplaceWith("net.kyori.adventure.bossbar.BossBar"))
-inline fun bossBarDsl(instance: T, builder: T.() -> Unit) : T {
+inline fun bossBarDsl(instance: T, builder: T.() -> Unit): T {
builder(instance)
instance.build()
return instance
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/DummyCommand.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/DummyCommand.kt
index 54d8a79..a544fb5 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/commands/DummyCommand.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/DummyCommand.kt
@@ -1,6 +1,5 @@
package com.mattmx.ktgui.commands
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.command.Command
import org.bukkit.command.CommandSender
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/SimpleCommandBuilder.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/SimpleCommandBuilder.kt
index d379004..d243870 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/commands/SimpleCommandBuilder.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/SimpleCommandBuilder.kt
@@ -35,32 +35,32 @@ open class SimpleCommandBuilder(
constructor(name: String) : this(name, null)
constructor(name: String, vararg alias: String) : this(name, null, *alias)
- infix fun permission(permission: String) : SimpleCommandBuilder {
+ infix fun permission(permission: String): SimpleCommandBuilder {
this.permission = permission
return this
}
- infix fun alias(alias: String) : SimpleCommandBuilder {
+ infix fun alias(alias: String): SimpleCommandBuilder {
this.aliases.add(alias)
return this
}
- fun noPermissions(cb: CommandInvocation.() -> Unit) : SimpleCommandBuilder {
+ fun noPermissions(cb: CommandInvocation.() -> Unit): SimpleCommandBuilder {
noPermissions = cb
return this
}
- infix fun subCommand(commandBuilder: SimpleCommandBuilder) : SimpleCommandBuilder {
+ infix fun subCommand(commandBuilder: SimpleCommandBuilder): SimpleCommandBuilder {
subCommands.add(commandBuilder)
return this
}
- infix fun hasPermission(executor: CommandSender) : Boolean {
+ infix fun hasPermission(executor: CommandSender): Boolean {
// todo check for subcommand permissions
return permission == null || executor.hasPermission(permission!!)
}
- fun onCooldown(executes: CommandInvocation.() -> Unit) : SimpleCommandBuilder {
+ fun onCooldown(executes: CommandInvocation.() -> Unit): SimpleCommandBuilder {
this.cooldownCallback = executes
return this
}
@@ -76,7 +76,7 @@ open class SimpleCommandBuilder(
this.cooldownCallback?.invoke(invocation)
}
- fun executes(execute: CommandInvocation.() -> Unit) : SimpleCommandBuilder {
+ fun executes(execute: CommandInvocation.() -> Unit): SimpleCommandBuilder {
this.execute = execute
return this
}
@@ -85,7 +85,7 @@ open class SimpleCommandBuilder(
this.execute = block
}
- fun unknownSubcommand(unknown: CommandInvocation.() -> Unit) : SimpleCommandBuilder {
+ fun unknownSubcommand(unknown: CommandInvocation.() -> Unit): SimpleCommandBuilder {
this.unknown = unknown
return this
}
@@ -106,11 +106,11 @@ open class SimpleCommandBuilder(
this.suggests = suggest
}
- fun allAliases() : List {
+ fun allAliases(): List {
return aliases.toMutableList() + name
}
- fun getSuggestions(invocation: CommandInvocation) : List {
+ fun getSuggestions(invocation: CommandInvocation): List {
suggests?.also {
return it(invocation) ?: listOf()
} ?: run {
@@ -125,7 +125,7 @@ open class SimpleCommandBuilder(
return listOf()
}
- infix fun suggestSubCommands(value: Boolean) : SimpleCommandBuilder {
+ infix fun suggestSubCommands(value: Boolean): SimpleCommandBuilder {
this.suggestSubCommands = value
return this
}
@@ -134,7 +134,7 @@ open class SimpleCommandBuilder(
if (isInConfig) {
Bukkit.getPluginCommand(name)?.setExecutor(DummyCommandExecutor(this))
} else {
- if(!GuiManager.isInitialized()) {
+ if (!GuiManager.isInitialized()) {
throw RuntimeException("Unregistered commands are unsupported when GuiManager not initialised! Call GuiManager.init")
}
val cmdMapField = Bukkit.getServer().javaClass.getDeclaredField("commandMap")
@@ -150,11 +150,12 @@ open class SimpleCommandBuilder(
val aliasesField = SimpleCommandMap::class.java.getDeclaredField("aliases")
aliasesField.setAccessible(true)
knownAliases = aliasesField.get(cmdMap) as MutableSet
- } catch (e: NoSuchFieldException) {}
+ } catch (e: NoSuchFieldException) {
+ }
val prefix = GuiManager.owningPlugin.name.lowercase()
event(plugin = GuiManager.owningPlugin) {
- if(plugin == GuiManager.owningPlugin) {
+ if (plugin == GuiManager.owningPlugin) {
synchronized(cmdMap) {
knownCommands.remove(name)
knownCommands.remove("$prefix:$name")
@@ -171,15 +172,16 @@ open class SimpleCommandBuilder(
}
}
}
- fun couldBeCommand(arg: String) : Boolean {
+
+ fun couldBeCommand(arg: String): Boolean {
return name.startsWith(arg) || aliases.any { it.startsWith(arg) }
}
- fun isCommand(arg: String) : Boolean {
+ fun isCommand(arg: String): Boolean {
return name == arg || aliases.any { it == arg }
}
- fun getCommand(args: List) : SimpleCommandBuilder? {
+ fun getCommand(args: List): SimpleCommandBuilder? {
if (args.isEmpty()) return this
subCommands.forEach { cmd ->
if (cmd.isCommand(args[0])) {
@@ -202,21 +204,21 @@ class CommandInvocation(
val player: Player
get() = source as Player
- fun player() : Player {
+ fun player(): Player {
return source as Player
}
- operator fun get(index: Int) : String? {
+ operator fun get(index: Int): String? {
if (index >= args.size) return null
return args[index]
}
- fun isNotEmpty() : Boolean = args.isNotEmpty()
- fun isEmpty() : Boolean = args.isEmpty()
+ fun isNotEmpty(): Boolean = args.isNotEmpty()
+ fun isEmpty(): Boolean = args.isEmpty()
}
@Deprecated("No longer considered a 'simple command'", ReplaceWith("rawCommand"))
-inline fun simpleCommand(cmd: (SimpleCommandBuilder.() -> Unit)) : SimpleCommandBuilder {
+inline fun simpleCommand(cmd: (SimpleCommandBuilder.() -> Unit)): SimpleCommandBuilder {
val cmdB = SimpleCommandBuilder()
cmd(cmdB)
return cmdB
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/Argument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/Argument.kt
index 54cd194..ec9bc8e 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/Argument.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/Argument.kt
@@ -21,7 +21,7 @@ open class Argument(
fun description() = description
- fun getDefaultSuggestions() : List? {
+ fun getDefaultSuggestions(): List? {
// todo need to invoke [suggests] with fake [CommandContext]
return null
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/CommandContext.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/CommandContext.kt
index 8546365..da31a34 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/CommandContext.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/CommandContext.kt
@@ -14,11 +14,11 @@ open class CommandContext(
operator fun ReadOnlyProperty.getValue(
thisRef: T,
property: KProperty<*>
- ) : V {
+ ): V {
return map[property.name] as V
}
- fun getValue(argument: Argument) : V? {
+ fun getValue(argument: Argument): V? {
return if (::map.isInitialized) map[argument.id] as V? else null
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/tests.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/tests.kt
index 8ce50d5..da8ba96 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/tests.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/tests.kt
@@ -2,7 +2,10 @@ package com.mattmx.ktgui.commands.alpha
import kotlin.concurrent.thread
-fun KtCommandBuilder.argument(description: String? = null, suggests: (CommandContext.() -> List)? = null) =
+fun KtCommandBuilder.argument(
+ description: String? = null,
+ suggests: (CommandContext.() -> List)? = null
+) =
Argument(ArgumentType.REQUIRED_SINGLE, { c -> c.args[0] }, suggests).apply {
this withDescription description
this@argument.expectedArguments += this
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/Argument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/Argument.kt
index ce0920b..b7feb0a 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/Argument.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/Argument.kt
@@ -1,6 +1,5 @@
package com.mattmx.ktgui.commands.declarative.arg
-import com.mattmx.ktgui.commands.declarative.DeclarativeCommandBuilder
import com.mattmx.ktgui.commands.declarative.invocation.InvalidArgContext
import com.mattmx.ktgui.commands.declarative.invocation.SuggestionInvocation
import com.mattmx.ktgui.commands.declarative.syntax.VariableType
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/Parser.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/Parser.kt
index 278d829..97970f0 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/Parser.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/Parser.kt
@@ -67,7 +67,15 @@ class Parser(
val optional = matchToken(SyntaxKind.QUESTION)
val closeDiamondBraces = matchToken(SyntaxKind.CLOSE_DIAMOND)
- return VariableDeclarationSyntax(openDiamondBraces, varName, colon, type, ellipsis, optional, closeDiamondBraces)
+ return VariableDeclarationSyntax(
+ openDiamondBraces,
+ varName,
+ colon,
+ type,
+ ellipsis,
+ optional,
+ closeDiamondBraces
+ )
}
private fun parseCommand(): CommandDeclarationSyntax {
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/SyntaxNode.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/SyntaxNode.kt
index f44b5ce..f66ff9d 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/SyntaxNode.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/SyntaxNode.kt
@@ -2,9 +2,9 @@ package com.mattmx.ktgui.commands.declarative.syntax
abstract class SyntaxNode {
- abstract fun kind() : SyntaxKind
+ abstract fun kind(): SyntaxKind
- open fun children() : List {
+ open fun children(): List {
val children = arrayListOf()
// default impl of children, you should override this.
for (member in this.javaClass.declaredFields) {
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/VariableDeclarationSyntax.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/VariableDeclarationSyntax.kt
index e6c4e57..19661b2 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/VariableDeclarationSyntax.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/syntax/VariableDeclarationSyntax.kt
@@ -15,5 +15,6 @@ class VariableDeclarationSyntax(
fun getType() = VariableType(typeToken.text!!, ellipsisToken.text != null, optional.text != null)
- override fun children() = listOf(openDiamondBracesToken, varNameToken, colonToken, typeToken, closeDiamondBracesToken)
+ override fun children() =
+ listOf(openDiamondBracesToken, varNameToken, colonToken, typeToken, closeDiamondBracesToken)
}
\ No newline at end of file
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/suggestions/CommandSuggestion.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/suggestions/CommandSuggestion.kt
index 635ff36..700a0a5 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/commands/suggestions/CommandSuggestion.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/suggestions/CommandSuggestion.kt
@@ -8,7 +8,7 @@ fun interface CommandSuggestion {
fun getLastArgSuggestion(invocation: SuggestionInvocation<*>) = getSuggestion(invocation)
?.filter { it.startsWith((invocation.rawArgs.lastOrNull() ?: ""), true) }
- fun getValue(argumentString: String) : V? {
+ fun getValue(argumentString: String): V? {
return argumentString as V?
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/suggestions/impl/OnlinePlayersCommandSuggestion.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/suggestions/impl/OnlinePlayersCommandSuggestion.kt
index 9b4fc92..5f52275 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/commands/suggestions/impl/OnlinePlayersCommandSuggestion.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/suggestions/impl/OnlinePlayersCommandSuggestion.kt
@@ -1,7 +1,7 @@
package com.mattmx.ktgui.commands.suggestions.impl
-import com.mattmx.ktgui.commands.suggestions.CommandSuggestion
import com.mattmx.ktgui.commands.declarative.invocation.SuggestionInvocation
+import com.mattmx.ktgui.commands.suggestions.CommandSuggestion
import org.bukkit.Bukkit
import org.bukkit.entity.Player
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/EffectBlock.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/EffectBlock.kt
index c60f5e8..7259f7b 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/EffectBlock.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/EffectBlock.kt
@@ -2,7 +2,6 @@ package com.mattmx.ktgui.components
import com.mattmx.ktgui.components.screen.GuiScreen
import com.mattmx.ktgui.components.signal.SignalListener
-import com.mattmx.ktgui.components.signal.SignalOwner
class EffectBlock(
val owner: T,
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/GuiPattern.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/GuiPattern.kt
index 9e3fb22..524f0ab 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/GuiPattern.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/GuiPattern.kt
@@ -3,7 +3,6 @@ package com.mattmx.ktgui.components
import com.mattmx.ktgui.components.button.GuiButton
import com.mattmx.ktgui.components.button.IGuiButton
import com.mattmx.ktgui.components.screen.GuiScreen
-import com.mattmx.ktgui.dsl.gui
import org.bukkit.Material
import org.bukkit.inventory.ItemStack
@@ -35,7 +34,7 @@ class GuiPattern(
* @param rows the number of rows the gui will have.
* @return a compiled map of Buttons to their respective slots in the gui.
*/
- fun build(rows: Int) : Map, ArrayList> {
+ fun build(rows: Int): Map, ArrayList> {
val map = mutableMapOf, ArrayList>()
val maxSlot = rows * 9
trimPattern()
@@ -86,7 +85,7 @@ class GuiPattern(
* @param char
* @return gui button of a character, or null if it hasn't been set yet
*/
- operator fun get(char: Char) : IGuiButton<*>? = items[char]
+ operator fun get(char: Char): IGuiButton<*>? = items[char]
}
/**
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/button/ButtonClickedEvent.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/button/ButtonClickedEvent.kt
index 526ab2a..af328db 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/button/ButtonClickedEvent.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/button/ButtonClickedEvent.kt
@@ -2,9 +2,6 @@ package com.mattmx.ktgui.components.button
import com.mattmx.ktgui.GuiManager
import com.mattmx.ktgui.extensions.getOpenGui
-import com.mattmx.ktgui.item.DslIBuilder
-import com.mattmx.ktgui.item.builder
-import org.bukkit.Material
import org.bukkit.entity.Player
import org.bukkit.event.Cancellable
import org.bukkit.event.Event
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiButton.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiButton.kt
index 8af9f09..1611c50 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiButton.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiButton.kt
@@ -17,9 +17,6 @@ import org.bukkit.event.inventory.InventoryDragEvent
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.ItemMeta
import org.bukkit.inventory.meta.PotionMeta
-import org.bukkit.potion.PotionEffect
-import java.lang.StringBuilder
-import java.util.StringJoiner
import java.util.function.Consumer
open class GuiButton>(
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiCycleButton.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiCycleButton.kt
index 53c152c..ea82ff3 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiCycleButton.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiCycleButton.kt
@@ -2,7 +2,6 @@ package com.mattmx.ktgui.components.button
import com.mattmx.ktgui.components.screen.GuiScreen
import org.bukkit.Material
-import org.bukkit.entity.Player
import org.bukkit.event.inventory.ClickType
import org.bukkit.inventory.ItemStack
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiToggleButton.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiToggleButton.kt
index e05bc07..ae9a1a5 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiToggleButton.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/button/GuiToggleButton.kt
@@ -11,6 +11,7 @@ open class GuiToggleButton(
private var state = false
lateinit var changedCallback: (ButtonClickedEvent) -> Unit
protected set
+
init {
this.item = if (state) enabledItem else disabledItem
}
@@ -31,7 +32,7 @@ open class GuiToggleButton(
update()
}
- fun enabledOnDefault(state: Boolean) : GuiToggleButton {
+ fun enabledOnDefault(state: Boolean): GuiToggleButton {
this.state = state
this.item = if (this.state) enabledItem else disabledItem
return this
@@ -42,7 +43,7 @@ open class GuiToggleButton(
return this
}
- fun enabled() : Boolean {
+ fun enabled(): Boolean {
return state
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/button/IGuiButton.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/button/IGuiButton.kt
index 59d0c05..41d88ed 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/button/IGuiButton.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/button/IGuiButton.kt
@@ -9,7 +9,7 @@ interface IGuiButton {
/**
* @return the ItemStack we want to display.
*/
- fun getItemStack() : ItemStack?
+ fun getItemStack(): ItemStack?
/**
* Called when this button is clicked
@@ -18,17 +18,17 @@ interface IGuiButton {
fun onButtonDrag(e: InventoryDragEvent)
- fun formatIntoItemStack(player: Player? = null) : ItemStack?
+ fun formatIntoItemStack(player: Player? = null): ItemStack?
- fun copy(parent: IGuiScreen) : T
+ fun copy(parent: IGuiScreen): T
- infix fun slot(slot: Int) : T
+ infix fun slot(slot: Int): T
- infix fun slots(slots: List) : T
+ infix fun slots(slots: List): T
- fun slots() : List?
+ fun slots(): List?
- infix fun childOf(parent: IGuiScreen) : T
+ infix fun childOf(parent: IGuiScreen): T
fun destroy()
}
\ No newline at end of file
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/button/LegacyGuiCycleButton.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/button/LegacyGuiCycleButton.kt
index 12a827b..9605213 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/button/LegacyGuiCycleButton.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/button/LegacyGuiCycleButton.kt
@@ -21,41 +21,43 @@ class LegacyGuiCycleButton(
click {
ClickType.RIGHT {
nextItem(player)
- changed?.invoke(ButtonClickedEvent(player, this.event).apply { button = this@LegacyGuiCycleButton })
+ changed?.invoke(ButtonClickedEvent(player, this.event).apply {
+ button = this@LegacyGuiCycleButton
+ })
}
ClickType.LEFT {
prevItem(player)
- changed?.invoke(ButtonClickedEvent(player, this.event).apply { button = this@LegacyGuiCycleButton })
+ changed?.invoke(ButtonClickedEvent(player, this.event).apply {
+ button = this@LegacyGuiCycleButton
+ })
}
}
}
- fun items(items: MutableMap.() -> Unit) : LegacyGuiCycleButton {
+ fun items(items: MutableMap.() -> Unit): LegacyGuiCycleButton {
items.invoke(map)
this.item = getSelectedItem()
return this
}
- fun getSelectedId() : String? {
+ fun getSelectedId(): String? {
return map.keys.toMutableList().getOrNull(selected)
}
- fun getSelectedItem() : ItemStack? {
+ fun getSelectedItem(): ItemStack? {
return map[getSelectedId()]
}
fun nextItem(player: Player) {
selected++
- if (selected >= map.size)
- selected = 0
+ if (selected >= map.size) selected = 0
this.item = getSelectedItem()
update(player)
}
fun prevItem(player: Player) {
selected--
- if (selected < 0)
- selected = map.size - 1
+ if (selected < 0) selected = map.size - 1
this.item = getSelectedItem()
update(player)
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/button/LegacyLoreCycleButton.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/button/LegacyLoreCycleButton.kt
index 7868fb9..696b4cb 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/button/LegacyLoreCycleButton.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/button/LegacyLoreCycleButton.kt
@@ -68,35 +68,35 @@ class LegacyLoreCycleButton(
return this
}
- fun clearSpecialLore() : LegacyLoreCycleButton {
+ fun clearSpecialLore(): LegacyLoreCycleButton {
lores.clear()
selectableLores.clear()
selected = 0
return this
}
- fun getSelectedId() : String? {
+ fun getSelectedId(): String? {
return lores().getOrNull(getSelectedNum())?.id
}
- fun getSelectedNum() : Int {
+ fun getSelectedNum(): Int {
return selectableLores.getOrNull(selected) ?: 0
}
- fun lores() : MutableList {
+ fun lores(): MutableList {
return lores.toMutableList()
}
- fun optionalLores() : MutableList {
+ fun optionalLores(): MutableList {
return selectableLores.map { lores[it] }.toMutableList()
}
- override fun formatIntoItemStack(player: Player?) : ItemStack? {
+ override fun formatIntoItemStack(player: Player?): ItemStack? {
// here we need to apply and format lores
val loreToApply = mutableListOf()
val selected = getSelectedId()
val i = item?.clone()
- lores.forEach {lo ->
+ lores.forEach { lo ->
if (lo.id != null) {
loreToApply.add(if (lo.id == selected) lo.lineSelected else lo.line)
} else loreToApply.add(lo.line)
@@ -111,7 +111,8 @@ class LegacyLoreCycleButton(
data class LoreEntry(
var id: String?,
var line: String,
- var lineSelected: String)
+ var lineSelected: String
+ )
override fun copy(parent: IGuiScreen): LegacyLoreCycleButton {
val copy = LegacyLoreCycleButton(lores = lores, item = item)
@@ -124,7 +125,7 @@ class LegacyLoreCycleButton(
}
}
-inline fun MutableList.addLore(cb: LegacyLoreCycleButton.LoreEntry.() -> Unit) : MutableList {
+inline fun MutableList.addLore(cb: LegacyLoreCycleButton.LoreEntry.() -> Unit): MutableList {
val l = LegacyLoreCycleButton.LoreEntry(null, "", "")
cb.invoke(l)
this.add(l)
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/button/LoreCycleButton.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/button/LoreCycleButton.kt
index e974d17..414f5a6 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/button/LoreCycleButton.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/button/LoreCycleButton.kt
@@ -4,8 +4,6 @@ import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.TextDecoration
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
-import kotlin.math.max
-import kotlin.math.min
class LoreCycleButton : GuiButton() {
var selected = 0
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/button/NumberWidgetButton.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/button/NumberWidgetButton.kt
index 335a87c..656fd3b 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/button/NumberWidgetButton.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/button/NumberWidgetButton.kt
@@ -21,11 +21,15 @@ class NumberWidgetButton(
amount(min(64, max(1, item!!.amount + step)))
update(e.player)
}
+
ClickType.LEFT -> {
amount(min(64, max(1, item!!.amount - step)))
update(e.player)
}
- else -> { click.run(e) }
+
+ else -> {
+ click.run(e)
+ }
}
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/button/SignalButton.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/button/SignalButton.kt
index e3dd41e..6e570c3 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/button/SignalButton.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/button/SignalButton.kt
@@ -6,8 +6,7 @@ import org.bukkit.inventory.ItemStack
@Deprecated("No longer supported", ReplaceWith("EffectBlock"))
class SignalButton(
- val material: Material,
- val builder: (SignalButton) -> Unit
+ val material: Material, val builder: (SignalButton) -> Unit
) : GuiButton(material), SignalListener {
override fun onChange(value: Any) {
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/screen/GuiInfiniteScreen.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/screen/GuiInfiniteScreen.kt
index 6b22bd3..fced1c9 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/screen/GuiInfiniteScreen.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/screen/GuiInfiniteScreen.kt
@@ -27,13 +27,19 @@ open class GuiInfiniteScreen(
operator fun set(x: Int, y: Int, button: IGuiButton<*>) = setSlot(x, y, button)
override fun open(player: Player) {
- val inv: Inventory = if (type != null) Bukkit.createInventory(player, type!!, title) else Bukkit.createInventory(player, totalSlots(), title)
+ val inv: Inventory =
+ if (type != null) Bukkit.createInventory(player, type!!, title) else Bukkit.createInventory(
+ player,
+ totalSlots(),
+ title
+ )
if (firePreBuildEvent(player)) return
items2D.forEach { (pos, item) ->
if (pos.first >= x && pos.first <= x + 9
- && pos.second >= y && pos.second <= y + rows) {
+ && pos.second >= y && pos.second <= y + rows
+ ) {
val normalSlot = (pos.second - y) * 9 + (pos.first - x)
if (normalSlot >= 0 && normalSlot <= last()) {
inv.setItem(normalSlot, item.formatIntoItemStack(player))
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/screen/GuiMultiPageScreen.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/screen/GuiMultiPageScreen.kt
index 677e0ee..c278904 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/screen/GuiMultiPageScreen.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/screen/GuiMultiPageScreen.kt
@@ -20,7 +20,7 @@ open class GuiMultiPageScreen(
update(p)
}
click {
- any {
+ any {
if (slot in minSlot until maxSlot) {
val index = slot + (page * pageSize()) - minSlot
itemList.getOrNull(index)?.onButtonClick(this)
@@ -47,7 +47,7 @@ open class GuiMultiPageScreen(
}
}
- fun getCurrentPage() : Int {
+ fun getCurrentPage(): Int {
return page
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/screen/IGuiScreen.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/screen/IGuiScreen.kt
index 14555b9..4dad285 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/screen/IGuiScreen.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/screen/IGuiScreen.kt
@@ -10,23 +10,25 @@ import org.bukkit.event.player.PlayerQuitEvent
interface IGuiScreen {
- fun getSlots(button: IGuiButton<*>) : List
+ fun getSlots(button: IGuiButton<*>): List
- fun totalSlots() : Int
+ fun totalSlots(): Int
- fun numberOfItems() : Int { return 0 }
+ fun numberOfItems(): Int {
+ return 0
+ }
- fun setSlot(button: IGuiButton<*>, slot: Int) : IGuiScreen
+ fun setSlot(button: IGuiButton<*>, slot: Int): IGuiScreen
fun clearSlot(vararg slot: Int)
fun open(player: Player)
- fun copy() : IGuiScreen
+ fun copy(): IGuiScreen
fun destroy() {}
- fun addChild(child: IGuiButton<*>) : IGuiScreen
+ fun addChild(child: IGuiButton<*>): IGuiScreen
/**
* Will be called if a player with this gui
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/components/signal/Signal.kt b/api/src/main/kotlin/com/mattmx/ktgui/components/signal/Signal.kt
index dd5bbae..ff8347f 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/components/signal/Signal.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/components/signal/Signal.kt
@@ -1,6 +1,5 @@
package com.mattmx.ktgui.components.signal
-import kotlin.math.sign
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
@@ -108,7 +107,7 @@ class Signal(initial: V, private val owner: SignalOwner) : ReadWriteProperty<
*
* @param signalListener the [SignalListener] to register.
*/
- fun addDependency(signalListener: SignalListener) : Boolean {
+ fun addDependency(signalListener: SignalListener): Boolean {
if (this.listeners.contains(signalListener)) return false
this.listeners += signalListener
return true
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/conversation/ConversationAbandonListener.kt b/api/src/main/kotlin/com/mattmx/ktgui/conversation/ConversationAbandonListener.kt
index 73f4df4..df3de0a 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/conversation/ConversationAbandonListener.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/conversation/ConversationAbandonListener.kt
@@ -5,7 +5,7 @@ import org.bukkit.conversations.ConversationAbandonedListener
class ConversationAbandonListener(
private val conv: ConversationBuilder
-): ConversationAbandonedListener {
+) : ConversationAbandonedListener {
override fun conversationAbandoned(abandonedEvent: ConversationAbandonedEvent) {
conv.abandon?.invoke(abandonedEvent)
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/conversation/ConversationBuilder.kt b/api/src/main/kotlin/com/mattmx/ktgui/conversation/ConversationBuilder.kt
index 633c3e5..ec1c69a 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/conversation/ConversationBuilder.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/conversation/ConversationBuilder.kt
@@ -8,53 +8,70 @@ class ConversationBuilder(val factory: ConversationFactory) {
var abandon: ((ConversationAbandonedEvent) -> Unit)? = null
var list = arrayListOf()
- fun stringPrompt(message: String, callback: (context: ConversationContext, input: String?) -> Unit) : ConversationBuilder {
+ fun stringPrompt(
+ message: String,
+ callback: (context: ConversationContext, input: String?) -> Unit
+ ): ConversationBuilder {
list.add(StringConvPrompt(message, callback))
return this
}
- fun fixedPrompt(message: String, vararg accept: String, cb: (ConversationContext, String) -> Unit) : ConversationBuilder {
+ fun fixedPrompt(
+ message: String,
+ vararg accept: String,
+ cb: (ConversationContext, String) -> Unit
+ ): ConversationBuilder {
list.add(FixedSetConvPrompt(message, *accept, cb = cb))
return this
}
- fun numberPrompt(message: String, fail: String? = "", accept: List? = null, cb: (ConversationContext, Number) -> Unit) : ConversationBuilder {
+ fun numberPrompt(
+ message: String,
+ fail: String? = "",
+ accept: List? = null,
+ cb: (ConversationContext, Number) -> Unit
+ ): ConversationBuilder {
list.add(NumericConvPrompt(message, fail, accept, cb = cb))
return this
}
- fun playerPrompt(plugin: JavaPlugin, message: String, fail: String, cb: (ConversationContext, Player) -> Unit) : ConversationBuilder {
+ fun playerPrompt(
+ plugin: JavaPlugin,
+ message: String,
+ fail: String,
+ cb: (ConversationContext, Player) -> Unit
+ ): ConversationBuilder {
list.add(PlayernameConvPrompt(plugin, message, fail, cb))
return this
}
- fun messagePrompt(message: String) : ConversationBuilder {
+ fun messagePrompt(message: String): ConversationBuilder {
list.add(MessageConvPrompt(message))
return this
}
- fun abandon(event: (ConversationAbandonedEvent) -> Unit) : ConversationBuilder {
+ fun abandon(event: (ConversationAbandonedEvent) -> Unit): ConversationBuilder {
abandon = event
factory.addConversationAbandonedListener(ConversationAbandonedListener(abandon!!))
return this
}
- fun exitOn(message: String) : ConversationBuilder {
+ fun exitOn(message: String): ConversationBuilder {
factory.withEscapeSequence(message)
return this
}
- fun timeout(time: Int) : ConversationBuilder {
+ fun timeout(time: Int): ConversationBuilder {
factory.withTimeout(time)
return this
}
- fun finish(message: String? = null, after: (() -> Unit)? = null) : ConversationBuilder {
+ fun finish(message: String? = null, after: (() -> Unit)? = null): ConversationBuilder {
list.add(EndEmptyPrompt(message, after))
return this
}
- fun build(conversable: Conversable) : Conversation {
+ fun build(conversable: Conversable): Conversation {
if (list.isNotEmpty()) factory.withFirstPrompt(list[0] as Prompt)
if (list.size - 1 > 0 && list[list.size - 1] !is EndEmptyPrompt) {
list.add(EndEmptyPrompt())
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/conversation/DummyEndOfConversationPrompt.kt b/api/src/main/kotlin/com/mattmx/ktgui/conversation/DummyEndOfConversationPrompt.kt
index caa1d49..06a516a 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/conversation/DummyEndOfConversationPrompt.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/conversation/DummyEndOfConversationPrompt.kt
@@ -4,7 +4,7 @@ import org.bukkit.conversations.ConversationContext
import org.bukkit.conversations.MessagePrompt
import org.bukkit.conversations.Prompt
-class DummyEndOfConversationPrompt() : MessagePrompt(), BuildablePrompt {
+class DummyEndOfConversationPrompt : MessagePrompt(), BuildablePrompt {
override fun getNextPrompt(context: ConversationContext): Prompt? {
return Prompt.END_OF_CONVERSATION
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/conversation/PlayernameConvPrompt.kt b/api/src/main/kotlin/com/mattmx/ktgui/conversation/PlayernameConvPrompt.kt
index 7d28019..b80f2f4 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/conversation/PlayernameConvPrompt.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/conversation/PlayernameConvPrompt.kt
@@ -18,7 +18,7 @@ class PlayernameConvPrompt(
return message
}
- override fun getFailedValidationText(context: ConversationContext, invalidInput: String): String? {
+ override fun getFailedValidationText(context: ConversationContext, invalidInput: String): String {
return fail
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/ConversationWrapper.kt b/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/ConversationWrapper.kt
index dba418c..a6fb01f 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/ConversationWrapper.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/ConversationWrapper.kt
@@ -2,18 +2,10 @@ package com.mattmx.ktgui.conversation.refactor
import com.mattmx.ktgui.GuiManager
import com.mattmx.ktgui.components.screen.IGuiScreen
-import com.mattmx.ktgui.conversation.refactor.result.ConversationEnd
import com.mattmx.ktgui.conversation.refactor.steps.Step
import com.mattmx.ktgui.extensions.getOpenGui
-import com.mattmx.ktgui.extensions.setOpenGui
import com.mattmx.ktgui.scheduling.sync
-import org.bukkit.conversations.Conversable
-import org.bukkit.conversations.Conversation
-import org.bukkit.conversations.ConversationAbandonedEvent
-import org.bukkit.conversations.ConversationAbandonedListener
-import org.bukkit.conversations.ConversationContext
-import org.bukkit.conversations.ConversationFactory
-import org.bukkit.conversations.ConversationPrefix
+import org.bukkit.conversations.*
import org.bukkit.entity.Player
import org.bukkit.plugin.java.JavaPlugin
import java.time.Duration
@@ -27,7 +19,7 @@ class ConversationWrapper(
.withLocalEcho(false)
private val steps = arrayListOf()
private var exit = Optional.empty<(ConversationAbandonedEvent) -> Unit>()
- private var start = Optional.empty<(T) -> Unit>()
+ var start = Optional.empty<(T) -> Unit>()
/**
* More than often, the conversation is created as the result of a button
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/steps/NumberConversationStep.kt b/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/steps/NumberConversationStep.kt
index c868ccf..21dd763 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/steps/NumberConversationStep.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/steps/NumberConversationStep.kt
@@ -6,7 +6,7 @@ import java.util.*
abstract class NumberConversationStep, C : Conversable> : RawConversationStep() {
lateinit var range: ClosedRange
- abstract fun get(str: String) : T?
+ abstract fun get(str: String): T?
override fun validate(input: String?): Optional {
if (input == null) return Optional.empty()
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/steps/StringConversationStep.kt b/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/steps/StringConversationStep.kt
index 603f525..70254c6 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/steps/StringConversationStep.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/steps/StringConversationStep.kt
@@ -2,6 +2,4 @@ package com.mattmx.ktgui.conversation.refactor.steps
import org.bukkit.conversations.Conversable
-open class StringConversationStep : RawConversationStep() {
-
-}
\ No newline at end of file
+open class StringConversationStep : RawConversationStep()
\ No newline at end of file
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/t.kt b/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/t.kt
index 048dbb5..3fb88ce 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/t.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/conversation/refactor/t.kt
@@ -6,7 +6,7 @@ import org.bukkit.Bukkit
import org.bukkit.entity.Player
fun main() {
- conversation {
+ conversation {
exitOn = "cancel"
exit {
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/cooldown/ActionCoolDown.kt b/api/src/main/kotlin/com/mattmx/ktgui/cooldown/ActionCoolDown.kt
index da60c40..ed35735 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/cooldown/ActionCoolDown.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/cooldown/ActionCoolDown.kt
@@ -3,7 +3,6 @@ package com.mattmx.ktgui.cooldown
import java.time.Duration
import java.util.*
import kotlin.math.max
-import kotlin.math.min
class ActionCoolDown(
duration: Duration
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/dsl/conversation.kt b/api/src/main/kotlin/com/mattmx/ktgui/dsl/conversation.kt
index 20d695b..5fc2527 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/dsl/conversation.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/dsl/conversation.kt
@@ -12,7 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin
*
* @return the conversation created
*/
-inline fun conversation(plugin: JavaPlugin, block: ConversationBuilder.() -> Unit) : ConversationBuilder {
+inline fun conversation(plugin: JavaPlugin, block: ConversationBuilder.() -> Unit): ConversationBuilder {
val conversationFactory = ConversationFactory(plugin)
.withLocalEcho(false)
.withModality(true)
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/dsl/event.kt b/api/src/main/kotlin/com/mattmx/ktgui/dsl/event.kt
index 0f63287..db2a6e7 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/dsl/event.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/dsl/event.kt
@@ -19,6 +19,7 @@ inline fun JavaPlugin.event(
val listener = KListener()
listener.event(this, priority, ignoreCancelled, block)
}
+
inline fun event(
plugin: JavaPlugin,
priority: EventPriority = EventPriority.NORMAL,
@@ -90,7 +91,7 @@ inline fun Listener.event(
type,
this,
priority,
- { _, event -> if(type.isInstance(event)) callback(event as T) },
+ { _, event -> if (type.isInstance(event)) callback(event as T) },
plugin,
ignoreCancelled
)
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/dsl/gui.kt b/api/src/main/kotlin/com/mattmx/ktgui/dsl/gui.kt
index ce939cc..16825e3 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/dsl/gui.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/dsl/gui.kt
@@ -13,16 +13,15 @@ import org.bukkit.event.inventory.InventoryType
import java.util.function.Supplier
inline fun gui(title: Component, rows: Int = 6, block: GuiScreen.() -> Unit) = GuiScreen(title, rows).apply(block)
-inline fun gui(title: Component, type: InventoryType, block: GuiScreen.() -> Unit) = GuiScreen(title, type = type).apply(block)
+inline fun gui(title: Component, type: InventoryType, block: GuiScreen.() -> Unit) =
+ GuiScreen(title, type = type).apply(block)
inline fun > IGuiScreen.button(
- constructor: Supplier = Supplier { GuiButton() as T },
- block: T.() -> Unit
+ constructor: Supplier = Supplier { GuiButton() as T }, block: T.() -> Unit
) = constructor.get().apply(block).apply { childOf(this@button) }
inline fun > button(
- constructor: Supplier = Supplier { GuiButton() as T },
- block: T.() -> Unit
+ constructor: Supplier = Supplier { GuiButton() as T }, block: T.() -> Unit
) = constructor.get().apply(block)
inline fun button(material: Material, block: GuiButton<*>.() -> Unit) = GuiButton(material).apply(block)
@@ -35,7 +34,7 @@ inline fun IGuiScreen.button(material: Material, block: GuiButton<*>.() -> Unit)
fun IGuiScreen.signalButton(material: Material, block: SignalButton.() -> Unit) =
SignalButton(material, block).apply { childOf(this@signalButton) }
-fun GuiScreen.effect(block: GuiScreen.() -> Unit) =
- EffectBlock(this, block).apply { this@effect.addEffect(this) }
+fun GuiScreen.effect(block: GuiScreen.() -> Unit) = EffectBlock(this, block).apply { this@effect.addEffect(this) }
+
fun GuiScreen.refresh(repeat: Long, block: GuiScreen.() -> Unit) =
RefreshBlock(repeat, this, block).apply { this@refresh.addRefreshBlock(this) }
\ No newline at end of file
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/dsl/scoreboard.kt b/api/src/main/kotlin/com/mattmx/ktgui/dsl/scoreboard.kt
index 4ae8d47..526c323 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/dsl/scoreboard.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/dsl/scoreboard.kt
@@ -4,14 +4,16 @@ import com.mattmx.ktgui.scoreboards.AnimatedScoreboardBuilder
import com.mattmx.ktgui.scoreboards.LegacyScoreboardBuilder
@Deprecated("No longer supported", ReplaceWith("scoreboard"))
-inline fun scoreboard(title: String = "null", build: LegacyScoreboardBuilder.() -> Unit) : LegacyScoreboardBuilder {
+inline fun scoreboard(title: String = "null", build: LegacyScoreboardBuilder.() -> Unit): LegacyScoreboardBuilder {
val builder = LegacyScoreboardBuilder(title)
build.invoke(builder)
return builder
}
@Deprecated("No longer supported", ReplaceWith("scoreboard"))
-inline fun animatedScoreboard(title: String = "null", updateEvery: Long = 20, build: LegacyScoreboardBuilder.() -> Unit) : AnimatedScoreboardBuilder {
+inline fun animatedScoreboard(
+ title: String = "null", updateEvery: Long = 20, build: LegacyScoreboardBuilder.() -> Unit
+): AnimatedScoreboardBuilder {
val builder = AnimatedScoreboardBuilder(title, updateEvery)
build.invoke(builder)
return builder
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/event/ContinuousEventCallback.kt b/api/src/main/kotlin/com/mattmx/ktgui/event/ContinuousEventCallback.kt
index baafc92..2dc0741 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/event/ContinuousEventCallback.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/event/ContinuousEventCallback.kt
@@ -4,7 +4,7 @@ import org.bukkit.event.Cancellable
class ContinuousEventCallback : EventCallback() {
- override operator fun invoke(value: T) : Boolean {
+ override operator fun invoke(value: T): Boolean {
for (cb in callbacks) {
cb.invoke(value)
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/event/EventCallback.kt b/api/src/main/kotlin/com/mattmx/ktgui/event/EventCallback.kt
index 9b55b40..e48b87b 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/event/EventCallback.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/event/EventCallback.kt
@@ -8,7 +8,7 @@ open class EventCallback(
callbacks.add(block)
}
- open operator fun invoke(value: T) : Boolean {
+ open operator fun invoke(value: T): Boolean {
callbacks.forEach { it.invoke(value) }
return true
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/extensions/ConversationExtensions.kt b/api/src/main/kotlin/com/mattmx/ktgui/extensions/ConversationExtensions.kt
index d7602a6..d97e0a8 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/extensions/ConversationExtensions.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/extensions/ConversationExtensions.kt
@@ -5,6 +5,6 @@ import org.bukkit.entity.Player
fun ConversationContext.player() = getPlayer()
-fun ConversationContext.getPlayer() : Player {
+fun ConversationContext.getPlayer(): Player {
return this.forWhom as Player
}
\ No newline at end of file
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/extensions/PlayerExtensions.kt b/api/src/main/kotlin/com/mattmx/ktgui/extensions/PlayerExtensions.kt
index 0ca2af4..e64c423 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/extensions/PlayerExtensions.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/extensions/PlayerExtensions.kt
@@ -2,11 +2,10 @@ package com.mattmx.ktgui.extensions
import com.mattmx.ktgui.GuiManager
import com.mattmx.ktgui.components.screen.IGuiScreen
-import com.mattmx.ktgui.utils.JavaCompatibility
import org.bukkit.Bukkit
import org.bukkit.entity.Player
-fun Player.getOpenGui() : IGuiScreen? {
+fun Player.getOpenGui(): IGuiScreen? {
return GuiManager.getPlayer(this)
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/extensions/SlotsExtensions.kt b/api/src/main/kotlin/com/mattmx/ktgui/extensions/SlotsExtensions.kt
index 4f37a28..fcd613f 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/extensions/SlotsExtensions.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/extensions/SlotsExtensions.kt
@@ -1,5 +1,5 @@
package com.mattmx.ktgui.extensions
-fun Int.downTo(end: Int) : List {
+fun Int.downTo(end: Int): List {
return (this..end).toList().filter { (it - this) % 9 == 0 }
}
\ No newline at end of file
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/extensions/StringExtensions.kt b/api/src/main/kotlin/com/mattmx/ktgui/extensions/StringExtensions.kt
index cc01ab5..d2a7b99 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/extensions/StringExtensions.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/extensions/StringExtensions.kt
@@ -2,6 +2,6 @@ package com.mattmx.ktgui.extensions
import org.bukkit.ChatColor
-fun String.stripColor() : String {
+fun String.stripColor(): String {
return ChatColor.stripColor(this) ?: ""
}
\ No newline at end of file
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/extensions/config.kt b/api/src/main/kotlin/com/mattmx/ktgui/extensions/config.kt
index 3036db3..e9fe397 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/extensions/config.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/extensions/config.kt
@@ -2,20 +2,17 @@ package com.mattmx.ktgui.extensions
import com.mattmx.ktgui.GuiManager
import com.mattmx.ktgui.components.button.GuiButton
-import com.mattmx.ktgui.components.button.SignalButton
import com.mattmx.ktgui.dsl.button
import com.mattmx.ktgui.item.lvl
import com.mattmx.ktgui.utils.component
import com.mattmx.ktgui.utils.legacy
import com.mattmx.ktgui.utils.not
import com.mattmx.ktgui.utils.parsePotionData
-import net.kyori.adventure.text.Component
import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.configuration.file.FileConfiguration
import org.bukkit.enchantments.Enchantment
import org.bukkit.potion.PotionData
-import org.bukkit.potion.PotionEffect
fun String.translatableList(config: FileConfiguration): List {
val list = config.getStringList(this)
@@ -53,7 +50,7 @@ fun String.translatableButton(config: FileConfiguration) = this.translatableButt
* @param button to apply the changes to
* @return button as [T] with changes applied or null if the path is invalid
*/
-fun > String.translatableButton(config: FileConfiguration, button: GuiButton) : T? {
+fun > String.translatableButton(config: FileConfiguration, button: GuiButton): T? {
val section = config.getConfigurationSection(this)
?: return null
return button.apply {
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/item/ItemBuilderDsl.kt b/api/src/main/kotlin/com/mattmx/ktgui/item/ItemBuilderDsl.kt
index 4fabb67..37bd59f 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/item/ItemBuilderDsl.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/item/ItemBuilderDsl.kt
@@ -20,6 +20,7 @@ import org.bukkit.potion.PotionEffectType
* [KT] is an empty object used for starting the inline item builder.
*/
object KT
+
infix fun KT.ib(material: Material) = iBuilder(material)
infix fun KT.itemBuilder(material: Material) = iBuilder(material)
infix fun KT.iBuilder(material: Material): DslIBuilder {
@@ -32,7 +33,9 @@ infix fun KT.iBuilder(material: Material): DslIBuilder {
* @param builder block for building the item
* @return the item as a stack or a builder.
*/
-inline fun itemBuilderStack(material: Material, builder: DslIBuilder.() -> Unit): ItemStack = itemBuilder(material, builder).build()
+inline fun itemBuilderStack(material: Material, builder: DslIBuilder.() -> Unit): ItemStack =
+ itemBuilder(material, builder).build()
+
inline fun itemBuilder(material: Material, builder: DslIBuilder.() -> Unit) = DslIBuilder(material).apply(builder)
fun itemBuilder(material: Material) = DslIBuilder(material)
@@ -124,7 +127,7 @@ class DslIBuilder(var material: Material) {
durability = d; return this
}
- infix fun modelData(d: Int) : DslIBuilder {
+ infix fun modelData(d: Int): DslIBuilder {
customModelData = d; return this
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/scheduling/scheduling.kt b/api/src/main/kotlin/com/mattmx/ktgui/scheduling/scheduling.kt
index cc6377d..03a730c 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/scheduling/scheduling.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/scheduling/scheduling.kt
@@ -85,7 +85,7 @@ fun sync(task: BukkitTask.() -> Unit): BukkitTask {
*/
fun syncRepeat(period: Long, delay: Long = 0, task: BukkitTask.() -> Unit): BukkitTask {
var delayedInit: BukkitTask? = null
- delayedInit = Bukkit.getScheduler().runTaskTimer(Scheduling.plugin, {-> task(delayedInit!!) }, delay, period)
+ delayedInit = Bukkit.getScheduler().runTaskTimer(Scheduling.plugin, { -> task(delayedInit!!) }, delay, period)
return delayedInit
}
@@ -98,7 +98,7 @@ fun syncRepeat(period: Long, delay: Long = 0, task: BukkitTask.() -> Unit): Bukk
*/
fun syncDelayed(delay: Long, task: BukkitTask.() -> Unit): BukkitTask {
var delayedInit: BukkitTask? = null
- delayedInit = Bukkit.getScheduler().runTaskLater(Scheduling.plugin, {-> task(delayedInit!!) }, delay)
+ delayedInit = Bukkit.getScheduler().runTaskLater(Scheduling.plugin, { -> task(delayedInit!!) }, delay)
return delayedInit
}
@@ -126,7 +126,8 @@ fun async(task: BukkitTask.() -> Unit): BukkitTask {
*/
fun asyncRepeat(period: Long, delay: Long = 0, task: BukkitTask.() -> Unit): BukkitTask {
var delayedInit: BukkitTask? = null
- delayedInit = Bukkit.getScheduler().runTaskTimerAsynchronously(Scheduling.plugin, {-> task(delayedInit!!) }, delay, period)
+ delayedInit =
+ Bukkit.getScheduler().runTaskTimerAsynchronously(Scheduling.plugin, { -> task(delayedInit!!) }, delay, period)
return delayedInit
}
@@ -139,7 +140,7 @@ fun asyncRepeat(period: Long, delay: Long = 0, task: BukkitTask.() -> Unit): Buk
*/
fun asyncDelayed(delay: Long, task: BukkitTask.() -> Unit): BukkitTask {
var delayedInit: BukkitTask? = null
- delayedInit = Bukkit.getScheduler().runTaskLaterAsynchronously(Scheduling.plugin, {-> task(delayedInit!!) }, delay)
+ delayedInit = Bukkit.getScheduler().runTaskLaterAsynchronously(Scheduling.plugin, { -> task(delayedInit!!) }, delay)
return delayedInit
}
@@ -150,7 +151,7 @@ fun asyncDelayed(delay: Long, task: BukkitTask.() -> Unit): BukkitTask {
* @author MattMX
* @param block that returns our value
*/
-fun future(block: () -> T) : CompletableFuture {
+fun future(block: () -> T): CompletableFuture {
val future = CompletableFuture()
async {
val result = block()
@@ -166,7 +167,7 @@ fun future(block: () -> T) : CompletableFuture {
* @author MattMX
* @param block that returns our value
*/
-fun call(block: () -> T) : Future {
+fun call(block: () -> T): Future {
return Bukkit.getScheduler().callSyncMethod(Scheduling.plugin, block)
}
@@ -179,7 +180,7 @@ fun call(block: () -> T) : Future {
*
* @author MattMX
*/
-inline val Future.await : T
+inline val Future.await: T
get() {
return this.get(30, TimeUnit.SECONDS)
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/AnimatedScoreboardBuilder.kt b/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/AnimatedScoreboardBuilder.kt
index a007032..c105f28 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/AnimatedScoreboardBuilder.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/AnimatedScoreboardBuilder.kt
@@ -20,7 +20,7 @@ open class AnimatedScoreboardBuilder(
*
* @param plugin the plugin instance
*/
- fun begin(plugin: JavaPlugin) : AnimatedScoreboardBuilder {
+ fun begin(plugin: JavaPlugin): AnimatedScoreboardBuilder {
started = System.currentTimeMillis()
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, { it ->
if (!cancel) update?.invoke(this)
@@ -28,21 +28,21 @@ open class AnimatedScoreboardBuilder(
it.cancel()
}
iterations++
- } ,0, updateEvery)
+ }, 0, updateEvery)
return this
}
/**
* @return the number of iterations we have been through.
*/
- fun getIterations() : Long {
+ fun getIterations(): Long {
return iterations
}
/**
* @return the time (in millis) that we have been running this scoreboard for.
*/
- fun getTimeRunning() : Long {
+ fun getTimeRunning(): Long {
return System.currentTimeMillis() - started
}
@@ -50,7 +50,7 @@ open class AnimatedScoreboardBuilder(
* If you want to stop animating the scoreboard, call this.
* To begin animating again, call begin(plugin)
*/
- fun cancel() : AnimatedScoreboardBuilder {
+ fun cancel(): AnimatedScoreboardBuilder {
cancel = true
return this
}
@@ -60,7 +60,7 @@ open class AnimatedScoreboardBuilder(
*
* @param scoreboard the callback of how we want the scoreboard to update.
*/
- fun update(scoreboard: AnimatedScoreboardBuilder.() -> Unit) : AnimatedScoreboardBuilder {
+ fun update(scoreboard: AnimatedScoreboardBuilder.() -> Unit): AnimatedScoreboardBuilder {
this.update = scoreboard
return this
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/LegacyScoreboardBuilder.kt b/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/LegacyScoreboardBuilder.kt
index f2f4598..f9ac4da 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/LegacyScoreboardBuilder.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/LegacyScoreboardBuilder.kt
@@ -15,7 +15,7 @@ open class LegacyScoreboardBuilder(
// Holds the lines of text, we are able to remove them because of this
private val scoreboardLines = arrayListOf()
- private val scoreboard: Scoreboard = Bukkit.getScoreboardManager()!!.newScoreboard
+ private val scoreboard: Scoreboard = Bukkit.getScoreboardManager().newScoreboard
private val objective: Objective = scoreboard.registerNewObjective(title, "dummy")
init {
@@ -106,7 +106,7 @@ open class LegacyScoreboardBuilder(
return this
}
- fun addRGB(line: String) : LegacyScoreboardBuilder {
+ fun addRGB(line: String): LegacyScoreboardBuilder {
if (scoreboardLines.size > MAX_LINES) throw IndexOutOfBoundsException("You can't add more than 16 lines.")
val name = "&r".repeat(scoreboardLines.size)
val team = scoreboard.getTeam(name) ?: scoreboard.registerNewTeam(name)
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/ScoreboardBuilder.kt b/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/ScoreboardBuilder.kt
index 6f5ee9e..98a7936 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/ScoreboardBuilder.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/scoreboards/ScoreboardBuilder.kt
@@ -1,9 +1,8 @@
package com.mattmx.ktgui.scoreboards
import com.mattmx.ktgui.extensions.removeScoreboard
-import com.mattmx.ktgui.utils.legacyColor
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.JavaCompatibility
+import com.mattmx.ktgui.utils.legacyColor
import com.mattmx.ktgui.utils.not
import net.kyori.adventure.text.Component
import org.bukkit.Bukkit
@@ -113,6 +112,7 @@ open class ScoreboardBuilder(
fun showFor(player: Player) {
player.scoreboard = scoreboard
}
+
fun removeFor(player: Player) {
player.removeScoreboard()
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/utils/InstancePackageClassCache.kt b/api/src/main/kotlin/com/mattmx/ktgui/utils/InstancePackageClassCache.kt
index c1c7087..6c298b7 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/utils/InstancePackageClassCache.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/utils/InstancePackageClassCache.kt
@@ -13,7 +13,7 @@ class InstancePackageClassCache {
packageList[packagePath] = instance
}
- fun clearInstance(clazz: Class) : V {
+ fun clearInstance(clazz: Class): V {
return packageList.remove(getShortPackageName(clazz)) as V
}
@@ -21,7 +21,7 @@ class InstancePackageClassCache {
return packageList[getShortPackageName(clazz)]!! as V
}
- fun getInstanceOrNull(clazz: Class) : V? {
+ fun getInstanceOrNull(clazz: Class): V? {
return packageList[getShortPackageName(clazz)] as V?
}
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/utils/JavaCompatibility.kt b/api/src/main/kotlin/com/mattmx/ktgui/utils/JavaCompatibility.kt
index 24fda53..41504f7 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/utils/JavaCompatibility.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/utils/JavaCompatibility.kt
@@ -4,4 +4,4 @@ package com.mattmx.ktgui.utils
* Marker annotation to help identify functions added
* specifically for Java compatibility.
*/
-annotation class JavaCompatibility()
+annotation class JavaCompatibility
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/utils/StopWatch.kt b/api/src/main/kotlin/com/mattmx/ktgui/utils/StopWatch.kt
index 6715ee0..954eeac 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/utils/StopWatch.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/utils/StopWatch.kt
@@ -15,6 +15,12 @@ class StopWatch(
fun debug() {
val nanos = elapsed()
- println(" [$name] took ${nanos}ns (${nanos / 1_000_000}ms${if (nanos > 100_000_000) ", " + Duration.ofNanos(nanos).pretty() else ""})")
+ println(
+ " [$name] took ${nanos}ns (${nanos / 1_000_000}ms${
+ if (nanos > 100_000_000) ", " + Duration.ofNanos(
+ nanos
+ ).pretty() else ""
+ })"
+ )
}
}
\ No newline at end of file
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/utils/color.kt b/api/src/main/kotlin/com/mattmx/ktgui/utils/color.kt
index 86fdb25..a5fb4a8 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/utils/color.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/utils/color.kt
@@ -5,12 +5,10 @@ import me.clip.placeholderapi.PlaceholderAPI
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.event.ClickEvent
import net.kyori.adventure.text.event.HoverEvent
-import net.kyori.adventure.text.event.HoverEvent.ShowEntity
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
import net.md_5.bungee.api.ChatColor
import org.bukkit.OfflinePlayer
-import org.bukkit.entity.Player
import java.util.regex.Matcher
import java.util.regex.Pattern
@@ -30,6 +28,7 @@ fun JsonElement.component() = gsonSerializer.deserializeFromTree(this)
fun String.component() = serializer.deserialize(this)
val String.component: Component
get() = component()
+
fun String.legacyToComponent() = legacySerializer.deserialize(this)
fun String.placeholders(player: OfflinePlayer? = null): String {
if (Dependencies.papi) {
@@ -37,6 +36,7 @@ fun String.placeholders(player: OfflinePlayer? = null): String {
}
return this
}
+
private val pattern: Pattern = Pattern.compile("[a-fA-F0-9]{6}")
fun String.legacyColor(): String {
var string = this
@@ -49,6 +49,7 @@ fun String.legacyColor(): String {
}
return ChatColor.translateAlternateColorCodes('&', string)
}
+
operator fun Component.plus(component: Component) = this.append(component)
infix fun Component.clickEvent(event: ClickEvent) = clickEvent(event)
infix fun Component.hoverEvent(event: HoverEvent) = hoverEvent(event)
diff --git a/api/src/main/kotlin/com/mattmx/ktgui/utils/formatting.kt b/api/src/main/kotlin/com/mattmx/ktgui/utils/formatting.kt
index 3257243..29c3add 100644
--- a/api/src/main/kotlin/com/mattmx/ktgui/utils/formatting.kt
+++ b/api/src/main/kotlin/com/mattmx/ktgui/utils/formatting.kt
@@ -46,7 +46,7 @@ fun Double.dp(decimalPlace: Int = 2): Double {
* @param decimalPlace number of following digits.
* @return rounded [Float]
*/
-fun Float.dp(decimalPlace: Int = 2) : Float {
+fun Float.dp(decimalPlace: Int = 2): Float {
val df = DecimalFormat("#." + "#".repeat(decimalPlace))
df.roundingMode = RoundingMode.CEILING
diff --git a/build.gradle.kts b/build.gradle.kts
index d75e030..ccec172 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,29 +1,10 @@
plugins {
- kotlin("jvm") version "1.7.10"
+ alias(libs.plugins.updateDeps) apply true
+ alias(libs.plugins.kotlinJvm) apply false
+ alias(libs.plugins.shadow) apply false
+ alias(libs.plugins.grgit) apply false
}
val version = "2.4.0"
-rootProject.version = version
-
-subprojects {
- apply(plugin = "java")
- apply(plugin = "org.jetbrains.kotlin.jvm")
-
- repositories {
- mavenCentral()
- maven("https://jitpack.io")
- maven("https://repo.papermc.io/repository/maven-public/")
- maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
- }
- dependencies {
- compileOnly("org.jetbrains.kotlin:kotlin-stdlib:1.7.10")
- compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
- compileOnly("me.clip:placeholderapi:2.11.1")
- }
-
- java {
- withJavadocJar()
- withSourcesJar()
- }
-}
\ No newline at end of file
+rootProject.version = version
\ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
new file mode 100644
index 0000000..a644afe
--- /dev/null
+++ b/gradle/libs.versions.toml
@@ -0,0 +1,24 @@
+[versions]
+
+kotlin = "2.0.0"
+updateVersions = "0.51.0"
+shadow = "8.1.8"
+grgit = "5.2.2"
+paperApi = "1.20.2-R0.1-SNAPSHOT"
+placeholderapi = "2.11.6"
+protocolLib = "5.1.0"
+
+[libraries]
+
+kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
+kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
+paper-api = { module = "io.papermc.paper:paper-api", version.ref = "paperApi" }
+placeholder-api = { module = "me.clip:placeholderapi", version.ref = "placeholderapi" }
+protocolLib = { module = "com.comphenix.protocol:ProtocolLib", version.ref = "protocolLib" }
+
+[plugins]
+
+kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
+updateDeps = { id = "com.github.ben-manes.versions", version.ref = "updateVersions" }
+shadow = { id = "io.github.goooler.shadow", version.ref = "shadow" }
+grgit = { id = "org.ajoberstar.grgit", version.ref = "grgit" }
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index aa991fc..0d18421 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts
index 384dfc0..6b27de4 100644
--- a/plugin/build.gradle.kts
+++ b/plugin/build.gradle.kts
@@ -1,23 +1,17 @@
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
plugins {
- kotlin("jvm")
- id("com.github.johnrengelman.shadow") version "7.1.2"
+ alias(libs.plugins.kotlinJvm) apply true
+ alias(libs.plugins.shadow) apply true
+ alias(libs.plugins.grgit) apply true
`maven-publish`
- id("org.ajoberstar.grgit") version "4.1.0"
-}
-
-repositories {
- mavenCentral()
- maven("https://maven.pvphub.me/releases")
- maven("https://repo.papermc.io/repository/maven-public/")
- maven("https://repo.dmulloy2.net/repository/public/")
}
dependencies {
shadow(implementation(project(":api"))!!)
shadow(implementation("co.pvphub:ProtocolLibDsl:-SNAPSHOT")!!)
- compileOnly("com.comphenix.protocol:ProtocolLib:4.7.0")
+ compileOnly(libs.protocolLib)
+ compileOnly(libs.kotlin.stdlib)
+ compileOnly(libs.paper.api)
+ compileOnly(libs.placeholder.api)
}
tasks.test {
@@ -26,8 +20,12 @@ tasks.test {
sourceSets["main"].resources.srcDir("src/resources/")
-tasks.withType {
- kotlinOptions.jvmTarget = "17"
+kotlin {
+ jvmToolchain(JavaVersion.VERSION_17.ordinal)
+}
+
+java {
+ toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
fun getCheckedOutGitCommitHash(): String = grgit.head().abbreviatedId
@@ -35,7 +33,7 @@ fun getCheckedOutGitCommitHash(): String = grgit.head().abbreviatedId
val commitHash = getCheckedOutGitCommitHash()
tasks {
- withType {
+ processResources {
val props = "version" to "${rootProject.version}-commit-$commitHash"
inputs.properties(props)
filteringCharset = "UTF-8"
@@ -46,12 +44,11 @@ tasks {
build {
dependsOn(shadowJar)
}
-}
-
-tasks.withType {
- archiveBaseName.set("ktgui-plugin")
- archiveClassifier.set("")
- archiveVersion.set(rootProject.version.toString())
- exclude { it.name.startsWith("kotlin") }
- mergeServiceFiles()
+ shadowJar {
+ archiveBaseName.set("ktgui-plugin")
+ archiveClassifier.set("")
+ archiveVersion.set(rootProject.version.toString())
+ exclude { it.name.startsWith("kotlin") }
+ mergeServiceFiles()
+ }
}
\ No newline at end of file
diff --git a/plugin/src/main/java/com/mattmx/ktgui/examples/JavaUpdateCommandExample.java b/plugin/src/main/java/com/mattmx/ktgui/examples/JavaUpdateCommandExample.java
index 2bd533c..87032c0 100644
--- a/plugin/src/main/java/com/mattmx/ktgui/examples/JavaUpdateCommandExample.java
+++ b/plugin/src/main/java/com/mattmx/ktgui/examples/JavaUpdateCommandExample.java
@@ -4,7 +4,6 @@
import com.mattmx.ktgui.commands.declarative.DeclarativeCommandBuilder;
import com.mattmx.ktgui.commands.declarative.arg.ArgumentContext;
import net.kyori.adventure.text.Component;
-import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class JavaUpdateCommandExample {
diff --git a/plugin/src/main/java/com/mattmx/ktgui/examples/JavaUpdateExample.java b/plugin/src/main/java/com/mattmx/ktgui/examples/JavaUpdateExample.java
index e9a4393..b85aec6 100644
--- a/plugin/src/main/java/com/mattmx/ktgui/examples/JavaUpdateExample.java
+++ b/plugin/src/main/java/com/mattmx/ktgui/examples/JavaUpdateExample.java
@@ -2,9 +2,9 @@
import com.mattmx.ktgui.GuiManager;
import com.mattmx.ktgui.components.GuiPattern;
+import com.mattmx.ktgui.components.button.BaseGuiButton;
import com.mattmx.ktgui.components.button.ButtonClickedEvent;
import com.mattmx.ktgui.components.button.GuiButton;
-import com.mattmx.ktgui.components.button.BaseGuiButton;
import com.mattmx.ktgui.components.screen.GuiScreen;
import com.mattmx.ktgui.components.signal.Signal;
import com.mattmx.ktgui.event.PreGuiBuildEvent;
@@ -19,7 +19,6 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
-import static com.mattmx.ktgui.dsl.EventKt.event;
import static com.mattmx.ktgui.dsl.EventKt.event;
import static com.mattmx.ktgui.utils.ColorKt.component;
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/KotlinGui.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/KotlinGui.kt
index b086a9f..2e916fa 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/KotlinGui.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/KotlinGui.kt
@@ -7,14 +7,11 @@ import com.mattmx.ktgui.commands.declarative.invoke
import com.mattmx.ktgui.commands.rawCommand
import com.mattmx.ktgui.commands.usage.CommandUsageOptions
import com.mattmx.ktgui.designer.GuiDesigner
-import com.mattmx.ktgui.dsl.button
-import com.mattmx.ktgui.dsl.gui
import com.mattmx.ktgui.examples.*
import com.mattmx.ktgui.scheduling.sync
import com.mattmx.ktgui.utils.not
import com.mattmx.ktgui.utils.pretty
import org.bukkit.Bukkit
-import org.bukkit.Material
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import org.bukkit.event.inventory.InventoryType
@@ -40,8 +37,7 @@ class KotlinGui : JavaPlugin() {
val animatedScoreboard = AnimatedScoreboardExample()
val scoreboardExample = ScoreboardExample()
- val examples = hashMapOf(
- "animated-scoreboard" to { animatedScoreboard },
+ val examples = hashMapOf("animated-scoreboard" to { animatedScoreboard },
"scoreboard" to { scoreboardExample },
"anvil-input" to { AnvilInputGuiExample() },
"config" to { ConfigScreenExample() },
@@ -57,8 +53,7 @@ class KotlinGui : JavaPlugin() {
"java-simple" to { JavaGuiExample() },
"java-new" to { JavaUpdateExample() },
"refresh" to { RefreshBlockExample() },
- "config-gui" to { GuiConfigExample() }
- )
+ "config-gui" to { GuiConfigExample() })
GuiHookExample.registerListener(this)
sync {
@@ -99,8 +94,7 @@ class KotlinGui : JavaPlugin() {
source.sendMessage(!"&aNot on cool-down!")
if (args.isNotEmpty()) {
- val newCoolDown = args.first().toLongOrNull()
- ?: return@executes
+ val newCoolDown = args.first().toLongOrNull() ?: return@executes
val dur = Duration.ofMillis(newCoolDown)
source.sendMessage(!"&aNew cool-down set: ${dur.pretty()}")
@@ -153,8 +147,13 @@ class KotlinGui : JavaPlugin() {
id suggests { cachedDesigners.keys.toList() }
runs {
- val designer = cachedDesigners[id()]
- ?: return@runs reply(!"&cInvalid id, create one using &7/&fdesigner ${create.getUsage(defaultUsageOptions, false)}")
+ val designer = cachedDesigners[id()] ?: return@runs reply(
+ !"&cInvalid id, create one using &7/&fdesigner ${
+ create.getUsage(
+ defaultUsageOptions, false
+ )
+ }"
+ )
designer.open(sender)
}
}
@@ -165,8 +164,13 @@ class KotlinGui : JavaPlugin() {
id suggests { cachedDesigners.keys.toList() }
runs {
- val designer = cachedDesigners[id()]
- ?: return@runs reply(!"&cInvalid id, create one using &7/&fdesigner ${create.getUsage(defaultUsageOptions, false)}")
+ val designer = cachedDesigners[id()] ?: return@runs reply(
+ !"&cInvalid id, create one using &7/&fdesigner ${
+ create.getUsage(
+ defaultUsageOptions, false
+ )
+ }"
+ )
designer.exportTitle = newTitle()
reply(!"&aSet title of ${id()} to ${newTitle()}")
}
@@ -188,20 +192,16 @@ class KotlinGui : JavaPlugin() {
someArg {
missing { reply(!"&cMissing argument 'someArg'!") }
}
- ("foo" /
- listOf(
- ("fizz" / someArg) {
- withDefaultUsageSubCommand(defaultUsageOptions)
- runs {
- reply(!"&c${someArg().replace("l", "w")} :3")
- }
- },
- ("bar") {
- runs {
- reply(!"&1bar")
- }
- })
- ) {
+ ("foo" / listOf(("fizz" / someArg) {
+ withDefaultUsageSubCommand(defaultUsageOptions)
+ runs {
+ reply(!"&c${someArg().replace("l", "w")} :3")
+ }
+ }, ("bar") {
+ runs {
+ reply(!"&1bar")
+ }
+ })) {
withDefaultUsageSubCommand(defaultUsageOptions)
runs {
reply(!"&cfoo&f!")
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/designer/GuiDesignerButton.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/designer/GuiDesignerButton.kt
index 1b43680..2254b53 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/designer/GuiDesignerButton.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/designer/GuiDesignerButton.kt
@@ -1,7 +1,6 @@
package com.mattmx.ktgui.designer
import com.mattmx.ktgui.components.button.GuiButton
-import com.mattmx.ktgui.extensions.stripColor
import com.mattmx.ktgui.utils.legacy
import org.bukkit.inventory.ItemStack
@@ -14,7 +13,7 @@ class GuiDesignerButton(item: ItemStack) : GuiButton(item) {
if (enchantments.isEmpty()) return null
val middle = enchantments.joinToString("\n") { (e, l) ->
- " this += Enchantment.${e.name} lvl $l"
+ " this += Enchantment.${e.key} lvl $l"
}
return "$start$middle\n}"
}
@@ -52,7 +51,7 @@ class GuiDesignerButton(item: ItemStack) : GuiButton(item) {
middle += namedPart + "\n"
if (lorePart != null)
- middle += lorePart!!.split("\n").joinToString("\n$tab") + "\n"
+ middle += lorePart!!.split("\n").joinToString("\n$tab") + "\n"
if (enchantPart != null)
middle += enchantPart!!.split("\n").joinToString("\n$tab") + "\n"
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/AnvilInputGuiExample.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/AnvilInputGuiExample.kt
index 069bfa8..fcd7109 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/AnvilInputGuiExample.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/AnvilInputGuiExample.kt
@@ -8,7 +8,6 @@ import com.mattmx.ktgui.KotlinGui
import com.mattmx.ktgui.components.screen.GuiScreen
import com.mattmx.ktgui.dsl.button
import com.mattmx.ktgui.dsl.gui
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.Material
import org.bukkit.entity.Player
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ConfigScreenExample.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ConfigScreenExample.kt
index 6aca000..cb90587 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ConfigScreenExample.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ConfigScreenExample.kt
@@ -3,7 +3,6 @@ package com.mattmx.ktgui.examples
import com.mattmx.ktgui.components.button.*
import com.mattmx.ktgui.components.screen.GuiScreen
import com.mattmx.ktgui.item.itemBuilder
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.Material
import org.bukkit.entity.Player
@@ -23,7 +22,8 @@ class ConfigScreenExample : GuiScreen(!"Example Config", 3), Example {
*/
GuiToggleButton(
enabled.copy().lore(!"&8This is item $it").build(),
- disabled.copy().lore(!"&8This is item $it").build())
+ disabled.copy().lore(!"&8This is item $it").build()
+ )
.enabledOnDefault(true)
.changeWithClickType(ClickType.LEFT)
.changed {
@@ -40,8 +40,14 @@ class ConfigScreenExample : GuiScreen(!"Example Config", 3), Example {
*/
GuiCycleButton()
.set("dirt", itemBuilder(Material.DIRT).name(!"&6Dirt").lore(!"&8Click to cycle").build())
- .set("grass_block", itemBuilder(Material.GRASS_BLOCK).lore(!"&8Click to cycle").name(!"&6Grass Block").build())
- .set("diamond", itemBuilder(Material.DIAMOND_BLOCK).lore(!"&8Click to cycle").name(!"&bDiamond Block").build())
+ .set(
+ "grass_block",
+ itemBuilder(Material.GRASS_BLOCK).lore(!"&8Click to cycle").name(!"&6Grass Block").build()
+ )
+ .set(
+ "diamond",
+ itemBuilder(Material.DIAMOND_BLOCK).lore(!"&8Click to cycle").name(!"&bDiamond Block").build()
+ )
.withDefaultClickEvents()
.changed {
player.sendMessage(!"&7You changed to ${button.selectedValue}")
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ConversationGuiExample.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ConversationGuiExample.kt
index 0d45f84..727e535 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ConversationGuiExample.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ConversationGuiExample.kt
@@ -1,16 +1,12 @@
package com.mattmx.ktgui.examples
-import com.mattmx.ktgui.KotlinGui
import com.mattmx.ktgui.components.button.GuiButton
import com.mattmx.ktgui.components.screen.GuiScreen
import com.mattmx.ktgui.conversation.refactor.conversation
import com.mattmx.ktgui.conversation.refactor.getInteger
import com.mattmx.ktgui.conversation.refactor.getString
-import com.mattmx.ktgui.dsl.conversation
import com.mattmx.ktgui.utils.legacyColor
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
-import net.kyori.adventure.title.Title
import org.bukkit.Material
import org.bukkit.entity.Player
import org.bukkit.event.inventory.ClickType
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/CustomGUI.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/CustomGUI.kt
index 0aa2502..c1cd535 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/CustomGUI.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/CustomGUI.kt
@@ -4,7 +4,6 @@ import com.mattmx.ktgui.components.button.GuiButton
import com.mattmx.ktgui.components.button.GuiToggleButton
import com.mattmx.ktgui.components.screen.GuiScreen
import com.mattmx.ktgui.item.itemBuilder
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.Bukkit
import org.bukkit.Material
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/GuiHookExample.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/GuiHookExample.kt
index 43a9645..c6c4ae5 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/GuiHookExample.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/GuiHookExample.kt
@@ -7,7 +7,6 @@ import com.mattmx.ktgui.dsl.button
import com.mattmx.ktgui.dsl.event
import com.mattmx.ktgui.dsl.gui
import com.mattmx.ktgui.event.PreGuiBuildEvent
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.Material
import org.bukkit.entity.Player
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/GuiPatternExample.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/GuiPatternExample.kt
index 1ff3d1f..c0f3ee9 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/GuiPatternExample.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/GuiPatternExample.kt
@@ -5,7 +5,6 @@ import com.mattmx.ktgui.components.applyPattern
import com.mattmx.ktgui.dsl.button
import com.mattmx.ktgui.dsl.gui
import com.mattmx.ktgui.item.itemBuilderStack
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.Bukkit
import org.bukkit.Material
@@ -17,11 +16,13 @@ import java.util.*
class GuiPatternExample : Example {
val gui = gui(!"Pattern Example", 3) {
- val pattern = GuiPattern("""
+ val pattern = GuiPattern(
+ """
xxxxxxxxx
-a-b-c-d-
xxxxxxxxx
- """.trimIndent())
+ """.trimIndent()
+ )
pattern['x'] = button(Material.BLUE_STAINED_GLASS_PANE) {
named(!"")
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/InfiniteGuiExample.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/InfiniteGuiExample.kt
index 70eb867..1a52820 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/InfiniteGuiExample.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/InfiniteGuiExample.kt
@@ -3,7 +3,6 @@ package com.mattmx.ktgui.examples
import com.mattmx.ktgui.GuiManager
import com.mattmx.ktgui.components.screen.GuiInfiniteScreen
import com.mattmx.ktgui.dsl.button
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.Material
import org.bukkit.entity.Player
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/MultiPageExample.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/MultiPageExample.kt
index 8021c86..7dd73fc 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/MultiPageExample.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/MultiPageExample.kt
@@ -2,7 +2,6 @@ package com.mattmx.ktgui.examples
import com.mattmx.ktgui.components.screen.GuiMultiPageScreen
import com.mattmx.ktgui.dsl.button
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.Material
import org.bukkit.entity.Player
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ScoreboardExample.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ScoreboardExample.kt
index 969b7e1..0ea4aed 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ScoreboardExample.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/ScoreboardExample.kt
@@ -2,17 +2,16 @@ package com.mattmx.ktgui.examples
import com.mattmx.ktgui.extensions.removeScoreboard
import com.mattmx.ktgui.scoreboards.scoreboard
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.entity.Player
-class ScoreboardExample : Example{
+class ScoreboardExample : Example {
// Create a new scoreboard builder with a title.
private val builder = scoreboard(!"&6&lTitle") {
// Add a line of text, then whitespace, then another line of text.
- + !"&7This is a scoreboard example!"
- + !" "
- + !"&7New lines!"
+ +!"&7This is a scoreboard example!"
+ +!" "
+ +!"&7New lines!"
}
fun toggle(player: Player) {
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/SignalsExample.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/SignalsExample.kt
index 7e32c06..3170d33 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/SignalsExample.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/SignalsExample.kt
@@ -5,7 +5,6 @@ import com.mattmx.ktgui.components.signal.signal
import com.mattmx.ktgui.dsl.button
import com.mattmx.ktgui.dsl.effect
import com.mattmx.ktgui.dsl.gui
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.Material
import org.bukkit.entity.Player
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/SignalsListExample.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/SignalsListExample.kt
index 00c2c62..33d4f28 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/SignalsListExample.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/SignalsListExample.kt
@@ -4,7 +4,6 @@ import com.mattmx.ktgui.components.signal.signal
import com.mattmx.ktgui.dsl.button
import com.mattmx.ktgui.dsl.effect
import com.mattmx.ktgui.dsl.gui
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.Material
import org.bukkit.entity.Player
diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/TitleCounterExample.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/TitleCounterExample.kt
index 985dc7b..ec9b42c 100644
--- a/plugin/src/main/kotlin/com/mattmx/ktgui/examples/TitleCounterExample.kt
+++ b/plugin/src/main/kotlin/com/mattmx/ktgui/examples/TitleCounterExample.kt
@@ -2,7 +2,6 @@ package com.mattmx.ktgui.examples
import com.mattmx.ktgui.dsl.button
import com.mattmx.ktgui.dsl.gui
-import com.mattmx.ktgui.scheduling.not
import com.mattmx.ktgui.utils.not
import org.bukkit.Material
import org.bukkit.entity.Player
diff --git a/plugin/src/main/resources/plugin.yml b/plugin/src/main/resources/plugin.yml
index 5158156..88bbd4f 100644
--- a/plugin/src/main/resources/plugin.yml
+++ b/plugin/src/main/resources/plugin.yml
@@ -6,4 +6,6 @@ prefix: KtGUI
authors: [ MattMX ]
description: Declarative GUI Library for Paper.
softdepend:
- - PlaceholderAPI
\ No newline at end of file
+ - PlaceholderAPI
+libraries:
+ - org.jetbrains.kotlin:kotlin-stdlib:2.0.0
\ No newline at end of file
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 6b9cb00..c976877 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,17 +1,38 @@
rootProject.name = "ktgui"
-include("api")
-include("plugin")
+
+pluginManagement {
+ repositories {
+ google()
+ gradlePluginPortal()
+ mavenCentral()
+ }
+}
plugins {
- id("com.gradle.enterprise") version("3.15")
+ //id("com.gradle.develocity") version("3.17.5")
}
-gradleEnterprise {
- if (System.getenv("CI") != null) {
- buildScan {
- publishAlways()
- termsOfServiceUrl = "https://gradle.com/terms-of-service"
- termsOfServiceAgree = "yes"
- }
+dependencyResolutionManagement {
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ maven("https://repo.papermc.io/repository/maven-public/")
+ maven("https://maven.pvphub.me/releases")
+ maven("https://repo.dmulloy2.net/repository/public/")
+ maven("https://jitpack.io")
+ maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
}
-}
\ No newline at end of file
+}
+
+include("api")
+include("plugin")
+
+//gradleEnterprise {
+// if (System.getenv("CI") != null) {
+// buildScan {
+// publishAlways()
+// termsOfServiceUrl = "https://gradle.com/terms-of-service"
+// termsOfServiceAgree = "yes"
+// }
+// }
+//}
\ No newline at end of file