-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0268eff
commit 825d939
Showing
4 changed files
with
44 additions
and
0 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
33 changes: 33 additions & 0 deletions
33
...main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/filters/impl/TeamFilter.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,33 @@ | ||
package com.craftmend.openaudiomc.spigot.modules.voicechat.filters.impl; | ||
|
||
import com.craftmend.openaudiomc.spigot.modules.voicechat.filters.CustomFilterFunction; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.scoreboard.Team; | ||
|
||
public class TeamFilter implements CustomFilterFunction { | ||
|
||
@Override | ||
public boolean isPlayerValidListener(Player listener, Player possibleSpeaker) { | ||
// is there a scoreboard present? | ||
if (Bukkit.getScoreboardManager() == null) return true; | ||
|
||
boolean assignmentMatch = true; | ||
for (Team team : Bukkit.getScoreboardManager().getMainScoreboard().getTeams()) { | ||
boolean foundPlayerA = team.hasEntry(listener.getName()); | ||
boolean foundPlayerB = team.hasEntry(possibleSpeaker.getName()); | ||
|
||
if (foundPlayerA && foundPlayerB) { | ||
return true; | ||
} | ||
|
||
// is only one of the players in the team? | ||
if (foundPlayerA || foundPlayerB) { | ||
assignmentMatch = false; | ||
} | ||
} | ||
|
||
return assignmentMatch; | ||
} | ||
|
||
} |
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