FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add Kotlin DSL support for delegations by DerEchtePilz · Pull Request #482 · CommandAPI/CommandAPI · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .kt  (10) .md  (5) .xml  (8) dotfile  (2) All 4 file types selected
Only manifest files
Deleted files Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
  • README.md
    • Examples.kt
    • ExamplesKotlinDSL.kt
      • pom.xml
        • CommandAPICommandDSL.kt
        • CommandTreeDSL.kt
        • ExecutorDSL.kt
      • pom.xml
        • CommandAPIDSL.kt
      • pom.xml
        • CommandAPICommandDSL.kt
        • CommandTreeDSL.kt
        • ExecutorDSL.kt
    • pom.xml
        • .gitignore
        • DelegationTests.kt
      • pom.xml
        • .gitignore
      • pom.xml
    • pom.xml
  • pom.xml
1 change: 1 addition & 0 deletions README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ This is the current roadmap for the CommandAPI (as of 11th May 2023):
<ul>
<li>https://github.com/JorelAli/CommandAPI/issues/487 Added support for disabling integer centering for location arguments</li>
<li>https://github.com/JorelAli/CommandAPI/issues/488 Fixed calling CommandAPI commands with <code>Bukkit.createCommandSender()</code> not working on paper</li>
<li>https://github.com/JorelAli/CommandAPI/pull/482 Adds Kotlin DSL support for delegations</li>
</ul>
</td>
</tr>
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import dev.jorel.commandapi.arguments.CustomArgument.CustomArgumentException
import dev.jorel.commandapi.arguments.CustomArgument.MessageBuilder
import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException
import dev.jorel.commandapi.executors.*
import dev.jorel.commandapi.kotlindsl.commandAPICommand
import dev.jorel.commandapi.kotlindsl.getValue
import dev.jorel.commandapi.kotlindsl.playerArgument
import dev.jorel.commandapi.kotlindsl.playerExecutor
import dev.jorel.commandapi.kotlindsl.stringArgument
import dev.jorel.commandapi.wrappers.*
import dev.jorel.commandapi.wrappers.Rotation
import net.kyori.adventure.inventory.Book
Expand Down Expand Up @@ -1526,6 +1531,20 @@ Converter.convert(essentials, "speed",
}
}

fun delegatedProperties() {
/* ANCHOR: delegatedProperties1 */
CommandAPICommand("mycommand")
.withArguments(StringArgument("string"))
.withArguments(PlayerArgument("target"))
.executesPlayer(PlayerCommandExecutor { player, args ->
val string: String by args
val target: Player by args
// Implementation...
})
.register()
/* ANCHOR_END: delegatedProperties1 */
}

class functions {
/* ANCHOR: functions1 */
class Main : JavaPlugin() {
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package dev.jorel.commandapi.examples.kotlin

import de.tr7zw.changeme.nbtapi.NBTContainer
import dev.jorel.commandapi.*
import dev.jorel.commandapi.arguments.*
import dev.jorel.commandapi.arguments.LiteralArgument.of
import dev.jorel.commandapi.executors.*
import dev.jorel.commandapi.kotlindsl.*
import dev.jorel.commandapi.wrappers.*
import dev.jorel.commandapi.wrappers.Rotation
Expand Down Expand Up @@ -895,6 +892,20 @@ commandAPICommand("cmd") {
/* ANCHOR_END: arguments4 */
}

fun delegatedProperties() {
/* ANCHOR: delegatedProperties1 */
commandAPICommand("mycommand") {
stringArgument("string")
playerArgument("target")
playerExecutor { player, args ->
val string: String by args
val target: Player by args
// Implementation...
}
}
/* ANCHOR_END: delegatedProperties1 */
}

fun help() {
/* ANCHOR: help1 */
commandAPICommand("mycmd") {
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<parent>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit</artifactId>
<artifactId>commandapi-kotlin</artifactId>
<version>9.2.0-SNAPSHOT</version>
</parent>

Expand Down Expand Up @@ -89,5 +89,10 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-core-kotlin</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
76 changes: 76 additions & 0 deletions commandapi-kotlin/commandapi-core-kotlin/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-kotlin</artifactId>
<version>9.2.0-SNAPSHOT</version>
</parent>

<artifactId>commandapi-core-kotlin</artifactId>

<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>16</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>empty-javadoc-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>javadoc</classifier>
<classesDirectory>${basedir}/javadoc</classesDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dev.jorel.commandapi.kotlindsl

import dev.jorel.commandapi.executors.CommandArguments
import kotlin.reflect.KProperty

// CommandArguments DSL
inline operator fun <reified T> CommandArguments.getValue(nothing: Nothing?, property: KProperty<*>) = this[property.name] as T
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

<parent>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-velocity</artifactId>
<artifactId>commandapi-kotlin</artifactId>
<version>9.2.0-SNAPSHOT</version>
</parent>

<artifactId>commandapi-velocity-kotlin</artifactId>
<packaging>jar</packaging>

<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
Expand Down Expand Up @@ -59,13 +58,18 @@
<scope>provided</scope>
</dependency>

<!--- CommandAPI velocity core dependency -->
<!--- CommandAPI dependencies -->
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-velocity-core</artifactId>
<version>9.2.0-SNAPSHOT</version>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-core-kotlin</artifactId>
<version>${project.version}</version>
</dependency>

<!--- Kotlin dependencies -->
<dependency>
Expand All @@ -74,11 +78,5 @@
<version>${kotlin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
15 changes: 15 additions & 0 deletions commandapi-kotlin/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>dev.jorel</groupId>
<artifactId>commandapi</artifactId>
<version>9.2.0-SNAPSHOT</version>
</parent>

<artifactId>commandapi-kotlin</artifactId>
<packaging>pom</packaging>

</project>

This file was deleted.

Loading

Back | FazBrowse Home | New Git URL