Contents
- Description
- Nested Class Summary
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- get()
- scheduleImmediatePositionUpdate(PlayerRef)
- getPlayerState(UUID)
- setPlayerVoiceChannel(UUID, String)
- getVoiceRouter()
- addPlayerVoiceInterceptor(PlayerVoiceInterceptor)
- addPlayerVoiceInterceptor(EventPriority, PlayerVoiceInterceptor)
- openEntityVoice(Ref)
- openPositionalVoice(World, Vector3d)
- openDirectVoice(Collection)
- isVoiceEnabled()
- setVoiceEnabled(boolean)
- isDeadPlayersCanHear()
- getMaxHearingDistance()
- setMaxHearingDistance(float)
- getReferenceDistance()
- setReferenceDistance(float)
- isPlayerMuted(UUID)
- mutePlayer(UUID)
- unmutePlayer(UUID)
- getGloballyMutedPlayers()
- getMaxPacketsPerSecond()
- getBurstCapacity()
- getMaxPacketSize()
- getCachedPosition(UUID)
- getVoiceExecutor(UUID)
- isShutdown()
- getPlayerStates()
Class VoiceModule
java.lang.Object
com.hypixel.hytale.server.core.plugin.PluginBase
com.hypixel.hytale.server.core.plugin.JavaPlugin
com.hypixel.hytale.server.core.modules.voice.VoiceModule
- All Implemented Interfaces:
CommandOwner
Server-side voice chat module. Routes player voice to nearby listeners by proximity, and exposes the
plugin voice-emit API (
openEntityVoice(Ref), openPositionalVoice(World, Vector3d), openDirectVoice(Collection))
for emitting Opus streams from entity-tracked, fixed-position, and non-spatial direct sources.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordImmutable position snapshot for thread-safe spatial queries from the voice executor. -
Field Summary
FieldsFields inherited from class PluginBase
METRICS_REGISTRY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPlayerVoiceInterceptor(EventPriority priority, PlayerVoiceInterceptor interceptor) Registers a hook invoked for each inbound player voice frame at the given priority.addPlayerVoiceInterceptor(PlayerVoiceInterceptor interceptor) Registers a hook invoked for each inbound player voice frame, letting a plugin observe, rewrite, re- route, or drop it, atEventPriority.NORMALpriority.static VoiceModuleget()intGets the burst capacity for token bucket rate limiting.getCachedPosition(UUID playerId) Gets a cached position snapshot for a player.Gets the set of globally muted players.floatGets the maximum distance at which voice can be heard.intGets the max packet size for validation.intGets the max packets per second for rate limiting.getPlayerState(UUID playerId) Gets the voice state for a player.Gets the map of player states (thread-safe).floatGets the full volume distance (distance at which voice is heard at 100% volume).getVoiceExecutor(UUID speakerId) Gets the voice executor for routing voice packets off the WorldThread.Gets the voice router for routing voice packets.booleanChecks if dead players can hear living players' voice.booleanisPlayerMuted(UUID playerId) Checks if a player is globally muted on the server.booleanWhether the module has been shut down.booleanChecks if voice is enabled on the server.booleanmutePlayer(UUID playerId) Globally mutes a player on the server.openDirectVoice(Collection<UUID> listeners) Opens a non-spatial voice stream delivered to exactly the given players (any world, no distance falloff), playing at the listener.openEntityVoice(Ref<EntityStore> entity) Opens a voice stream that follows an entity, heard by nearby players.openPositionalVoice(World world, org.joml.Vector3d position) Opens a voice stream at a world position, heard by nearby players.voidscheduleImmediatePositionUpdate(PlayerRef playerRef) Schedules an immediate position cache update for a player.voidsetMaxHearingDistance(float distance) Sets the maximum hearing distance.voidsetPlayerVoiceChannel(UUID playerId, String channel) Assigns a player to a named voice channel, or clears the assignment whenchannelis null.voidsetReferenceDistance(float distance) Sets the full volume distance.voidsetVoiceEnabled(boolean enabled) Sets whether voice is enabled on the server.booleanunmutePlayer(UUID playerId) Unmutes a globally muted player.Methods inherited from class JavaPlugin
getClassLoader, getFile, getTypeMethods inherited from class PluginBase
getAssetRegistry, getBasePermission, getChunkStoreRegistry, getClientFeatureRegistry, getCodecRegistry, getCodecRegistry, getCodecRegistry, getCommandRegistry, getDataDirectory, getEntityRegistry, getEntityStoreRegistry, getEventRegistry, getIdentifier, getLogger, getManifest, getName, getState, getTaskRegistry, isDisabled, isEnabled, preLoad
-
Field Details
-
MANIFEST
-
-
Constructor Details
-
VoiceModule
-
-
Method Details
-
get
-
scheduleImmediatePositionUpdate
Schedules an immediate position cache update for a player. This ensures the player's position is available for voice routing right away, without waiting for the periodic position update task (~100ms). Called on player connect and on respawn after death. -
getPlayerState
Gets the voice state for a player. -
setPlayerVoiceChannel
Assigns a player to a named voice channel, or clears the assignment whenchannelis null.A speaker with a channel is heard only by that channel's members, and channel-less speech stays public. Channel membership does not restrict what the player hears: members still hear public world speech around them. Explicit delivery chosen by an interceptor bypasses channels.
- Parameters:
playerId- the player to assignchannel- the channel name, or null to make the player's speech public again
-
getVoiceRouter
Gets the voice router for routing voice packets. -
addPlayerVoiceInterceptor
Registers a hook invoked for each inbound player voice frame, letting a plugin observe, rewrite, re- route, or drop it, atEventPriority.NORMALpriority. SeeaddPlayerVoiceInterceptor(EventPriority, PlayerVoiceInterceptor)to control ordering.- Parameters:
interceptor- the hook to install- Returns:
- a handle whose
Registration.unregister()removes the interceptor. Call it from the plugin'sshutdown(), or the interceptor keeps running and pins the plugin in memory
-
addPlayerVoiceInterceptor
@Nonnull public Registration addPlayerVoiceInterceptor(@Nonnull EventPriority priority, @Nonnull PlayerVoiceInterceptor interceptor) Registers a hook invoked for each inbound player voice frame at the given priority. Interceptors run fromEventPriority.FIRSTtoEventPriority.LAST, and ties run in registration order, so aLASTinterceptor sees the audience and audio that earlier ones chose and gets the final say. SeePlayerVoiceInterceptorfor the threading and safety contract andPlayerVoiceFramefor the controls.- Parameters:
priority- when this interceptor runs relative to the othersinterceptor- the hook to install- Returns:
- a handle whose
Registration.unregister()removes the interceptor. Call it from the plugin'sshutdown(), or the interceptor keeps running and pins the plugin in memory
-
openEntityVoice
Opens a voice stream that follows an entity, heard by nearby players. The entity's network id drives the overhead speaking indicator and the speaker auto-closes when the entity despawns. Push Opus frames viaVoiceSpeaker.pushOpus(byte[])andVoiceSpeaker.close()when done.The entity's position is sampled immediately so a clip started right away is spatialized; any frame pushed in the brief window before that first sample completes is dropped.
- Parameters:
entity- the entity the speaker follows; the speaker auto-closes when it despawns- Returns:
- a handle for pushing Opus frames and closing the stream
-
openPositionalVoice
@Nonnull public PositionalVoiceSpeaker openPositionalVoice(@Nonnull World world, @Nonnull org.joml.Vector3d position) Opens a voice stream at a world position, heard by nearby players. Move it afterwards withPositionalVoiceSpeaker.setPosition(Vector3d). Does not apply the underwater muffle. Only entity speakers sample fluid state.- Parameters:
world- the world the speaker emits inposition- the initial emit position; movable later viaPositionalVoiceSpeaker.setPosition(Vector3d)- Returns:
- a positional speaker handle for pushing Opus frames, moving the source, and closing the stream
- Throws:
IllegalArgumentException- if any coordinate ofpositionis not finite
-
openDirectVoice
Opens a non-spatial voice stream delivered to exactly the given players (any world, no distance falloff), playing at the listener.The listener set is copied and fixed at open time; there is no add/remove API, so changing membership means closing this speaker and opening a new one.
- Parameters:
listeners- the players to deliver to; copied on open, must contain no null elements- Returns:
- a handle for pushing Opus frames and closing the stream
- Throws:
NullPointerException- iflistenerscontains a null element
-
isVoiceEnabled
public boolean isVoiceEnabled()Checks if voice is enabled on the server. -
setVoiceEnabled
public void setVoiceEnabled(boolean enabled) Sets whether voice is enabled on the server. -
isDeadPlayersCanHear
public boolean isDeadPlayersCanHear()Checks if dead players can hear living players' voice. Configurable per-server; defaults to false for competitive integrity. -
getMaxHearingDistance
public float getMaxHearingDistance()Gets the maximum distance at which voice can be heard. -
setMaxHearingDistance
public void setMaxHearingDistance(float distance) Sets the maximum hearing distance. -
getReferenceDistance
public float getReferenceDistance()Gets the full volume distance (distance at which voice is heard at 100% volume). -
setReferenceDistance
public void setReferenceDistance(float distance) Sets the full volume distance. -
isPlayerMuted
Checks if a player is globally muted on the server. -
mutePlayer
Globally mutes a player on the server.- Returns:
- true if the player was muted, false if already muted
-
unmutePlayer
Unmutes a globally muted player.- Returns:
- true if the player was unmuted, false if not muted
-
getGloballyMutedPlayers
-
getMaxPacketsPerSecond
public int getMaxPacketsPerSecond()Gets the max packets per second for rate limiting. -
getBurstCapacity
public int getBurstCapacity()Gets the burst capacity for token bucket rate limiting. -
getMaxPacketSize
public int getMaxPacketSize()Gets the max packet size for validation. -
getCachedPosition
Gets a cached position snapshot for a player. Thread-safe for use from voice executor. -
getVoiceExecutor
Gets the voice executor for routing voice packets off the WorldThread. Partitions by speaker UUID to maintain per-speaker ordering while parallelizing across speakers. -
isShutdown
public boolean isShutdown()Whether the module has been shut down. -
getPlayerStates
Gets the map of player states (thread-safe).
-