Skip to content

Commit cd62114

Browse files
authored
Add Audiences#withPermission (#2215)
* Add Audiences#withPermission * Add final and requireNonNull
1 parent 1d96cd1 commit cd62114

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/main/java/org/spongepowered/api/adventure/Audiences.java

+18-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import net.kyori.adventure.audience.Audience;
2828
import org.spongepowered.api.Sponge;
2929

30+
import java.util.Objects;
31+
3032
/**
3133
* {@link Audience}s.
3234
*/
@@ -47,7 +49,19 @@ public static Audience server() {
4749
* @return An audience
4850
*/
4951
public static Audience onlinePlayers() {
50-
return factory().onlinePlayers();
52+
return Sponge.getRegistry().getFactoryRegistry().provideFactory(Factory.class).onlinePlayers();
53+
}
54+
55+
/**
56+
* Gets an {@link Audience} that targets all online players
57+
* with the specified permission.
58+
*
59+
* @param permission The permission
60+
* @return An audience
61+
*/
62+
public static Audience withPermission(final String permission) {
63+
Objects.requireNonNull(permission);
64+
return Sponge.getRegistry().getFactoryRegistry().provideFactory(Factory.class).withPermission(permission);
5165
}
5266

5367
/**
@@ -59,13 +73,14 @@ public static Audience system() {
5973
return Sponge.getGame().getSystemSubject();
6074
}
6175

62-
// TODO: withPermission
63-
6476
private static Factory factory() {
6577
return Sponge.getRegistry().getFactoryRegistry().provideFactory(Factory.class);
6678
}
6779

6880
public interface Factory {
81+
6982
Audience onlinePlayers();
83+
84+
Audience withPermission(String permission);
7085
}
7186
}

0 commit comments

Comments
 (0)