aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-06-29 18:03:19 -0500
committermat <github@matdoes.dev>2021-06-29 18:03:19 -0500
commit568c74568c1397ea0db329b205e6ff6fd80eabd4 (patch)
treed277de555558d404715208889f9459500552ac6a
parent49ff24343e1c964b6cb82fdf76957ffd2f27d049 (diff)
downloadskyblock-api-568c74568c1397ea0db329b205e6ff6fd80eabd4.tar.gz
skyblock-api-568c74568c1397ea0db329b205e6ff6fd80eabd4.tar.bz2
skyblock-api-568c74568c1397ea0db329b205e6ff6fd80eabd4.zip
fix youtube rank displaying wrongly
closes #49
-rw-r--r--build/cleaners/rank.js17
-rw-r--r--src/cleaners/rank.ts25
2 files changed, 33 insertions, 9 deletions
diff --git a/build/cleaners/rank.js b/build/cleaners/rank.js
index df8e964..19e4938 100644
--- a/build/cleaners/rank.js
+++ b/build/cleaners/rank.js
@@ -21,6 +21,7 @@ function cleanRank({ packageRank, newPackageRank, monthlyPackageRank, rankPlusCo
let name;
let color;
let colored;
+ let bracketColor;
if (prefix) { // derive values from prefix
colored = prefix;
color = util_1.minecraftColorCodes[colored.match(/§./)[0][1]];
@@ -41,6 +42,7 @@ function cleanRank({ packageRank, newPackageRank, monthlyPackageRank, rankPlusCo
// YouTube rank is called YouTuber, change this to the proper name
case 'YOUTUBER':
name = 'YOUTUBE';
+ bracketColor = 'c';
break;
case 'GAME_MASTER':
name = 'GM';
@@ -54,13 +56,22 @@ function cleanRank({ packageRank, newPackageRank, monthlyPackageRank, rankPlusCo
}
const plusColor = rankPlusColor ? util_1.colorCodeFromName(rankPlusColor) : null;
color = util_1.minecraftColorCodes[rankColors[name]];
- const rankColorPrefix = rankColors[name] ? '§' + rankColors[name] : '';
+ let rankColorPrefix = rankColors[name] ? '§' + rankColors[name] : '';
+ // the text is white, but only in the prefix
+ if (name === 'YOUTUBE')
+ rankColorPrefix = '§f';
const nameWithoutPlus = name.split('+')[0];
const plusesInName = '+'.repeat(name.split('+').length - 1);
if (plusColor && plusesInName.length >= 1)
- colored = `${rankColorPrefix}[${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}]`;
+ if (bracketColor)
+ colored = `§${bracketColor}[${rankColorPrefix}${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}§${bracketColor}]`;
+ else
+ colored = `${rankColorPrefix}[${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}]`;
else if (name !== 'NONE')
- colored = `${rankColorPrefix}[${name}]`;
+ if (bracketColor)
+ colored = `§${bracketColor}[${rankColorPrefix}${name}§${bracketColor}]`;
+ else
+ colored = `${rankColorPrefix}[${name}]`;
else
// nons don't have a prefix
colored = `${rankColorPrefix}`;
diff --git a/src/cleaners/rank.ts b/src/cleaners/rank.ts
index 76bf518..4892bf2 100644
--- a/src/cleaners/rank.ts
+++ b/src/cleaners/rank.ts
@@ -30,12 +30,13 @@ export function cleanRank({
rank,
prefix
}: HypixelPlayer): CleanRank {
- let name
- let color
- let colored
+ let name: string | undefined
+ let color: string
+ let colored: string
+ let bracketColor: string | undefined
if (prefix) { // derive values from prefix
colored = prefix
- color = minecraftColorCodes[colored.match(/§./)[0][1]]
+ color = minecraftColorCodes[colored.match(/§./)![0][1]]
name = colored.replace(/§./g, '').replace(/[\[\]]/g, '')
} else {
if (monthlyPackageRank && monthlyPackageRank !== 'NONE')
@@ -54,6 +55,7 @@ export function cleanRank({
// YouTube rank is called YouTuber, change this to the proper name
case 'YOUTUBER':
name = 'YOUTUBE'
+ bracketColor = 'c'
break
case 'GAME_MASTER':
name = 'GM'
@@ -68,12 +70,23 @@ export function cleanRank({
const plusColor = rankPlusColor ? colorCodeFromName(rankPlusColor) : null
color = minecraftColorCodes[rankColors[name]]
- const rankColorPrefix = rankColors[name] ? '§' + rankColors[name] : ''
+ let rankColorPrefix = rankColors[name] ? '§' + rankColors[name] : ''
+
+ // the text is white, but only in the prefix
+ if (name === 'YOUTUBE')
+ rankColorPrefix = '§f'
+
const nameWithoutPlus = name.split('+')[0]
const plusesInName = '+'.repeat(name.split('+').length - 1)
if (plusColor && plusesInName.length >= 1)
- colored = `${rankColorPrefix}[${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}]`
+ if (bracketColor)
+ colored = `§${bracketColor}[${rankColorPrefix}${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}§${bracketColor}]`
+ else
+ colored = `${rankColorPrefix}[${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}]`
else if (name !== 'NONE')
+ if (bracketColor)
+ colored = `§${bracketColor}[${rankColorPrefix}${name}§${bracketColor}]`
+ else
colored = `${rankColorPrefix}[${name}]`
else
// nons don't have a prefix