用户:快乐的皮卡丘A查看:8 回复:3 评论:8 创建时间:2022-04-27T10:51:07
话不多说,上代码
const gly = [`管喵名称`]//定义管喵变量
world.onChat(({message,entity})=>{//当玩家发起聊天时
if (!gly.includes(entity.player.name)) return//如果玩家不是管喵就返回
if(message[0]==='$'){//如喵天内容第一个字符是$(可改)
try{//尝试运行代码
world.say(`<~${eval(message.slice(1))}`)//世界广播返回值,可以理解成求出代码返回值也就是运行
}catch(baocuo){//如果运行报错
world.say(`<~${baocuo}`)//让世界广播报错
};
};
});