Skip to content

Commit

Permalink
core: add executeCommand extension for MinecraftServer (#24)
Browse files Browse the repository at this point in the history
* add executeCommand extension for server

* reformat server executeCommand extension

* add docs for the core.server package

Co-authored-by: Jakob K <[email protected]>
  • Loading branch information
btwonion and jakobkmar authored Jun 24, 2022
1 parent dcd9632 commit 40f0006
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions silk-core/docs/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Operator functions and extensions for working with vectors

Simple extensions for sending packets

# Package net.silkmc.silk.core.server

General extensions for the Minecraft server

# Package net.silkmc.silk.core.task

Coroutine utilities (for example a Minecraft main thread dispatcher) and coroutine task functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import net.minecraft.world.entity.player.Player

/**
* Executes the given [command] for this player.
*
* Note that the [command] must not contain the slash prefix.
*/
fun Player.executeCommand(command: String) {
server?.commands?.performCommand(createCommandSourceStack(), command)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.silkmc.silk.core.server

import net.minecraft.server.MinecraftServer

/**
* Executes the given [command] for this server.
*
* Note that the [command] must not contain the slash prefix.
*/
fun MinecraftServer.executeCommand(command: String) {
commands.performCommand(createCommandSourceStack(), command)
}

0 comments on commit 40f0006

Please sign in to comment.