{"rawtext":[null]}
at tryShow (forceShow.js:15)```forceshow.js ```js
import { system } from "@minecraft/server";
import { FormCancelationReason } from "@minecraft/server-ui";
export async function forceShow(player, form, timeout = Infinity) {
const startTick = system.currentTick;
return new Promise((resolve, reject) => {
function tryShow() {
if (system.currentTick - startTick >= timeout) {
reject(new Error(`Timed out after ${timeout} ticks`));
return;
}
form
.show(player)
.then((response) => {
if (
!response ||
response.cancelationReason === FormCancelationReason.UserBusy
) {
system.run(tryShow); // Erneut versuchen
} else {
resolve(response);
}
})
.catch((error) => reject(error));
}
system.run(tryShow);
});
}
```the form is in the attached file ```openPermissionEditor```
#problem with form
1 messages · Page 1 of 1 (latest)
The problem appears when this line +code is added
.textField("Rank Name", {
placeholder: "Name des Rangs",
default: rank.rankName,
});
[Scripting][error]-Unhandled promise rejection: TypeError: Native type conversion failed. Function argument [2] expected type: ModalFormDataTextFieldOptions | undefined at openPermissionEditor (commands/permissions/permissions.js:56)
at openRankSelectionMenu (commands/permissions/permissions.js:36)``````js
export async function openPermissionEditor(player, rankId) {
const rank = ranksList[rankId];
if (!rank) {
player.sendMessage(`doesn't exist.`);
return;
}
const allPermissions = getAllPermissions();
const currentPermissions = new Set(rank.allowedCommands || []);
const form = new ModalFormData()
.title(`Edit Rank: ${rank.rankName}`)
.textField("Rank Name", "Name des Rangs", "test");
for (const cmd of allPermissions) {
if (typeof cmd !== "string") continue;
const isAllowed =
currentPermissions.has("*") ||
Array.from(currentPermissions).some((allowed) =>
allowed.includes("#")
? cmd.startsWith(allowed.split("#")[0])
: allowed === cmd
);
form.toggle(cmd, { defaultValue: isAllowed });
}
try {
const response = await form.show(player);
if (response.canceled) {
player.sendMessage("§7abgebrochen.");
return;
}
const values = response.formValues;
if (!Array.isArray(values) || values.length === 0) {
player.sendMessage("§cUngültige Formularantwort.");
return;
}
const newRankName = values[0];
if (typeof newRankName === "string" && newRankName.trim().length > 0) {
rank.rankName = newRankName.trim();
} else {
player.sendMessage("§cUngültiger Rangname. Nichts geändert.");
}
const newAllowed = [];
for (let i = 1; i < values.length; i++) {
if (values[i]) newAllowed.push(allPermissions[i - 1]);
}
rank.allowedCommands = newAllowed;
saveRanks();
} catch (err) {
const msg = err?.message || "Unbekannter Fehler";
console.log(`${msg}`);
}
}```
Ur textField’s arguments are wrong, should be like this: (header, placeholder, { defaultValue: blahblah, tooltip; dhdjevshs })
So the .textField("Rank Name", "Name of Rank", "test"); must be .textField("Rank Name", "Name of Rank"); and there is no 3rd option?
There is a third option but it is wrapped in an Object, or {}, and holds optional extra functions like defaultValue and tooltip. Besides that it is just the 2 .textField(label, placeholder) that is required
Could you give me an example