Skip to content

Commit

Permalink
Readd SimpleComponent#ignoreEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
kangarko committed Apr 27, 2024
1 parent d4ef1fe commit 6a1ead6
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/org/mineacademy/fo/model/SimpleComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public final class SimpleComponent implements ConfigSerializable {
@Getter
private boolean firingEvent = false;

/**
* Shall this component ignore empty components? Defaults to false
*/
private boolean ignoreEmpty = false;

/**
* Create a new interactive chat component
*
Expand Down Expand Up @@ -473,7 +478,7 @@ public <T extends CommandSender> void sendAs(@Nullable final CommandSender sende

final String legacy = Common.colorize(component.toLegacyText());

if (Common.stripColors(legacy).trim().isEmpty()) {
if (Common.stripColors(legacy).trim().isEmpty() && this.ignoreEmpty) {
Debugger.debug("component", "Message is empty, skipping.");

continue;
Expand Down Expand Up @@ -546,6 +551,18 @@ public SimpleComponent setFiringEvent(final boolean firingEvent) {
return this;
}

/**
* Set if this component should ignore empty components? Defaults to false
*
* @param ignoreEmpty
* @return
*/
public SimpleComponent setIgnoreEmpty(final boolean ignoreEmpty) {
this.ignoreEmpty = ignoreEmpty;

return this;
}

/**
* @see java.lang.Object#toString()
*/
Expand Down

0 comments on commit 6a1ead6

Please sign in to comment.