Revert "Use translatablecomponents"

This reverts commit 5585452f
This commit is contained in:
Draycia committed 2020-09-06 01:55:02 -07:00
1 parent 5585452fdc
commit 82023a0e72
2 files changed
+11 -13

No files matched your search

@@ -8,7 +8,6 @@ import net.draycia.carbon.events.PreChatFormatEvent;
import net.draycia.carbon.storage.ChatUser;
import net.draycia.carbon.util.CarbonUtils;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.Component;
@@ -131,7 +130,6 @@ public class CarbonChatChannel extends ChatChannel {
"phase", Long.toString(System.currentTimeMillis() % 25),
"server", carbonChat.getConfig().getString("server-name", "Server"));
if (isUserSpying(user, target)) {
String prefix = processPlaceholders(user, carbonChat.getConfig().getString("spy-prefix"));
@@ -139,8 +137,6 @@ public class CarbonChatChannel extends ChatChannel {
targetColor.asHexString()).append(formatComponent);
}
TranslatableComponent translation = TranslatableComponent.of("<message>", formatComponent);
TextComponent messageComponent;
if (user.isOnline() && user.asPlayer().hasPermission("carbonchat.formatting")) {
@@ -154,7 +150,9 @@ public class CarbonChatChannel extends ChatChannel {
messageComponent = TextComponent.of(formatEvent.getMessage());
}
TranslatableComponent processedComponent = translation.args(messageComponent);
TextComponent processedComponent = (TextComponent)formatComponent.replaceFirstText(MESSAGE_PATTERN, (input) -> {
return messageComponent.toBuilder();
});
ChatComponentEvent newEvent = new ChatComponentEvent(user, target, this, processedComponent,
formatEvent.getMessage());
@@ -180,10 +178,11 @@ public class CarbonChatChannel extends ChatChannel {
TextComponent consoleMessage = TextComponent.of(consoleFormatEvent.getMessage());
TranslatableComponent consoleTranslation = TranslatableComponent.of("<message>", consoleFormat)
.args(consoleMessage);
TextComponent consoleComponent = (TextComponent)consoleFormat.replaceFirstText(MESSAGE_PATTERN, (input) -> {
return consoleMessage.toBuilder();
});
ChatComponentEvent consoleEvent = new ChatComponentEvent(user, null, this, consoleTranslation,
ChatComponentEvent consoleEvent = new ChatComponentEvent(user, null, this, consoleComponent,
consoleFormatEvent.getMessage());
Bukkit.getPluginManager().callEvent(consoleEvent);
@@ -2,7 +2,6 @@ package net.draycia.carbon.events;
import net.draycia.carbon.channels.ChatChannel;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.event.Cancellable;
@@ -19,10 +18,10 @@ public class ChatComponentEvent extends Event implements Cancellable {
private @NotNull final ChatUser sender;
private @Nullable final ChatUser target;
private ChatChannel chatChannel;
private Component component;
private TextComponent component;
private final String originalMessage;
public ChatComponentEvent(@NotNull ChatUser sender, @Nullable ChatUser target, ChatChannel chatChannel, Component component, String originalMessage) {
public ChatComponentEvent(@NotNull ChatUser sender, @Nullable ChatUser target, ChatChannel chatChannel, TextComponent component, String originalMessage) {
super(!Bukkit.isPrimaryThread());
this.sender = sender;
@@ -70,11 +69,11 @@ public class ChatComponentEvent extends Event implements Cancellable {
this.chatChannel = chatChannel;
}
public Component getComponent() {
public TextComponent getComponent() {
return component;
}
public void setComponent(Component component) {
public void setComponent(TextComponent component) {
this.component = component;
}