pumpkin-plugin-wit/v0.1/command.wit
Alexander Medvedev 41d8c71c65 first commit
2026-05-19 17:43:50 +02:00

225 lines
5.4 KiB
Plaintext

interface command {
use %world.{%world, entity};
use player.{player};
use block-entity.{command-block-entity};
use common.{position, block-pos, locale, game-mode};
use item-stack.{item-stack};
use server.{server, difficulty};
use text.{text-component};
variant command-error {
invalid-consumption(option<string>),
invalid-requirement,
permission-denied,
command-failed(text-component),
}
resource command-node {
literal: static func(name: string) -> command-node;
argument: static func(name: string, %type: argument-type) -> command-node;
then: func(node: command-node);
execute-with-handler-id: func(handler-id: u32);
require-with-handler-id: func(handler-id: u32);
}
variant argument-type {
%bool,
float(tuple<option<f32>, option<f32>>),
double(tuple<option<f64>, option<f64>>),
integer(tuple<option<s32>, option<s32>>),
long(tuple<option<s64>, option<s64>>),
%string(string-type),
entities,
entity,
players,
game-profile,
block-pos,
column-pos,
position3d,
position2d,
block-state,
block-predicate,
item,
item-predicate,
color,
component,
style,
message,
nbt-compound-tag,
nbt-tag,
nbt-path,
objective,
objective-criteria,
operation,
particle,
angle,
rotation,
scoreboard-slot,
score-holder(bool),
swizzle,
team,
item-slot,
resource-location,
mob-effect,
function,
entity-anchor,
int-range,
float-range,
dimension,
gamemode,
difficulty,
time(option<s32>),
%resource(string),
resource-or-tag(string),
resource-or-tag-key(string),
resource-key(string),
template-mirror,
template-rotation,
uuid,
}
record entity-argument {
single: bool,
players-only: bool,
}
variant command-sender-type {
rcon,
console,
player(player),
command-block(tuple<command-block-entity, %world>),
dummy,
}
enum permission-level {
zero,
one,
two,
three,
four,
}
resource command-sender {
get-command-sender-type: func() -> command-sender-type;
get-name: func() -> string;
send-message: func(text: text-component);
send-system-message: func(text: text-component);
send-error: func(text: text-component);
set-success-count: func(count: s32);
is-player: func() -> bool;
is-console: func() -> bool;
as-player: func() -> option<player>;
permission-level: func() -> permission-level;
has-permission-level: func(level: permission-level) -> bool;
has-permission: func(server: borrow<server>, node: string) -> bool;
position: func() -> option<position>;
%world: func() -> option<%world>;
get-locale: func() -> locale;
should-receive-feedback: func() -> bool;
should-broadcast-console-to-ops: func() -> bool;
should-track-output: func() -> bool;
}
enum string-type {
single-word,
quotable,
greedy,
}
enum suggestion-type {
ask-server,
all-recipes,
available-sounds,
available-biomes,
summonable-entities,
}
variant arg {
simple(string),
msg(string),
%bool(bool),
item(string),
item-predicate(string),
resource-location(string),
block(string),
block-predicate(string),
time(s32),
num(result<number, not-in-bounds>),
block-pos(block-pos),
pos3d(tuple<f64, f64, f64>),
pos2d(tuple<f64, f64>),
rotation(tuple<f32, bool, f32, bool>),
gamemode(game-mode),
difficulty(difficulty),
players(list<player>),
particle(string),
text-component(text-component),
bossbar-color(bossbar-color),
bossbar-style(bossbar-style),
sound-category(sound-category),
damage-type(string),
effect(string),
enchantment(string),
entity-anchor(entity-anchor),
}
enum bossbar-color {
pink,
blue,
red,
green,
yellow,
purple,
white,
}
enum bossbar-style {
no-division,
notches6,
notches10,
notches12,
notches20,
}
enum sound-category {
master,
music,
records,
weather,
blocks,
hostile,
neutral,
players,
ambient,
voice,
}
enum entity-anchor {
eyes,
feet,
}
variant number {
float64(f64),
float32(f32),
int32(s32),
int64(s64),
}
variant not-in-bounds {
lower-bound(tuple<number, number>),
upper-bound(tuple<number, number>),
}
resource consumed-args {
get-value: func(key: string) -> arg;
}
resource command {
/// First name is primary, rest are aliases
constructor(names: list<string>, description: string);
then: func(node: command-node);
execute-with-handler-id: func(handler-id: u32);
}
}