API
명령어와 권한
타입이 지정된 인수, 하위 명령어, 별칭, 자동 제안, 권한을 갖춘 명령어. 누군가 잘못 사용하면, 직접 메시지를 쓰지 않아도 올바른 사용법이 표시됩니다.
CraftScript에서
명령어 하나에 파일 하나, commands/ 안에 명령어와 같은 이름으로 둡니다.
command pay(to: player, amount: int) requires "eco.pay" alias "send" describe "코인 보내기" {
if player == null { return "플레이어만 사용할 수 있습니다" }
if amount <= 0 { return "&c금액은 양수여야 합니다" }
return "{to.name}에게 코인 {amount}개를 보냈습니다"
}command announce(message: text) requires "eco.admin" describe "모두에게 공지" {
broadcast("&6[공지] {message}")
}인수가 빠졌거나 기대한 타입이 아니면 플레이어에게 예를 들어 Missing <amount>. Usage: /pay <to> <amount> 또는 'abc' is not a whole number가 표시됩니다.
| 타입 | 받는 값 |
|---|---|
player |
접속 중인 플레이어, 자동 제안 포함 |
int, number |
정수, 숫자 |
bool |
true/false, yes/no, on/off |
string |
단어 하나, 또는 따옴표로 묶은 여러 단어 |
text |
줄의 나머지 전부 |
id |
게임 id(minecraft:stone) |
인수를 선택 사항으로 만들려면 ?를 붙입니다(target: player?).
Kotlin에서
package com.example.homes.commands
object HomeCommand {
private val homes = mutableMapOf<UUID, Location>()
fun register() {
Crafting.commands.command("home") {
description = "집으로 순간이동"
alias("h")
executes { c -> c.player.teleport(homes[c.player.uuid] ?: c.fail("&c설정된 집이 없습니다")) }
sub("set") {
executes { c -> homes[c.player.uuid] = c.player.location; c.reply("&a집을 설정했습니다") }
}
sub("of") {
permission = "homes.others"
player("target")
executes { c -> c.player.teleport(homes[c.player("target").uuid] ?: c.fail("&c집이 없습니다")) }
}
}
}
}인수: string, greedy, int, double, bool, player, identifier, 각각 optional 사용 가능. executes 안에서는 c.player(실행한 사람), c.player("target"), c.int("n"), c.getOrNull<Int>("n"), c.reply(…), 그리고 오류 메시지와 함께 중단하는 c.fail(…)을 사용할 수 있습니다.
권한
Crafting에는 그룹 기반 권한이 포함되어 있으며 config/crafting/permissions.json에 있습니다. 서버 관리자(OP)는 모든 권한을 가집니다.
{
"groups": {
"default": ["homes.use", "eco.pay"],
"mod": ["homes.*", "chatguard.*", "-homes.others"],
"admin": ["*"]
},
"players": {
"Steve": { "groups": ["mod"], "permissions": ["homes.others"] }
}
}*는 모든 권한을,homes.*는homes.로 시작하는 모든 권한을 부여합니다.-권한은 그 권한을 거부합니다. 가장 구체적인 규칙이 우선하며, 동등하면 거부가 우선합니다.- 모든 플레이어는
default그룹에 속합니다. - 다른 모드와 겹치지 않도록 권한 앞에 모드 id를 붙이세요(
rubies.give).
Crafting 명령어
게임에서도, 서버 콘솔에서도 작동합니다.
| 명령어 | 하는 일 |
|---|---|
/crafting(또는 /cf) |
버전과 도움말. |
/crafting mods |
불러온 모드와 그 상태. |
/crafting reload <id> |
스크립트나 플러그인을 다시 불러옵니다. crafting.admin이 필요합니다. |
/crafting profile |
처음 실행하면 측정을 시작하고, 두 번째에는 각 모드의 시간을 보여 줍니다. |
/crafting info |
시작 시간, 리스너, 작업, 메모리, 콘텐츠. |