Skip to content

Commit

Permalink
Revert "Merge pull request #35 from Matt-MX/master"
Browse files Browse the repository at this point in the history
This reverts commit bb1e003, reversing
changes made to f928a6b.
  • Loading branch information
Matt-MX committed Jun 28, 2024
1 parent bb1e003 commit ad9870f
Show file tree
Hide file tree
Showing 140 changed files with 2,085 additions and 892 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@
/build/classes/kotlin/main/
/build/classes/kotlin/test/
/api/build
/plugin/build
/api/.gradle
/plugin/.gradle
/plugin/build
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.

13 changes: 13 additions & 0 deletions .idea/modules/ktgui.main.iml

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

15 changes: 15 additions & 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.

2 changes: 2 additions & 0 deletions api/.gradle/caches/paperweight/taskCache/reobfJar.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Command: C:\Program Files\Java\jdk-17\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 2815.14 ms.
40 changes: 25 additions & 15 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.kotlinJvm) apply true
alias(libs.plugins.shadow) apply true
kotlin("jvm") version "1.7.10"
id("com.github.johnrengelman.shadow") version "7.0.0"
`maven-publish`
}

val paper_version: String by rootProject

repositories {
mavenCentral()
}

dependencies {
compileOnly(libs.paper.api)
compileOnly(libs.placeholder.api)
implementation(libs.kotlin.reflect)
compileOnly(libs.kotlin.stdlib)
// compileOnly(kotlin("reflect"))
shadow(implementation(kotlin("reflect"))!!)
// implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10")

paperweight.paperDevBundle(paper_version)
}

tasks.test {
Expand All @@ -19,8 +28,8 @@ version = rootProject.version

sourceSets["main"].resources.srcDir("src/resources/")

kotlin {
jvmToolchain(JavaVersion.VERSION_17.ordinal)
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}

tasks {
Expand All @@ -29,17 +38,18 @@ tasks {
}
shadowJar {
mergeServiceFiles()
// exclude {
//// it.path.startsWith("kotlin") && !it.path.contains("reactive")
// it.name.startsWith("kotlin")
// }
archiveBaseName.set("ktgui")
mergeServiceFiles()
}
assemble {
dependsOn(reobfJar)
}
}

tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
archiveBaseName.set("ktgui")
mergeServiceFiles()
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
withJavadocJar()
withSourcesJar()
}
Expand Down
5 changes: 2 additions & 3 deletions api/src/main/kotlin/com/mattmx/ktgui/GuiManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -89,8 +89,7 @@ object GuiManager : Listener {
val aliasesField = SimpleCommandMap::class.java.getDeclaredField("aliases")
aliasesField.setAccessible(true)
knownAliases = aliasesField.get(cmdMap) as MutableSet<String?>
} catch (e: NoSuchFieldException) {
}
} catch (e: NoSuchFieldException) {}

event<PluginDisableEvent>(cmdPlugin) {
if (this.plugin == cmdPlugin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ 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 <T : LegacyBossBarBuilder> bossBarDsl(instance: T, builder: T.() -> Unit): T {
inline fun <T : LegacyBossBarBuilder> bossBarDsl(instance: T, builder: T.() -> Unit) : T {
builder(instance)
instance.build()
return instance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -106,11 +106,11 @@ open class SimpleCommandBuilder(
this.suggests = suggest
}

fun allAliases(): List<String> {
fun allAliases() : List<String> {
return aliases.toMutableList() + name
}

fun getSuggestions(invocation: CommandInvocation): List<String> {
fun getSuggestions(invocation: CommandInvocation) : List<String> {
suggests?.also {
return it(invocation) ?: listOf()
} ?: run {
Expand All @@ -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
}
Expand All @@ -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")
Expand All @@ -150,12 +150,11 @@ open class SimpleCommandBuilder(
val aliasesField = SimpleCommandMap::class.java.getDeclaredField("aliases")
aliasesField.setAccessible(true)
knownAliases = aliasesField.get(cmdMap) as MutableSet<String?>
} catch (e: NoSuchFieldException) {
}
} catch (e: NoSuchFieldException) {}
val prefix = GuiManager.owningPlugin.name.lowercase()

event<PluginDisableEvent>(plugin = GuiManager.owningPlugin) {
if (plugin == GuiManager.owningPlugin) {
if(plugin == GuiManager.owningPlugin) {
synchronized(cmdMap) {
knownCommands.remove(name)
knownCommands.remove("$prefix:$name")
Expand All @@ -172,16 +171,15 @@ 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<String>): SimpleCommandBuilder? {
fun getCommand(args: List<String>) : SimpleCommandBuilder? {
if (args.isEmpty()) return this
subCommands.forEach { cmd ->
if (cmd.isCommand(args[0])) {
Expand All @@ -204,21 +202,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
Expand Down
32 changes: 0 additions & 32 deletions api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/Argument.kt

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit ad9870f

Please sign in to comment.