Skip to content

Commit

Permalink
add info about default player source filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehum committed Nov 21, 2024
1 parent 16e655b commit f71efd7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/api/sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,21 @@ Entity sources are attached to the entities.
:::

### Player source
Player sources are attached to the players.
Player source is attached to the player, audio will be played at a certain distance around the player.

::: code-group
<<< @/snippets/api/sources/player.java [java]
<<< @/snippets/api/sources/player.kt{kotlin} [kotlin]
:::

By default, the player attached to the source can't hear the audio.
If you want to override this behaviour, you need to remove the first source filter:
::: code-group
<<< @/snippets/api/sources/player-remove-filter.java [java]
<<< @/snippets/api/sources/player-remove-filter.kt{kotlin} [kotlin]
:::
You can also remove all filters, but beware that vanish support won't work for this source.

### Direct source
Direct sources are attached to a specific player and can only be heard by that player.

Expand Down
6 changes: 6 additions & 0 deletions snippets/api/sources/player-remove-filter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ServerPlayerSource source = /* */;

source.getFilters()
.stream()
.findFirst()
.ifPresent(source::removeFilter);
3 changes: 3 additions & 0 deletions snippets/api/sources/player-remove-filter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
val source: ServerPlayerSource = /* */

source.removeFilter(source.filters.first())

0 comments on commit f71efd7

Please sign in to comment.