现场问一下这个问题如何解决,我的模式切换代码JavaScript片段:
- function mode(player) {
- const mode = new ModalFormData()
- .title(`游戏模式`)
- .dropdown(`模式选择`,[`生存`,`创造`,`冒险`,`旁观`],0)
- .show(player)
- .then((mode) => {
- if (mode.formValues[0] == `生存`) {
- player.runCommand(`gamemode survival`)
- } else if (mode.formValues[0] == `创造`){
- player.runCommand(`gamemode creative`)
- } else if (mode.formValues[0] == `冒险`) {
- player.runCommand(`gamemode adventure`)
- } else {
- player.runCommand(`gamemode spectator`)
- }
- })
- }
复制代码
|