Class BukkitPlayerSource<K>
java.lang.Object
io.github.projectunified.valuevenue.bukkit.BukkitPlayerSource<K>
- Type Parameters:
K- type of the key
- All Implemented Interfaces:
ValueSource<K,,org.bukkit.OfflinePlayer> Function<K,List<org.bukkit.OfflinePlayer>>
public class BukkitPlayerSource<K>
extends Object
implements ValueSource<K,org.bukkit.OfflinePlayer>
A
ValueSource whose values are the players of the server.
<key> resolves to the name of the player, and <key>_<variable> is delegated to
replaceVariable(String, OfflinePlayer), which returns null by default. Override it to resolve the player
variables of the owner, calling the default for the rest.
Whether a player is active is decided by its own filter, which is refreshed by the update of the generator. Which players a key may see is decided by the key filter, which gets both the player and the key, so the source does not have to know what a key is.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBukkitPlayerSource(boolean viewOffline) Creates the source withDEFAULT_KEY, without a filter.BukkitPlayerSource(boolean viewOffline, BiPredicate<org.bukkit.OfflinePlayer, K> playerFilter) Creates the source withDEFAULT_KEY.BukkitPlayerSource(boolean viewOffline, Predicate<org.bukkit.OfflinePlayer> activatedFilter, BiPredicate<org.bukkit.OfflinePlayer, K> playerFilter) Creates the source withDEFAULT_KEY.BukkitPlayerSource(String key, boolean viewOffline, Predicate<org.bukkit.OfflinePlayer> activatedFilter, BiPredicate<org.bukkit.OfflinePlayer, K> playerFilter) Creates the source. -
Method Summary
Modifier and TypeMethodDescriptionprotected Stream<org.bukkit.OfflinePlayer> Applies the filter of the source to the players of the key.Stream<org.bukkit.OfflinePlayer> All source values that do not depend on a key.Stream<org.bukkit.OfflinePlayer> getSourceValueStream(K key) Source values to expose for the given key.booleanisSourceValueActivated(org.bukkit.OfflinePlayer value) Whether a source value is currently active.Resolves a variable of the source value.protected ObjectreplaceVariable(String variable, org.bukkit.OfflinePlayer value) Resolves a player variable, the part of<key>_<variable>after the prefix.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.projectunified.valuevenue.core.ValueSource
apply
-
Field Details
-
DEFAULT_KEY
The key used when none is given.- See Also:
-
-
Constructor Details
-
BukkitPlayerSource
public BukkitPlayerSource(boolean viewOffline) Creates the source withDEFAULT_KEY, without a filter.- Parameters:
viewOffline- whether offline players are included
-
BukkitPlayerSource
public BukkitPlayerSource(boolean viewOffline, BiPredicate<org.bukkit.OfflinePlayer, K> playerFilter) Creates the source withDEFAULT_KEY.- Parameters:
viewOffline- whether offline players are includedplayerFilter- filter a player has to pass to be exposed for a key, or null to expose every player
-
BukkitPlayerSource
public BukkitPlayerSource(boolean viewOffline, Predicate<org.bukkit.OfflinePlayer> activatedFilter, BiPredicate<org.bukkit.OfflinePlayer, K> playerFilter) Creates the source withDEFAULT_KEY.- Parameters:
viewOffline- whether offline players are includedactivatedFilter- filter a player has to pass to be active, or null to activate every playerplayerFilter- filter a player has to pass to be exposed for a key, or null to expose every player
-
BukkitPlayerSource
public BukkitPlayerSource(String key, boolean viewOffline, Predicate<org.bukkit.OfflinePlayer> activatedFilter, BiPredicate<org.bukkit.OfflinePlayer, K> playerFilter) Creates the source.- Parameters:
key- name of the variable holding the player itself, without the trailing underscoreviewOffline- whether offline players are includedactivatedFilter- filter a player has to pass to be active, or null to activate every playerplayerFilter- filter a player has to pass to be exposed for a key, or null to expose every player
-
-
Method Details
-
replace
Description copied from interface:ValueSourceResolves a variable of the source value.- Specified by:
replacein interfaceValueSource<K,org.bukkit.OfflinePlayer> - Parameters:
input- name of the variable, without its markersvalue- source value the variable is resolved for- Returns:
- the replacement, or null if the variable is not known
-
replaceVariable
Resolves a player variable, the part of<key>_<variable>after the prefix.- Parameters:
variable- name of the variablevalue- player the variable is resolved for- Returns:
- the replacement, or null if the variable is not known
-
isSourceValueActivated
public boolean isSourceValueActivated(org.bukkit.OfflinePlayer value) Description copied from interface:ValueSourceWhether a source value is currently active.- Specified by:
isSourceValueActivatedin interfaceValueSource<K,org.bukkit.OfflinePlayer> - Parameters:
value- source value to check- Returns:
- true if the value may be exposed
-
getSourceValueStream
Description copied from interface:ValueSourceAll source values that do not depend on a key.Empty by default: a source that only knows its values through
ValueSource.getSourceValueStream(Object)needs no override.- Specified by:
getSourceValueStreamin interfaceValueSource<K,org.bukkit.OfflinePlayer> - Returns:
- stream of every key-independent source value
-
getSourceValueStream
Description copied from interface:ValueSourceSource values to expose for the given key. Defaults toValueSource.getSourceValueStream().- Specified by:
getSourceValueStreamin interfaceValueSource<K,org.bukkit.OfflinePlayer> - Parameters:
key- key whose source values are requested- Returns:
- stream of source values for the key
-
filter
Applies the filter of the source to the players of the key.- Parameters:
players- the players to filterkey- the key they are exposed for- Returns:
- stream of the players the key may see
-