Add gradient on LuckPerms prefix option
This commit is contained in:
parent
4d21241150
commit
df06da900a
3 changed files with 25 additions and 2 deletions
|
|
@ -122,7 +122,7 @@ public class GradientModule {
|
||||||
GradientPlayerData data = dataManager.getPlayerData(player.getUniqueId());
|
GradientPlayerData data = dataManager.getPlayerData(player.getUniqueId());
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
// Сначала LuckPerms префикс (если нет кастомного)
|
// LuckPerms префикс
|
||||||
String lpPrefix = null;
|
String lpPrefix = null;
|
||||||
if (luckPermsHook.isEnabled()) {
|
if (luckPermsHook.isEnabled()) {
|
||||||
lpPrefix = luckPermsHook.getActivePrefix(player);
|
lpPrefix = luckPermsHook.getActivePrefix(player);
|
||||||
|
|
@ -137,7 +137,13 @@ public class GradientModule {
|
||||||
result.append(customPrefix);
|
result.append(customPrefix);
|
||||||
}
|
}
|
||||||
} else if (lpPrefix != null && !lpPrefix.isEmpty()) {
|
} else if (lpPrefix != null && !lpPrefix.isEmpty()) {
|
||||||
result.append(lpPrefix);
|
// Применяем градиент на LP префикс если включено и есть цвета
|
||||||
|
if (data.hasColors() && data.isColorEnabled() && config.isGradientOnLuckPermsPrefix()) {
|
||||||
|
String cleanPrefix = stripColors(lpPrefix);
|
||||||
|
result.append(GradientUtil.applyGradient(cleanPrefix, data.getColors(), config.isUseLegacyRgbFormat()));
|
||||||
|
} else {
|
||||||
|
result.append(lpPrefix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ник с градиентом
|
// Ник с градиентом
|
||||||
|
|
@ -150,6 +156,14 @@ public class GradientModule {
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Убирает цветовые коды из строки
|
||||||
|
*/
|
||||||
|
private String stripColors(String text) {
|
||||||
|
if (text == null) return "";
|
||||||
|
return text.replaceAll("(?i)(§x(§[0-9a-f]){6}|§[0-9a-fk-or]|&[0-9a-fk-or]|&#[0-9a-f]{6}|<[^>]+>)", "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получает только градиентный ник (без префикса)
|
* Получает только градиентный ник (без префикса)
|
||||||
*/
|
*/
|
||||||
|
|
@ -185,6 +199,11 @@ public class GradientModule {
|
||||||
if (luckPermsHook.isEnabled()) {
|
if (luckPermsHook.isEnabled()) {
|
||||||
String lpPrefix = luckPermsHook.getActivePrefix(player);
|
String lpPrefix = luckPermsHook.getActivePrefix(player);
|
||||||
if (lpPrefix != null && !lpPrefix.isEmpty()) {
|
if (lpPrefix != null && !lpPrefix.isEmpty()) {
|
||||||
|
// Применяем градиент если включено
|
||||||
|
if (data.hasColors() && data.isColorEnabled() && config.isGradientOnLuckPermsPrefix()) {
|
||||||
|
String cleanPrefix = stripColors(lpPrefix);
|
||||||
|
return GradientUtil.applyGradient(cleanPrefix, data.getColors(), config.isUseLegacyRgbFormat());
|
||||||
|
}
|
||||||
return lpPrefix;
|
return lpPrefix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ public class GradientConfig {
|
||||||
public int getMaxPrefixLength() { return config.getInt("max-prefix-length", 7); }
|
public int getMaxPrefixLength() { return config.getInt("max-prefix-length", 7); }
|
||||||
public String getPrefixFormat() { return config.getString("prefix-format", "[{prefix}] "); }
|
public String getPrefixFormat() { return config.getString("prefix-format", "[{prefix}] "); }
|
||||||
public boolean isGradientOnPrefix() { return config.getBoolean("gradient-on-prefix", true); }
|
public boolean isGradientOnPrefix() { return config.getBoolean("gradient-on-prefix", true); }
|
||||||
|
public boolean isGradientOnLuckPermsPrefix() { return config.getBoolean("gradient-on-luckperms-prefix", true); }
|
||||||
public boolean isContinuousGradient() { return config.getBoolean("continuous-gradient", true); }
|
public boolean isContinuousGradient() { return config.getBoolean("continuous-gradient", true); }
|
||||||
public boolean isUseLegacyRgbFormat() { return config.getBoolean("use-legacy-rgb-format", true); }
|
public boolean isUseLegacyRgbFormat() { return config.getBoolean("use-legacy-rgb-format", true); }
|
||||||
public String getStorageType() { return config.getString("storage-type", "YAML"); }
|
public String getStorageType() { return config.getString("storage-type", "YAML"); }
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,9 @@ prefix-format: "[{prefix}] "
|
||||||
# Применять градиент на префикс
|
# Применять градиент на префикс
|
||||||
gradient-on-prefix: true
|
gradient-on-prefix: true
|
||||||
|
|
||||||
|
# Применять градиент на LuckPerms префикс (если нет кастомного)
|
||||||
|
gradient-on-luckperms-prefix: true
|
||||||
|
|
||||||
# Единый градиент на префикс + ник
|
# Единый градиент на префикс + ник
|
||||||
continuous-gradient: true
|
continuous-gradient: true
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue