mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
Support placeholders in color placeholder
This commit is contained in:
1 parent
00f1a23f4f
commit
e03b43119b
6 files changed
+21
-15
No files matched your search
@@ -8,7 +8,6 @@ import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.draycia.carbon.common.utils;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.adventure.MessageProcessor;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.common.adventure.AdventureManager;
|
||||
import net.draycia.carbon.api.adventure.FormatType;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
@@ -26,21 +27,14 @@ public final class ColorUtils {
|
||||
}
|
||||
|
||||
public @Nullable static TextColor parseColor(@Nullable final CarbonUser user, @Nullable String input) {
|
||||
if (user instanceof PlayerUser) {
|
||||
input = ((PlayerUser) user).parsePlaceholders(input);
|
||||
}
|
||||
|
||||
if (input == null || input.isEmpty()) {
|
||||
return NamedTextColor.WHITE;
|
||||
}
|
||||
|
||||
// TODO: find out way to do this
|
||||
// TODO: add parsePlaceholders() to PlayerUser class
|
||||
|
||||
// if (user != null) {
|
||||
// final Player player = Bukkit.getPlayer(user.uuid());
|
||||
//
|
||||
// if (player != null) {
|
||||
// input = PlaceholderAPI.setPlaceholders(player, input);
|
||||
// }
|
||||
// }
|
||||
|
||||
for (final NamedTextColor namedColor : NamedTextColor.NAMES.values()) {
|
||||
if (namedColor.toString().equalsIgnoreCase(input)) {
|
||||
return namedColor;
|
||||
@@ -73,7 +67,7 @@ public final class ColorUtils {
|
||||
final MessageProcessor messageProcessor = CarbonChatProvider.carbonChat().messageProcessor();
|
||||
|
||||
if (messageProcessor instanceof AdventureManager) {
|
||||
if (((AdventureManager) messageProcessor).formatType() == FormatType.MINEDOWN) {
|
||||
if (messageProcessor.formatType() == FormatType.MINEDOWN) {
|
||||
hexReplacement = "&#$1$2$3$4$5$6&";
|
||||
legacyCapable = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user