Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-MX committed Jun 28, 2024
1 parent c20e556 commit fc76019
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 35 deletions.
1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules/plugin/ktgui.plugin.test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/.gradle/caches/paperweight/taskCache/reobfJar.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Command: C:\Users\Mangr\.gradle\jdks\adoptium-21-x64-hotspot-windows\bin\java.exe -Xmx1G -classpath C:\Users\Mangr\.gradle\caches\modules-2\files-2.1\net.fabricmc\tiny-remapper\0.10.1\c293b2384ae12af74f407fa3aaa553bba4ac6763\tiny-remapper-0.10.1-fat.jar net.fabricmc.tinyremapper.Main D:\PC\Projects\KtBukkitGui\api\build\libs\ktgui-2.4.0-dev-all.jar D:\PC\Projects\KtBukkitGui\api\build\libs\api-2.4.0.jar C:\Users\Mangr\.gradle\caches\paperweight-userdev\383bcea64446e2cc830258ba4061f82beae144700277ae2c736ef37b9c989d6c\module\io.papermc.paper\dev-bundle\1.20.4-R0.1-SNAPSHOT\paperweight\setupCache\extractDevBundle.dir\data\mojang+yarn-spigot-reobf.tiny mojang+yarn spigot C:\Users\Mangr\.gradle\caches\paperweight-userdev\383bcea64446e2cc830258ba4061f82beae144700277ae2c736ef37b9c989d6c\module\io.papermc.paper\dev-bundle\1.20.4-R0.1-SNAPSHOT\paperweight\setupCache\applyMojangMappedPaperclipPatch.jar --threads=1
Finished after 2799.54 ms.
Command: C:\Users\Mangr\.gradle\jdks\adoptium-21-x64-hotspot-windows\bin\java.exe -Xmx1G -classpath C:\Users\Mangr\.gradle\caches\modules-2\files-2.1\net.fabricmc\tiny-remapper\0.10.1\c293b2384ae12af74f407fa3aaa553bba4ac6763\tiny-remapper-0.10.1-fat.jar net.fabricmc.tinyremapper.Main D:\PC\Projects\KtBukkitGui\api\build\libs\ktgui-2.4.0-dev-all.jar D:\PC\Projects\KtBukkitGui\api\build\libs\api-2.4.0.jar C:\Users\Mangr\.gradle\caches\paperweight-userdev\ff775525efc29c3503a07d1006e63e5695a742b7505cf63e157d49d32419c69f\module\io.papermc.paper\dev-bundle\1.20.4-R0.1-SNAPSHOT\paperweight\setupCache\extractDevBundle.dir\data\mojang+yarn-spigot-reobf.tiny mojang+yarn spigot C:\Users\Mangr\.gradle\caches\paperweight-userdev\ff775525efc29c3503a07d1006e63e5695a742b7505cf63e157d49d32419c69f\module\io.papermc.paper\dev-bundle\1.20.4-R0.1-SNAPSHOT\paperweight\setupCache\applyMojangMappedPaperclipPatch.jar --threads=1
Finished after 2887.82 ms.
2 changes: 1 addition & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ version = rootProject.version
sourceSets["main"].resources.srcDir("src/resources/")

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
kotlinOptions.jvmTarget = "21"
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.mattmx.ktgui.commands.declarative

import com.mattmx.ktgui.commands.declarative.arg.Argument
import com.mattmx.ktgui.commands.declarative.arg.impl.MultiArgument
import com.mattmx.ktgui.commands.declarative.invocation.RunnableCommandContext
import com.mattmx.ktgui.utils.JavaCompatibility
import org.bukkit.block.data.type.Chain
import org.bukkit.command.CommandSender

class ChainCommandBuilder(val name: String) {
val arguments = arrayListOf<Argument<*>>()
Expand All @@ -19,6 +21,8 @@ class ChainCommandBuilder(val name: String) {
subcommands.addAll(command)
}

inline infix fun <reified S : CommandSender> runs(noinline block: RunnableCommandContext<S>.() -> Unit) = build().runs(block)

fun build() = build(DeclarativeCommandBuilder(name))

fun <T : DeclarativeCommandBuilder> build(existing: T) = existing.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ fun main() {
processor.takeOne("username")
processor.takeRemaining("msg")

username consumes single()
msg consumes until { false }
msg consumes remaining()
// username consumes single()
// msg consumes until { false }
// msg consumes remaining()

println(processor)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.mattmx.ktgui.commands.declarative.arg.impl

import com.mattmx.ktgui.commands.declarative.arg.Argument
import com.mattmx.ktgui.commands.declarative.arg.consumer.ArgumentConsumer

class MultiChoiceArgument<T : Any>(
name: String,
typeName: String,
consumer: ArgumentConsumer
) : Argument<T>(name, typeName, consumer) {



}
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ class PlaceholderExpansionWrapper(
private val placeholders = arrayListOf<Placeholder>()
var id = owner.name
private set
var author = owner.pluginMeta.authors.joinToString(", ")
var _author = owner.pluginMeta.authors.joinToString(", ")
private set
var version = owner.pluginMeta.version
var _version = owner.pluginMeta.version
private set
var splitArgs = { params: String -> params.split("_") }
private set

override fun getIdentifier() = id
override fun getAuthor() = author
override fun getVersion() = version
override fun getAuthor() = _author
override fun getVersion() = _version
override fun getPlaceholders() = placeholders.map { it.toString() }.toMutableList()

infix fun id(id: String) = apply {
this.id = id
}

infix fun author(author: String) = apply {
this.author = author
this._author = author
}

infix fun version(version: String) = apply {
this.version = version
this._version = version
}

infix fun splitArgs(splitArgs: (String) -> List<String>) = apply {
Expand Down
49 changes: 34 additions & 15 deletions api/src/main/kotlin/com/mattmx/ktgui/scheduling/TaskTracker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,62 +10,81 @@ import java.util.*
* Any scheduled tasks will be added to [list].
*/
class TaskTracker : Invokable<TaskTracker> {
private val list = Collections.synchronizedList(arrayListOf<BukkitTask>())
private val list = Collections.synchronizedList(arrayListOf<IteratingTask>())

fun runAsync(block: TaskTrackerTask.() -> Unit) {
infix fun runAsync(block: TaskTrackerTask.() -> Unit) {
var task: TaskTrackerTask? = null
task = TaskTrackerTask(this, async {
block(task!!)
list.remove(this)
}.apply { list.add(this) })
list.remove(task!!)
}).apply { list.add(this) }
}

fun runSync(block: TaskTrackerTask.() -> Unit) {
infix fun runSync(block: TaskTrackerTask.() -> Unit) {
var task: TaskTrackerTask? = null
task = TaskTrackerTask(this, sync {
block(task!!)
list.remove(this)
}.apply { list.add(this) })
list.remove(task!!)
}).apply { list.add(this) }
}

fun runAsyncLater(period: Long, block: TaskTrackerTask.() -> Unit) {
var task: TaskTrackerTask? = null
task = TaskTrackerTask(this, asyncDelayed(period) {
block(task!!)
list.remove(this)
}.apply { list.add(this) })
list.remove(task!!)
}).apply { list.add(this) }
}

fun runSyncLater(period: Long, block: TaskTrackerTask.() -> Unit) {
var task: TaskTrackerTask? = null
task = TaskTrackerTask(this, syncDelayed(period) {
block(task!!)
list.remove(this)
}.apply { list.add(this) })
list.remove(task!!)
}).apply { list.add(this) }
}

fun runAsyncRepeat(delay: Long, period: Long = 0L, block: TaskTrackerTask.() -> Unit) {
var task: TaskTrackerTask? = null
task = TaskTrackerTask(this, asyncRepeat(delay, period) {
block(task!!)
task!!.iterations++
}.apply { list.add(this) })
}).apply { list.add(this) }
}

fun runSyncRepeat(delay: Long, period: Long = 0L, block: TaskTrackerTask.() -> Unit) {
var task: TaskTrackerTask? = null
task = TaskTrackerTask(this, syncRepeat(delay, period) {
block(task!!)
task!!.iterations++
}.apply { list.add(this) })
}).apply { list.add(this) }
}

fun cancelAll() = list.apply {
forEach { it.cancel() }
val temp = this.toList()
temp.forEach { it.cancel() }
list.clear()
}

fun removeTask(task: BukkitTask) {
infix fun cancelIf(predicate: (IteratingTask) -> Boolean): List<IteratingTask> {
val removed = arrayListOf<IteratingTask>()
val it = list.iterator()
while (it.hasNext()) {
val t = it.next()
if (predicate(t)) {
it.remove()
removed.add(t)
}
}
return removed.toList()
}

inline fun <reified T : TaskTrackerTask> cancelIfInstance() =
cancelIf { it is T } as List<T>

infix fun removeTask(task: BukkitTask) = cancelIf { it.task == task }

infix fun removeTask(task: TaskTrackerTask) {
list.remove(task)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.bukkit.scheduler.BukkitTask
/**
* Wrapper class for the [BukkitTask] task.
*/
class TaskTrackerTask(
open class TaskTrackerTask(
private val owner: TaskTracker,
task: BukkitTask
) : IteratingTask(task) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.mattmx.ktgui.scheduling.builder

import com.mattmx.ktgui.scheduling.asyncDelayed
import com.mattmx.ktgui.scheduling.asyncRepeat
import com.mattmx.ktgui.utils.seconds

object Task {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tasks.test {
sourceSets["main"].resources.srcDir("src/resources/")

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
kotlinOptions.jvmTarget = "21"
}

fun getCheckedOutGitCommitHash(): String = grgit.head().abbreviatedId
Expand Down

0 comments on commit fc76019

Please sign in to comment.