Skip to content

Commit

Permalink
scuffed ahh minimessage support
Browse files Browse the repository at this point in the history
  • Loading branch information
bwmp committed Dec 16, 2023
1 parent e8e4053 commit 1e93073
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
52 changes: 28 additions & 24 deletions src/components/util/RGBUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,35 +125,39 @@ export function AnimationOutput(store: any) {
}

export function generateOutput(text: string = 'SimplyMC', colors: string[] = ['#00FFE0', '#EB00FF'], format: string = '&#$1$2$3$4$5$6$f$c', formatchar: string = '&', prefix?: string, bold?: boolean, italic?: boolean, underline?: boolean, strikethrough?: boolean) {
let newColors = colors?.map((color: string) => convertToRGB(color));
if (colors.length < 2) newColors = [convertToRGB('#00FFE0'), convertToRGB('#EB00FF')];
if (format != 'MiniMessage') {
let newColors = colors?.map((color: string) => convertToRGB(color));
if (colors.length < 2) newColors = [convertToRGB('#00FFE0'), convertToRGB('#EB00FF')];

let output = prefix;
let output = prefix;

const gradient = new Gradient(newColors!, text.replace(/ /g, '').length);
const gradient = new Gradient(newColors!, text.replace(/ /g, '').length);

for (let i = 0; i < text.length; i++) {
const char = text.charAt(i);
if (char == ' ') {
output += char;
continue;
}
for (let i = 0; i < text.length; i++) {
const char = text.charAt(i);
if (char == ' ') {
output += char;
continue;
}

const hex = convertToHex(gradient.next());
let hexOutput = format;
for (let n = 1; n <= 6; n++) hexOutput = hexOutput.replace(`$${n}`, hex.charAt(n - 1));
let formatCodes = '';
if (format.includes('$f')) {
if (bold) formatCodes += formatchar + 'l';
if (italic) formatCodes += formatchar + 'o';
if (underline) formatCodes += formatchar + 'n';
if (strikethrough) formatCodes += formatchar + 'm';
const hex = convertToHex(gradient.next());
let hexOutput = format;
for (let n = 1; n <= 6; n++) hexOutput = hexOutput.replace(`$${n}`, hex.charAt(n - 1));
let formatCodes = '';
if (format.includes('$f')) {
if (bold) formatCodes += formatchar + 'l';
if (italic) formatCodes += formatchar + 'o';
if (underline) formatCodes += formatchar + 'n';
if (strikethrough) formatCodes += formatchar + 'm';
}

hexOutput = hexOutput.replace('$f', formatCodes);
hexOutput = hexOutput.replace('$c', char);
output += hexOutput;
}

hexOutput = hexOutput.replace('$f', formatCodes);
hexOutput = hexOutput.replace('$c', char);
output += hexOutput;
return output;
} else {
return `<gradient${colors.join(':')}>${text}`;
}

return output;
}
1 change: 1 addition & 0 deletions src/routes/gradients/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const formats = [
'&x&$1&$2&$3&$4&$5&$6$f$c',
'§x§$1§$2§$3§$4§$5§$6$f$c',
'[COLOR=#$1$2$3$4$5$6]$c[/COLOR]',
'MiniMessage',
];

const presets = {
Expand Down

0 comments on commit 1e93073

Please sign in to comment.