From 30324ebab3a98921df8df940d532f8759917d774 Mon Sep 17 00:00:00 2001 From: Mo9ses <65575019+moisesgamingtv9@users.noreply.github.com> Date: Thu, 8 Dec 2022 21:50:04 -0500 Subject: [PATCH] ROT V3 part 3 --- manifest.json | 20 ++-- scripts/Papers/CommandPaper/CommandPaper.js | 25 ++--- scripts/Papers/LangPaper.js | 2 +- scripts/Papers/PlayerPaper.js | 104 ++++++++++++------ .../Papers/paragraphs/ConvertersParagraphs.js | 12 +- scripts/Papers/paragraphs/ExtrasParagraphs.js | 18 +-- scripts/Stories/Management/rank.js | 23 ++-- scripts/Stories/Server/clearchat.js | 2 +- scripts/main.js | 21 ++-- 9 files changed, 122 insertions(+), 105 deletions(-) diff --git a/manifest.json b/manifest.json index 186ca93..7362a13 100644 --- a/manifest.json +++ b/manifest.json @@ -1,18 +1,18 @@ { "format_version": 2, "header": { - "name": "§4§lROT V3 §aPart 2", + "name": "§3§lROT V3 §aPart 3", "description": "§cWelcome to §4§lROT§r§c! §4§lROT§r§c is a Minecraft Bedrock addon designed to make §6§lYOUR§r§c Minecraft server §4§lBETTER§r§c! Remember to use \"§7!help§c\"!", - "uuid": "62dd78b5-8197-4f8f-97cd-8f1f9ddc4c9f", + "uuid": "d061afe6-08db-4925-b1a4-655f7f69a7dd", "version": [ - 2, 3, - 0 + 0, + 3 ], "min_engine_version": [ 1, - 18, - 31 + 19, + 40 ] }, "modules": [ @@ -21,9 +21,9 @@ "type": "data", "uuid": "42f17752-1b47-4dbe-82b7-0b0d96192698", "version": [ - 2, 3, - 0 + 0, + 3 ] }, { @@ -32,9 +32,9 @@ "language": "javascript", "uuid": "a188da6f-fccc-473a-94aa-f6fa7ef59962", "version": [ - 2, 3, - 0 + 0, + 3 ], "entry": "scripts/main.js" } diff --git a/scripts/Papers/CommandPaper/CommandPaper.js b/scripts/Papers/CommandPaper/CommandPaper.js index d4b229e..999430b 100644 --- a/scripts/Papers/CommandPaper/CommandPaper.js +++ b/scripts/Papers/CommandPaper/CommandPaper.js @@ -23,7 +23,6 @@ import Server from '../../ServerBook.js'; import lang from '../LangPaper.js'; import quick from '../../main.js'; import { DatabasePaper } from '../DatabasePaper'; -import { getNameColor, getRanks } from '../paragraphs/ExtrasParagraphs.js'; /** * This is what initiates the commands */ @@ -40,7 +39,7 @@ world.events.beforeChat.subscribe(data => { return; if (!ROT.has('setup')) return data.cancel = false; - const message = data.message.charAt(0).toUpperCase() + data.message.slice(1), rank = `§7[${getRanks(data.sender.name)}§r§7] ${getNameColor(data.sender.name)}`; + const message = data.message.charAt(0).toUpperCase() + data.message.slice(1), rank = `§7[${player.getPrefixes().join('§r§7, ')}§r§7] ${player.getNameColors().join('')}`; let currentHour = time.getUTCHours(), AMPM = ''; if (currentHour < 0) currentHour = currentHour + 24; @@ -48,7 +47,7 @@ world.events.beforeChat.subscribe(data => { AMPM = currentHour === 12 ? 'PM' : 'AM', currentHour === 0 ? currentHour = 12 : null; else currentHour = currentHour - 12, AMPM = 'PM'; - return Array.from(world.getPlayers()).forEach(plr => plr.tell(`${rank}${data.sender.nameTag}§r§7 ${currentHour}:${time.getUTCMinutes() < 10 ? '0' + time.getUTCMinutes() : time.getUTCMinutes()} ${AMPM}: §f${message}`)); + return Array.from(world.getPlayers()).forEach(plr => plr.tell(`${rank}${player.nameTag}§r§7 ${currentHour}:${time.getUTCMinutes() < 10 ? '0' + time.getUTCMinutes() : time.getUTCMinutes()} ${AMPM}: §f${message}`)); } const args = data.message.slice(quick.prefix.length).trim().split(/\s+/), command = args.shift().toLowerCase(); Server.command.run(command, Server.player.paperPlayer(data.sender, { from: command }), args); @@ -56,7 +55,7 @@ world.events.beforeChat.subscribe(data => { /* * Welcome to the CommandPaper! * Main Developer: Mo9ses - * Sub developer: notbeer + * Sub developer: Nobody! * Link to name: Command Paper */ export class CommandPaper { @@ -127,18 +126,15 @@ export class CommandPaper { for (const a of nextArgs) { if (!['sta', 'dyn'].includes(cmd.aR[a].tY)) continue; - if (cmd.aR[a].tY === 'sta') { - if (cmd.aR[a].tV[0].includes(args[0])) - return { aRN: a, tV: args[1], nA: args.slice(cmd.aR[a].tV[1] ? 2 : 1) }; + if (cmd.aR[a].tY === 'sta') if (staticBook[cmd.aR[a].tV[0]].val.includes(args[0])) - return { aRN: a, tV: args[1], nA: args.slice(cmd.aR[a].tV[1] ? 2 : 1) }; - continue; - } + return { aRN: a, tV: cmd.aR[a].tV[1] ? args[1] : cmd.aR[a].tV[0], nA: args.slice(cmd.aR[a].tV[1] ? 2 : 1) }; + else + continue; const res = cmd.aR[a].tV[0].find((v) => v === '*' || args.slice(0, v.split(' ').length).join(' ') === v); if (res) return { aRN: a, tV: cmd.aR[a].tV[2] ? args.slice(0, cmd.aR[a].tV[2]) : cmd.aR[a].tV[0].includes('*') ? args.slice(0, res.split(' ').length).join(' ') : args[0], nA: cmd.aR[a].tV[2] ? args.slice(cmd.aR[a].tV[2]) : args.slice(res.split(' ').length) }; } - ; const argTypes = {}; nextArgs?.filter(a => !['sta', 'dyn'].includes(cmd.aR[a].tY))?.forEach(a => Object.assign(argTypes, { [cmd.aR[a].tY]: a })); const allTypes = Object.keys(argTypes); @@ -189,7 +185,8 @@ export class CommandPaper { else testing = false; } - if (left !== args[0]) + const minMax = cmd.aR[argTypes['plr']].tV; + if (left !== args[0] && (minMax?.min ?? 0) <= time && time <= (minMax?.max ?? 0)) return { aRN: argTypes['tim'], tV: time, nA: args.slice(1) }; } } @@ -209,7 +206,7 @@ export class CommandPaper { if (type.tY === 'boo') return 'true'; if (type.tV === 'tim') - return ''; + return MS(type.tV.max); return; } /** @@ -226,7 +223,7 @@ export class CommandPaper { return player.error(ROT.read('setup') ? lang.cmd.unknown : lang.setup.notSetup, 'ROT'); if (!cmd.rM.cM) return player.error(lang.cmd.useForm, 'ROT'); - if (player.isAdmin ? true : cmd.admin || (cmd.tags?.length ? !player.hasTags(cmd.tags) : false)) + if (player.isAdmin ? false : cmd.admin || (cmd.tags?.length ? !player.hasTags(cmd.tags) : false)) return player.error(lang.cmd.noPerms, 'ROT'); if (!cmd.sT[0].length && args.length) return player.error(lang.cmd.noArgs, 'ROT'); diff --git a/scripts/Papers/LangPaper.js b/scripts/Papers/LangPaper.js index 054e0d7..36d72e7 100644 --- a/scripts/Papers/LangPaper.js +++ b/scripts/Papers/LangPaper.js @@ -37,7 +37,7 @@ export const startLang = () => Object.assign(Lang, { useForm: 'This command cannot be execute in chat. Use "§3!ui§1" to run it as a form command.', wrongPrefix: `Sorry, the prefix on this server is now "§3${quick.prefix}§1"`, noArgs: 'This commands does not have any arguments! You only need to type the command.', - notAArg: (cmd, before, err, afther, tip) => `Not sure what you mean by "§3${quick.prefix + cmd}${before.length ? ` ${before.join(' ')}` : ''}§r §b${err}§r§3${afther ? ` §e${afther}` : ''}§r§1". §b${err[0].toUpperCase() + err.slice(1)}§r§1 is not a vaild argument.${tip ? ` Maybe try typing §a${tip}§1?` : ''}`, + notAArg: (cmd, before, err, afther, tip) => `Not sure what you mean by "§3${quick.prefix + cmd}${before.length ? ` ${before.join(' ')}` : ''}§r §b${err}§r§3${afther ? ` §3${afther}` : ''}§r§1". §b${err[0].toUpperCase() + err.slice(1)}§r§1 is not a vaild argument.${tip ? ` Maybe try typing §a${tip}§1?` : ''}`, noPerms: 'You do not have permission to execute this command.', noArgPerm: 'You do not have permission to execute this argument. How do you even know about it?', missingArgs: (cmd, args, tip) => `The command you typed: "§3${quick.prefix + cmd}${args.length ? ' ' + args.join(' ') : ''}§1" is missing arguments!${tip ? ` Maybe try typing §a${tip}§1 at the end.` : ''} If you need more help, type "§3${quick.prefix}help ${cmd}§1" in chat :)`, diff --git a/scripts/Papers/PlayerPaper.js b/scripts/Papers/PlayerPaper.js index 9671eb6..7eb1e6b 100644 --- a/scripts/Papers/PlayerPaper.js +++ b/scripts/Papers/PlayerPaper.js @@ -16,51 +16,67 @@ Website: https://www.rotmc.ml Docs: https://docServer.google.com/document/d/1hasFU7_6VOBfjXrQ7BE_mTzwacOQs5HC21MJNaraVgg Thank you! */ -import { world, Player, Location } from '@minecraft/server'; -import { DatabasePaper } from './DatabasePaper.js'; -import { MessageForm } from './FormPaper.js'; +import { world, Player } from '@minecraft/server'; +import { DatabasePaper } from './DatabasePaper'; import quick from '../main.js'; -const playerData = {}, cache = {}; +/* + * Defining possibly arbitrary varibles +*/ +const ranksDB = new DatabasePaper('ranks'); +/* + * Welcome to the PlayerPaper! + * Main Developer: Mo9ses + * Sub developer: Nobody! + * Link to name: Player Paper +*/ export class PlayerPaper { + /** + * Converts a normal Minecraft player to the ROT paper standard + * @param {Player | string} player The player you want to transform + * @param {playerData} data Additional paper data + * @returns {PlayerType} Don't get this confused with playertype + */ paperPlayer(player, data) { const plr = player instanceof Player ? player : Array.from(world.getPlayers()).find(p => p.nameTag.toLowerCase() === player.toLowerCase()); if (!player) return; - data.from = data.from[0].toUpperCase() + data.from.slice(1); + if (data?.from) + data.from = data.from[0].toUpperCase() + data.from.slice(1); // @ts-ignore const db = new DatabasePaper(plr.id.toString(16).toUpperCase(), 'PLR'); return Object.assign(player, { isAdmin: plr.hasTag(quick.adminTag), - write: (key, value) => { - Object.assign(cache[plr.nameTag], { [key]: value }); - db.write(key, value); - }, - read: (key) => cache[plr.nameTag]?.[key] ?? db.read(key), - delete: (key) => { - db.delete(key); - delete cache[plr.nameTag][key]; - }, + write: (key, value) => db.write(key, value), + read: (key) => db.read(key), + delete: (key) => db.delete(key), send: (msg, from) => { plr.runCommandAsync('playsound random.toast @s ~~~ 1 0.5'); - plr.tell({ 'rawtext': [{ 'text': `§l§3${from ? `${from} ` : data.from ? `${data.from} ` : ''}§3>>§r§1 ` }, { 'text': msg }] }); + plr.tell({ 'rawtext': [{ 'text': `§l§3${from ? `${from} ` : data?.from ? `${data.from} ` : ''}§3>>§r§1 ` }, { 'text': msg }] }); }, tip: (msg, from) => { plr.runCommandAsync('playsound random.toast @s ~~~ 1 0.5'); - plr.tell({ 'rawtext': [{ 'text': `§l§1${from ? `${from} ` : data.from ? `${data.from} ` : ''}§aTIP §3>>§r§1 ` }, { 'text': msg }] }); + plr.tell({ 'rawtext': [{ 'text': `§l§1${from ? `${from} ` : data?.from ? `${data.from} ` : ''}§aTIP §3>>§r§1 ` }, { 'text': msg }] }); }, error: (msg, from) => { plr.runCommandAsync('playsound random.glass @s ~~~ 1 0.5'); - plr.tell({ 'rawtext': [{ 'text': `§l§1${from ? `${from} ` : data.from ? `${data.from} ` : ''}§3Error >>§r§1 ` }, { 'text': msg }] }); + plr.tell({ 'rawtext': [{ 'text': `§l§1${from ? `${from} ` : data?.from ? `${data.from} ` : ''}§3Error >>§r§1 ` }, { 'text': msg }] }); }, - UIerror: (msg, buttons, from) => { - const UI = new MessageForm(); - let val = false; - UI.setTitle(`${from ?? `§c§l${data.from} Error` ?? '§c§lError!'}`); - UI.setBody(`§c${msg}`); - UI.setButton1(buttons[0] ?? '§e§lTry again'); - UI.setButton1(buttons[1] ?? '§c§lClose'); - UI.send(plr, res => val = Boolean(res.selection)); - return val; + /** + * @function getRanks Gets the ranks of a player + * @example getRanks(Mo9ses); + */ + getPrefixes: () => { + const ranks = plr.getTags().filter(tag => tag.startsWith('rank:')).map(c => c.replace('rank:', '').trim()); + ranksDB.allKeys().forEach(k => plr.hasTag(ranksDB.read(k).tag) && ranks.push(ranksDB.read(k).prefix)); + return ranks.length ? ranks : [quick.defaultRank]; + }, + /** + * @function getColors Gets the color of a player + * @example getColor(Mo9ses); + */ + getNameColors: () => { + const colors = plr.getTags().filter(tag => tag.startsWith('colors:')).map(c => c.replace('rank:', '').trim()); + return colors.length ? colors : [quick.defaultNameColor]; }, /** * Get players score on a specific objective @@ -75,10 +91,6 @@ export class PlayerPaper { tags.forEach(t => !plr.hasTag(t) && (all = false)); return all; }, - veiwLocation: (dist) => { - const l = plr.viewVector; - return new Location(l.x, l.y, l.z); - }, veiwBlock: (getBlock) => { const l = plr.getBlockFromViewVector({ includeLiquidBlocks: true, maxDistance: 300 }); return getBlock ? l : [l.x, l.y, l.z]; @@ -86,9 +98,30 @@ export class PlayerPaper { veiwEntity: (getPos) => { const l = plr.getEntitiesFromViewVector({ maxDistance: 300 }); return getPos ? [l[0].location.x, l[0].location.y, l[0].location.z] : l; - } + }, + // UIerror: (msg: string, buttons: string[], from?: string): boolean => { + // const UI = new MessageForm(); + // let val = false; + // UI.setTitle(`${from ?? `§c§l${data.from} Error` ?? '§c§lError!'}`); + // UI.setBody(`§c${msg}`); + // UI.setButton1(buttons[0] ?? '§e§lTry again'); + // UI.setButton1(buttons[1] ?? '§c§lClose'); + // UI.send(plr, res => val = Boolean(res.selection)); + // return val; + // }, + // veiwLocation: (dist: [number, number, number]) => { //To be finished + // const l = plr.viewVector; + // return new Location(l.x, l.y, l.z); + // }, }); } + /** + * Used to execute certain functions on players that might be offline or online + * @param name The name of the player + * @param from Where this will be used + * @param player Additional information sent if the player is online + * @returns {OfflineType} + */ offlinePlayer(name, from, player) { return { nameTag: name, @@ -97,8 +130,7 @@ export class PlayerPaper { }; } } -world.events.playerJoin.subscribe(({ player }) => { - new DatabasePaper(player.id, 'PLR'); - Object.assign(cache, { [player.name]: { 'default': 0 } }); -}); -world.events.playerLeave.subscribe(data => delete cache[data.playerName]); +/* + * I don't think this is useful... + */ +world.events.playerJoin.subscribe(({ player }) => new DatabasePaper(player.id, 'PLR')); diff --git a/scripts/Papers/paragraphs/ConvertersParagraphs.js b/scripts/Papers/paragraphs/ConvertersParagraphs.js index a55baa0..0f005a9 100644 --- a/scripts/Papers/paragraphs/ConvertersParagraphs.js +++ b/scripts/Papers/paragraphs/ConvertersParagraphs.js @@ -88,12 +88,12 @@ const toMS = (value) => { const toDuration = (value, { compactDuration, fullDuration, avoidDuration } = {}) => { const absMs = Math.abs(value); const duration = [ - { short: 'w', long: 'week', duration: Math.floor(absMs / 6.048e+8) }, - { short: 'd', long: 'day', duration: Math.floor(absMs / 8.64e+7) % 7 }, - { short: 'h', long: 'hour', duration: Math.floor(absMs / 3.6e+6) % 24 }, - { short: 'm', long: 'minute', duration: Math.floor(absMs / 60000) % 60 }, - { short: 's', long: 'second', duration: Math.floor(absMs / 1000) % 60 }, - { short: 'ms', long: 'millisecond', duration: absMs % 1000 } + { short: 'W', long: 'Week', duration: Math.floor(absMs / 6.048e+8) }, + { short: 'D', long: 'Day', duration: Math.floor(absMs / 8.64e+7) % 7 }, + { short: 'H', long: 'Hour', duration: Math.floor(absMs / 3.6e+6) % 24 }, + { short: 'M', long: 'Minute', duration: Math.floor(absMs / 60000) % 60 }, + { short: 'S', long: 'Second', duration: Math.floor(absMs / 1000) % 60 }, + { short: 'MS', long: 'Millisecond', duration: absMs % 1000 } ]; const mappedDuration = duration .filter(obj => obj.duration !== 0 && avoidDuration ? fullDuration && !avoidDuration.map(v => v.toLowerCase()).includes(obj.short) : obj.duration) diff --git a/scripts/Papers/paragraphs/ExtrasParagraphs.js b/scripts/Papers/paragraphs/ExtrasParagraphs.js index 9e1ca53..137573c 100644 --- a/scripts/Papers/paragraphs/ExtrasParagraphs.js +++ b/scripts/Papers/paragraphs/ExtrasParagraphs.js @@ -45,24 +45,8 @@ world.events.tick.subscribe(() => { * Notes: I don't really know what goes on down here... * Sub developer: Mo9ses * Link to name: Miscellaneous -**************************************** -* @function getRanks Gets the ranks of a player you -* @param {string} player the player -* @example getRanks(Mo9ses); -*/ -export const getRanks = (player) => { - const ranks = Array.from(world.getPlayers()).find(n => n.name.toLowerCase() === player.toLowerCase()).getTags()?.filter(tag => tag.startsWith('rank:')); - return ranks?.[0] ? ranks.map(c => c.replace('rank:', '').trim()) : [config.defaultRank]; -}, -/** -* @function getColors Gets the color of a player -* @param {string} player the player -* @example getColor(Mo9ses); */ -getNameColor = (player) => { - const colors = Array.from(world.getPlayers()).find(n => n.name.toLowerCase() === player.toLowerCase()).getTags()?.filter(tag => tag.startsWith('colors:')); - return colors?.[0] ? colors.map(c => c.replace('rank:', '').trim()) : [config.defaultNameColor]; -}, +export const /** * @function getChat Gets the chat color of a player * @param {string} player the player diff --git a/scripts/Stories/Management/rank.js b/scripts/Stories/Management/rank.js index 711da84..cf4b3b9 100644 --- a/scripts/Stories/Management/rank.js +++ b/scripts/Stories/Management/rank.js @@ -27,14 +27,14 @@ const cmd = Server.command.create({ admin: true, developers: ['Mo9ses'] }); -cmd.startingArgs(['create', 'delete', 'plr', 'remove', 'prefix']); +cmd.startingArgs(['create', 'delete', 'list', 'plr', /*'prefix'*/]); cmd.staticType('create', 'create', (plr, val, args) => { if (db.has(val)) return plr.error(`A rank with the name "§3${val}§1" has already been created!`); - db.write(val, { tag: val, prefix: args[0].length ? args[0].join(' ') : '§eNew Rank' }); - plr.send(`Successfully created rank §3${val}§1 with the prefix "§r${args[0].length ? args[0].join(' ') : '§eNew Rank'}§r§1"!`); -}, 'set prefix', true, false); -cmd.dynamicType('set prefix', '*'); + db.write(val, { tag: val, prefix: args[0]?.length ? args[0].join(' ') : '§eNew Rank' }); + plr.send(`Successfully created rank §3${val}§1 with the prefix "§r${args[0]?.length ? args[0].join(' ') : '§eNew Rank'}§r§1"!`); +}, 'any', true, false); +cmd.dynamicType('any', '*'); cmd.staticType('delete', 'delyeet', (plr, val) => { if (!db.has(val)) return plr.error(`There aren't any ranks with the name "§3${val}§1". Are you sure it isn't a tag?`); @@ -47,9 +47,12 @@ cmd.staticType('list', 'list', plr => { return plr.send('There are no ranks on the server at this moment'); plr.send(`Here are all of the ranks!\n${db.allKeys().map(r => `§3Name: §1${r[0].toUpperCase() + r.slice(1)}§3, tag: §1${db.read(r).tag}§3, prefix: §1${db.read(r).prefix}§r`).join('\n')}`); }, null, false); -cmd.playerType('set player', (plr, plr2, args) => { +cmd.playerType('plr', (plr, plr2, args) => { + if (args[0] === 'add') + plr2.addTag(args[1].join(' ')); + else + plr.removeTag(args[1].join(' ')); + plr.send(`The rank "§3${args[1].join(' ')}§1" have been ${args[0] === 'add' ? '§agranted§1 to' : '§crevoked§1 from'} §3${plr2.nameTag}§1!`); }, true, ['add', 'remove']); -cmd.staticType('add', 'add', (plr, _, args) => { -}, 'set player', false); -cmd.staticType('remove', 'remove', (plr, _, args) => { -}, 'set player', false); +cmd.staticType('add', 'add', null, 'any', false); +cmd.staticType('remove', 'remove', null, 'any', false); diff --git a/scripts/Stories/Server/clearchat.js b/scripts/Stories/Server/clearchat.js index fcd3d70..8466081 100644 --- a/scripts/Stories/Server/clearchat.js +++ b/scripts/Stories/Server/clearchat.js @@ -27,5 +27,5 @@ const cmd = Server.command.create({ }); cmd.callback((plr) => { Server.broadcast('\n\n\n\n\n'.repeat(100)); - Server.broadcast(`The chat has been cleared by §c${plr.nameTag}§r§1!`, 'ROT'); + Server.broadcast(`The chat has been cleared by §3${plr.nameTag}§r§1!`, 'ROT'); }); diff --git a/scripts/main.js b/scripts/main.js index d23f3e4..b754158 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -20,6 +20,7 @@ import { world } from '@minecraft/server'; import { config } from './config.js'; import { DatabasePaper } from './Papers/DatabasePaper.js'; import { startLang } from './Papers/LangPaper.js'; +import Server from './ServerBook.js'; /** * Quick * This handles in game configuration @@ -40,14 +41,14 @@ world.events.worldInitialize.subscribe(() => { * startup function. This will start ROT */ import './Stories/ROT/setup.js'; -export function startup() { - const time = new Date().getTime(), Server = import('./ServerBook.js'); - Server.then(i => i.default.command.list.splice(i.default.command.list.findIndex(c => c.name === 'setup'), 1)); +export async function startup() { + ROT.write('setup', 1); + const time = new Date().getTime(); + Server.command.list.splice(Server.command.list.findIndex(c => c.name === 'setup'), 1); if (config.useQuick && ROT.has('ServerConfig')) Object.entries(ROT.read('ServerConfig')).forEach(s => Object.assign(quick, { [s[0]]: s[1] })); - Object.keys(quick.toggle).forEach(c => Object.keys(quick.toggle[c]).forEach(cmd => import(`./Stories/${c}/${cmd}.js`).catch(e => console.warn(`Failed to import command "${cmd}" from category "${c}" ${e}: ${e.stack}`)))); - ROT.write('setup', 1); - Server.then(s => s.default.command.list.forEach((cmd, i) => { + await Object.keys(quick.toggle).forEach(c => Object.keys(quick.toggle[c]).forEach(cmd => import(`./Stories/${c}/${cmd}.js`).catch(e => console.warn(`Failed to import command "${cmd}" from category "${c}" ${e}: ${e.stack}`)))); + Server.command.list.forEach((cmd, i) => { try { const length = Object.keys(cmd.aR).length, fakeArgs = cmd.aR; if (length && !cmd.sT[0].length) @@ -55,7 +56,7 @@ export function startup() { if (!length && cmd.sT[0].length) throw Error(`Command "${cmd.name}" has starting args, but no args.`); if (cmd.sT[0].some(a => !cmd.aR.hasOwnProperty(a))) - console.warn(`Some of the starting arguments for the command "${cmd.name}" don't exist.`); + throw Error(`Some of the starting arguments for the command "${cmd.name}" don't exist.`); Object.assign(fakeArgs, { '-1': { nA: cmd.sT[0] } }); for (const arg in fakeArgs) { if (fakeArgs[arg].nN && !fakeArgs[arg].nA.length) @@ -71,8 +72,8 @@ export function startup() { } catch (e) { console.warn(e); - s.default.command.list.splice(i, 1); + Server.command.list.splice(i, 1); } - })); - Server.then(i => i.default.broadcast(`ROT has been loaded in §3${new Date().getTime() - time}§1 milliseconds!`, 'Server')); + }); + Server.broadcast(`ROT has been loaded in §3${new Date().getTime() - time}§1 milliseconds!`, 'Server'); }