chore: initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import type {Bot} from '@wp2508/mineflayer';
|
||||
import type {BaseFunction, FunctionArgument} from '../../../types/bot/function/function.ts';
|
||||
|
||||
export class init implements BaseFunction<number[]> {
|
||||
readonly name = 'change_main_hand_slot';
|
||||
readonly i18n = {
|
||||
lang: 'zh-CN', name: '切换主手槽位', description: '切换主手选中的快捷栏槽位,编号为 0 到 8',
|
||||
};
|
||||
readonly args: FunctionArgument[] = [{
|
||||
name: 'slot', type: 'number',
|
||||
i18n: {lang: 'zh-CN', name: '快捷栏槽位', description: '0 到 8 的整数,分别对应快捷栏第 1 到第 9 格'},
|
||||
}];
|
||||
|
||||
async run(bot: Bot, args: number[]): Promise<boolean> {
|
||||
if (!Array.isArray(args) || args.length !== 1 || !Number.isSafeInteger(args[0])
|
||||
|| args[0] < 0 || args[0] > 8) return false;
|
||||
try {
|
||||
bot.setQuickBarSlot(args[0]);
|
||||
return bot.quickBarSlot === args[0];
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user