-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bump ver
- Loading branch information
Showing
10 changed files
with
89 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
package me.zodd | ||
|
||
import me.zodd.dsl.command.CommandManager | ||
import org.apache.logging.log4j.Logger | ||
import org.spongepowered.api.Server | ||
import org.spongepowered.api.Sponge | ||
import org.spongepowered.api.command.manager.CommandManager | ||
import org.spongepowered.api.event.EventManager | ||
import org.spongepowered.api.plugin.PluginManager | ||
import org.spongepowered.api.scheduler.Scheduler | ||
import org.spongepowered.api.service.ServiceProvider | ||
import org.spongepowered.plugin.PluginContainer | ||
import org.spongepowered.api.command.manager.CommandManager as SpongeCommandManager | ||
|
||
inline val SpongeServer: Server get() = Sponge.server() | ||
inline val SpongePluginManager: PluginManager get() = Sponge.pluginManager() | ||
inline val SpongeCommandManager: CommandManager get() = Sponge.server().commandManager() | ||
inline val SpongeCommandManager: SpongeCommandManager get() = Sponge.server().commandManager() | ||
inline val SpongeEventManager: EventManager get() = Sponge.eventManager() | ||
inline val SpongeServerServiceManager: ServiceProvider.ServerScoped get() = Sponge.server().serviceProvider() | ||
inline val SpongeGameServiceManager: ServiceProvider.GameScoped get() = Sponge.serviceProvider() | ||
inline val Scheduler: Scheduler get() = Sponge.server().scheduler() | ||
inline val SpongeAsyncScheduler: Scheduler get() = Sponge.asyncScheduler() | ||
inline val Container: PluginContainer get() = API.container | ||
inline val Logger: Logger get() = API.logger | ||
inline val ScriptCommandManager: me.zodd.CommandManager get() = CommandManager() | ||
inline val ScriptCommandManager: CommandManager get() = CommandManager |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package me.zodd.dsl.command | ||
|
||
interface CommandArgument : CommandParameter, CommandFlag |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package me.zodd.dsl.command | ||
|
||
import net.kyori.adventure.text.Component | ||
import org.spongepowered.api.command.CommandResult | ||
import org.spongepowered.api.command.parameter.Parameter | ||
import org.spongepowered.api.command.parameter.managed.Flag | ||
import org.spongepowered.api.command.parameter.CommandContext as SpongeContext | ||
|
||
sealed interface CommandContext { | ||
infix fun <T> SpongeContext.requireOne(param: Parameter.Value<T>): T = this.requireOne(param) | ||
|
||
fun SpongeContext.success(): CommandResult = CommandResult.success() | ||
|
||
infix fun SpongeContext.error(errorMessage: Component): CommandResult = CommandResult.error(errorMessage) | ||
|
||
infix fun SpongeContext.hasFlag(flag: Flag) = this.hasFlag(flag) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package me.zodd.dsl.command | ||
|
||
import org.spongepowered.api.command.parameter.managed.Flag | ||
|
||
sealed interface CommandFlag { | ||
infix fun String.buildFlag(permission: String): Flag { | ||
return asFlag(permission).build() | ||
} | ||
|
||
infix fun String.asFlag(permission: String): Flag.Builder { | ||
return Flag.builder().aliases(this.split(",")).setPermission(permission) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package me.zodd.dsl.command | ||
|
||
import me.zodd.RegistrationHelper | ||
import me.zodd.annotations.ScriptDsl | ||
|
||
@ScriptDsl | ||
object CommandManager : CommandArgument, CommandContext { | ||
|
||
operator fun invoke(initializer: CommandManager.() -> Unit): List<DslCommand> { | ||
this.initializer() | ||
RegistrationHelper.registerCommand(CommandBuilder.builtCommands) | ||
return CommandBuilder.builtCommands | ||
} | ||
|
||
fun command(name: String, initializer: CommandBuilder.(name: String) -> Unit): DslCommand { | ||
val builder = CommandBuilder() | ||
builder.aliases += name | ||
builder.initializer(name) | ||
return builder.buildCommand() | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
api/src/main/kotlin/me/zodd/dsl/command/CommandParameter.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package me.zodd.dsl.command | ||
|
||
import org.spongepowered.api.command.parameter.Parameter | ||
|
||
sealed interface CommandParameter { | ||
infix fun <T> String.withType(type: Parameter.Value.Builder<T>): Parameter.Value<T> { | ||
return type.key(this).build() | ||
} | ||
|
||
infix fun <T> Parameter.Value.Builder<T>.keyedWith(key: String): Parameter.Value<T> { | ||
return this.key(key).build() | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package me.zodd.dsl.command | ||
|
||
import org.spongepowered.api.command.Command | ||
|
||
data class DslCommand( | ||
val aliases: List<String>, | ||
val command: Command.Parameterized, | ||
) { | ||
val baseAlias = aliases[0] | ||
val remainingAliases = aliases.filterNot { it.contentEquals(baseAlias) }.toTypedArray() | ||
} |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ plugins { | |
} | ||
|
||
group = "me.zodd" | ||
version = "0.1.0" | ||
version = "0.1.1" | ||
|
||
repositories { | ||
mavenCentral() | ||
|