Use a variable for the chat component & if they have a prefix, append the prefix to that variable instead of using else if

This commit is contained in:
Business Goose 2022-05-04 16:08:52 +01:00
parent cbbdb0248f
commit d716f77ac0
No known key found for this signature in database
GPG Key ID: 77DCA801362E9645

View File

@ -61,20 +61,15 @@ public class ChatListener extends PlexListener
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer) public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer)
{ {
String text = ((TextComponent)message).content(); String text = ((TextComponent)message).content();
Component component = Component.empty();
if (hasPrefix) if (hasPrefix)
{ {
return Component.empty() component = component.append(prefix);
.append(prefix)
.append(Component.space())
.append(PlexUtils.mmDeserialize(plugin.config.getString("chat.name-color", "<white>") + MiniMessage.builder().tags(TagResolver.resolver(StandardTags.color(), StandardTags.rainbow(), StandardTags.decorations(), StandardTags.gradient(), StandardTags.transition())).build().serialize(sourceDisplayName)))
.append(Component.space())
.append(Component.text("»").color(NamedTextColor.GRAY))
.append(Component.space())
.append(PlexUtils.mmDeserialize(text))
.replaceText(URL_REPLACEMENT_CONFIG);
} }
return Component.empty()
return component
.append(Component.space())
.append(PlexUtils.mmDeserialize(plugin.config.getString("chat.name-color", "<white>") + MiniMessage.builder().tags(TagResolver.resolver(StandardTags.color(), StandardTags.rainbow(), StandardTags.decorations(), StandardTags.gradient(), StandardTags.transition())).build().serialize(sourceDisplayName))) .append(PlexUtils.mmDeserialize(plugin.config.getString("chat.name-color", "<white>") + MiniMessage.builder().tags(TagResolver.resolver(StandardTags.color(), StandardTags.rainbow(), StandardTags.decorations(), StandardTags.gradient(), StandardTags.transition())).build().serialize(sourceDisplayName)))
.append(Component.space()) .append(Component.space())
.append(Component.text("»").color(NamedTextColor.GRAY)) .append(Component.text("»").color(NamedTextColor.GRAY))