> For the complete documentation index, see [llms.txt](https://wyne.gitbook.io/wyne-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wyne.gitbook.io/wyne-docs/contributing/common/sounds.md).

# Sounds, Randomness and Placeholders

Three small packages gathered onto one page: SoundUtils, RandomUtils and PAPIUtils.

Three unrelated one- or two-method packages, merged onto a single page rather than left as stubs: `sound/` (`SoundUtils`), `random/` (`RandomUtils`), and `placeholder/` (`PAPIUtils`).

## SoundUtils

`SoundUtils` (`common/src/main/java/me/wyne/wutils/common/sound/SoundUtils.java`) converts a legacy `org.bukkit.Sound` enum constant into an Adventure `net.kyori.adventure.sound.Sound`, for APIs (like Adventure's `Audience.playSound`) that expect the latter. Five overloads, all delegating to the five-argument form (`common/src/main/java/me/wyne/wutils/common/sound/SoundUtils.java:11-33`):

* `getSound(Sound)` — `Sound.Source.MASTER`, volume `1f`, pitch `1f`.
* `getSound(Sound, Sound.Source)` — volume `1f`, pitch `1f`.
* `getSound(Sound, float volume)` — `Sound.Source.MASTER`, pitch `1f`.
* `getSound(Sound, float volume, float pitch)` — `Sound.Source.MASTER`.
* `getSound(Sound, Sound.Source, float volume, float pitch)` — the full form; builds the Adventure `Sound` from the legacy sound's key string.

## RandomUtils.weightedRandom

`weightedRandom(Map<K, V extends Number> map)` (`common/src/main/java/me/wyne/wutils/common/random/RandomUtils.java:17-37`) picks a random entry from `map`, where each value is that entry's selection weight. Entries with a non-positive weight are excluded from selection (their weight does not count toward the total, and they cannot be picked) but are not removed from consideration otherwise.

**Returns `null`** if `map` is empty, or if every weight in it is zero or negative (total weight `<= 0`) — callers must check for `null` rather than assuming an entry is always returned. Otherwise it draws uniformly from `[0, totalWeight)` via `ThreadLocalRandom` and walks the map's entries to find the one the draw landed in.

## PAPIUtils

`PAPIUtils` (`common/src/main/java/me/wyne/wutils/common/placeholder/PAPIUtils.java`) has one method: `getPlaceholder(String identifier, String params)` (`common/src/main/java/me/wyne/wutils/common/placeholder/PAPIUtils.java:13-15`), which joins its two arguments as `identifier + "_" + params` — the body of a PlaceholderAPI placeholder, without the surrounding `%...%` delimiters.

**Only meaningful with PlaceholderAPI.** This method itself has no PlaceholderAPI dependency (it's plain string concatenation), but its purpose only makes sense in the context of registering a PlaceholderAPI expansion, which requires PlaceholderAPI as a `compileOnly` dependency the consumer must supply. See the [module overview](/wyne-docs/contributing/common/common.md) for the full list of optional integrations.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wyne.gitbook.io/wyne-docs/contributing/common/sounds.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
