Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions api/src/main/java/net/kyori/adventure/audience/Audience.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.util.function.Predicate;
import java.util.stream.Collector;
import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.bossbar.BossBarViewer;
import net.kyori.adventure.chat.ChatType;
import net.kyori.adventure.chat.SignedMessage;
import net.kyori.adventure.dialog.DialogLike;
Expand All @@ -50,6 +49,7 @@
import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.title.Title;
import net.kyori.adventure.title.TitlePart;
import org.jetbrains.annotations.UnmodifiableView;

/**
* A receiver of Minecraft media.
Expand Down Expand Up @@ -95,7 +95,6 @@
* and any new methods will be stubbed by default.</p>
*
* @see ForwardingAudience
* @see BossBarViewer
* @since 4.0.0
*/
public interface Audience extends Pointered {
Expand Down Expand Up @@ -441,6 +440,17 @@ default void showBossBar(final BossBar bar) {
default void hideBossBar(final BossBar bar) {
}

/**
* Gets an unmodifiable view of all known currently active bossbars.
*
* @return an unmodifiable view of all known currently active bossbars
* @since 4.14.0
*/
@UnmodifiableView
default Iterable<? extends BossBar> activeBossBars() {
return List.of();
}

/**
* Plays a sound at the location of the recipient of the sound.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Predicate;
Expand All @@ -46,6 +48,7 @@
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.UnknownNullability;
import org.jetbrains.annotations.UnmodifiableView;
import org.jspecify.annotations.Nullable;

/**
Expand Down Expand Up @@ -162,6 +165,16 @@ default void hideBossBar(final BossBar bar) {
for (final Audience audience : this.audiences()) audience.hideBossBar(bar);
}

@Override
default @UnmodifiableView Iterable<? extends BossBar> activeBossBars() {
final Set<BossBar> bossBars = new HashSet<>();
for (final Audience audience : this.audiences()) {
for (final BossBar bb : audience.activeBossBars()) bossBars.add(bb);
}

return bossBars;
}

@Override
default void playSound(final Sound sound) {
for (final Audience audience : this.audiences()) audience.playSound(sound);
Expand Down Expand Up @@ -343,6 +356,11 @@ default void hideBossBar(final BossBar bar) {
this.audience().hideBossBar(bar);
}

@Override
default @UnmodifiableView Iterable<? extends BossBar> activeBossBars() {
return this.audience().activeBossBars();
}

@Override
default void playSound(final Sound sound) {
this.audience().playSound(sound);
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/net/kyori/adventure/bossbar/BossBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ default BossBar name(final ComponentLike name) {
* @since 4.14.0
*/
@UnmodifiableView
Iterable<? extends BossBarViewer> viewers();
Iterable<? extends Audience> viewers();

/**
* Show this bossbar to {@code viewer}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.function.BiConsumer;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.util.Services;
import org.jspecify.annotations.Nullable;
Expand Down Expand Up @@ -261,7 +262,7 @@ public BossBar removeListener(final Listener listener) {
}

@Override
public Iterable<? extends BossBarViewer> viewers() {
public Iterable<? extends Audience> viewers() {
if (this.implementation != null) {
return this.implementation.viewers();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package net.kyori.adventure.bossbar;

import java.util.List;
import net.kyori.adventure.audience.Audience;
import org.jetbrains.annotations.ApiStatus;

/**
Expand Down Expand Up @@ -54,7 +55,7 @@ static <I extends BossBarImplementation> I get(final BossBar bar, final Class<I>
* @since 4.14.0
*/
@ApiStatus.Internal
default Iterable<? extends BossBarViewer> viewers() {
default Iterable<? extends Audience> viewers() {
return List.of();
}

Expand Down
42 changes: 0 additions & 42 deletions api/src/main/java/net/kyori/adventure/bossbar/BossBarViewer.java

This file was deleted.