Data on /give

This commit is contained in:
2026-10-25 15:42:20 -03:00
parent 583cce88c1
commit feb1ddd1f7
7 changed files with 121 additions and 25 deletions
+18
View File
@@ -333,6 +333,20 @@ export function greedy_string(): ArgumentType<string> {
return { greedy: true, parse: (text) => text };
}
// a json value, the rest of the line so it can have spaces, like an item's data
export function json(): ArgumentType<unknown> {
return {
greedy: true,
parse(text) {
try {
return JSON.parse(text);
} catch {
throw new CommandError(`${text} isn't JSON`);
}
},
};
}
// one of a few words, suggested
export function choice<T extends string>(options: readonly T[]): ArgumentType<T> {
return {
@@ -376,3 +390,7 @@ export function item(): ArgumentType<string> {
export function block(): ArgumentType<string> {
return registry_id("blocks", "block");
}
export function fluid(): ArgumentType<string> {
return registry_id("fluids", "fluid");
}