Package com.craftmend.openaudiomc.api
Interface WorldApi
public interface WorldApi
The WorldApi is a collection of methods to interact with features that is linked to worlds.
This API is only available if the OpenAudioMc plugin on spigot, and is not available on the bungee side.
-
Method Summary
Modifier and TypeMethodDescriptionstatic WorldApi
Get an instance of the world api.@NotNull Collection<AudioRegion>
getRegionsAt
(int x, int y, int z, @NotNull String world) Get all regions at a location@Nullable BasicSpeaker
getSpeakerAt
(int x, int y, int z, @NotNull String world) Get a speaker at a location, or null if invalidvoid
registerRegion
(String worldName, String regionId, RegionMediaOptions regionMedia) Register a region in a world.void
registerTempRegion
(String worldName, String regionId, RegionMediaOptions regionMedia, int duration) Register a temporary region in a world Important: - this will overwrite current temporary regions - this will throw an invalid region exception if the region is not found - this will throw an unknown world exception if the world is not loaded - this will throw an invalid region exception if the region already has permanent media - this will throw an invalid thread exception if not called from the main threadvoid
registerVirtualSpeaker
(int x, int y, int z, @NotNull String world, @NotNull String media, SpeakerType speakerType, int radius, ExtraSpeakerOptions... extraOptions) Register a virtual speaker at a location.void
unregisterRegion
(String worldName, String regionId) Unregister a region from the worldvoid
unregisterVirtualSpeaker
(@NotNull BasicSpeaker speaker) Unregister a virtual speaker (which has been registered by the api)
-
Method Details
-
getInstance
Get an instance of the world api. May be null if the plugin is not loaded yet- Returns:
- instance
-
getRegionsAt
@NotNull @NotNull Collection<AudioRegion> getRegionsAt(int x, int y, int z, @NotNull @NotNull String world) Get all regions at a location- Parameters:
x
- xy
- yz
- zworld
- world- Returns:
- regions
-
getSpeakerAt
Get a speaker at a location, or null if invalid- Parameters:
x
- xy
- yz
- zworld
- world- Returns:
- speaker
-
registerVirtualSpeaker
void registerVirtualSpeaker(int x, int y, int z, @NotNull @NotNull String world, @NotNull @NotNull String media, SpeakerType speakerType, int radius, ExtraSpeakerOptions... extraOptions) throws InvalidThreadException, InvalidLocationException Register a virtual speaker at a location. This is a location that will play sound as if there's a speaker there, but there isn't.- Parameters:
x
- xy
- yz
- zworld
- worldmedia
- The media sourcespeakerType
- speaker typeradius
- radiusextraOptions
- extra options (redstone requirement, loop, etc)- Throws:
InvalidThreadException
- if called from the main thread. This is to prevent blocking the main thread with the underlying Sqlite databaseInvalidLocationException
- if the location is not valid (this location is already occupied by a real or virtual speaker)- Since:
- 6.10.8
-
unregisterVirtualSpeaker
void unregisterVirtualSpeaker(@NotNull @NotNull BasicSpeaker speaker) throws InvalidSpeakerException, InvalidThreadException Unregister a virtual speaker (which has been registered by the api)- Parameters:
speaker
- speaker- Throws:
InvalidSpeakerException
- if the speaker is not valid (already unregistered, or not registered by the api)InvalidThreadException
- if called from the main thread.- Since:
- 6.10.8
-
registerRegion
void registerRegion(String worldName, String regionId, RegionMediaOptions regionMedia) throws UnknownWorldException, InvalidThreadException, InvalidRegionException Register a region in a world. Important: - this will overwrite current temporary regions - this will throw an invalid region exception if the region is not found - this will throw an unknown world exception if the world is not loaded - this will throw an invalid region exception if the region already has permanent media - this will throw an invalid thread exception if not called from the main thread- Parameters:
worldName
- worldregionId
- idregionMedia
- the media to attach- Throws:
UnknownWorldException
- if the world is not loadedInvalidRegionException
- if the region is not foundInvalidThreadException
- if not called from the main thread- Since:
- 6.10.2
-
registerTempRegion
void registerTempRegion(String worldName, String regionId, RegionMediaOptions regionMedia, int duration) throws UnknownWorldException, InvalidThreadException, InvalidRegionException Register a temporary region in a world Important: - this will overwrite current temporary regions - this will throw an invalid region exception if the region is not found - this will throw an unknown world exception if the world is not loaded - this will throw an invalid region exception if the region already has permanent media - this will throw an invalid thread exception if not called from the main thread- Parameters:
worldName
- worldregionId
- the region to targeregionMedia
- the media to attachduration
- the duration in seconds- Throws:
UnknownWorldException
- if the world is not loadedInvalidRegionException
- if the region is not foundInvalidThreadException
- if not called from the main thread- Since:
- 6.10.2
-
unregisterRegion
Unregister a region from the world- Parameters:
worldName
- worldregionId
- region id- Throws:
InvalidThreadException
- if not called from the main thread- Since:
- 6.10.2
-