mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
Allow PAPI placeholders in color option
This commit is contained in:
1 parent
e69a9fb2a4
commit
8d77995250
7 files changed
+22
-13
No files matched your search
@@ -15,7 +15,7 @@ public abstract class ChatChannel implements ForwardingAudience {
|
||||
/**
|
||||
* @return The color that represents this channel. Optionally used in formatting.
|
||||
*/
|
||||
public abstract TextColor getColor();
|
||||
public abstract TextColor getChannelColor(ChatUser user);
|
||||
|
||||
/**
|
||||
* @return The MiniMessage styled format for the group in this channel.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.draycia.carbon.channels.impls;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.channels.ChatChannel;
|
||||
import net.draycia.carbon.events.ChatComponentEvent;
|
||||
@@ -79,7 +80,7 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
if (userColor != null) {
|
||||
return userColor;
|
||||
} else {
|
||||
return getColor();
|
||||
return getChannelColor(user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +135,7 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
|
||||
TextComponent consoleMessage = (TextComponent) carbonChat.getAdventureManager().processMessage(preFormatEvent.getFormat(),
|
||||
"br", "\n",
|
||||
"color", "<" + getColor().asHexString() + ">",
|
||||
"color", "<" + getColor(user).asHexString() + ">",
|
||||
"phase", Long.toString(System.currentTimeMillis() % 25),
|
||||
"server", carbonChat.getConfig().getString("server-name", "Server"),
|
||||
"message", preFormatEvent.getMessage());
|
||||
@@ -289,8 +290,14 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextColor getColor() {
|
||||
return TextColor.fromHexString(getString("color"));
|
||||
public TextColor getChannelColor(ChatUser user) {
|
||||
String color = getString("color");
|
||||
|
||||
if (user.isOnline()) {
|
||||
return TextColor.fromHexString(PlaceholderAPI.setPlaceholders(user.asPlayer(), color));
|
||||
}
|
||||
|
||||
return TextColor.fromHexString(color);
|
||||
}
|
||||
|
||||
private String getDefaultFormatName() {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class AliasedChannelCommand extends BaseCommand {
|
||||
user.setSelectedChannel(getChatChannel());
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessage(getChatChannel().getSwitchMessage(),
|
||||
"color", "<" + getChatChannel().getColor().toString() + ">",
|
||||
"color", "<" + getChatChannel().getChannelColor(user).toString() + ">",
|
||||
"channel", getChatChannel().getName()));
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ChannelCommand extends BaseCommand {
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, channel.getSwitchMessage(),
|
||||
"br", "\n",
|
||||
"color", "<" + channel.getColor().toString() + ">",
|
||||
"color", "<" + channel.getChannelColor(user).toString() + ">",
|
||||
"channel", channel.getName()));
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
|
||||
@@ -45,10 +45,10 @@ public class ChannelCommand extends BaseCommand {
|
||||
String otherMessage = channel.getSwitchOtherMessage();
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
||||
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName()));
|
||||
|
||||
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(carbonChat.getAdventureManager().processMessage(otherMessage, "br", "\n",
|
||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName(),
|
||||
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName(),
|
||||
"player", user.asOfflinePlayer().getName()));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class SpyChannelCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n",
|
||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
||||
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName()));
|
||||
}
|
||||
|
||||
@Subcommand("whispers")
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ToggleCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n",
|
||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
||||
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName()));
|
||||
}
|
||||
|
||||
@CommandPermission("carbonchat.toggle.others")
|
||||
@@ -57,10 +57,10 @@ public class ToggleCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
||||
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName()));
|
||||
|
||||
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(carbonChat.getAdventureManager().processMessage(otherMessage,
|
||||
"br", "\n", "color", "<color:" + channel.getColor().toString() + ">",
|
||||
"br", "\n", "color", "<color:" + channel.getChannelColor(user).toString() + ">",
|
||||
"channel", channel.getName(), "player", user.asOfflinePlayer().getName()));
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,8 @@ default:
|
||||
# filter only works when CarbonChatModeration is installed.
|
||||
# Modifies / prevents messages depending on how filters are setup.
|
||||
filter: true
|
||||
# The <color> placeholder in channel formats (and other formats).
|
||||
# This option does support PlaceholderAPI placeholders, however the resulting string must be a valid color!
|
||||
color: '#FFFFFF'
|
||||
# Can players /toggle this channel and hide its messages?
|
||||
ignorable: true
|
||||
|
||||
Reference in new issue
Block a user