-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from SpigotBasics/dev
added ArgumentPathBuilder, renamed ParsedCommand classes
- Loading branch information
Showing
37 changed files
with
195 additions
and
182 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
core/src/main/kotlin/com/github/spigotbasics/core/command/BasicsTabCompleter.kt
This file contains 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,5 +1,5 @@ | ||
package com.github.spigotbasics.core.command | ||
|
||
interface BasicsTabCompleter { | ||
fun tabComplete(context: BasicsCommandContext): MutableList<String>? | ||
fun tabComplete(context: RawCommandContext): MutableList<String>? | ||
} |
This file contains 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
This file contains 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
This file contains 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
28 changes: 27 additions & 1 deletion
28
core/src/main/kotlin/com/github/spigotbasics/core/command/parsed/ArgumentPathBuilder.kt
This file contains 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,3 +1,29 @@ | ||
package com.github.spigotbasics.core.command.parsed | ||
|
||
class ArgumentPathBuilder | ||
import org.bukkit.command.CommandSender | ||
import org.bukkit.permissions.Permission | ||
|
||
class ArgumentPathBuilder<T : ParsedCommandContext> { | ||
private var senderType: SenderType<*> = AnySender | ||
private var arguments = emptyList<CommandArgument<*>>() | ||
private var permissions = emptyList<Permission>() | ||
private var contextBuilder: ((CommandSender, List<Any?>) -> T)? = null | ||
|
||
private fun senderType(senderType: SenderType<*>) = apply { this.senderType = senderType } | ||
|
||
fun playerOnly() = apply { senderType(PlayerSender) } | ||
|
||
fun permissions(vararg permissions: Permission) = apply { this.permissions = permissions.toList() } | ||
|
||
fun arguments(vararg arguments: CommandArgument<*>) = apply { this.arguments = arguments.toList() } | ||
|
||
fun contextBuilder(contextBuilder: (CommandSender, List<Any?>) -> T) = apply { this.contextBuilder = contextBuilder } | ||
|
||
fun build() = | ||
ArgumentPath( | ||
senderType, | ||
arguments, | ||
permissions, | ||
contextBuilder ?: error("Context builder not set"), | ||
) | ||
} |
This file contains 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
2 changes: 1 addition & 1 deletion
2
...ics/core/command/parsed/CommandContext.kt → ...re/command/parsed/ParsedCommandContext.kt
This file contains 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,3 +1,3 @@ | ||
package com.github.spigotbasics.core.command.parsed | ||
|
||
interface CommandContext | ||
interface ParsedCommandContext |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.