Created
April 18, 2019 04:31
-
-
Save ItsDoot/f05ada3c47e6d751dbcd39a3040967b3 to your computer and use it in GitHub Desktop.
SKC Example
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
| package frontier.skcexample | |
| import frontier.skc.KClassCallable | |
| import frontier.skc.annotation.Command | |
| import frontier.skc.annotation.Source | |
| import frontier.skc.match.SKCMatcher | |
| import frontier.skc.value.commandSource | |
| import frontier.skc.value.player | |
| import frontier.skc.value.string | |
| import frontier.ske.server | |
| import org.spongepowered.api.command.CommandSource | |
| import org.spongepowered.api.entity.living.player.Player | |
| import org.spongepowered.api.event.Listener | |
| import org.spongepowered.api.event.game.state.GameInitializationEvent | |
| import org.spongepowered.api.plugin.Plugin | |
| import org.spongepowered.api.text.Text | |
| @Plugin(id = "skc-example", name = "SKC Example", version = "1.0.0") | |
| class SKCExamplePlugin { | |
| @Listener | |
| fun onInit(event: GameInitializationEvent) { | |
| val matcher = SKCMatcher().apply { | |
| this.commandSource() | |
| this.player() | |
| this.string() | |
| } | |
| val callable = KClassCallable(CommandMyCmd::class, matcher) | |
| callable.register(this) | |
| } | |
| } | |
| @Command("mycmd") | |
| object CommandMyCmd { | |
| @Command("test") | |
| fun test(@Source src: CommandSource, target: Player, message: String) { | |
| target.sendMessage(Text.of("${src.name} says: $message")) | |
| } | |
| @Command("another") | |
| object SubAnother { | |
| @Command("broadcast") | |
| fun broadcast(@Source src: CommandSource, message: String) { | |
| server.broadcastChannel.send(Text.of("[Broadcast] ${src.name} says: ")) | |
| } | |
| } | |
| class Test | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment