From 7cec4037ead3287c1d88db4274824b21d9d57d51 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Thu, 14 Jul 2022 09:01:43 -0400 Subject: messing around with repo stuff --- src/commands/moulberry-bush/neuRepo.ts | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/commands/moulberry-bush/neuRepo.ts (limited to 'src/commands/moulberry-bush/neuRepo.ts') diff --git a/src/commands/moulberry-bush/neuRepo.ts b/src/commands/moulberry-bush/neuRepo.ts new file mode 100644 index 0000000..24f83ad --- /dev/null +++ b/src/commands/moulberry-bush/neuRepo.ts @@ -0,0 +1,47 @@ +import { BushCommand, clientSendAndPermCheck, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; +import { ApplicationCommandOptionType, AutocompleteInteraction, CacheType, PermissionFlagsBits } from 'discord.js'; + +export default class NeuRepoCommand extends BushCommand { + public static items: { name: string; id: string }[] = []; + + public constructor() { + super('neuRepo', { + aliases: ['neu-repo', 'repo-item', 'neu-item', 'item-repo'], + category: "Moulberry's Bush", + description: 'Get information about an item from the NEU item repo.', + usage: ['neu-repo '], + examples: ['neu-repo BARRIER'], + args: [ + { + id: 'item', + description: 'The item id that you would like to find neu item information about.', + type: 'string', + prompt: 'What SkyBlock item would you like to get information about?', + retry: '{error} Pick a valid SkyBlock item ID. Try using the slash command for a better experience.', + slashType: ApplicationCommandOptionType.String, + autocomplete: true + } + /* { + id: 'dangerous', + description: 'Whether or not to use the dangerous branch.', + prompt: 'Would you like to use the dangerous branch instead of the master branch?', + match: 'flag', + flag: ['--dangerous', '-d'], + default: false, + optional: true, + slashType: ApplicationCommandOptionType.Boolean + } */ + ], + slash: true, + clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + userPermissions: [] + }); + } + + public override async exec( + message: CommandMessage | SlashMessage, + args: { item: ArgType<'string'> /* dangerous: ArgType<'flag'> */ } + ) {} + + public override async autocomplete(interaction: AutocompleteInteraction) {} +} -- cgit From 2ec1de170091178263e53ecfce744c7a0710a409 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Fri, 5 Aug 2022 20:11:45 -0400 Subject: wip tooltip rendering --- .eslintignore | 5 + assets/minecraft_font.ttf | Bin 0 -> 15700 bytes src/commands/moulberry-bush/neuRepo.ts | 153 +++++++++++++- src/lib/common/util/Minecraft.ts | 234 +++++++++++---------- src/lib/common/util/Minecraft_Test.ts | 86 ++++++++ test.js | 365 +++++++++++++++++++++++++++++++++ test.png | Bin 0 -> 41015 bytes tooltips.nnb | 118 +++++++++++ tsconfig.eslint.json | 15 ++ tsconfig.json | 13 +- 10 files changed, 865 insertions(+), 124 deletions(-) create mode 100644 .eslintignore create mode 100644 assets/minecraft_font.ttf create mode 100644 src/lib/common/util/Minecraft_Test.ts create mode 100644 test.js create mode 100644 test.png create mode 100644 tooltips.nnb create mode 100644 tsconfig.eslint.json (limited to 'src/commands/moulberry-bush/neuRepo.ts') diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..c531fde --- /dev/null +++ b/.eslintignore @@ -0,0 +1,5 @@ +dist +.yarn +node_modules +*.nnb +tooltips* \ No newline at end of file diff --git a/assets/minecraft_font.ttf b/assets/minecraft_font.ttf new file mode 100644 index 0000000..61b4610 Binary files /dev/null and b/assets/minecraft_font.ttf differ diff --git a/src/commands/moulberry-bush/neuRepo.ts b/src/commands/moulberry-bush/neuRepo.ts index 24f83ad..9d76810 100644 --- a/src/commands/moulberry-bush/neuRepo.ts +++ b/src/commands/moulberry-bush/neuRepo.ts @@ -1,5 +1,16 @@ import { BushCommand, clientSendAndPermCheck, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; -import { ApplicationCommandOptionType, AutocompleteInteraction, CacheType, PermissionFlagsBits } from 'discord.js'; +import canvas from 'canvas'; +import { + ApplicationCommandOptionType, + AttachmentBuilder, + AutocompleteInteraction, + CacheType, + PermissionFlagsBits +} from 'discord.js'; +import { dirname, join } from 'path'; +import tinycolor from 'tinycolor2'; +import { fileURLToPath } from 'url'; +import { formattingInfo, RawNeuItem } from '../../lib/common/util/Minecraft.js'; export default class NeuRepoCommand extends BushCommand { public static items: { name: string; id: string }[] = []; @@ -34,14 +45,148 @@ export default class NeuRepoCommand extends BushCommand { ], slash: true, clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), - userPermissions: [] + userPermissions: [], + ownerOnly: true }); } public override async exec( message: CommandMessage | SlashMessage, args: { item: ArgType<'string'> /* dangerous: ArgType<'flag'> */ } - ) {} + ) { + const itemPath = join(import.meta.url, '..', '..', '..', '..', '..', 'neu-item-repo-dangerous', 'items', `${args.item}.json`); + const item = (await import(itemPath, { assert: { type: 'json' } })).default as RawNeuItem; - public override async autocomplete(interaction: AutocompleteInteraction) {} + const toolTip = this.toolTip(item); + + return message.util.reply({ + files: [new AttachmentBuilder(toolTip, { name: `${item.internalname}.png`, description: item.displayname })] + }); + } + + public toolTip(item: RawNeuItem): Buffer { + canvas.registerFont(join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..', 'assets', 'Faithful.ttf'), { + family: 'Faithful' + }); + + const background = '#100010'; + + const width = 250; + const height = 250; + const scale = 10; + + const itemRender = canvas.createCanvas(width, height), + ctx = itemRender.getContext('2d'); + + ctx.globalAlpha = 0.94; + ctx.fillStyle = background; + + // top outside + ctx.fillRect(scale, 0, width - 2 * scale, scale); + + // bottom outside + ctx.fillRect(scale, height - scale, width - 2 * scale, scale); + + // left outside + ctx.fillRect(0, scale, scale, height - 2 * scale); + + // right outside + ctx.fillRect(width - scale, scale, scale, height - 2 * scale); + + // middle + ctx.fillRect(2 * scale, 2 * scale, width - 4 * scale, height - 4 * scale); + + ctx.globalAlpha = 0.78; + + const borderColorStart = parseInt(new tinycolor(this.getPrimaryColour(item.displayname)).toHex(), 16); + const borderColorEnd = ((borderColorStart & 0xfefefe) >> 1) | (borderColorStart & 0xff000000); + + const borderColorStartStr = `#${borderColorStart.toString(16)}`; + const borderColorEndStr = `#${borderColorEnd.toString(16)}`; + + ctx.fillStyle = borderColorStartStr; + + // top highlight + ctx.fillRect(scale, scale, width - 2 * scale, scale); + + // left highlight + ctx.fillRect(scale, 2 * scale, scale, height - 3 * scale); + + // bottom highlight + { + const x = 2 * scale, + y = height - 2 * scale, + w = width - 3 * scale, + h = scale; + const gradient = ctx.createLinearGradient(x, y, x + w, y + h); + gradient.addColorStop(0, borderColorStartStr); + gradient.addColorStop(1, borderColorEndStr); + ctx.fillStyle = gradient; + + ctx.fillRect(x, y, w, h); + } + + // right highlight + { + const x = width - 2 * scale, + y = 2 * scale, + w = scale, + h = height - 4 * scale; + const gradient = ctx.createLinearGradient(x, y, x + w, y + h); + gradient.addColorStop(0, borderColorStartStr); + gradient.addColorStop(1, borderColorEndStr); + ctx.fillStyle = gradient; + + ctx.fillRect(x, y, w, h); + } + + item.displayname.split(''); + + return itemRender.toBuffer(); + } + + // stolen from NEU and modified + public getPrimaryColourCode(displayname: string): code { + let lastColourCode = -99; + let currentColour = 0; + const mostCommon = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + for (let i = 0; i < displayname.length; i++) { + const c = displayname.charAt(i); + if (c === '\u00A7') { + lastColourCode = i; + } else if (lastColourCode === i - 1) { + const colIndex = '0123456789abcdef'.indexOf(c); + if (colIndex >= 0) { + currentColour = colIndex; + } else { + currentColour = 0; + } + } else if ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(c) >= 0) { + if (currentColour > 0) { + mostCommon[currentColour] = mostCommon[currentColour]++; + } + } + } + let mostCommonCount = 0; + for (let index = 0; index < mostCommon.length; index++) { + if (mostCommon[index] > mostCommonCount) { + mostCommonCount = mostCommon[index]; + currentColour = index; + } + } + + return '0123456789abcdef'.charAt(currentColour); + } + + // stolen from NEU and modified + public getPrimaryColour(displayname: string) { + const code = this.getPrimaryColourCode(displayname); + return formattingInfo[`§${code}`].foregroundDarker; + } + + public override async autocomplete(interaction: AutocompleteInteraction) { + return interaction.respond([{ name: 'Blazetekk™ Ham Radio', value: 'BLAZETEKK_HAM_RADIO' }]); + } } + +type code = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f'; diff --git a/src/lib/common/util/Minecraft.ts b/src/lib/common/util/Minecraft.ts index b4b013f..a12ebf2 100644 --- a/src/lib/common/util/Minecraft.ts +++ b/src/lib/common/util/Minecraft.ts @@ -1,6 +1,5 @@ import { Byte, Int, parse } from '@ironm00n/nbt-ts'; import { BitField } from 'discord.js'; -import fs from 'fs/promises'; import path from 'path'; import { fileURLToPath } from 'url'; @@ -34,22 +33,118 @@ export enum FormattingCodes { // https://minecraft.fandom.com/wiki/Formatting_codes export const formattingInfo = { - [FormattingCodes.Black]: { foreground: '#000000', background: '#000000', ansi: '\u001b[0;30m' }, - [FormattingCodes.DarkBlue]: { foreground: '#0000AA', background: '#00002A', ansi: '\u001b[0;34m' }, - [FormattingCodes.DarkGreen]: { foreground: '#00AA00', background: '#002A00', ansi: '\u001b[0;32m' }, - [FormattingCodes.DarkAqua]: { foreground: '#00AAAA', background: '#002A2A', ansi: '\u001b[0;36m' }, - [FormattingCodes.DarkRed]: { foreground: '#AA0000', background: '#2A0000', ansi: '\u001b[0;31m' }, - [FormattingCodes.DarkPurple]: { foreground: '#AA00AA', background: '#2A002A', ansi: '\u001b[0;35m' }, - [FormattingCodes.Gold]: { foreground: '#FFAA00', background: '#2A2A00', ansi: '\u001b[0;33m' }, - [FormattingCodes.Gray]: { foreground: '#AAAAAA', background: '#2A2A2A', ansi: '\u001b[0;37m' }, - [FormattingCodes.DarkGray]: { foreground: '#555555', background: '#151515', ansi: '\u001b[0;90m' }, - [FormattingCodes.Blue]: { foreground: '#5555FF', background: '#15153F', ansi: '\u001b[0;94m' }, - [FormattingCodes.Green]: { foreground: '#55FF55', background: '#153F15', ansi: '\u001b[0;92m' }, - [FormattingCodes.Aqua]: { foreground: '#55FFFF', background: '#153F3F', ansi: '\u001b[0;96m' }, - [FormattingCodes.Red]: { foreground: '#FF5555', background: '#3F1515', ansi: '\u001b[0;91m' }, - [FormattingCodes.LightPurple]: { foreground: '#FF55FF', background: '#3F153F', ansi: '\u001b[0;95m' }, - [FormattingCodes.Yellow]: { foreground: '#FFFF55', background: '#3F3F15', ansi: '\u001b[0;93m' }, - [FormattingCodes.White]: { foreground: '#FFFFFF', background: '#3F3F3F', ansi: '\u001b[0;97m' }, + [FormattingCodes.Black]: { + foreground: 'rgb(0, 0, 0)', + foregroundDarker: 'rgb(0, 0, 0)', + background: 'rgb(0, 0, 0)', + backgroundDarker: 'rgb(0, 0, 0)', + ansi: '\u001b[0;30m' + }, + [FormattingCodes.DarkBlue]: { + foreground: 'rgb(0, 0, 170)', + foregroundDarker: 'rgb(0, 0, 118)', + background: 'rgb(0, 0, 42)', + backgroundDarker: 'rgb(0, 0, 29)', + ansi: '\u001b[0;34m' + }, + [FormattingCodes.DarkGreen]: { + foreground: 'rgb(0, 170, 0)', + foregroundDarker: 'rgb(0, 118, 0)', + background: 'rgb(0, 42, 0)', + backgroundDarker: 'rgb(0, 29, 0)', + ansi: '\u001b[0;32m' + }, + [FormattingCodes.DarkAqua]: { + foreground: 'rgb(0, 170, 170)', + foregroundDarker: 'rgb(0, 118, 118)', + background: 'rgb(0, 42, 42)', + backgroundDarker: 'rgb(0, 29, 29)', + ansi: '\u001b[0;36m' + }, + [FormattingCodes.DarkRed]: { + foreground: 'rgb(170, 0, 0)', + foregroundDarker: 'rgb(118, 0, 0)', + background: 'rgb(42, 0, 0)', + backgroundDarker: 'rgb(29, 0, 0)', + ansi: '\u001b[0;31m' + }, + [FormattingCodes.DarkPurple]: { + foreground: 'rgb(170, 0, 170)', + foregroundDarker: 'rgb(118, 0, 118)', + background: 'rgb(42, 0, 42)', + backgroundDarker: 'rgb(29, 0, 29)', + ansi: '\u001b[0;35m' + }, + [FormattingCodes.Gold]: { + foreground: 'rgb(255, 170, 0)', + foregroundDarker: 'rgb(178, 118, 0)', + background: 'rgb(42, 42, 0)', + backgroundDarker: 'rgb(29, 29, 0)', + ansi: '\u001b[0;33m' + }, + [FormattingCodes.Gray]: { + foreground: 'rgb(170, 170, 170)', + foregroundDarker: 'rgb(118, 118, 118)', + background: 'rgb(42, 42, 42)', + backgroundDarker: 'rgb(29, 29, 29)', + ansi: '\u001b[0;37m' + }, + [FormattingCodes.DarkGray]: { + foreground: 'rgb(85, 85, 85)', + foregroundDarker: 'rgb(59, 59, 59)', + background: 'rgb(21, 21, 21)', + backgroundDarker: 'rgb(14, 14, 14)', + ansi: '\u001b[0;90m' + }, + [FormattingCodes.Blue]: { + foreground: 'rgb(85, 85, 255)', + foregroundDarker: 'rgb(59, 59, 178)', + background: 'rgb(21, 21, 63)', + backgroundDarker: 'rgb(14, 14, 44)', + ansi: '\u001b[0;94m' + }, + [FormattingCodes.Green]: { + foreground: 'rgb(85, 255, 85)', + foregroundDarker: 'rgb(59, 178, 59)', + background: 'rgb(21, 63, 21)', + backgroundDarker: 'rgb(14, 44, 14)', + ansi: '\u001b[0;92m' + }, + [FormattingCodes.Aqua]: { + foreground: 'rgb(85, 255, 255)', + foregroundDarker: 'rgb(59, 178, 178)', + background: 'rgb(21, 63, 63)', + backgroundDarker: 'rgb(14, 44, 44)', + ansi: '\u001b[0;96m' + }, + [FormattingCodes.Red]: { + foreground: 'rgb(255, 85, 85)', + foregroundDarker: 'rgb(178, 59, 59)', + background: 'rgb(63, 21, 21)', + backgroundDarker: 'rgb(44, 14, 14)', + ansi: '\u001b[0;91m' + }, + [FormattingCodes.LightPurple]: { + foreground: 'rgb(255, 85, 255)', + foregroundDarker: 'rgb(178, 59, 178)', + background: 'rgb(63, 21, 63)', + backgroundDarker: 'rgb(44, 14, 44)', + ansi: '\u001b[0;95m' + }, + [FormattingCodes.Yellow]: { + foreground: 'rgb(255, 255, 85)', + foregroundDarker: 'rgb(178, 178, 59)', + background: 'rgb(63, 63, 21)', + backgroundDarker: 'rgb(44, 44, 14)', + ansi: '\u001b[0;93m' + }, + [FormattingCodes.White]: { + foreground: 'rgb(255, 255, 255)', + foregroundDarker: 'rgb(178, 178, 178)', + background: 'rgb(63, 63, 63)', + backgroundDarker: 'rgb(44, 44, 44)', + ansi: '\u001b[0;97m' + }, [FormattingCodes.Obfuscated]: { ansi: '\u001b[8m' }, [FormattingCodes.Bold]: { ansi: '\u001b[1m' }, @@ -68,7 +163,7 @@ export type SbRecipe = { }; export type InfoType = 'WIKI_URL' | ''; -type Slayer = `${'WOLF' | 'BLAZE' | 'EMAN'}_${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`; +export type Slayer = `${'WOLF' | 'BLAZE' | 'EMAN'}_${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`; export interface RawNeuItem { itemid: McItemId; @@ -128,87 +223,8 @@ export function removeMCFormatting(str: string) { } const repo = path.join(__dirname, '..', '..', '..', '..', '..', 'neu-item-repo-dangerous'); -const itemPath = path.join(repo, 'items'); -const items = await fs.readdir(itemPath); - -// for (let i = 0; i < 5; i++) { -for (const path_ of items) { - // const randomItem = items[Math.floor(Math.random() * items.length)]; - // console.log(randomItem); - const item = (await import(path.join(itemPath, /* randomItem */ path_), { assert: { type: 'json' } })).default as RawNeuItem; - if (/.*?((_MONSTER)|(_NPC)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$/.test(item.internalname)) continue; - if (!/.*?;[0-5]$/.test(item.internalname)) continue; - /* console.log(path_); - console.dir(item, { depth: Infinity }); */ - - /* console.log('==========='); */ - const nbt = parse(item.nbttag) as NbtTag; - - if (nbt?.SkullOwner?.Properties?.textures?.[0]?.Value) { - nbt.SkullOwner.Properties.textures[0].Value = parse( - Buffer.from(nbt.SkullOwner.Properties.textures[0].Value, 'base64').toString('utf-8') - ) as string; - } - - if (nbt.ExtraAttributes?.petInfo) { - nbt.ExtraAttributes.petInfo = JSON.parse(nbt.ExtraAttributes.petInfo as any as string); - } - // delete nbt.display?.Lore; - - console.dir(nbt, { depth: Infinity }); - console.log('==========='); - - /* if (nbt?.display && nbt.display.Name !== item.displayname) - console.log(`${path_} display name mismatch: ${mcToAnsi(nbt.display.Name)} != ${mcToAnsi(item.displayname)}`); - - if (nbt?.ExtraAttributes && nbt?.ExtraAttributes.id !== item.internalname) - console.log(`${path_} internal name mismatch: ${mcToAnsi(nbt?.ExtraAttributes.id)} != ${mcToAnsi(item.internalname)}`); */ - - /* console.log('==========='); - - console.log(mcToAnsi(item.displayname)); - console.log(item.lore.map((l) => mcToAnsi(l)).join('\n')); */ - - /* const keys = [ - 'itemid', - 'displayname', - 'nbttag', - 'damage', - 'lore', - 'recipe', - 'internalname', - 'modver', - 'infoType', - 'info', - 'crafttext', - 'vanilla', - 'useneucraft', - 'slayer_req', - 'clickcommand', - 'x', - 'y', - 'z', - 'island', - 'recipes', - 'parent', - 'noseal' - ]; - - Object.keys(item).forEach((k) => { - if (!keys.includes(k)) throw new Error(`Unknown key: ${k}`); - }); - - if ( - 'slayer_req' in item && - !new Array(10).flatMap((_, i) => ['WOLF', 'BLAZE', 'EMAN'].map((e) => e + (i + 1)).includes(item.slayer_req!)) - ) - throw new Error(`Unknown slayer req: ${item.slayer_req!}`); */ - - /* console.log('=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-'); */ -} - -interface NbtTag { +export interface NbtTag { overrideMeta?: Byte; Unbreakable?: Int; ench?: string[]; @@ -218,22 +234,22 @@ interface NbtTag { ExtraAttributes?: ExtraAttributes; } -interface SkullOwner { +export interface SkullOwner { Id?: string; Properties?: { textures?: { Value?: string }[]; }; } -interface NbtTagDisplay { +export interface NbtTagDisplay { Lore?: string[]; color?: Int; Name?: string; } -type RuneId = string; +export type RuneId = string; -interface ExtraAttributes { +export interface ExtraAttributes { originTag?: Origin; id?: string; generator_tier?: Int; @@ -244,7 +260,7 @@ interface ExtraAttributes { petInfo?: PetInfo; } -interface PetInfo { +export interface PetInfo { type: 'ZOMBIE'; active: boolean; exp: number; @@ -253,7 +269,7 @@ interface PetInfo { candyUsed: number; } -type Origin = 'SHOP_PURCHASE'; +export type Origin = 'SHOP_PURCHASE'; const neuConstantsPath = path.join(repo, 'constants'); const neuPetsPath = path.join(neuConstantsPath, 'pets.json'); @@ -261,14 +277,14 @@ const neuPets = (await import(neuPetsPath, { assert: { type: 'json' } })) as Pet const neuPetNumsPath = path.join(neuConstantsPath, 'petnums.json'); const neuPetNums = (await import(neuPetNumsPath, { assert: { type: 'json' } })) as PetNums; -interface PetsConstants { +export interface PetsConstants { pet_rarity_offset: Record; pet_levels: number[]; custom_pet_leveling: Record; pet_types: Record; } -interface PetNums { +export interface PetNums { [key: string]: { [key: string]: { '1': { @@ -284,7 +300,7 @@ interface PetNums { }; } -class NeuItem { +export class NeuItem { public itemId: McItemId; public displayName: string; public nbtTag: NbtTag; @@ -315,6 +331,8 @@ class NeuItem { const curve = petInfoTier?.stats_levelling_curve?.split(';'); + // todo: finish copying from neu + const minStatsLevel = parseInt(curve?.[0] ?? '0'); const maxStatsLevel = parseInt(curve?.[0] ?? '100'); @@ -323,7 +341,7 @@ class NeuItem { } } -function mcToAnsi(str: string) { +export function mcToAnsi(str: string) { for (const format in formattingInfo) { str = str.replaceAll(format, formattingInfo[format as keyof typeof formattingInfo].ansi); } diff --git a/src/lib/common/util/Minecraft_Test.ts b/src/lib/common/util/Minecraft_Test.ts new file mode 100644 index 0000000..26ca648 --- /dev/null +++ b/src/lib/common/util/Minecraft_Test.ts @@ -0,0 +1,86 @@ +import fs from 'fs/promises'; +import path from 'path'; +import { fileURLToPath } from 'url'; +import { mcToAnsi, RawNeuItem } from './Minecraft.js'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const repo = path.join(__dirname, '..', '..', '..', '..', '..', 'neu-item-repo-dangerous'); +const itemPath = path.join(repo, 'items'); +const items = await fs.readdir(itemPath); + +// for (let i = 0; i < 5; i++) { +for (const path_ of items) { + // const randomItem = items[Math.floor(Math.random() * items.length)]; + // console.log(randomItem); + const item = (await import(path.join(itemPath, /* randomItem */ path_), { assert: { type: 'json' } })).default as RawNeuItem; + if (/.*?((_MONSTER)|(_NPC)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$/.test(item.internalname)) continue; + if (!/.*?;[0-5]$/.test(item.internalname)) continue; + /* console.log(path_); + console.dir(item, { depth: Infinity }); */ + + /* console.log('==========='); */ + // const nbt = parse(item.nbttag) as NbtTag; + + // if (nbt?.SkullOwner?.Properties?.textures?.[0]?.Value) { + // nbt.SkullOwner.Properties.textures[0].Value = parse( + // Buffer.from(nbt.SkullOwner.Properties.textures[0].Value, 'base64').toString('utf-8') + // ) as string; + // } + + // if (nbt.ExtraAttributes?.petInfo) { + // nbt.ExtraAttributes.petInfo = JSON.parse(nbt.ExtraAttributes.petInfo as any as string); + // } + + // delete nbt.display?.Lore; + + // console.dir(nbt, { depth: Infinity }); + // console.log('==========='); + + /* if (nbt?.display && nbt.display.Name !== item.displayname) + console.log(`${path_} display name mismatch: ${mcToAnsi(nbt.display.Name)} != ${mcToAnsi(item.displayname)}`); + + if (nbt?.ExtraAttributes && nbt?.ExtraAttributes.id !== item.internalname) + console.log(`${path_} internal name mismatch: ${mcToAnsi(nbt?.ExtraAttributes.id)} != ${mcToAnsi(item.internalname)}`); */ + + // console.log('==========='); + + console.log(mcToAnsi(item.displayname)); + console.log(item.lore.map((l) => mcToAnsi(l)).join('\n')); + + /* const keys = [ + 'itemid', + 'displayname', + 'nbttag', + 'damage', + 'lore', + 'recipe', + 'internalname', + 'modver', + 'infoType', + 'info', + 'crafttext', + 'vanilla', + 'useneucraft', + 'slayer_req', + 'clickcommand', + 'x', + 'y', + 'z', + 'island', + 'recipes', + 'parent', + 'noseal' + ]; + + Object.keys(item).forEach((k) => { + if (!keys.includes(k)) throw new Error(`Unknown key: ${k}`); + }); + + if ( + 'slayer_req' in item && + !new Array(10).flatMap((_, i) => ['WOLF', 'BLAZE', 'EMAN'].map((e) => e + (i + 1)).includes(item.slayer_req!)) + ) + throw new Error(`Unknown slayer req: ${item.slayer_req!}`); */ + + /* console.log('=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-'); */ +} diff --git a/test.js b/test.js new file mode 100644 index 0000000..d0840ec --- /dev/null +++ b/test.js @@ -0,0 +1,365 @@ +/* eslint-disable */ +// @ts-check + +import { createCanvas, registerFont } from 'canvas'; +import fs from 'fs/promises'; +import path, { dirname, join } from 'path'; +import tinycolor from 'tinycolor2'; +import { fileURLToPath } from 'url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +registerFont(join(__dirname, 'assets', 'Faithful.ttf'), { family: 'ComplianceSans' }); +registerFont(join(dirname(fileURLToPath(import.meta.url)), 'assets', 'Roboto-Regular.ttf'), { family: 'Roboto' }); + +/** @typedef {string} McItemId */ +/** @typedef {string} SbItemId */ +/** @typedef {string} MojangJson */ +/** @typedef {`${SbItemId}:${number}` | ''} SbRecipeItem */ +/** @typedef {{[Location in `${'A' | 'B' | 'C'}${1 | 2 | 3}`]: SbRecipeItem;}} SbRecipe */ +/** @typedef {'WIKI_URL' | ''} InfoType */ +/** @typedef {`${'WOLF' | 'BLAZE' | 'EMAN'}_${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`} Slayer */ +/** @typedef {'0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'|'a'|'b'|'c'|'d'|'e'|'f'} code */ +/** + * @typedef RawNeuItem + * @property {McItemId} itemid + * @property {string} displayname + * @property {MojangJson} nbttag + * @property {number} damage + * @property {string[]} lore + * @property {SbRecipe} [recipe] + * @property {SbItemId} internalname + * @property {InfoType} infoType + * @property {string[]} [info] + * @property {string} crafttext + * @property {boolean} [vanilla] + * @property {boolean} [useneucraft] + * @property {Slayer} [slayer_req] + * @property {string} [clickcommand] + * @property {number} [x] + * @property {number} [y] + * @property {number} [z] + * @property {string} [island] + * @property {{ type: string; cost: any[]; result: SbItemId }[]} [recipes] + * @property {SbItemId} [parent] + * @property {boolean} [noseal] + */ + +const FormattingCodes = { + Black: '§0', + DarkBlue: '§1', + DarkGreen: '§2', + DarkAqua: '§3', + DarkRed: '§4', + DarkPurple: '§5', + Gold: '§6', + Gray: '§7', + DarkGray: '§8', + Blue: '§9', + Green: '§a', + Aqua: '§b', + Red: '§c', + LightPurple: '§d', + Yellow: '§e', + White: '§f', + + Obfuscated: '§k', + Bold: '§l', + Strikethrough: '§m', + Underline: '§n', + Italic: '§o', + Reset: '§r' +}; + +const formattingInfo = { + [FormattingCodes.Black]: { + foreground: 'rgb(0, 0, 0)', + foregroundDarker: 'rgb(0, 0, 0)', + background: 'rgb(0, 0, 0)', + backgroundDarker: 'rgb(0, 0, 0)', + ansi: '\u001b[0;30m' + }, + [FormattingCodes.DarkBlue]: { + foreground: 'rgb(0, 0, 170)', + foregroundDarker: 'rgb(0, 0, 118)', + background: 'rgb(0, 0, 42)', + backgroundDarker: 'rgb(0, 0, 29)', + ansi: '\u001b[0;34m' + }, + [FormattingCodes.DarkGreen]: { + foreground: 'rgb(0, 170, 0)', + foregroundDarker: 'rgb(0, 118, 0)', + background: 'rgb(0, 42, 0)', + backgroundDarker: 'rgb(0, 29, 0)', + ansi: '\u001b[0;32m' + }, + [FormattingCodes.DarkAqua]: { + foreground: 'rgb(0, 170, 170)', + foregroundDarker: 'rgb(0, 118, 118)', + background: 'rgb(0, 42, 42)', + backgroundDarker: 'rgb(0, 29, 29)', + ansi: '\u001b[0;36m' + }, + [FormattingCodes.DarkRed]: { + foreground: 'rgb(170, 0, 0)', + foregroundDarker: 'rgb(118, 0, 0)', + background: 'rgb(42, 0, 0)', + backgroundDarker: 'rgb(29, 0, 0)', + ansi: '\u001b[0;31m' + }, + [FormattingCodes.DarkPurple]: { + foreground: 'rgb(170, 0, 170)', + foregroundDarker: 'rgb(118, 0, 118)', + background: 'rgb(42, 0, 42)', + backgroundDarker: 'rgb(29, 0, 29)', + ansi: '\u001b[0;35m' + }, + [FormattingCodes.Gold]: { + foreground: 'rgb(255, 170, 0)', + foregroundDarker: 'rgb(178, 118, 0)', + background: 'rgb(42, 42, 0)', + backgroundDarker: 'rgb(29, 29, 0)', + ansi: '\u001b[0;33m' + }, + [FormattingCodes.Gray]: { + foreground: 'rgb(170, 170, 170)', + foregroundDarker: 'rgb(118, 118, 118)', + background: 'rgb(42, 42, 42)', + backgroundDarker: 'rgb(29, 29, 29)', + ansi: '\u001b[0;37m' + }, + [FormattingCodes.DarkGray]: { + foreground: 'rgb(85, 85, 85)', + foregroundDarker: 'rgb(59, 59, 59)', + background: 'rgb(21, 21, 21)', + backgroundDarker: 'rgb(14, 14, 14)', + ansi: '\u001b[0;90m' + }, + [FormattingCodes.Blue]: { + foreground: 'rgb(85, 85, 255)', + foregroundDarker: 'rgb(59, 59, 178)', + background: 'rgb(21, 21, 63)', + backgroundDarker: 'rgb(14, 14, 44)', + ansi: '\u001b[0;94m' + }, + [FormattingCodes.Green]: { + foreground: 'rgb(85, 255, 85)', + foregroundDarker: 'rgb(59, 178, 59)', + background: 'rgb(21, 63, 21)', + backgroundDarker: 'rgb(14, 44, 14)', + ansi: '\u001b[0;92m' + }, + [FormattingCodes.Aqua]: { + foreground: 'rgb(85, 255, 255)', + foregroundDarker: 'rgb(59, 178, 178)', + background: 'rgb(21, 63, 63)', + backgroundDarker: 'rgb(14, 44, 44)', + ansi: '\u001b[0;96m' + }, + [FormattingCodes.Red]: { + foreground: 'rgb(255, 85, 85)', + foregroundDarker: 'rgb(178, 59, 59)', + background: 'rgb(63, 21, 21)', + backgroundDarker: 'rgb(44, 14, 14)', + ansi: '\u001b[0;91m' + }, + [FormattingCodes.LightPurple]: { + foreground: 'rgb(255, 85, 255)', + foregroundDarker: 'rgb(178, 59, 178)', + background: 'rgb(63, 21, 63)', + backgroundDarker: 'rgb(44, 14, 44)', + ansi: '\u001b[0;95m' + }, + [FormattingCodes.Yellow]: { + foreground: 'rgb(255, 255, 85)', + foregroundDarker: 'rgb(178, 178, 59)', + background: 'rgb(63, 63, 21)', + backgroundDarker: 'rgb(44, 44, 14)', + ansi: '\u001b[0;93m' + }, + [FormattingCodes.White]: { + foreground: 'rgb(255, 255, 255)', + foregroundDarker: 'rgb(178, 178, 178)', + background: 'rgb(63, 63, 63)', + backgroundDarker: 'rgb(44, 44, 44)', + ansi: '\u001b[0;97m' + }, + + [FormattingCodes.Obfuscated]: { ansi: '\u001b[8m' }, + [FormattingCodes.Bold]: { ansi: '\u001b[1m' }, + [FormattingCodes.Strikethrough]: { ansi: '\u001b[9m' }, + [FormattingCodes.Underline]: { ansi: '\u001b[4m' }, + [FormattingCodes.Italic]: { ansi: '\u001b[3m' }, + [FormattingCodes.Reset]: { ansi: '\u001b[0m' } +}; + +/** + * stolen from NEU + * @param {string} displayname + * @returns {code} + */ +function getPrimaryColourCode(displayname) { + let lastColourCode = -99; + let currentColour = 0; + const mostCommon = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + for (let i = 0; i < displayname.length; i++) { + const c = displayname.charAt(i); + if (c === '\u00A7') { + lastColourCode = i; + } else if (lastColourCode === i - 1) { + const colIndex = '0123456789abcdef'.indexOf(c); + if (colIndex >= 0) { + currentColour = colIndex; + } else { + currentColour = 0; + } + } else if ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(c) >= 0) { + if (currentColour > 0) { + mostCommon[currentColour] = mostCommon[currentColour]++; + } + } + } + let mostCommonCount = 0; + for (let index = 0; index < mostCommon.length; index++) { + if (mostCommon[index] > mostCommonCount) { + mostCommonCount = mostCommon[index]; + currentColour = index; + } + } + + /** @type {code} */ + // @ts-ignore + const code = '0123456789abcdef'.charAt(currentColour); + return code; +} + +/** + * @param {number} decimal + */ +function decimalToHex(decimal) { + return decimal.toString(16).padStart(6, '0'); +} + +/** + * @param {RawNeuItem} item + * @returns {Buffer} + */ +function tooltip(item) { + const background = '#100010'; + + const width = 1920; + const height = 1080; + const scale = 10; + + const itemRender = createCanvas(width, height), + ctx = itemRender.getContext('2d'); + + // ctx.fillStyle = '#000'; + // ctx.fillRect(0, 0, width, height); + + // ctx.globalAlpha = 0.94; + ctx.fillStyle = background; + + // top outside + ctx.fillRect(scale, 0, width - 2 * scale, scale); + + // bottom outside + ctx.fillRect(scale, height - scale, width - 2 * scale, scale); + + // left outside + ctx.fillRect(0, scale, scale, height - 2 * scale); + + // right outside + ctx.fillRect(width - scale, scale, scale, height - 2 * scale); + + // middle + ctx.fillRect(2 * scale, 2 * scale, width - 4 * scale, height - 4 * scale); + + // ctx.globalAlpha = 0.78; + + const borderColorStart = parseInt(new tinycolor(getPrimaryColour(item.displayname)).toHex(), 16); + const borderColorEnd = ((borderColorStart & 0xfefefe) >> 1) | (borderColorStart & 0xff000000); + + const borderColorStartStr = `#${decimalToHex(borderColorStart)}`; + const borderColorEndStr = `#${decimalToHex(borderColorEnd)}`; + + console.log(borderColorStartStr, borderColorEndStr); + + ctx.fillStyle = borderColorStartStr; + + // top highlight + ctx.fillRect(scale, scale, width - 2 * scale, scale); + + // left highlight + ctx.fillRect(scale, 2 * scale, scale, height - 3 * scale); + + // bottom highlight + { + const x = 2 * scale, + y = height - 2 * scale, + w = width - 3 * scale, + h = scale; + const gradient = ctx.createLinearGradient(x, y, x + w, y + h); + gradient.addColorStop(0, borderColorStartStr); + gradient.addColorStop(1, borderColorEndStr); + ctx.fillStyle = gradient; + + ctx.fillRect(x, y, w, h); + } + + // right highlight + { + const x = width - 2 * scale, + y = 2 * scale, + w = scale, + h = height - 4 * scale; + const gradient = ctx.createLinearGradient(x, y, x + w, y + h); + gradient.addColorStop(0, borderColorStartStr); + gradient.addColorStop(1, borderColorEndStr); + ctx.fillStyle = gradient; + + ctx.fillRect(x, y, w, h); + } + + ctx.font = `50px ComplianceSans`; + ctx.fillText(stripCodes(item.displayname), scale * 4, scale * 7); + + for (let i = 0; i < item.lore.length; i++) { + const line = item.lore[i]; + + ctx.fillStyle = `#${decimalToHex(parseInt(new tinycolor(getPrimaryColour(line)).toHex(), 16))}`; + ctx.fillText(stripCodes(line), scale * 4, scale * (7 + (i + 1) * 5)); + } + + return itemRender.toBuffer('image/png'); +} + +/** + * @param {string} displayname + */ +function getPrimaryColour(displayname) { + const code = getPrimaryColourCode(displayname); + return formattingInfo[`§${code}`].foregroundDarker; +} + +/** + * @param {string} str + * @returns {string} + */ +function stripCodes(str) { + for (const format in formattingInfo) { + // @ts-ignore + str = str.replaceAll(new RegExp(format, 'ig'), ''); + } + return str; +} + +const repo = path.join(__dirname, 'neu-item-repo-dangerous'); +const itemPath = path.join(repo, 'items'); +const items = await fs.readdir(itemPath); + +const randomItem = items[Math.floor(Math.random() * items.length)]; +/** @type {RawNeuItem} */ +const item = (await import(path.join(itemPath, randomItem), { assert: { type: 'json' } })).default; + +console.log(randomItem); +fs.writeFile('./test.png', tooltip(item)); diff --git a/test.png b/test.png new file mode 100644 index 0000000..942a85e Binary files /dev/null and b/test.png differ diff --git a/tooltips.nnb b/tooltips.nnb new file mode 100644 index 0000000..6e36999 --- /dev/null +++ b/tooltips.nnb @@ -0,0 +1,118 @@ +{ + "cells": [ + { + "language": "markdown", + "source": [ + "# Thingy" + ], + "outputs": [] + }, + { + "language": "typescript", + "source": [ + "function drawGradientRect(\n\tzLevel: number,\n\tleft: number,\n\ttop: number,\n\tright: number,\n\tbottom: number,\n\tstartColor: number,\n\tendColor: number\n) {\n\tconst startAlpha = ((startColor >> 24) & 255) / 255.0;\n\tconst startRed = ((startColor >> 16) & 255) / 255.0;\n\tconst startGreen = ((startColor >> 8) & 255) / 255.0;\n\tconst startBlue = (startColor & 255) / 255.0;\n\tconst endAlpha = ((endColor >> 24) & 255) / 255.0;\n\tconst endRed = ((endColor >> 16) & 255) / 255.0;\n\tconst endGreen = ((endColor >> 8) & 255) / 255.0;\n\tconst endBlue = (endColor & 255) / 255.0;\n\n\tconsole.dir({ startAlpha, startRed, startGreen, startBlue, endAlpha, endRed, endGreen, endBlue });\n\tconsole.dir({\n\t\tstartAlpha: color(startAlpha),\n\t\tstartRed: color(startRed),\n\t\tstartGreen: color(startGreen),\n\t\tstartBlue: color(startBlue),\n\t\tendAlpha: color(endAlpha),\n\t\tendRed: color(endRed),\n\t\tendGreen: color(endGreen),\n\t\tendBlue: color(endBlue)\n\t});\n}\n\nfunction color(num: number) {\n\treturn Math.floor(num * 255);\n}\n\nconst zLevel = 300;\nconst backgroundColor = 0xF0100010;\ndrawGradientRect(\n zLevel,\n 0,\n 0,\n 0,\n 0,\n backgroundColor,\n backgroundColor\n);" + ], + "outputs": [ + { + "items": [ + { + "mime": "application/vnd.code.notebook.stdout", + "value": [ + "{", + " startAlpha: 0.9411764705882353,", + " startRed: 0.06274509803921569,", + " startGreen: 0,", + " startBlue: 0.06274509803921569,", + " endAlpha: 0.9411764705882353,", + " endRed: 0.06274509803921569,", + " endGreen: 0,", + " endBlue: 0.06274509803921569", + "}", + "{", + " startAlpha: 240,", + " startRed: 16,", + " startGreen: 0,", + " startBlue: 16,", + " endAlpha: 240,", + " endRed: 16,", + " endGreen: 0,", + " endBlue: 16", + "}", + "" + ] + } + ] + } + ] + }, + { + "language": "markdown", + "source": [ + "# Thingy 2" + ], + "outputs": [] + }, + { + "language": "typescript", + "source": [ + "enum FormattingCodes {\n\tBlack = '§0',\n\tDarkBlue = '§1',\n\tDarkGreen = '§2',\n\tDarkAqua = '§3',\n\tDarkRed = '§4',\n\tDarkPurple = '§5',\n\tGold = '§6',\n\tGray = '§7',\n\tDarkGray = '§8',\n\tBlue = '§9',\n\tGreen = '§a',\n\tAqua = '§b',\n\tRed = '§c',\n\tLightPurple = '§d',\n\tYellow = '§e',\n\tWhite = '§f',\n\n\tObfuscated = '§k',\n\tBold = '§l',\n\tStrikethrough = '§m',\n\tUnderline = '§n',\n\tItalic = '§o',\n\tReset = '§r'\n}\n\nconst formattingInfo = {\n\t[FormattingCodes.Black]: {\n\t\tforeground: 'rgb(0, 0, 0)',\n\t\tforegroundDarker: 'rgb(0, 0, 0)',\n\t\tbackground: 'rgb(0, 0, 0)',\n\t\tbackgroundDarker: 'rgb(0, 0, 0)',\n\t\tansi: '\\u001b[0;30m'\n\t},\n\t[FormattingCodes.DarkBlue]: {\n\t\tforeground: 'rgb(0, 0, 170)',\n\t\tforegroundDarker: 'rgb(0, 0, 118)',\n\t\tbackground: 'rgb(0, 0, 42)',\n\t\tbackgroundDarker: 'rgb(0, 0, 29)',\n\t\tansi: '\\u001b[0;34m'\n\t},\n\t[FormattingCodes.DarkGreen]: {\n\t\tforeground: 'rgb(0, 170, 0)',\n\t\tforegroundDarker: 'rgb(0, 118, 0)',\n\t\tbackground: 'rgb(0, 42, 0)',\n\t\tbackgroundDarker: 'rgb(0, 29, 0)',\n\t\tansi: '\\u001b[0;32m'\n\t},\n\t[FormattingCodes.DarkAqua]: {\n\t\tforeground: 'rgb(0, 170, 170)',\n\t\tforegroundDarker: 'rgb(0, 118, 118)',\n\t\tbackground: 'rgb(0, 42, 42)',\n\t\tbackgroundDarker: 'rgb(0, 29, 29)',\n\t\tansi: '\\u001b[0;36m'\n\t},\n\t[FormattingCodes.DarkRed]: {\n\t\tforeground: 'rgb(170, 0, 0)',\n\t\tforegroundDarker: 'rgb(118, 0, 0)',\n\t\tbackground: 'rgb(42, 0, 0)',\n\t\tbackgroundDarker: 'rgb(29, 0, 0)',\n\t\tansi: '\\u001b[0;31m'\n\t},\n\t[FormattingCodes.DarkPurple]: {\n\t\tforeground: 'rgb(170, 0, 170)',\n\t\tforegroundDarker: 'rgb(118, 0, 118)',\n\t\tbackground: 'rgb(42, 0, 42)',\n\t\tbackgroundDarker: 'rgb(29, 0, 29)',\n\t\tansi: '\\u001b[0;35m'\n\t},\n\t[FormattingCodes.Gold]: {\n\t\tforeground: 'rgb(255, 170, 0)',\n\t\tforegroundDarker: 'rgb(178, 118, 0)',\n\t\tbackground: 'rgb(42, 42, 0)',\n\t\tbackgroundDarker: 'rgb(29, 29, 0)',\n\t\tansi: '\\u001b[0;33m'\n\t},\n\t[FormattingCodes.Gray]: {\n\t\tforeground: 'rgb(170, 170, 170)',\n\t\tforegroundDarker: 'rgb(118, 118, 118)',\n\t\tbackground: 'rgb(42, 42, 42)',\n\t\tbackgroundDarker: 'rgb(29, 29, 29)',\n\t\tansi: '\\u001b[0;37m'\n\t},\n\t[FormattingCodes.DarkGray]: {\n\t\tforeground: 'rgb(85, 85, 85)',\n\t\tforegroundDarker: 'rgb(59, 59, 59)',\n\t\tbackground: 'rgb(21, 21, 21)',\n\t\tbackgroundDarker: 'rgb(14, 14, 14)',\n\t\tansi: '\\u001b[0;90m'\n\t},\n\t[FormattingCodes.Blue]: {\n\t\tforeground: 'rgb(85, 85, 255)',\n\t\tforegroundDarker: 'rgb(59, 59, 178)',\n\t\tbackground: 'rgb(21, 21, 63)',\n\t\tbackgroundDarker: 'rgb(14, 14, 44)',\n\t\tansi: '\\u001b[0;94m'\n\t},\n\t[FormattingCodes.Green]: {\n\t\tforeground: 'rgb(85, 255, 85)',\n\t\tforegroundDarker: 'rgb(59, 178, 59)',\n\t\tbackground: 'rgb(21, 63, 21)',\n\t\tbackgroundDarker: 'rgb(14, 44, 14)',\n\t\tansi: '\\u001b[0;92m'\n\t},\n\t[FormattingCodes.Aqua]: {\n\t\tforeground: 'rgb(85, 255, 255)',\n\t\tforegroundDarker: 'rgb(59, 178, 178)',\n\t\tbackground: 'rgb(21, 63, 63)',\n\t\tbackgroundDarker: 'rgb(14, 44, 44)',\n\t\tansi: '\\u001b[0;96m'\n\t},\n\t[FormattingCodes.Red]: {\n\t\tforeground: 'rgb(255, 85, 85)',\n\t\tforegroundDarker: 'rgb(178, 59, 59)',\n\t\tbackground: 'rgb(63, 21, 21)',\n\t\tbackgroundDarker: 'rgb(44, 14, 14)',\n\t\tansi: '\\u001b[0;91m'\n\t},\n\t[FormattingCodes.LightPurple]: {\n\t\tforeground: 'rgb(255, 85, 255)',\n\t\tforegroundDarker: 'rgb(178, 59, 178)',\n\t\tbackground: 'rgb(63, 21, 63)',\n\t\tbackgroundDarker: 'rgb(44, 14, 44)',\n\t\tansi: '\\u001b[0;95m'\n\t},\n\t[FormattingCodes.Yellow]: {\n\t\tforeground: 'rgb(255, 255, 85)',\n\t\tforegroundDarker: 'rgb(178, 178, 59)',\n\t\tbackground: 'rgb(63, 63, 21)',\n\t\tbackgroundDarker: 'rgb(44, 44, 14)',\n\t\tansi: '\\u001b[0;93m'\n\t},\n\t[FormattingCodes.White]: {\n\t\tforeground: 'rgb(255, 255, 255)',\n\t\tforegroundDarker: 'rgb(178, 178, 178)',\n\t\tbackground: 'rgb(63, 63, 63)',\n\t\tbackgroundDarker: 'rgb(44, 44, 44)',\n\t\tansi: '\\u001b[0;97m'\n\t},\n\n\t[FormattingCodes.Obfuscated]: { ansi: '\\u001b[8m' },\n\t[FormattingCodes.Bold]: { ansi: '\\u001b[1m' },\n\t[FormattingCodes.Strikethrough]: { ansi: '\\u001b[9m' },\n\t[FormattingCodes.Underline]: { ansi: '\\u001b[4m' },\n\t[FormattingCodes.Italic]: { ansi: '\\u001b[3m' },\n\t[FormattingCodes.Reset]: { ansi: '\\u001b[0m' }\n} as const;" + ], + "outputs": [] + }, + { + "language": "markdown", + "source": [ + "# Thingy 3" + ], + "outputs": [] + }, + { + "language": "typescript", + "source": [ + "type code = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f';\n\n// stolen from NEU\nfunction getPrimaryColourCode(displayname: string): code {\n\tlet lastColourCode = -99;\n\tlet currentColour = 0;\n\tconst mostCommon = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n\tfor (let i = 0; i < displayname.length; i++) {\n\t\tconst c = displayname.charAt(i);\n\t\tif (c === '\\u00A7') {\n\t\t\tlastColourCode = i;\n\t\t} else if (lastColourCode === i - 1) {\n\t\t\tconst colIndex = '0123456789abcdef'.indexOf(c);\n\t\t\tif (colIndex >= 0) {\n\t\t\t\tcurrentColour = colIndex;\n\t\t\t} else {\n\t\t\t\tcurrentColour = 0;\n\t\t\t}\n\t\t} else if ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(c) >= 0) {\n\t\t\tif (currentColour > 0) {\n\t\t\t\tmostCommon[currentColour] = mostCommon[currentColour]++;\n\t\t\t}\n\t\t}\n\t}\n\tlet mostCommonCount = 0;\n\tfor (let index = 0; index < mostCommon.length; index++) {\n\t\tif (mostCommon[index] > mostCommonCount) {\n\t\t\tmostCommonCount = mostCommon[index];\n\t\t\tcurrentColour = index;\n\t\t}\n\t}\n\n\treturn '0123456789abcdef'.charAt(currentColour);\n}\n\nfunction getPrimaryColour(displayname: string) {\n\tconst code = getPrimaryColourCode(displayname);\n\treturn formattingInfo[`§${code}`].foregroundDarker;\n}\n\nfunction stripCodes(str: string) {\n\tfor (const format in formattingInfo) {\n\t\tstr = str.replaceAll(format, '');\n\t}\n\treturn str;\n}\n" + ], + "outputs": [] + }, + { + "language": "markdown", + "source": [ + "# Thingy 4" + ], + "outputs": [] + }, + { + "language": "typescript", + "source": [ + "import tinycolor from 'tinycolor2';\nimport canvas from 'canvas';\nimport path from 'path';\n\ntype McItemId = Lowercase;\ntype SbItemId = Uppercase;\ntype MojangJson = string;\ntype SbRecipeItem = `${SbItemId}:${number}` | '';\ntype SbRecipe = {\n\t[Location in `${'A' | 'B' | 'C'}${1 | 2 | 3}`]: SbRecipeItem;\n};\ntype InfoType = 'WIKI_URL' | '';\ntype Slayer = `${'WOLF' | 'BLAZE' | 'EMAN'}_${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`;\ninterface RawNeuItem {\n\titemid: McItemId;\n\tdisplayname: string;\n\tnbttag: MojangJson;\n\tdamage: number;\n\tlore: string[];\n\trecipe?: SbRecipe;\n\tinternalname: SbItemId;\n\tmodver: string;\n\tinfoType: InfoType;\n\tinfo?: string[];\n\tcrafttext: string;\n\tvanilla?: boolean;\n\tuseneucraft?: boolean;\n\tslayer_req?: Slayer;\n\tclickcommand?: string;\n\tx?: number;\n\ty?: number;\n\tz?: number;\n\tisland?: string;\n\trecipes?: { type: string; cost: any[]; result: SbItemId }[];\n\t/** @deprecated */\n\tparent?: SbItemId;\n\tnoseal?: boolean;\n}\n\nfunction tooltip(item: RawNeuItem) {\n\tconst background = '#100010';\n\n\tconst width = 1000;\n\tconst height = 250;\n\tconst scale = 10;\n\n\tcanvas.registerFont(path.join(__dirname, 'assets', 'Faithful.ttf'), { family: 'Compliance Sans' });\n\tcanvas.registerFont(path.join(__dirname, 'assets', 'Roboto-Regular.ttf'), { family: 'Roboto' });\n\n\tconst itemRender = canvas.createCanvas(width, height),\n\t\tctx = itemRender.getContext('2d');\n\n\tctx.globalAlpha = 0.94;\n\tctx.fillStyle = background;\n\n\t// top outside\n\tctx.fillRect(scale, 0, width - 2 * scale, scale);\n\n\t// bottom outside\n\tctx.fillRect(scale, height - scale, width - 2 * scale, scale);\n\n\t// left outside\n\tctx.fillRect(0, scale, scale, height - 2 * scale);\n\n\t// right outside\n\tctx.fillRect(width - scale, scale, scale, height - 2 * scale);\n\n\t// middle\n\tctx.fillRect(2 * scale, 2 * scale, width - 4 * scale, height - 4 * scale);\n\n\tctx.globalAlpha = 0.78;\n\n\tconst borderColorStart = parseInt(new tinycolor(getPrimaryColour(item.displayname)).toHex(), 16);\n\tconst borderColorEnd = ((borderColorStart & 0xfefefe) >> 1) | (borderColorStart & 0xff000000);\n\n\tconst borderColorStartStr = `#${borderColorStart.toString(16)}`;\n\tconst borderColorEndStr = `#${borderColorEnd.toString(16)}`;\n\n\tctx.fillStyle = borderColorStartStr;\n\n\t// top highlight\n\tctx.fillRect(scale, scale, width - 2 * scale, scale);\n\n\t// left highlight\n\tctx.fillRect(scale, 2 * scale, scale, height - 3 * scale);\n\n\t// bottom highlight\n\t{\n\t\tconst x = 2 * scale,\n\t\t\ty = height - 2 * scale,\n\t\t\tw = width - 3 * scale,\n\t\t\th = scale;\n\t\tconst gradient = ctx.createLinearGradient(x, y, x + w, y + h);\n\t\tgradient.addColorStop(0, borderColorStartStr);\n\t\tgradient.addColorStop(1, borderColorEndStr);\n\t\tctx.fillStyle = gradient;\n\n\t\tctx.fillRect(x, y, w, h);\n\t}\n\n\t// right highlight\n\t{\n\t\tconst x = width - 2 * scale,\n\t\t\ty = 2 * scale,\n\t\t\tw = scale,\n\t\t\th = height - 4 * scale;\n\t\tconst gradient = ctx.createLinearGradient(x, y, x + w, y + h);\n\t\tgradient.addColorStop(0, borderColorStartStr);\n\t\tgradient.addColorStop(1, borderColorEndStr);\n\t\tctx.fillStyle = gradient;\n\n\t\tctx.fillRect(x, y, w, h);\n\t}\n\n\tctx.font = `48px Roboto`;\n\tctx.fillText(stripCodes(item.displayname), scale * 4, scale * 7);\n\n\tconst buf = itemRender.toBuffer();\n\treturn buf;\n}\n" + ], + "outputs": [] + }, + { + "language": "typescript", + "source": [ + "import fs from 'fs/promises';\nimport path from 'path';\n\nconst repo = path.join(__dirname, 'neu-item-repo-dangerous');\nconst itemPath = path.join(repo, 'items');\nconst items = await fs.readdir(itemPath);\n\nconst randomItem = items[Math.floor(Math.random() * items.length)];\nconst item = (await import(path.join(itemPath, randomItem), { assert: { type: 'json' } })).default as RawNeuItem;\n\nconsole.log(stripCodes(item.displayname));\ntooltip(item);\n" + ], + "outputs": [ + { + "items": [ + { + "mime": "application/vnd.code.notebook.stdout", + "value": [ + "Enderman Minion IV", + "" + ] + } + ] + }, + { + "items": [ + { + "mime": "image/png", + "value": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA+gAAAD6CAYAAAAyVW3pAAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nO3daZAkaX3f8efJoyqzju7qY3q659je7tnZnZ1ddlmWJWSWsBEskgOQhfElwMIYAmNH6JXDjvBLXtt+Y4etCFsO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ADAAAAADAEFVNOJ6ADAAAAABBBXMF8FwEdAAAAAIBI4k3oTBIHAAAAAEACENABAAAAAEgAStwBAAAAAIgkiPXV6EEHAAAAACABCOgAAAAAACQAJe4AAAAAAEQS7yzuBHQAAAAAACKKcy10StwBAAAAAIggznAuBD3oAAAAAABEFG9CpwcdAAAAAIAEIKADAAAAAJAAlLgDAAAAABAJJe4AAAAAAIwdAjoAAAAAAAlAiTsAAAAAAJEEsb4aAR0AAAAAgIiCGDM6Je4AAAAAAEQQZzgXgh50AAAAAAAiYhZ3AAAAAADGDgEdAAAAAIAEoMQdAAAAAIBIKHEHAAAAAGDsENABAAAAAEiA2Evcn3j+xVc7fxu123//eWqgl4g61/1w2zn4FPtHv52DHcdh3y/K/jXea/DtPMptbLzf0R7L6PsXbemHo91OpY7nmh34WdFOujjKa71xvo/+czbwO6lh3u9otnP/dB/1dg72vP3tTO511Po9lMzt7Ly8k3m9j8J2hv/dSd71Ht+xPMptHOb9Du954duZrGu9e3soWddQ96ZGcrbz4OZQcq6jg9vAydnOdvSgAwAAAACQAAR0HJKod+sAAACGQRsEwOgioAMAAAAAkAAEdAAAAAAAEoCAjh7iXdcPAACgP7RBADx4RiKgR544GQAAAACAETESAR1x4C4HAAA4DrRBAKBfBHQAAAAAABKAgA4AwIhiCBgAAONF9vvAgihsHeaGAAAAAAAwjrbEVqGfx9GDDgAAAABAAhDQAQAAAABIAAI6AAAAAAAJQEAHAAAAACABCOgAAAAAACQAAR0AAAAAgAQgoAMAAAAAkAAEdAAAAAAAEoCADgAAAABAAvx/698dMJgpvRYAAAAASUVORK5CYII=" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json new file mode 100644 index 0000000..59f6ecc --- /dev/null +++ b/tsconfig.eslint.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "include": [ + "src/**/*.ts", + "src/**/*d.ts", + "lib/**/*.ts", + "ecosystem.config.cjs", + ".eslintrc.cjs", + "config/**/*.ts", + "tests/**/*.ts", + "vite.config.ts", + "tooltips*", + "test*" + ] +} diff --git a/tsconfig.json b/tsconfig.json index 565346b..6d24566 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,17 +27,6 @@ "#tags": ["./src/lib/common/tags.js"] } }, - "include": [ - "src/**/*.ts", - "src/**/*d.ts", - "lib/**/*.ts", - "ecosystem.config.cjs", - ".eslintrc.cjs", - "config/**/*.ts", - "tests/**/*.ts", - "vite.config.ts", - "src/bot.ts", - "src/lib/common/util/Minecraft.ts" - ], + "include": ["src/**/*.ts", "src/**/*d.ts", "lib/**/*.ts", "test.js"], "exclude": ["dist", "node_modules"] } -- cgit From 7824c911806e368f6a1bea7f6b55d1f470b755d1 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Fri, 5 Aug 2022 20:14:49 -0400 Subject: hide incomplete commands --- src/commands/moulberry-bush/neuRepo.ts | 5 +++-- src/commands/tickets/ticket-!.ts | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/commands/moulberry-bush/neuRepo.ts') diff --git a/src/commands/moulberry-bush/neuRepo.ts b/src/commands/moulberry-bush/neuRepo.ts index 9d76810..d07ba53 100644 --- a/src/commands/moulberry-bush/neuRepo.ts +++ b/src/commands/moulberry-bush/neuRepo.ts @@ -43,10 +43,11 @@ export default class NeuRepoCommand extends BushCommand { slashType: ApplicationCommandOptionType.Boolean } */ ], - slash: true, + slash: false, clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [], - ownerOnly: true + ownerOnly: true, + hidden: true }); } diff --git a/src/commands/tickets/ticket-!.ts b/src/commands/tickets/ticket-!.ts index 7751df1..6ec4093 100644 --- a/src/commands/tickets/ticket-!.ts +++ b/src/commands/tickets/ticket-!.ts @@ -29,10 +29,12 @@ export default class TicketCommand extends BushCommand { slashOptions: Object.entries(ticketSubcommands).map( ([subcommand, options]) => ({ name: subcommand, ...options } as SlashOption) ), - slash: true, + slash: false, channel: 'guild', clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: [] + userPermissions: [], + ownerOnly: true, + hidden: true }); } -- cgit