Skip to content

Commit

Permalink
🔥 feat: Remove empty lines from tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-MX committed Oct 7, 2024
1 parent 27099ef commit 7226a47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@

import java.util.Locale;
import java.util.Objects;
import java.util.stream.Stream;

public class TextDisplayMetaConfiguration {

public static boolean applyTextMeta(@NotNull ConfigurationSection section, @NotNull TextDisplayMeta to, @NotNull Player self, @NotNull Player sender) {
Component text = section.getStringList("text")
Stream<Component> stream = section.getStringList("text")
.stream()
.map((line) -> convertToComponent(self, sender, line))
.filter((line) -> line != Component.empty() && !line.children().stream().allMatch((c) -> c == Component.empty()));

// TODO(matt): Test + Use config for filtering empty lines

Component text = stream
.reduce((a, b) -> a.append(Component.newline()).append(b))
.orElse(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public void updateSneak(boolean sneaking) {
previousBackgroundOpacity = color.getAlpha();
previousTextOpacity = meta.getTextOpacity();

// Not sure if this is vanilla behavior? Does only text opacity change??
meta.setBackgroundColor(withCustomSneakOpacity(color).asARGB());
meta.setTextOpacity((byte) getCustomOpacity());
} else {
Expand Down

0 comments on commit 7226a47

Please sign in to comment.