-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #403 from Mindgamesnl/feature/peer-filter-api
Migrate peer filter api, support legacy, add author DiamondDagger590 …
- Loading branch information
Showing
13 changed files
with
224 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
api/src/main/java/com/craftmend/openaudiomc/api/voice/CustomPlayerFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.craftmend.openaudiomc.api.voice; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
/** | ||
* <p>This represents a function that can be implemented by any plugin in order to modify how players will be checked | ||
* against each other.</p> | ||
* | ||
* <p>The easiest example is a game plugin, which will not let players hear each other if they are on different teams, or moderation | ||
* where you would prevent two players from hearing each other if one of them has been muted/punished.</p> | ||
* | ||
* <p>This function is called AFTER the other sanity checks at the time of writing, meaning that these functions will | ||
* be called assuming the players are in valid range of each other and so forth.</p> | ||
* | ||
* <p>Please note that a filter is only called in one direction, meaning that if its called for playerA -> playerB, it will not be called for playerB -> playerA. | ||
* This is done as an optimization to prevent poor scaling with a large amount of players.</p> | ||
* | ||
* <p>Because of that, filters should only be used to filter players that should be considered for voicechat. | ||
* If you with to setup one-directional voicechat, then you should use {@link com.craftmend.openaudiomc.api.events.client.ClientPeerAddEvent}, which will be called twice | ||
* (once for each player) and allow you to cancel the event if you don't want the players to be able to hear each other.</p> | ||
* | ||
* <p>Filters are managed through the {@link com.craftmend.openaudiomc.api.VoiceApi}</p> | ||
* | ||
* @author DiamondDagger590 | ||
* @author Mats | ||
* @since 6.10.0 | ||
*/ | ||
@FunctionalInterface | ||
public interface CustomPlayerFilter { | ||
|
||
/** | ||
* This method is effectively a filter call from a Stream. | ||
* The return value decides if the two players should be allowed to connect in voicechat, granted that the events (which are only fired | ||
* for players who pass) aren't cancelled. | ||
* <br /> | ||
* This method is called once for every combination of players (ignoring order) | ||
* <br /> | ||
* If this combination should result in a valid connection, then the method should return {@code true}. | ||
* If the combination should not be valid, then the method should return {@code false}, which will also prevent further | ||
* events or filters from being called for this combination. | ||
* | ||
* @param listener The {@link Player} searching for other players to listen to | ||
* @param possibleSpeaker The {@link Player} who is being checked to see if they can be heard | ||
* @return {@code true} if the listener should be able to hear the possibleSpeaker | ||
*/ | ||
boolean isPlayerValidListener(Player listener, Player possibleSpeaker); | ||
} |
11 changes: 11 additions & 0 deletions
11
...java/com/craftmend/openaudiomc/spigot/modules/voicechat/filters/CustomFilterFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.craftmend.openaudiomc.spigot.modules.voicechat.filters; | ||
|
||
import com.craftmend.openaudiomc.api.voice.CustomPlayerFilter; | ||
|
||
@FunctionalInterface | ||
@Deprecated | ||
/** | ||
* This is a deprecated class, only kept to prevent breaking changes in the API due to class path. | ||
* Please use {@link CustomPlayerFilter} instead | ||
*/ | ||
public interface CustomFilterFunction extends CustomPlayerFilter {} |
5 changes: 5 additions & 0 deletions
5
...rc/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/filters/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* This package only contains some deprecated classes by the name/classpath of some old commonly used classes. | ||
* They are kept here to prevent breaking changes in the API, but are not used anymore and will be removed in the future. | ||
*/ | ||
package com.craftmend.openaudiomc.spigot.modules.voicechat.filters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
...java/com/craftmend/openaudiomc/spigot/modules/voicechat/filters/CustomFilterFunction.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.