Skip to content
On this page

Source lines

Source lines are used to create sources and to control the volume of the sources on the client, which are created within the source line.

Registering a source line

To register a source line, you need to create addon first, how to do it see Creating an addon.

Source lines are dynamically synced with players, allowing you to register or unregister source lines at any time.

java
PlasmoVoiceServer voiceServer = /* */;
Object addon = /* */;

ServerSourceLine sourceLine = voiceServer.getSourceLineManager().createBuilder(
    addon,
    "priority", // name
    "pv.activation.priority", // translation key
    "plasmovoice:textures/icons/speaker_priority.png", // icon resource location
    10 // weight
).build();
kotlin
val voiceServer: PlasmoVoiceServer
val addon: Any

val sourceLine = voiceServer.sourceLineManager.createBuilder(
    addon,
    "priority", // name
    "pv.activation.priority", // translation key
    "plasmovoice:textures/icons/speaker_priority.png", // icon resource location
    10 // weight
).build()

Icon

You can also use InputStream as an icon. It can be done the same way as in Activation.

Weight

Source line weight is determined how high it will be in the list. Lower weight means higher place, if source lines have the same weight, then they would be sorted alphabetically.

Players in overlay

To add players to the overlay, you need to enable this function using ServerSourceLine.Builder#withPlayers.

After building the source line with players feature enabled, you can access the ServerPlayerSetManager.

An example using this feature with a built-in broadcast player set, which synchronizes the players within the set.

java
PlasmoVoiceServer voiceServer = /* */;

ServerSourceLine sourceLine = voiceServer.getSourceLineManager()
        .createBuilder(/*...*/)
        .withPlayers(true)
        .build();

VoicePlayer player = /* voice player */;

ServerPlayerSetManager playerSetManager = sourceLine.getPlayerSetManager();
ServerPlayerSet broadcastSet = playerSetManager.createBroadcastSet();
broadcastSet.addPlayer(player);

// sets the broadcast player set to the player
playerSetManager.setPlayerSet(player, broadcastSet);
kotlin
val voiceServer: PlasmoVoiceServer

val sourceLine: ServerSourceLine = voiceServer.sourceLineManager
    .createBuilder(/* */)
    .withPlayers(true)
    .build()

val player: VoicePlayer /* voice player */

val playerSetManager = sourceLine.playerSetManager
val broadcastSet = playerSetManager.createBroadcastSet()
broadcastSet.addPlayer(player)

// sets the broadcast player set to the player
playerSetManager.setPlayerSet(player, broadcastSet)

Default volume

You can set a default volume of the source line using ServerSourceLine.Builder#setDefaultVolume, with an allowed range of 0.0 to 1.0.

Obtaining an existing source line

If you don't want to create your own source line, you can obtain an existing one:

java
PlasmoVoiceServer voiceServer = /* */;

ServerSourceLine sourceLine = voiceServer.getSourceLineManager()
        .getLineByName("proximity")
        .orElseThrow(() -> new IllegalStateException("Proximity source line not found"));
kotlin
val voiceServer: PlasmoVoiceServer

val sourceLine = voiceServer.sourceLineManager
    .getLineByName("proximity")
    .orElseThrow { IllegalStateException("Proximity source line not found") }