mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Somewhat working on Paper 1.19.3
This commit is contained in:
1 parent
67520cd2dc
commit
a45ae78f22
50 files changed
+176
-440
No files matched your search
@@ -28,7 +28,6 @@ import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.channels.ChannelRegistry;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.draycia.carbon.common.messages.CarbonMessageSender;
|
||||
@@ -81,7 +80,7 @@ public final class CarbonCommonModule extends AbstractModule {
|
||||
final BooleanPlaceholderResolver<Audience> booleanPlaceholderResolver,
|
||||
final CarbonMessageSource carbonMessageSource,
|
||||
final CarbonMessageSender carbonMessageSender,
|
||||
final IMessageRenderer<Audience, String, RenderedMessage, Component> messageRenderer
|
||||
final IMessageRenderer<Audience, String, Component, Component> messageRenderer
|
||||
) throws UnscannableMethodException {
|
||||
return Moonshine.<CarbonMessages, Audience>builder(new TypeToken<>() {})
|
||||
.receiverLocatorResolver(receiverResolver, 0)
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.util.Set;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.key.Key;
|
||||
@@ -58,7 +57,7 @@ public final class BasicChatChannel implements ChatChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RenderedMessage render(
|
||||
public @NotNull Component render(
|
||||
final CarbonPlayer sender,
|
||||
final Audience recipient,
|
||||
final Component message,
|
||||
|
||||
@@ -48,7 +48,6 @@ import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.events.CarbonChatEvent;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.KeyedRenderer;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.common.ForCarbon;
|
||||
import net.draycia.carbon.common.command.Commander;
|
||||
import net.draycia.carbon.common.command.PlayerCommander;
|
||||
@@ -58,7 +57,6 @@ import net.draycia.carbon.common.events.ChannelRegisterEvent;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.draycia.carbon.common.messaging.packets.ChatMessagePacket;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -334,16 +332,16 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
|
||||
return;
|
||||
}
|
||||
|
||||
var renderedMessage = new RenderedMessage(chatEvent.message(), MessageType.CHAT);
|
||||
var renderedMessage = chatEvent.message();
|
||||
|
||||
for (final var renderer : chatEvent.renderers()) {
|
||||
renderedMessage = renderer.render(sender, sender, renderedMessage.component(), chatEvent.message());
|
||||
renderedMessage = renderer.render(sender, sender, renderedMessage, chatEvent.message());
|
||||
}
|
||||
|
||||
final Identity identity = sender.hasPermission("carbon.hideidentity") ? Identity.nil() : sender.identity();
|
||||
|
||||
for (final Audience recipient : chatEvent.recipients()) {
|
||||
recipient.sendMessage(identity, renderedMessage.component(), renderedMessage.messageType());
|
||||
recipient.sendMessage(identity, renderedMessage);
|
||||
}
|
||||
|
||||
final @Nullable PacketService packetService = this.carbonChat.packetService();
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.util.UUID;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.api.util.SourcedAudience;
|
||||
import net.draycia.carbon.common.channels.messages.ConfigChannelMessageSource;
|
||||
import net.draycia.carbon.common.channels.messages.ConfigChannelMessages;
|
||||
@@ -144,7 +143,7 @@ public final class ConfigChatChannel implements ChatChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RenderedMessage render(
|
||||
public @NotNull Component render(
|
||||
final CarbonPlayer sender,
|
||||
final Audience recipient,
|
||||
final Component message,
|
||||
|
||||
+1
-5
@@ -20,10 +20,7 @@
|
||||
package net.draycia.carbon.common.channels.messages;
|
||||
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.api.util.SourcedAudience;
|
||||
import net.draycia.carbon.common.util.ChatType;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.moonshine.annotation.Message;
|
||||
@@ -36,8 +33,7 @@ public interface ConfigChannelMessages {
|
||||
|
||||
// TODO: locale placeholders?
|
||||
@Message("channel.format")
|
||||
@ChatType(MessageType.CHAT)
|
||||
RenderedMessage chatFormat(
|
||||
Component chatFormat(
|
||||
final SourcedAudience audience,
|
||||
@Placeholder UUID uuid,
|
||||
@Placeholder Key channel,
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class ClearChatCommand extends CarbonCommand {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.permission("carbon.clearchat.clear")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandClearChatDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandClearChatDescription())
|
||||
.handler(handler -> {
|
||||
// Not fond of having to send 50 messages to each player
|
||||
// Are we not able to just paste in 50 newlines and call it a day?
|
||||
|
||||
+2
-2
@@ -80,10 +80,10 @@ public class ContinueCommand extends CarbonCommand {
|
||||
public void init() {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(StringArgument.greedy("message"),
|
||||
RichDescription.of(this.carbonMessages.commandContinueArgumentMessage().component()))
|
||||
RichDescription.of(this.carbonMessages.commandContinueArgumentMessage()))
|
||||
.permission("carbon.whisper.continue")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandContinueDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandContinueDescription())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
|
||||
|
||||
@@ -71,10 +71,10 @@ public class DebugCommand extends CarbonCommand {
|
||||
public void init() {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.builder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandDebugArgumentPlayer().component()))
|
||||
RichDescription.of(this.carbonMessages.commandDebugArgumentPlayer()))
|
||||
.permission("carbon.debug")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandDebugDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandDebugDescription())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
final CarbonPlayer target;
|
||||
|
||||
@@ -78,10 +78,10 @@ public final class HelpCommand extends CarbonCommand {
|
||||
public void init() {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.literal("help",
|
||||
RichDescription.of(this.carbonMessages.commandHelpDescription().component()))
|
||||
RichDescription.of(this.carbonMessages.commandHelpDescription()))
|
||||
.argument(StringArgument.<Commander>builder("query")
|
||||
.greedy().withSuggestionsProvider(this::suggestQueries).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandHelpArgumentQuery().component()))
|
||||
RichDescription.of(this.carbonMessages.commandHelpArgumentQuery()))
|
||||
.permission("carbon.help")
|
||||
.handler(this::execute)
|
||||
.build();
|
||||
|
||||
@@ -73,15 +73,15 @@ public class IgnoreCommand extends CarbonCommand {
|
||||
public void init() {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.builder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandIgnoreArgumentPlayer().component()))
|
||||
RichDescription.of(this.carbonMessages.commandIgnoreArgumentPlayer()))
|
||||
.flag(this.commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandIgnoreArgumentUUID().component()))
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandIgnoreArgumentUUID()))
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
)
|
||||
.permission("carbon.ignore")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandIgnoreDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandIgnoreDescription())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
final CarbonPlayer target;
|
||||
|
||||
@@ -73,15 +73,15 @@ public class MuteCommand extends CarbonCommand {
|
||||
public void init() {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.builder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandMuteArgumentPlayer().component()))
|
||||
RichDescription.of(this.carbonMessages.commandMuteArgumentPlayer()))
|
||||
.flag(this.commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandMuteArgumentUUID().component()))
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandMuteArgumentUUID()))
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
)
|
||||
.permission("carbon.mute")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandMuteDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandMuteDescription())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
final CarbonPlayer target;
|
||||
|
||||
+3
-3
@@ -73,15 +73,15 @@ public class MuteInfoCommand extends CarbonCommand {
|
||||
public void init() {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.builder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandMuteInfoArgumentPlayer().component()))
|
||||
RichDescription.of(this.carbonMessages.commandMuteInfoArgumentPlayer()))
|
||||
.flag(this.commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandMuteInfoArgumentUUID().component()))
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandMuteInfoArgumentUUID()))
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
)
|
||||
.permission("carbon.mute.info")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandMuteInfoDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandMuteInfoDescription())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
final CarbonPlayer target;
|
||||
|
||||
+4
-4
@@ -77,13 +77,13 @@ public class NicknameCommand extends CarbonCommand {
|
||||
// TODO: Allow UUID input for target player
|
||||
.flag(this.commandManager.flagBuilder("player")
|
||||
.withAliases("p")
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandNicknameArgumentPlayer().component()))
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandNicknameArgumentPlayer()))
|
||||
.withArgument(CarbonPlayerArgument.builder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional())
|
||||
.withPermission(Permission.of("carbon.nickname.others"))
|
||||
)
|
||||
.flag(this.commandManager.flagBuilder("nickname")
|
||||
.withAliases("n")
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandNicknameArgumentNickname().component()))
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandNicknameArgumentNickname()))
|
||||
.withArgument(FlagArgument.<Commander, String>ofType(String.class, "value")
|
||||
.withParser(new OptionValueParser<>())
|
||||
.asOptional()
|
||||
@@ -92,12 +92,12 @@ public class NicknameCommand extends CarbonCommand {
|
||||
)
|
||||
.flag(this.commandManager.flagBuilder("reset")
|
||||
.withAliases("r")
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandNicknameArgumentReset().component()))
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandNicknameArgumentReset()))
|
||||
.withPermission(Permission.of("carbon.nickname.set"))
|
||||
)
|
||||
.permission("carbon.nickname")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandNicknameDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandNicknameDescription())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ReloadCommand extends CarbonCommand {
|
||||
.literal("reload")
|
||||
.permission("carbon.reload")
|
||||
.senderType(Commander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandReloadDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandReloadDescription())
|
||||
.handler(handler -> {
|
||||
// TODO: Check if all listeners succeeded
|
||||
this.carbonChat.eventHandler().emit(new CarbonReloadEvent());
|
||||
|
||||
@@ -80,10 +80,10 @@ public class ReplyCommand extends CarbonCommand {
|
||||
public void init() {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(StringArgument.greedy("message"),
|
||||
RichDescription.of(this.carbonMessages.commandReplyArgumentMessage().component()))
|
||||
RichDescription.of(this.carbonMessages.commandReplyArgumentMessage()))
|
||||
.permission("carbon.whisper.reply")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandReplyDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandReplyDescription())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
|
||||
|
||||
+3
-3
@@ -74,15 +74,15 @@ public class UnignoreCommand extends CarbonCommand {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
// TODO: Filter, and only show muted players, but allow inputting any player name.
|
||||
.argument(CarbonPlayerArgument.builder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandUnignoreArgumentPlayer().component()))
|
||||
RichDescription.of(this.carbonMessages.commandUnignoreArgumentPlayer()))
|
||||
.flag(this.commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandUnignoreArgumentUUID().component()))
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandUnignoreArgumentUUID()))
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
)
|
||||
.permission("carbon.ignore.unignore")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandUnignoreDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandUnignoreDescription())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
final CarbonPlayer target;
|
||||
|
||||
@@ -73,15 +73,15 @@ public class UnmuteCommand extends CarbonCommand {
|
||||
public void init() {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.builder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandUnmuteArgumentPlayer().component()))
|
||||
RichDescription.of(this.carbonMessages.commandUnmuteArgumentPlayer()))
|
||||
.flag(this.commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandUnmuteArgumentUUID().component()))
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandUnmuteArgumentUUID()))
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
)
|
||||
.permission("carbon.mute.unmute")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandUnmuteDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandUnmuteDescription())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
final CarbonPlayer target;
|
||||
|
||||
+3
-3
@@ -75,15 +75,15 @@ public class UpdateUsernameCommand extends CarbonCommand {
|
||||
public void init() {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.builder("player").withMessages(this.messageService).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.messageService.commandUpdateUsernameArgumentPlayer().component()))
|
||||
RichDescription.of(this.messageService.commandUpdateUsernameArgumentPlayer()))
|
||||
.flag(this.commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withDescription(RichDescription.of(this.messageService.commandUpdateUsernameArgumentUUID().component()))
|
||||
.withDescription(RichDescription.of(this.messageService.commandUpdateUsernameArgumentUUID()))
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
)
|
||||
.permission("carbon.updateusername")
|
||||
.senderType(Commander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.messageService.commandUpdateUsernameDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.messageService.commandUpdateUsernameDescription())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
CarbonPlayer target;
|
||||
|
||||
@@ -81,12 +81,12 @@ public class WhisperCommand extends CarbonCommand {
|
||||
public void init() {
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.builder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asRequired(),
|
||||
RichDescription.of(this.carbonMessages.commandWhisperArgumentPlayer().component()))
|
||||
RichDescription.of(this.carbonMessages.commandWhisperArgumentPlayer()))
|
||||
.argument(StringArgument.greedy("message"),
|
||||
RichDescription.of(this.carbonMessages.commandWhisperArgumentMessage().component()))
|
||||
RichDescription.of(this.carbonMessages.commandWhisperArgumentMessage()))
|
||||
.permission("carbon.whisper.message")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandWhisperDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandWhisperDescription())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.events.CarbonChatEvent;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.KeyedRenderer;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -44,7 +43,7 @@ public class MuteHandler {
|
||||
// This is an annoying side effect of the RenderedComponent change
|
||||
final var prefix = this.carbonMessages.muteSpyPrefix(recipient);
|
||||
|
||||
return new RenderedMessage(prefix.component().append(message), prefix.messageType());
|
||||
return prefix.append(message);
|
||||
});
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -25,9 +25,7 @@ import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.events.CarbonChatEvent;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.KeyedRenderer;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
@@ -47,12 +45,12 @@ public class PingHandler {
|
||||
public PingHandler(final CarbonChat carbonChat, final ConfigFactory configFactory) {
|
||||
this.renderer = keyedRenderer(this.muteKey, (sender, recipient, message, originalMessage) -> {
|
||||
if (!(recipient instanceof CarbonPlayer recipientPlayer)) {
|
||||
return new RenderedMessage(message, MessageType.CHAT);
|
||||
return message;
|
||||
}
|
||||
|
||||
final String prefix = configFactory.primaryConfig().pings().prefix();
|
||||
|
||||
return new RenderedMessage(message.replaceText(TextReplacementConfig.builder()
|
||||
return message.replaceText(TextReplacementConfig.builder()
|
||||
.match(Pattern.compile(Pattern.quote(prefix + recipientPlayer.username()), Pattern.CASE_INSENSITIVE))
|
||||
.replacement(matchedText -> {
|
||||
if (configFactory.primaryConfig().pings().playSound()) {
|
||||
@@ -61,7 +59,7 @@ public class PingHandler {
|
||||
|
||||
return Component.text(recipientPlayer.username()).color(configFactory.primaryConfig().pings().highlightTextColor());
|
||||
})
|
||||
.build()), MessageType.CHAT);
|
||||
.build());
|
||||
});
|
||||
|
||||
carbonChat.eventHandler().subscribe(CarbonChatEvent.class, 1, false, event -> {
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2021 Josua Parks (Vicarious)
|
||||
* Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.draycia.carbon.common.messages;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.draycia.carbon.common.util.ChatType;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.moonshine.message.IMessageRenderer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class CarbonMessageRenderer implements IMessageRenderer<Audience, String, RenderedMessage, Component> {
|
||||
|
||||
private final ConfigFactory configFactory;
|
||||
|
||||
@Inject
|
||||
public CarbonMessageRenderer(final ConfigFactory configFactory) {
|
||||
this.configFactory = configFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderedMessage render(
|
||||
final Audience receiver,
|
||||
final String intermediateMessage,
|
||||
final Map<String, ? extends Component> resolvedPlaceholders,
|
||||
final Method method,
|
||||
final Type owner
|
||||
) {
|
||||
final TagResolver.Builder tagResolver = TagResolver.builder();
|
||||
|
||||
for (final var entry : resolvedPlaceholders.entrySet()) {
|
||||
tagResolver.tag(entry.getKey(), Tag.inserting(entry.getValue()));
|
||||
}
|
||||
|
||||
// https://github.com/KyoriPowered/adventure-text-minimessage/issues/131
|
||||
// TLDR: 25/10/21, tags in templates aren't parsed. we want them parsed.
|
||||
String placeholderResolvedMessage = intermediateMessage;
|
||||
|
||||
for (final var entry : this.configFactory.primaryConfig().customPlaceholders().entrySet()) {
|
||||
placeholderResolvedMessage = placeholderResolvedMessage.replace("<" + entry.getKey() + ">",
|
||||
entry.getValue());
|
||||
}
|
||||
|
||||
final Component message = MiniMessage.miniMessage().deserialize(placeholderResolvedMessage, tagResolver.build());
|
||||
final MessageType messageType;
|
||||
final @Nullable ChatType chatType = method.getAnnotation(ChatType.class);
|
||||
|
||||
if (chatType != null) {
|
||||
messageType = chatType.value();
|
||||
} else {
|
||||
messageType = MessageType.SYSTEM;
|
||||
}
|
||||
|
||||
return new RenderedMessage(message, messageType);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,27 +20,27 @@
|
||||
package net.draycia.carbon.common.messages;
|
||||
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.api.util.SourcedAudience;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.moonshine.message.IMessageSender;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class CarbonMessageSender implements IMessageSender<Audience, RenderedMessage> {
|
||||
public class CarbonMessageSender implements IMessageSender<Audience, Component> {
|
||||
|
||||
@Override
|
||||
public void send(final Audience receiver, final RenderedMessage renderedMessage) {
|
||||
public void send(final Audience receiver, final Component renderedMessage) {
|
||||
if (receiver instanceof SourcedAudience sourcedAudience) {
|
||||
if (sourcedAudience.sender() instanceof CarbonPlayer sender && !sender.hasPermission("carbon.hideidentity")) {
|
||||
sourcedAudience.recipient().sendMessage(Identity.identity(sender.uuid()), renderedMessage.component(), renderedMessage.messageType());
|
||||
sourcedAudience.recipient().sendMessage(Identity.identity(sender.uuid()), renderedMessage);
|
||||
} else {
|
||||
sourcedAudience.recipient().sendMessage(Identity.nil(), renderedMessage.component(), renderedMessage.messageType());
|
||||
sourcedAudience.recipient().sendMessage(Identity.nil(), renderedMessage);
|
||||
}
|
||||
} else {
|
||||
receiver.sendMessage(Identity.nil(), renderedMessage.component(), renderedMessage.messageType());
|
||||
receiver.sendMessage(Identity.nil(), renderedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,8 @@
|
||||
package net.draycia.carbon.common.messages;
|
||||
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.api.util.SourcedAudience;
|
||||
import net.draycia.carbon.common.util.ChatType;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.moonshine.annotation.Message;
|
||||
import net.kyori.moonshine.annotation.Placeholder;
|
||||
@@ -38,8 +35,7 @@ public interface CarbonMessages {
|
||||
*/
|
||||
|
||||
@Message("channel.format.basic")
|
||||
@ChatType(MessageType.CHAT)
|
||||
RenderedMessage basicChatFormat(
|
||||
Component basicChatFormat(
|
||||
final Audience audience,
|
||||
final UUID uuid,
|
||||
@Placeholder("display_name") final Component displayName,
|
||||
@@ -96,7 +92,7 @@ public interface CarbonMessages {
|
||||
void muteNoTarget(final Audience audience);
|
||||
|
||||
@Message("mute.spy.prefix")
|
||||
RenderedMessage muteSpyPrefix(final Audience audience);
|
||||
Component muteSpyPrefix(final Audience audience);
|
||||
|
||||
/*
|
||||
* =============================================================
|
||||
@@ -105,7 +101,6 @@ public interface CarbonMessages {
|
||||
*/
|
||||
|
||||
@Message("whisper.to")
|
||||
@ChatType(MessageType.CHAT)
|
||||
void whisperSender(
|
||||
final SourcedAudience audience,
|
||||
@Placeholder("sender_display_name") final Component senderDisplayName,
|
||||
@@ -114,7 +109,6 @@ public interface CarbonMessages {
|
||||
);
|
||||
|
||||
@Message("whisper.from")
|
||||
@ChatType(MessageType.CHAT)
|
||||
void whisperRecipient(
|
||||
final SourcedAudience audience,
|
||||
@Placeholder("sender_display_name") final Component senderDisplayName,
|
||||
@@ -237,7 +231,7 @@ public interface CarbonMessages {
|
||||
void errorCommandArgumentParsing(final Audience audience, @Placeholder("throwable_message") final Component throwableMessage);
|
||||
|
||||
@Message("error.command.invalid_player")
|
||||
RenderedMessage errorCommandInvalidPlayer(final Audience audience, final String input);
|
||||
Component errorCommandInvalidPlayer(final Audience audience, final String input);
|
||||
|
||||
@Message("error.command.invalid_sender")
|
||||
void errorCommandInvalidSender(final Audience audience, final String sender_type);
|
||||
@@ -252,109 +246,109 @@ public interface CarbonMessages {
|
||||
*/
|
||||
|
||||
@Message("command.clearchat.description")
|
||||
RenderedMessage commandClearChatDescription();
|
||||
Component commandClearChatDescription();
|
||||
|
||||
@Message("command.continue.argument.message")
|
||||
RenderedMessage commandContinueArgumentMessage();
|
||||
Component commandContinueArgumentMessage();
|
||||
|
||||
@Message("command.continue.description")
|
||||
RenderedMessage commandContinueDescription();
|
||||
Component commandContinueDescription();
|
||||
|
||||
@Message("command.debug.argument.player")
|
||||
RenderedMessage commandDebugArgumentPlayer();
|
||||
Component commandDebugArgumentPlayer();
|
||||
|
||||
@Message("command.debug.description")
|
||||
RenderedMessage commandDebugDescription();
|
||||
Component commandDebugDescription();
|
||||
|
||||
@Message("command.help.argument.query")
|
||||
RenderedMessage commandHelpArgumentQuery();
|
||||
Component commandHelpArgumentQuery();
|
||||
|
||||
@Message("command.help.description")
|
||||
RenderedMessage commandHelpDescription();
|
||||
Component commandHelpDescription();
|
||||
|
||||
@Message("command.ignore.argument.player")
|
||||
RenderedMessage commandIgnoreArgumentPlayer();
|
||||
Component commandIgnoreArgumentPlayer();
|
||||
|
||||
@Message("command.ignore.argument.uuid")
|
||||
RenderedMessage commandIgnoreArgumentUUID();
|
||||
Component commandIgnoreArgumentUUID();
|
||||
|
||||
@Message("command.ignore.description")
|
||||
RenderedMessage commandIgnoreDescription();
|
||||
Component commandIgnoreDescription();
|
||||
|
||||
@Message("command.mute.argument.player")
|
||||
RenderedMessage commandMuteArgumentPlayer();
|
||||
Component commandMuteArgumentPlayer();
|
||||
|
||||
@Message("command.mute.argument.uuid")
|
||||
RenderedMessage commandMuteArgumentUUID();
|
||||
Component commandMuteArgumentUUID();
|
||||
|
||||
@Message("command.mute.description")
|
||||
RenderedMessage commandMuteDescription();
|
||||
Component commandMuteDescription();
|
||||
|
||||
@Message("command.muteinfo.argument.player")
|
||||
RenderedMessage commandMuteInfoArgumentPlayer();
|
||||
Component commandMuteInfoArgumentPlayer();
|
||||
|
||||
@Message("command.muteinfo.argument.uuid")
|
||||
RenderedMessage commandMuteInfoArgumentUUID();
|
||||
Component commandMuteInfoArgumentUUID();
|
||||
|
||||
@Message("command.muteinfo.description")
|
||||
RenderedMessage commandMuteInfoDescription();
|
||||
Component commandMuteInfoDescription();
|
||||
|
||||
@Message("command.nickname.argument.player")
|
||||
RenderedMessage commandNicknameArgumentPlayer();
|
||||
Component commandNicknameArgumentPlayer();
|
||||
|
||||
@Message("command.nickname.argument.nickname")
|
||||
RenderedMessage commandNicknameArgumentNickname();
|
||||
Component commandNicknameArgumentNickname();
|
||||
|
||||
@Message("command.nickname.argument.reset")
|
||||
RenderedMessage commandNicknameArgumentReset();
|
||||
Component commandNicknameArgumentReset();
|
||||
|
||||
@Message("command.nickname.description")
|
||||
RenderedMessage commandNicknameDescription();
|
||||
Component commandNicknameDescription();
|
||||
|
||||
@Message("command.reload.description")
|
||||
RenderedMessage commandReloadDescription();
|
||||
Component commandReloadDescription();
|
||||
|
||||
@Message("command.reply.argument.message")
|
||||
RenderedMessage commandReplyArgumentMessage();
|
||||
Component commandReplyArgumentMessage();
|
||||
|
||||
@Message("command.reply.description")
|
||||
RenderedMessage commandReplyDescription();
|
||||
Component commandReplyDescription();
|
||||
|
||||
@Message("command.unignore.argument.player")
|
||||
RenderedMessage commandUnignoreArgumentPlayer();
|
||||
Component commandUnignoreArgumentPlayer();
|
||||
|
||||
@Message("command.unignore.argument.uuid")
|
||||
RenderedMessage commandUnignoreArgumentUUID();
|
||||
Component commandUnignoreArgumentUUID();
|
||||
|
||||
@Message("command.unignore.description")
|
||||
RenderedMessage commandUnignoreDescription();
|
||||
Component commandUnignoreDescription();
|
||||
|
||||
@Message("command.unmute.argument.player")
|
||||
RenderedMessage commandUnmuteArgumentPlayer();
|
||||
Component commandUnmuteArgumentPlayer();
|
||||
|
||||
@Message("command.unmute.argument.uuid")
|
||||
RenderedMessage commandUnmuteArgumentUUID();
|
||||
Component commandUnmuteArgumentUUID();
|
||||
|
||||
@Message("command.unmute.description")
|
||||
RenderedMessage commandUnmuteDescription();
|
||||
Component commandUnmuteDescription();
|
||||
|
||||
@Message("command.whisper.argument.player")
|
||||
RenderedMessage commandWhisperArgumentPlayer();
|
||||
Component commandWhisperArgumentPlayer();
|
||||
|
||||
@Message("command.whisper.argument.message")
|
||||
RenderedMessage commandWhisperArgumentMessage();
|
||||
Component commandWhisperArgumentMessage();
|
||||
|
||||
@Message("command.whisper.description")
|
||||
RenderedMessage commandWhisperDescription();
|
||||
Component commandWhisperDescription();
|
||||
|
||||
@Message("command.updateusername.description")
|
||||
RenderedMessage commandUpdateUsernameDescription();
|
||||
Component commandUpdateUsernameDescription();
|
||||
|
||||
@Message("command.updateusername.argument.player")
|
||||
RenderedMessage commandUpdateUsernameArgumentPlayer();
|
||||
Component commandUpdateUsernameArgumentPlayer();
|
||||
|
||||
@Message("command.updateusername.argument.uuid")
|
||||
RenderedMessage commandUpdateUsernameArgumentUUID();
|
||||
Component commandUpdateUsernameArgumentUUID();
|
||||
|
||||
@Message("command.updateusername.notupdated")
|
||||
void usernameNotUpdated(final Audience recipient);
|
||||
|
||||
@@ -20,22 +20,22 @@
|
||||
package net.draycia.carbon.common.messages;
|
||||
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.api.util.SourcedAudience;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.moonshine.message.IMessageSender;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class SourcedMessageSender implements IMessageSender<SourcedAudience, RenderedMessage> {
|
||||
public class SourcedMessageSender implements IMessageSender<SourcedAudience, Component> {
|
||||
|
||||
@Override
|
||||
public void send(final SourcedAudience receiver, final RenderedMessage renderedMessage) {
|
||||
public void send(final SourcedAudience receiver, final Component renderedMessage) {
|
||||
if (receiver.sender() instanceof CarbonPlayer sender) {
|
||||
receiver.recipient().sendMessage(Identity.identity(sender.uuid()), renderedMessage.component(), renderedMessage.messageType());
|
||||
receiver.recipient().sendMessage(Identity.identity(sender.uuid()), renderedMessage);
|
||||
} else {
|
||||
receiver.recipient().sendMessage(Identity.nil(), renderedMessage.component(), renderedMessage.messageType());
|
||||
receiver.recipient().sendMessage(Identity.nil(), renderedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2021 Josua Parks (Vicarious)
|
||||
* Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.draycia.carbon.common.util;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface ChatType {
|
||||
|
||||
MessageType value();
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user