mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 06:28:54 +00:00
Allow console to use chat with 'console_sender' channel format
This commit is contained in:
1 parent
19d17ce004
commit
2d89dc68c4
7 files changed
+290
-11
No files matched your search
@@ -34,6 +34,7 @@ import net.draycia.carbon.api.event.CarbonEventHandler;
|
||||
import net.draycia.carbon.api.event.events.CarbonChatEvent;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
|
||||
import net.draycia.carbon.common.users.ConsoleCarbonPlayer;
|
||||
import net.draycia.carbon.common.users.WrappedCarbonPlayer;
|
||||
import net.draycia.carbon.common.util.ChannelUtils;
|
||||
import net.draycia.carbon.paper.users.CarbonPlayerPaper;
|
||||
@@ -69,6 +70,11 @@ public final class DSRVChatHook implements ChatHook {
|
||||
events.subscribe(CarbonChatEvent.class, event -> {
|
||||
final ChatChannel chatChannel = event.chatChannel();
|
||||
final CarbonPlayer carbonPlayer = event.sender();
|
||||
|
||||
if (carbonPlayer instanceof ConsoleCarbonPlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ImmutablePair<CarbonPlayer, ChatChannel> pair = new ImmutablePair<>(carbonPlayer, chatChannel);
|
||||
Component messageComponent = awaitingEvent.getIfPresent(pair);
|
||||
awaitingEvent.invalidate(pair);
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.function.Supplier;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.SourcedAudience;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.draycia.carbon.common.users.ConsoleCarbonPlayer;
|
||||
import net.draycia.carbon.paper.CarbonChatPaper;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -92,6 +93,11 @@ public class PaperMessageRenderer<T extends Audience> implements IMessageRendere
|
||||
return this.miniMessage.deserialize(placeholderResolvedMessage, tagResolver.build());
|
||||
}
|
||||
|
||||
// We can't/shouldn't resolve placeholders for non-players
|
||||
if (sender instanceof ConsoleCarbonPlayer) {
|
||||
return this.miniMessage.deserialize(placeholderResolvedMessage, tagResolver.build());
|
||||
}
|
||||
|
||||
final Player senderBukkitPlayer = requireNonNull(Bukkit.getPlayer(sender.uuid()));
|
||||
|
||||
if (CarbonChatPaper.miniPlaceholdersLoaded()) {
|
||||
|
||||
Reference in new issue
Block a user