radium-v2/commands/validate.js

36 lines
No EOL
1.5 KiB
JavaScript

const desc = "validate a hash or check that you are authed";
const usages = " - validate [hash]";
const trustLevel = 0;
function inject (client, packet) {
const command = ((args) => {
function toNBTUUID(uuid) {
return `[I;${uuid.replace(/-/g, '').match(/.{8}/g).map(str => Number.parseInt(str, 16)).map(num => num & 0x80000000 ? num - 0xffffffff - 1 : num).join(',')}]`;
}
if (args[0]) {
switch (args[0]) {
case "" + client.trustedHash + "":
client.tellraw(`@a[nbt={UUID:${toNBTUUID(packet.sender)}}]`, { text: "Valid Trusted Hash", color: "green" } );
break;
case "" + client.ownerHash + "":
client.tellraw(`@a[nbt={UUID:${toNBTUUID(packet.sender)}}]`, { text: "Valid Owner Hash", color: "green" } );
break;
default:
client.tellraw(`@a[nbt={UUID:${toNBTUUID(packet.sender)}}]`, { text: "Invalid Hash", color: "red" } );
break;
}
} else {
if (client.trusted.includes(packet.sender)) {
client.tellraw(`@a`, { text: "You are authed for Trusted", color: "green" } );
} if (client.owner.includes(packet.sender)) {
client.tellraw(`@a`, { text: "You are authed for Owner", color: "green" } );
}
}
})
client.runCommand = command;
return command;
}
module.exports = { inject, desc, usages, trustLevel };