diff --git a/silk-core/docs/Module.md b/silk-core/docs/Module.md index c766199c..1b5500bc 100644 --- a/silk-core/docs/Module.md +++ b/silk-core/docs/Module.md @@ -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 diff --git a/silk-core/src/main/kotlin/net/silkmc/silk/core/entity/PlayerExtensions.kt b/silk-core/src/main/kotlin/net/silkmc/silk/core/entity/PlayerExtensions.kt index 8fb62aac..ae0ce7ba 100644 --- a/silk-core/src/main/kotlin/net/silkmc/silk/core/entity/PlayerExtensions.kt +++ b/silk-core/src/main/kotlin/net/silkmc/silk/core/entity/PlayerExtensions.kt @@ -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) diff --git a/silk-core/src/main/kotlin/net/silkmc/silk/core/server/ServerExtensions.kt b/silk-core/src/main/kotlin/net/silkmc/silk/core/server/ServerExtensions.kt new file mode 100644 index 00000000..e5db66a2 --- /dev/null +++ b/silk-core/src/main/kotlin/net/silkmc/silk/core/server/ServerExtensions.kt @@ -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) +}