diff --git a/api/.gradle/caches/paperweight/taskCache/reobfJar.log b/api/.gradle/caches/paperweight/taskCache/reobfJar.log index 46e4669..05db605 100644 --- a/api/.gradle/caches/paperweight/taskCache/reobfJar.log +++ b/api/.gradle/caches/paperweight/taskCache/reobfJar.log @@ -1,2 +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.1-dev-all.jar D:\PC\Projects\KtBukkitGui\api\build\libs\api-2.4.1.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 2782.23 ms. +Finished after 2640.75 ms. 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 a1aac1a..4b81d9a 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 @@ -114,7 +114,7 @@ open class Argument( open fun getValueOfString( cmd: DeclarativeCommandBuilder?, - context: BaseCommandContext<*>, + context: BaseCommandContext<*>?, split: List ): T? { return getValueOfString(cmd, context, split.joinToString(" ")) @@ -140,8 +140,8 @@ open class Argument( @JavaCompatibility fun getValue(context: RunnableCommandContext<*>) = context.getArgumentContext(name())?.getOrNull() - fun createContext(cmd: DeclarativeCommandBuilder?, context: BaseCommandContext<*>?, stringValue: String?) = - createContext(stringValue, getValueOfString(cmd, context, stringValue)) + fun createContext(cmd: DeclarativeCommandBuilder?, context: BaseCommandContext<*>?, stringValue: List) = + createContext(stringValue.joinToString(" "), getValueOfString(cmd, context, stringValue)) fun createContext(stringValue: String?, actualValue: Any?): ArgumentContext { return ArgumentContext(stringValue, Optional.ofNullable(actualValue as T?), this) diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/ArgumentProcessor.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/ArgumentProcessor.kt index 12cc27b..843d60b 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/ArgumentProcessor.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/ArgumentProcessor.kt @@ -31,7 +31,6 @@ class ArgumentProcessor( pointer++ } else { - println(command.permittedOptions) val option = command.permittedOptions.firstOrNull { it.chatName() == optionOrPointerId } diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/BooleanArgument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/BooleanArgument.kt index 5cd741d..48afc63 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/BooleanArgument.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/BooleanArgument.kt @@ -15,8 +15,8 @@ class BooleanArgument( } override fun getValueOfString( - cmd: DeclarativeCommandBuilder, - context: BaseCommandContext<*>, + cmd: DeclarativeCommandBuilder?, + context: BaseCommandContext<*>?, stringValue: String? ): Boolean? { return stringValue?.toBooleanStrictOrNull() diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/DoubleArgument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/DoubleArgument.kt index 1b750c0..e97fe67 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/DoubleArgument.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/DoubleArgument.kt @@ -17,8 +17,8 @@ class DoubleArgument( } override fun getValueOfString( - cmd: DeclarativeCommandBuilder, - context: BaseCommandContext<*>, + cmd: DeclarativeCommandBuilder?, + context: BaseCommandContext<*>?, stringValue: String? ): Double? { val doubleValue = stringValue?.toDoubleOrNull() ?: return null diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/EnumArgument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/EnumArgument.kt index 0507a3c..8cc5c4b 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/EnumArgument.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/EnumArgument.kt @@ -23,8 +23,8 @@ class EnumArgument>( } override fun getValueOfString( - cmd: DeclarativeCommandBuilder, - context: BaseCommandContext<*>, + cmd: DeclarativeCommandBuilder?, + context: BaseCommandContext<*>?, stringValue: String? ): E? { return if (toString.isEmpty) { diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/FlagArgument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/FlagArgument.kt index 9fbe95a..1443032 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/FlagArgument.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/FlagArgument.kt @@ -25,10 +25,10 @@ class FlagArgument( fun chatName() = name().replace("_", "-") override fun getValueOfString( - cmd: DeclarativeCommandBuilder, - context: BaseCommandContext<*>, + cmd: DeclarativeCommandBuilder?, + context: BaseCommandContext<*>?, split: List - ): Boolean? { + ): Boolean { // todo context should contain included flags/options return false } diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/IntArgument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/IntArgument.kt index 859eb1e..0b8e217 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/IntArgument.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/IntArgument.kt @@ -17,8 +17,8 @@ class IntArgument( } override fun getValueOfString( - cmd: DeclarativeCommandBuilder, - context: BaseCommandContext<*>, + cmd: DeclarativeCommandBuilder?, + context: BaseCommandContext<*>?, stringValue: String? ): Int? { val intValue = stringValue?.toIntOrNull() ?: return null diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/LongArgument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/LongArgument.kt index c4c9bb9..ac3693f 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/LongArgument.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/LongArgument.kt @@ -17,8 +17,8 @@ class LongArgument( } override fun getValueOfString( - cmd: DeclarativeCommandBuilder, - context: BaseCommandContext<*>, + cmd: DeclarativeCommandBuilder?, + context: BaseCommandContext<*>?, stringValue: String? ): Long? { val longValue = stringValue?.toLongOrNull() ?: return null diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/MultiChoiceArgument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/MultiChoiceArgument.kt index e269388..8b1536d 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/MultiChoiceArgument.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/MultiChoiceArgument.kt @@ -22,8 +22,8 @@ class MultiChoiceArgument( } override fun getValueOfString( - cmd: DeclarativeCommandBuilder, - context: BaseCommandContext<*>, + cmd: DeclarativeCommandBuilder?, + context: BaseCommandContext<*>?, stringValue: String? ) = choices()[stringValue] } \ No newline at end of file diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/OnlinePlayerArgument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/OnlinePlayerArgument.kt index cb88a0a..f546def 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/OnlinePlayerArgument.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/OnlinePlayerArgument.kt @@ -12,8 +12,8 @@ class OnlinePlayerArgument( ) : Argument(name, typeName) { override fun getValueOfString( - cmd: DeclarativeCommandBuilder, - context: BaseCommandContext<*>, + cmd: DeclarativeCommandBuilder?, + context: BaseCommandContext<*>?, stringValue: String? ): Player? { stringValue ?: return null diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/RelativeCoordinateArgument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/RelativeCoordinateArgument.kt index a47893d..820850b 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/RelativeCoordinateArgument.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/RelativeCoordinateArgument.kt @@ -18,13 +18,14 @@ class RelativeCoordinateArgument( } override fun getValueOfString( - cmd: DeclarativeCommandBuilder, - context: BaseCommandContext<*>, + cmd: DeclarativeCommandBuilder?, + context: BaseCommandContext<*>?, split: List ): Location? { if (split.size != 3) return null - val entity = (context.sender as Entity) + val entity = (context?.sender as Entity?) + ?: return null val location = entity.location.clone().toVector().list() var i = 0 diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/SimpleArgument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/SimpleArgument.kt index a445c69..f189aea 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/SimpleArgument.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/SimpleArgument.kt @@ -17,8 +17,8 @@ class SimpleArgument( } override fun getValueOfString( - cmd: DeclarativeCommandBuilder, - context: BaseCommandContext<*>, + cmd: DeclarativeCommandBuilder?, + context: BaseCommandContext<*>?, stringValue: String? ): T? { stringValue ?: return null diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/StringArgument.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/StringArgument.kt index 4e13c4c..74101c6 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/StringArgument.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/StringArgument.kt @@ -15,8 +15,8 @@ class StringArgument( val disallow = arrayListOf() override fun getValueOfString( - cmd: DeclarativeCommandBuilder, - context: BaseCommandContext<*>, + cmd: DeclarativeCommandBuilder?, + context: BaseCommandContext<*>?, stringValue: String? ): String? { stringValue ?: return null diff --git a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/args.kt b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/args.kt index ec88705..68ccba3 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/args.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/commands/declarative/arg/impl/args.kt @@ -50,6 +50,9 @@ fun flag() = delegateArgument(FlagArgument(DELEGATED_ARG_NAME)) fun multiChoiceArgument(vararg choices: Pair) = delegateArgument(MultiChoiceArgument(DELEGATED_ARG_NAME) { hashMapOf(*choices) }) +fun multiChoiceArgument(choices: HashMap) = + delegateArgument(MultiChoiceArgument(DELEGATED_ARG_NAME) { choices }) + fun multiChoiceArgument(choiceSupplier: () -> HashMap) = delegateArgument(MultiChoiceArgument(DELEGATED_ARG_NAME) { choiceSupplier() }) diff --git a/api/src/main/kotlin/com/mattmx/ktgui/papi/PlaceholderExpansionWrapper.kt b/api/src/main/kotlin/com/mattmx/ktgui/papi/PlaceholderExpansionWrapper.kt index 9806aa7..95d53a1 100644 --- a/api/src/main/kotlin/com/mattmx/ktgui/papi/PlaceholderExpansionWrapper.kt +++ b/api/src/main/kotlin/com/mattmx/ktgui/papi/PlaceholderExpansionWrapper.kt @@ -68,10 +68,15 @@ class PlaceholderExpansionWrapper( else null for (placeholder in placeholders.sortedByDescending { it.priority }) { + // todo support no identifiers (root placeholder) val identifier = placeholder.match.name if (paramsSplit.getOrNull(0) != identifier) continue - val argumentParser = ArgumentProcessor(emptyCommand, baseContext, paramsSplit) + val argumentParser = ArgumentProcessor( + emptyCommand, + baseContext, + paramsSplit.subList(1, paramsSplit.size) + ) var invalid = false @@ -80,15 +85,22 @@ class PlaceholderExpansionWrapper( val stringValue = expArg.consume(argumentParser) - if (isDebug) { - owner.logger.warning("Failed parsing for arg $expArg in placeholder $name") - } - if (expArg.isRequired() && stringValue.isEmpty()) { invalid = true + if (isDebug) { + owner.logger.warning( + "Placeholder(${ + identifier + }) Failed parsing for arg $expArg in placeholder $name - $stringValue" + ) + } continue } else { - args[expArg.name()] = expArg.createContext(emptyCommand, baseContext, stringValue.stringValue) + args[expArg.name()] = expArg.createContext( + emptyCommand, + baseContext, + stringValue.stringValue?.split("_", " ") ?: emptyList() + ) } } if (invalid) continue diff --git a/plugin/.gradle/caches/paperweight/taskCache/reobfJar.log b/plugin/.gradle/caches/paperweight/taskCache/reobfJar.log index bde4027..15a607f 100644 --- a/plugin/.gradle/caches/paperweight/taskCache/reobfJar.log +++ b/plugin/.gradle/caches/paperweight/taskCache/reobfJar.log @@ -1,2 +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\plugin\build\libs\ktgui-plugin-2.4.1-dev-all.jar D:\PC\Projects\KtBukkitGui\plugin\build\libs\plugin-unspecified.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 2866.75 ms. +Finished after 1620.52 ms. diff --git a/plugin/src/main/kotlin/com/mattmx/ktgui/KotlinGui.kt b/plugin/src/main/kotlin/com/mattmx/ktgui/KotlinGui.kt index 4f2144e..f8b0d6c 100644 --- a/plugin/src/main/kotlin/com/mattmx/ktgui/KotlinGui.kt +++ b/plugin/src/main/kotlin/com/mattmx/ktgui/KotlinGui.kt @@ -81,21 +81,27 @@ class KotlinGui : JavaPlugin() { String(original.map { c -> fontMap[c] ?: c }.toCharArray()) val smallFont = mapFont("ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ") - val doubleStruck = - mapFont("\uD835\uDD52\uD835\uDD53\uD835\uDD54\uD835\uDD55\uD835\uDD56\uD835\uDD57\uD835\uDD58\uD835\uDD59\uD835\uDD5A\uD835\uDD5B\uD835\uDD5C\uD835\uDD5D\uD835\uDD5E\uD835\uDD5F\uD835\uDD60\uD835\uDD61\uD835\uDD62\uD835\uDD63\uD835\uDD64\uD835\uDD65\uD835\uDD66\uD835\uDD67\uD835\uDD68\uD835\uDD69\uD835\uDD6A\uD835\uDD6B") val balls = mapFont("ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ") - val block = - mapFont("\uD83C\uDDE6\u200C\uD83C\uDDE7\u200C\uD83C\uDDE8\u200C\uD83C\uDDE9\u200C\uD83C\uDDEA\u200C\uD83C\uDDEB\u200C\uD83C\uDDEC\u200C\uD83C\uDDED\u200C\uD83C\uDDEE\u200C\uD83C\uDDEF\u200C\uD83C\uDDF0\u200C\uD83C\uDDF1\u200C\uD83C\uDDF2\u200C\uD83C\uDDF3\u200C\uD83C\uDDF4\u200C\uD83C\uDDF5\u200C\uD83C\uDDF6\u200C\uD83C\uDDF7\u200C\uD83C\uDDF8\u200C\uD83C\uDDF9\u200C\uD83C\uDDFA\u200C\uD83C\uDDFB\u200C\uD83C\uDDFC\u200C\uD83C\uDDFD\u200C\uD83C\uDDFE\u200C\uD83C\uDDFF\u200C") + val blackSquares = + mapFont("\uD83C\uDD70\uD83C\uDD71\uD83C\uDD72\uD83C\uDD73\uD83C\uDD74\uD83C\uDD75\uD83C\uDD76\uD83C\uDD77\uD83C\uDD78\uD83C\uDD79\uD83C\uDD7A\uD83C\uDD7B\uD83C\uDD7C\uD83C\uDD7D\uD83C\uDD7E\uD83C\uDD7F\uD83C\uDD80\uD83C\uDD81\uD83C\uDD82\uD83C\uDD83\uD83C\uDD84\uD83C\uDD85\uD83C\uDD86\uD83C\uDD87\uD83C\uDD88\uD83C\uDD89") val stringToConvert by greedyStringArgument() val fontType by multiChoiceArgument<(String) -> String>( "smalltext" to { convertFont(it, smallFont) }, - "doublestruck" to { convertFont(it, doubleStruck) }, "balls" to { convertFont(it, balls) }, - "block" to { convertFont(it, block) } + "blacksquares" to { convertFont(it, blackSquares) } + ) + + val brandingType by multiChoiceArgument( + config.getConfigurationSection("branding") + ?.let { section -> + section.getKeys(false).associateWithTo(HashMap()) { k -> section.getString(k) ?: "null" } + } + ?: hashMapOf() ) placeholderExpansion { + isDebug = true placeholder("font" / fontType / stringToConvert) { fontType()(stringToConvert()) } @@ -105,6 +111,8 @@ class KotlinGui : JavaPlugin() { fontType()(string) } + placeholder("branding" / brandingType) { brandingType() } + } id "ktgui" author "MattMX" ("font" / fontType / stringToConvert).runs { diff --git a/plugin/src/main/resources/config.yml b/plugin/src/main/resources/config.yml index 45a6f3d..59845ea 100644 --- a/plugin/src/main/resources/config.yml +++ b/plugin/src/main/resources/config.yml @@ -1,3 +1,11 @@ +branding: + name: "sᴇʀᴠᴇʀ ɴᴀᴍᴇ" + title: '&#B34262' + highlight: '&#AE76A6' + off-white: '&#A3C3D9' + dull: '&#CCD6EB' + primary: '&#E9ECF5' + gui: example: title: "Config Gui"