Use legacy serializer instead

This commit is contained in:
nossr50 2020-11-06 14:13:46 -08:00
parent 0f15f234b5
commit bd48680125
8 changed files with 12 additions and 12 deletions

View File

@ -13,7 +13,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.text.StringUtils; import com.gmail.nossr50.util.text.StringUtils;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -39,7 +39,7 @@ public abstract class AbstractPlayerAuthor implements Author {
return componentDisplayName; return componentDisplayName;
} else { } else {
//convert to adventure component //convert to adventure component
componentDisplayName = TextUtils.ofBungeeRawStrings(displayName); componentDisplayName = TextUtils.ofLegacyTextRaw(displayName);
} }
return componentDisplayName; return componentDisplayName;
} }
@ -56,7 +56,7 @@ public abstract class AbstractPlayerAuthor implements Author {
return componentUserName; return componentUserName;
} else { } else {
//convert to adventure component //convert to adventure component
componentUserName = TextUtils.ofBungeeRawStrings(player.getName()); componentUserName = TextUtils.ofLegacyTextRaw(player.getName());
} }
return componentUserName; return componentUserName;
} }

View File

@ -54,9 +54,9 @@ public class AdminChatMailer extends AbstractChatMailer {
*/ */
public @NotNull TextComponent addStyle(@NotNull Author author, @NotNull String message, boolean canColor) { public @NotNull TextComponent addStyle(@NotNull Author author, @NotNull String message, boolean canColor) {
if(canColor) { if(canColor) {
return TextUtils.ofBungeeRawStrings(LocaleLoader.getString("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), LocaleLoader.addColors(message))); return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), LocaleLoader.addColors(message)));
} else { } else {
return TextUtils.ofBungeeRawStrings(LocaleLoader.getString("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), message)); return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), message));
} }
} }

View File

@ -50,9 +50,9 @@ public class PartyChatMailer extends AbstractChatMailer {
} }
if(isLeader) { if(isLeader) {
return TextUtils.ofBungeeRawStrings(LocaleLoader.getString("Chat.Style.Party.Leader", author.getAuthoredName(ChatChannel.PARTY), message)); return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Party.Leader", author.getAuthoredName(ChatChannel.PARTY), message));
} else { } else {
return TextUtils.ofBungeeRawStrings(LocaleLoader.getString("Chat.Style.Party", author.getAuthoredName(ChatChannel.PARTY), message)); return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Party", author.getAuthoredName(ChatChannel.PARTY), message));
} }
} }

View File

@ -1,10 +1,8 @@
package com.gmail.nossr50.chat.message; package com.gmail.nossr50.chat.message;
import com.gmail.nossr50.chat.author.Author; import com.gmail.nossr50.chat.author.Author;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -1,9 +1,7 @@
package com.gmail.nossr50.chat.message; package com.gmail.nossr50.chat.message;
import com.gmail.nossr50.chat.author.Author; import com.gmail.nossr50.chat.author.Author;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -46,7 +46,7 @@ public class PartyChatMessage extends AbstractChatMessage {
//Sends to everyone but console //Sends to everyone but console
audience.sendMessage(author, componentMessage); audience.sendMessage(author, componentMessage);
TextComponent spyMessage = TextUtils.ofBungeeRawStrings(LocaleLoader.getString("Chat.Spy.Party", author.getAuthoredName(ChatChannel.PARTY), rawMessage, party.getName())); TextComponent spyMessage = TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Spy.Party", author.getAuthoredName(ChatChannel.PARTY), rawMessage, party.getName()));
//Relay to spies //Relay to spies
messagePartyChatSpies(spyMessage); messagePartyChatSpies(spyMessage);

View File

@ -6,6 +6,7 @@ import net.kyori.adventure.text.ComponentBuilder;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -98,4 +99,8 @@ public class TextUtils {
public static @NotNull TextComponent ofBungeeRawStrings(@NotNull String bungeeRawString) { public static @NotNull TextComponent ofBungeeRawStrings(@NotNull String bungeeRawString) {
return ofBungeeComponents(convertToBungeeComponent(bungeeRawString)); return ofBungeeComponents(convertToBungeeComponent(bungeeRawString));
} }
public static @NotNull TextComponent ofLegacyTextRaw(@NotNull String rawString) {
return LegacyComponentSerializer.legacySection().deserialize(rawString);
}
} }