mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Various compilation/merge issues
This commit is contained in:
1 parent
de834ac32b
commit
523d1d6c01
33 files changed
+263
-162
No files matched your search
@@ -32,8 +32,8 @@ 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;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.draycia.carbon.common.messages.CarbonMessageSource;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.draycia.carbon.common.messages.ReceiverResolver;
|
||||
import net.draycia.carbon.common.messages.StandardPlaceholderResolverStrategyButDifferent;
|
||||
import net.draycia.carbon.common.messages.placeholders.BooleanPlaceholderResolver;
|
||||
|
||||
@@ -230,7 +230,11 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
|
||||
}
|
||||
|
||||
if (chatChannel.shouldRegisterCommands()) {
|
||||
<<<<<<< HEAD
|
||||
this.registerChannelCommands(chatChannel, commandManager);
|
||||
=======
|
||||
this.registerChannelCommands(carbonMessages, chatChannel, commandManager);
|
||||
>>>>>>> 4f15ab66 (Various compilation/merge issues)
|
||||
}
|
||||
});
|
||||
|
||||
@@ -326,6 +330,10 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
|
||||
}
|
||||
|
||||
private void registerChannelCommands(
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
final CarbonMessages carbonMessages,
|
||||
>>>>>>> 4f15ab66 (Various compilation/merge issues)
|
||||
final ChatChannel channel,
|
||||
final CommandManager<Commander> commandManager
|
||||
) {
|
||||
@@ -353,6 +361,10 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
|
||||
|
||||
if (sender.muted()) {
|
||||
this.carbonMessages.muteCannotSpeak(sender);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
carbonMessages.muteCannotSpeak(sender);
|
||||
>>>>>>> 4f15ab66 (Various compilation/merge issues)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -380,7 +392,7 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
|
||||
|
||||
private void sendMessageInChannelAsPlayer(
|
||||
final CarbonPlayer sender,
|
||||
ChatChannel channel,
|
||||
final ChatChannel channel,
|
||||
final String plainMessage
|
||||
) {
|
||||
// Should we silent exit here? Chances are whatever caused the
|
||||
|
||||
@@ -31,8 +31,8 @@ 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.ConfigChannelMessages;
|
||||
import net.draycia.carbon.common.channels.messages.ConfigChannelMessageSource;
|
||||
import net.draycia.carbon.common.channels.messages.ConfigChannelMessages;
|
||||
import net.draycia.carbon.common.messages.SourcedMessageSender;
|
||||
import net.draycia.carbon.common.messages.SourcedReceiverResolver;
|
||||
import net.draycia.carbon.common.messages.placeholders.BooleanPlaceholderResolver;
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.draycia.carbon.common.command.PlayerCommander;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
+4
-4
@@ -105,7 +105,7 @@ public class ContinueCommand extends CarbonCommand {
|
||||
|
||||
if (!recipient.online() || !sender.awareOf(recipient) && !sender.hasPermission("carbon.whisper.vanished")) {
|
||||
final var rawNameInput = CloudUtils.rawInputByMatchingName(handler.getRawInput(), recipient);
|
||||
final var exception = new CarbonPlayerArgument.CarbonPlayerParseException(rawNameInput, handler, carbonMessages);
|
||||
final var exception = new CarbonPlayerArgument.CarbonPlayerParseException(rawNameInput, handler, this.carbonMessages);
|
||||
|
||||
carbonMessages.errorCommandArgumentParsing(sender, CloudUtils.message(exception));
|
||||
return;
|
||||
@@ -124,9 +124,9 @@ public class ContinueCommand extends CarbonCommand {
|
||||
final Component senderName = CarbonPlayer.renderName(sender);
|
||||
final Component recipientName = CarbonPlayer.renderName(recipient);
|
||||
|
||||
carbonMessages.whisperSender(new SourcedAudience(sender, sender), senderName, recipientName, message);
|
||||
carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
|
||||
carbonMessages.whisperConsoleLog(carbonChat.server().console(), senderName, recipientName, message);
|
||||
this.carbonMessages.whisperSender(new SourcedAudience(sender, sender), senderName, recipientName, message);
|
||||
this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
|
||||
this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message);
|
||||
|
||||
sender.lastWhisperTarget(recipient.uuid());
|
||||
sender.whisperReplyTarget(recipient.uuid());
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
||||
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.JoinConfiguration;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
@@ -31,11 +31,11 @@ import java.util.List;
|
||||
import net.draycia.carbon.common.command.CarbonCommand;
|
||||
import net.draycia.carbon.common.command.CommandSettings;
|
||||
import net.draycia.carbon.common.command.Commander;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.draycia.carbon.common.messages.CarbonMessageSource;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@@ -120,19 +120,17 @@ public final class HelpCommand extends CarbonCommand {
|
||||
|
||||
help.messageProvider((sender, key, args) -> {
|
||||
final String messageKey = "command.help.misc." + key;
|
||||
final TagResolver resolver;
|
||||
final TagResolver.Builder tagResolver = TagResolver.builder();
|
||||
|
||||
// Total hack but works for now
|
||||
if (args.length == 2) {
|
||||
resolver = TagResolver.resolver(
|
||||
Placeholder.component("page", text(args[0])),
|
||||
Placeholder.component("max_pages", text(args[1]))
|
||||
tagResolver
|
||||
.tag("page", Tag.inserting(text(args[0])))
|
||||
.tag("max_pages", Tag.inserting(text(args[1]))
|
||||
);
|
||||
} else {
|
||||
resolver = TagResolver.empty();
|
||||
}
|
||||
|
||||
return MiniMessage.miniMessage().deserialize(messageSource.messageOf(sender, messageKey), resolver);
|
||||
return MiniMessage.miniMessage().deserialize(messageSource.messageOf(sender, messageKey), tagResolver.build());
|
||||
});
|
||||
|
||||
return help;
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
||||
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@@ -71,10 +72,10 @@ public class IgnoreCommand extends CarbonCommand {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
final var command = commandManager.commandBuilder("ignore", "block")
|
||||
.argument(CarbonPlayerArgument.newBuilder("player").withMessages(this.carbonMessages).withSuggestionsProvider(playerSuggestions).asOptional(),
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.newBuilder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandIgnoreArgumentPlayer().component()))
|
||||
.flag(commandManager.flagBuilder("uuid")
|
||||
.flag(this.commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandIgnoreArgumentUUID().component()))
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
||||
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@@ -71,10 +72,10 @@ public class MuteCommand extends CarbonCommand {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
final var command = commandManager.commandBuilder("mute")
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.newBuilder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandMuteArgumentPlayer().component()))
|
||||
.flag(commandManager.flagBuilder("uuid")
|
||||
.flag(this.commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandMuteArgumentUUID().component()))
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
|
||||
+6
-5
@@ -35,6 +35,7 @@ import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
||||
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@@ -71,12 +72,12 @@ public class MuteInfoCommand extends CarbonCommand {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
final var command = commandManager.commandBuilder("muteinfo", "muted")
|
||||
.argument(CarbonPlayerArgument.newBuilder("player").withMessages(carbonMessages).withSuggestionsProvider(playerSuggestions).asOptional(),
|
||||
RichDescription.of(carbonMessages.commandMuteInfoArgumentPlayer().component()))
|
||||
.flag(commandManager.flagBuilder("uuid")
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.newBuilder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandMuteInfoArgumentPlayer().component()))
|
||||
.flag(this.commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withDescription(RichDescription.of(carbonMessages.commandMuteInfoArgumentUUID().component()))
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandMuteInfoArgumentUUID().component()))
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
)
|
||||
.permission("carbon.mute.info")
|
||||
|
||||
+3
-2
@@ -35,6 +35,7 @@ import net.draycia.carbon.common.command.argument.OptionValueParser;
|
||||
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -74,8 +75,8 @@ public class NicknameCommand extends CarbonCommand {
|
||||
// TODO: Allow UUID input for target player
|
||||
.flag(this.commandManager.flagBuilder("player")
|
||||
.withAliases("p")
|
||||
.withDescription(RichDescription.of(carbonMessages.commandNicknameArgumentPlayer().component()))
|
||||
.withArgument(CarbonPlayerArgument.newBuilder("player").withMessages(carbonMessages).withSuggestionsProvider(playerSuggestions).asOptional())
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandNicknameArgumentPlayer().component()))
|
||||
.withArgument(CarbonPlayerArgument.newBuilder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional())
|
||||
.withPermission(Permission.of("carbon.nickname.others"))
|
||||
)
|
||||
.flag(this.commandManager.flagBuilder("nickname")
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.draycia.carbon.common.command.Commander;
|
||||
import net.draycia.carbon.common.events.CarbonReloadEvent;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@@ -66,7 +67,7 @@ public class ReloadCommand extends CarbonCommand {
|
||||
.literal("reload")
|
||||
.permission("carbon.reload")
|
||||
.senderType(Commander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, carbonMessages.commandReloadDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandReloadDescription().component())
|
||||
.handler(handler -> {
|
||||
// TODO: Check if all listeners succeeded
|
||||
carbonChat.eventHandler().emit(new CarbonReloadEvent());
|
||||
|
||||
@@ -105,7 +105,7 @@ public class ReplyCommand extends CarbonCommand {
|
||||
|
||||
if (!recipient.online() || !sender.awareOf(recipient) && !sender.hasPermission("carbon.whisper.vanished")) {
|
||||
final var rawNameInput = CloudUtils.rawInputByMatchingName(handler.getRawInput(), recipient);
|
||||
final var exception = new CarbonPlayerArgument.CarbonPlayerParseException(rawNameInput, handler, carbonMessages);
|
||||
final var exception = new CarbonPlayerArgument.CarbonPlayerParseException(rawNameInput, handler, this.carbonMessages);
|
||||
|
||||
carbonMessages.errorCommandArgumentParsing(sender, CloudUtils.message(exception));
|
||||
return;
|
||||
@@ -124,9 +124,9 @@ public class ReplyCommand extends CarbonCommand {
|
||||
final Component senderName = CarbonPlayer.renderName(sender);
|
||||
final Component recipientName = CarbonPlayer.renderName(recipient);
|
||||
|
||||
carbonMessages.whisperSender(new SourcedAudience(sender, sender), senderName, recipientName, message);
|
||||
carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
|
||||
carbonMessages.whisperConsoleLog(carbonChat.server().console(), senderName, recipientName, message);
|
||||
this.carbonMessages.whisperSender(new SourcedAudience(sender, sender), senderName, recipientName, message);
|
||||
this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
|
||||
this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message);
|
||||
|
||||
sender.lastWhisperTarget(recipient.uuid());
|
||||
sender.whisperReplyTarget(recipient.uuid());
|
||||
|
||||
+4
-3
@@ -35,6 +35,7 @@ import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
||||
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@@ -73,9 +74,9 @@ public class UnignoreCommand extends CarbonCommand {
|
||||
public void init() {
|
||||
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.newBuilder("player").withMessages(carbonMessages).withSuggestionsProvider(playerSuggestions).asOptional(),
|
||||
RichDescription.of(carbonMessages.commandUnignoreArgumentPlayer().component()))
|
||||
.flag(commandManager.flagBuilder("uuid")
|
||||
.argument(CarbonPlayerArgument.newBuilder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandUnignoreArgumentPlayer().component()))
|
||||
.flag(this.commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withDescription(RichDescription.of(carbonMessages.commandUnignoreArgumentUUID().component()))
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
||||
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@@ -71,12 +72,12 @@ public class UnmuteCommand extends CarbonCommand {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
final var command = commandManager.commandBuilder("unmute")
|
||||
.argument(CarbonPlayerArgument.newBuilder("player").withMessages(carbonMessages).withSuggestionsProvider(playerSuggestions).asOptional(),
|
||||
RichDescription.of(carbonMessages.commandUnmuteArgumentPlayer().component()))
|
||||
.flag(commandManager.flagBuilder("uuid")
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.newBuilder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asOptional(),
|
||||
RichDescription.of(this.carbonMessages.commandUnmuteArgumentPlayer().component()))
|
||||
.flag(this.commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withDescription(RichDescription.of(carbonMessages.commandUnmuteArgumentUUID().component()))
|
||||
.withDescription(RichDescription.of(this.carbonMessages.commandUnmuteArgumentUUID().component()))
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
)
|
||||
.permission("carbon.mute.unmute")
|
||||
|
||||
@@ -73,14 +73,14 @@ public class WhisperCommand extends CarbonCommand {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
final var command = commandManager.commandBuilder("whisper", "w", "message", "msg", "m", "tell")
|
||||
.argument(CarbonPlayerArgument.newBuilder("player").withMessages(carbonMessages).withSuggestionsProvider(playerSuggestions).asRequired(),
|
||||
RichDescription.of(carbonMessages.commandWhisperArgumentPlayer().component()))
|
||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||
.argument(CarbonPlayerArgument.newBuilder("player").withMessages(this.carbonMessages).withSuggestionsProvider(this.playerSuggestions).asRequired(),
|
||||
RichDescription.of(this.carbonMessages.commandWhisperArgumentPlayer().component()))
|
||||
.argument(StringArgument.greedy("message"),
|
||||
RichDescription.of(carbonMessages.commandWhisperArgumentMessage().component()))
|
||||
RichDescription.of(this.carbonMessages.commandWhisperArgumentMessage().component()))
|
||||
.permission("carbon.whisper.message")
|
||||
.senderType(PlayerCommander.class)
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, carbonMessages.commandWhisperDescription().component())
|
||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandWhisperDescription().component())
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
|
||||
@@ -99,7 +99,7 @@ public class WhisperCommand extends CarbonCommand {
|
||||
|
||||
if (!recipient.online() || !sender.awareOf(recipient) && !sender.hasPermission("carbon.whisper.vanished")) {
|
||||
final var rawNameInput = CloudUtils.rawInputByMatchingName(handler.getRawInput(), recipient);
|
||||
final var exception = new CarbonPlayerArgument.CarbonPlayerParseException(rawNameInput, handler, carbonMessages);
|
||||
final var exception = new CarbonPlayerArgument.CarbonPlayerParseException(rawNameInput, handler, this.carbonMessages);
|
||||
|
||||
carbonMessages.errorCommandArgumentParsing(sender, CloudUtils.message(exception));
|
||||
return;
|
||||
@@ -118,9 +118,9 @@ public class WhisperCommand extends CarbonCommand {
|
||||
final Component senderName = CarbonPlayer.renderName(sender);
|
||||
final Component recipientName = CarbonPlayer.renderName(recipient);
|
||||
|
||||
carbonMessages.whisperSender(new SourcedAudience(sender, sender), senderName, recipientName, message);
|
||||
carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
|
||||
carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message);
|
||||
this.carbonMessages.whisperSender(new SourcedAudience(sender, sender), senderName, recipientName, message);
|
||||
this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
|
||||
this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message);
|
||||
|
||||
sender.lastWhisperTarget(recipient.uuid());
|
||||
sender.whisperReplyTarget(recipient.uuid());
|
||||
|
||||
@@ -21,7 +21,7 @@ package net.draycia.carbon.common.config;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -59,8 +59,10 @@ public class ClearChatSettings {
|
||||
|
||||
public Component broadcast(final Component displayName, final String username) {
|
||||
return MiniMessage.miniMessage().deserialize(this.broadcast,
|
||||
TagResolver.resolver(Placeholder.component("display_name", displayName),
|
||||
Placeholder.component("username", Component.text(username))));
|
||||
TagResolver.builder()
|
||||
.tag("display_name", Tag.inserting(displayName))
|
||||
.tag("username", Tag.inserting(Component.text(username)))
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,8 +22,6 @@ package net.draycia.carbon.common.messages;
|
||||
import com.google.inject.Inject;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
@@ -32,7 +30,7 @@ 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.resolver.Placeholder;
|
||||
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;
|
||||
@@ -57,10 +55,10 @@ public class CarbonMessageRenderer implements IMessageRenderer<Audience, String,
|
||||
final Method method,
|
||||
final Type owner
|
||||
) {
|
||||
final List<TagResolver> templates = new ArrayList<>();
|
||||
final TagResolver.Builder tagResolver = TagResolver.builder();
|
||||
|
||||
for (final var entry : resolvedPlaceholders.entrySet()) {
|
||||
templates.add(Placeholder.component(entry.getKey(), entry.getValue()));
|
||||
tagResolver.tag(entry.getKey(), Tag.inserting(entry.getValue()));
|
||||
}
|
||||
|
||||
// https://github.com/KyoriPowered/adventure-text-minimessage/issues/131
|
||||
@@ -72,7 +70,7 @@ public class CarbonMessageRenderer implements IMessageRenderer<Audience, String,
|
||||
entry.getValue());
|
||||
}
|
||||
|
||||
final Component message = MiniMessage.miniMessage().deserialize(placeholderResolvedMessage, TagResolver.resolver(templates));
|
||||
final Component message = MiniMessage.miniMessage().deserialize(placeholderResolvedMessage, tagResolver.build());
|
||||
final MessageType messageType;
|
||||
final @Nullable ChatType chatType = method.getAnnotation(ChatType.class);
|
||||
|
||||
|
||||
+27
-8
@@ -1,13 +1,32 @@
|
||||
/*
|
||||
* 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.messaging;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
|
||||
import net.draycia.carbon.common.messaging.packets.ChatMessagePacket;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import ninja.egg82.messenger.handler.AbstractMessagingHandler;
|
||||
import ninja.egg82.messenger.packets.Packet;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -28,19 +47,19 @@ public final class CarbonChatPacketHandler extends AbstractMessagingHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handlePacket(@NotNull Packet packet) {
|
||||
protected boolean handlePacket(final @NotNull Packet packet) {
|
||||
if (!(packet instanceof ChatMessagePacket messagePacket)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final var placeholders = new ArrayList<Placeholder<?>>();
|
||||
final TagResolver.Builder tagResolver = TagResolver.builder();
|
||||
|
||||
for (final var entry : messagePacket.getPlaceholders().entrySet()) {
|
||||
placeholders.add(Placeholder.miniMessage(entry.getKey(), entry.getValue()));
|
||||
for (final var entry : messagePacket.placeholders().entrySet()) {
|
||||
tagResolver.tag(entry.getKey(), Tag.inserting(Component.text(entry.getValue())));
|
||||
}
|
||||
|
||||
final var component = MiniMessage.miniMessage().deserialize(messagePacket.intermediary(),
|
||||
PlaceholderResolver.placeholders(placeholders));
|
||||
tagResolver.build());
|
||||
|
||||
for (final var recipient : CarbonChatProvider.carbonChat().server().players()) {
|
||||
if (recipient.hasPermission(messagePacket.channelPermission() + ".see")) {
|
||||
|
||||
@@ -82,38 +82,38 @@ public class MessagingManager {
|
||||
this.packetService = new PacketService(4, false, protocolVersion);
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
final MessagingHandlerImpl handlerImpl = new MessagingHandlerImpl(packetService);
|
||||
handlerImpl.addHandler(new CarbonServerHandler(carbonChat.serverId(), packetService, handlerImpl));
|
||||
final MessagingHandlerImpl handlerImpl = new MessagingHandlerImpl(this.packetService);
|
||||
handlerImpl.addHandler(new CarbonServerHandler(carbonChat.serverId(), this.packetService, handlerImpl));
|
||||
handlerImpl.addHandler(new CarbonChatPacketHandler(this, channelRegistry));
|
||||
|
||||
try {
|
||||
this.initMessagingService(packetService, handlerImpl, new File("/"),
|
||||
this.initMessagingService(this.packetService, handlerImpl, new File("/"),
|
||||
configFactory.primaryConfig().messagingSettings());
|
||||
} catch (final IOException | TimeoutException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
packetService.addMessenger(this.messagingService);
|
||||
this.packetService.addMessenger(this.messagingService);
|
||||
|
||||
packetService.queuePacket(new InitializationPacket(carbonChat.serverId(), protocolVersion));
|
||||
packetService.flushQueue();
|
||||
this.packetService.queuePacket(new InitializationPacket(carbonChat.serverId(), protocolVersion));
|
||||
this.packetService.flushQueue();
|
||||
|
||||
// Broadcast keepalive packets
|
||||
executorService.scheduleAtFixedRate(() -> {
|
||||
packetService.queuePacket(new KeepAlivePacket(carbonChat.serverId()));
|
||||
packetService.flushQueue();
|
||||
this.executorService.scheduleAtFixedRate(() -> {
|
||||
this.packetService.queuePacket(new KeepAlivePacket(carbonChat.serverId()));
|
||||
this.packetService.flushQueue();
|
||||
}, 5, 10, TimeUnit.SECONDS);
|
||||
|
||||
// Broadcast heartbeat packets
|
||||
executorService.scheduleAtFixedRate(() -> {
|
||||
packetService.queuePacket(new HeartbeatPacket(carbonChat.serverId(), protocolVersion));
|
||||
packetService.flushQueue();
|
||||
this.executorService.scheduleAtFixedRate(() -> {
|
||||
this.packetService.queuePacket(new HeartbeatPacket(carbonChat.serverId(), protocolVersion));
|
||||
this.packetService.flushQueue();
|
||||
}, 5, 5, TimeUnit.SECONDS);
|
||||
|
||||
executorService.scheduleAtFixedRate(() -> {
|
||||
this.executorService.scheduleAtFixedRate(() -> {
|
||||
try {
|
||||
packetService.flushQueue();
|
||||
this.packetService.flushQueue();
|
||||
} catch (final IndexOutOfBoundsException ignored) {
|
||||
|
||||
}
|
||||
@@ -195,9 +195,9 @@ public class MessagingManager {
|
||||
private static final class CarbonServerHandler extends AbstractServerMessagingHandler {
|
||||
|
||||
private CarbonServerHandler(
|
||||
@NotNull UUID serverId,
|
||||
@NotNull PacketService packetService,
|
||||
@NotNull MessagingHandler messagingHandler
|
||||
final @NotNull UUID serverId,
|
||||
final @NotNull PacketService packetService,
|
||||
final @NotNull MessagingHandler messagingHandler
|
||||
) {
|
||||
super(serverId, packetService, messagingHandler);
|
||||
}
|
||||
|
||||
@@ -34,16 +34,16 @@ public abstract class CarbonPacket extends AbstractPacket {
|
||||
|
||||
private final GsonComponentSerializer componentSerializer = GsonComponentSerializer.gson();
|
||||
|
||||
protected CarbonPacket(@NotNull UUID sender) {
|
||||
protected CarbonPacket(final @NotNull UUID sender) {
|
||||
super(sender);
|
||||
}
|
||||
|
||||
protected final void writeComponent(final Component component, final ByteBuf buffer) {
|
||||
this.writeString(componentSerializer.serialize(component), buffer);
|
||||
this.writeString(this.componentSerializer.serialize(component), buffer);
|
||||
}
|
||||
|
||||
protected final Component readComponent(final ByteBuf buffer) {
|
||||
return componentSerializer.deserialize(this.readString(buffer));
|
||||
return this.componentSerializer.deserialize(this.readString(buffer));
|
||||
}
|
||||
|
||||
protected final void writeKey(final Key key, final ByteBuf buffer) {
|
||||
|
||||
+27
-27
@@ -28,30 +28,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class ChatMessagePacket extends CarbonPacket {
|
||||
|
||||
public UUID userId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public String channelPermission() {
|
||||
return this.channelPermission;
|
||||
}
|
||||
|
||||
public Key channelKey() {
|
||||
return channelKey;
|
||||
}
|
||||
|
||||
public String username() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String intermediary() {
|
||||
return intermediary;
|
||||
}
|
||||
|
||||
public Map<String, String> getPlaceholders() {
|
||||
return placeholders;
|
||||
}
|
||||
|
||||
// TODO: store item link placeholder components
|
||||
private UUID userId;
|
||||
private String channelPermission;
|
||||
@@ -60,7 +36,31 @@ public final class ChatMessagePacket extends CarbonPacket {
|
||||
private String intermediary;
|
||||
private Map<String, String> placeholders;
|
||||
|
||||
public ChatMessagePacket(@NotNull UUID sender, @NotNull ByteBuf data) {
|
||||
public UUID userId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public String channelPermission() {
|
||||
return this.channelPermission;
|
||||
}
|
||||
|
||||
public Key channelKey() {
|
||||
return this.channelKey;
|
||||
}
|
||||
|
||||
public String username() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String intermediary() {
|
||||
return this.intermediary;
|
||||
}
|
||||
|
||||
public Map<String, String> placeholders() {
|
||||
return this.placeholders;
|
||||
}
|
||||
|
||||
public ChatMessagePacket(final @NotNull UUID sender, final @NotNull ByteBuf data) {
|
||||
super(sender);
|
||||
this.read(data);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public final class ChatMessagePacket extends CarbonPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(io.netty.buffer.@NotNull ByteBuf buffer) {
|
||||
public void read(final io.netty.buffer.@NotNull ByteBuf buffer) {
|
||||
this.userId = this.readUUID(buffer);
|
||||
this.channelPermission = this.readString(buffer);
|
||||
this.channelKey = this.readKey(buffer);
|
||||
@@ -98,7 +98,7 @@ public final class ChatMessagePacket extends CarbonPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(io.netty.buffer.@NotNull ByteBuf buffer) {
|
||||
public void write(final io.netty.buffer.@NotNull ByteBuf buffer) {
|
||||
this.writeUUID(this.userId, buffer);
|
||||
this.writeString(this.channelPermission, buffer);
|
||||
this.writeKey(this.channelKey, buffer);
|
||||
|
||||
Reference in new issue
Block a user