Class VibrativeVoiceApi

java.lang.Object
com.codinglitch.vibrativevoice.VibrativeVoiceApi
Direct Known Subclasses:
VibrativeVoiceApiImpl

public abstract class VibrativeVoiceApi extends Object
  • Field Details

  • Constructor Details

    • VibrativeVoiceApi

      public VibrativeVoiceApi()
  • Method Details

    • applyRestriction

      public abstract boolean applyRestriction(VibrativeVoiceApi.RestrictionType restrictionType, boolean flag)
      This is a way to apply a restriction based on whether or not it is enabled in the Vibrative Voice config.
      Parameters:
      restrictionType - The restriction type to apply
      flag - The flag of the restriction
      Returns:
      If the restriction is enabled in the config and if it can apply in the context
    • getConfigEntry

      public abstract <T> T getConfigEntry(String path, T defaultReturn)
      This is a method allowing the access of the Vibrative Voice config directly from the API.
      Parameters:
      path - The path to follow to retrieve the entry, i.e. "cooldownDuration" or "restrictions.whisperFactor"
      defaultReturn - The default value to return. Also used to infer the type of the config.
      Returns:
      If the restriction is enabled in the config and if it can apply in the context
    • trySendVibration

      public abstract void trySendVibration(UUID uuid, net.minecraft.core.BlockPos location, net.minecraft.world.level.Level level, VibrativeVoiceApi.VibrationType type)
      Tries to send a vibration originating at the specified location, checking if it is on cooldown and using the default config cooldown duration.
      Parameters:
      uuid - The UUID for the cooldown
      location - The location where the vibration originates from
      level - The level where the vibration exists
      type - The vibration type to send
    • trySendVibration

      public abstract void trySendVibration(UUID uuid, net.minecraft.world.entity.Entity entity, net.minecraft.world.level.Level level, VibrativeVoiceApi.VibrationType type)
      Tries to send a vibration originating from the specified entity, checking if it is on cooldown and using the default config cooldown duration.
      Parameters:
      uuid - The UUID for the cooldown
      entity - The Entity that the vibration originates from
      level - The level where the vibration exists
      type - The vibration type to send
    • trySendVibration

      public abstract void trySendVibration(net.minecraft.world.entity.Entity entity, net.minecraft.world.level.Level level, VibrativeVoiceApi.VibrationType type)
      Tries to send a vibration originating from the specified entity, checking if it is on cooldown.
      Parameters:
      entity - The Entity that the vibration originates from, using its UUID for the cooldown
      level - The level where the vibration exists
      type - The vibration type to send
    • trySendVibration

      public abstract void trySendVibration(UUID uuid, net.minecraft.core.BlockPos location, net.minecraft.world.level.Level level, VibrativeVoiceApi.VibrationType type, int cooldown)
      Tries to send a vibration originating at the specified location, checking if it is on cooldown.
      Parameters:
      uuid - The UUID for the cooldown
      location - The location where the vibration originates from
      level - The level where the vibration exists
      type - The vibration type to send
      cooldown - The cooldown duration (in ticks) to set
    • trySendVibration

      public abstract void trySendVibration(UUID uuid, net.minecraft.world.entity.Entity entity, net.minecraft.world.level.Level level, VibrativeVoiceApi.VibrationType type, int cooldown)
      Tries to send a vibration originating from the specified entity, checking if it is on cooldown.
      Parameters:
      uuid - The UUID for the cooldown
      entity - The Entity that the vibration originates from
      level - The level where the vibration exists
      type - The vibration type to send
      cooldown - The cooldown duration (in ticks) to set
    • sendVibration

      public abstract void sendVibration(net.minecraft.core.BlockPos location, net.minecraft.world.level.Level level, VibrativeVoiceApi.VibrationType vibrationType)
      Sends a vibration at the location with the specified type.
      Parameters:
      location - The location to send the vibration from
      level - The level to send the vibration in
      vibrationType - The type of vibration to send
    • sendVibration

      public abstract void sendVibration(net.minecraft.world.entity.Entity entity, net.minecraft.world.level.Level level, VibrativeVoiceApi.VibrationType vibrationType)
      Sends a vibration originating from an entity with the specified type.
      Parameters:
      entity - The entity the vibration originates from
      level - The level to send the vibration in
      vibrationType - The type of vibration to send
    • getPlayerLoudness

      public abstract double getPlayerLoudness(net.minecraft.world.entity.player.Player player)
      Gets a rough loudness value for the specified player at this current moment.
      Parameters:
      player - The player to get the loudness of
      Returns:
      The loudness of the player
    • setPlayerLoudness

      public abstract void setPlayerLoudness(net.minecraft.world.entity.player.Player player, double loudness, long timestamp)
      Sets the loudness value for the specified player.
      Parameters:
      player - The player to set the loudness of
      loudness - The loudness of the player
      timestamp - The timestamp this loudness was emitted
    • getEvent

      public abstract net.minecraft.world.level.gameevent.GameEvent getEvent(VibrativeVoiceApi.VibrationType type)
      Gets an event from a vibration type.
      Parameters:
      type - The vibration type
      Returns:
      The GameEvent corresponding to that type
    • getQualifyingType

      @Nullable public abstract VibrativeVoiceApi.VibrationType getQualifyingType(byte[] data)
      Gets a qualifying VibrationType for the volume level of the data, or null if none qualifies (audio too quiet).
      Parameters:
      data - The raw data that will be decoded
      Returns:
      The qualifying VibrationType, or null if none qualified
    • getQualifyingType

      @Nullable public abstract VibrativeVoiceApi.VibrationType getQualifyingType(byte[] data, float volumeFactor)
      Gets a qualifying VibrationType for the volume level of the data, or null if none qualifies (audio too quiet).
      Parameters:
      data - The raw data that will be decoded
      volumeFactor - The multiplier to skew volume by
      Returns:
      The qualifying VibrationType, or null if none qualified
    • getQualifyingType

      @Nullable public abstract VibrativeVoiceApi.VibrationType getQualifyingType(short[] decoded)
      Gets a qualifying VibrationType for the volume level of the data, or null if none qualifies (audio too quiet).
      Parameters:
      decoded - The opus decoded data
      Returns:
      The qualifying VibrationType, or null if none qualified
    • getQualifyingType

      @Nullable public abstract VibrativeVoiceApi.VibrationType getQualifyingType(short[] decoded, float volumeFactor)
      Gets a qualifying VibrationType for the volume level of the data, or null if none qualifies (audio too quiet).
      Parameters:
      decoded - The opus decoded data
      volumeFactor - The multiplier to skew volume by
      Returns:
      The qualifying VibrationType, or null if none qualified
    • getQualifyingType

      @Nullable public abstract VibrativeVoiceApi.VibrationType getQualifyingType(double volume)
      Gets a qualifying VibrationType for the specified volume level, or null if none qualifies (audio too quiet).
      Parameters:
      volume - The volume
      Returns:
      The qualifying VibrationType, or null if none qualified
    • getVolume

      public abstract double getVolume(byte[] data)
      Gets a rough volume level from the raw data
      Parameters:
      data - The raw data
      Returns:
      The approximate volume (in no particular measurement)
    • getVolume

      public abstract double getVolume(short[] decoded)
      Gets a rough volume level from the decoded data
      Parameters:
      decoded - The opus decoded data
      Returns:
      The approximate volume (in no particular measurement)
    • setCooldown

      public abstract void setCooldown(UUID uuid, net.minecraft.world.level.Level level, int cooldown)
    • getTimestamp

      public abstract long getTimestamp(UUID uuid)
    • isOnCooldown

      public abstract boolean isOnCooldown(UUID uuid, net.minecraft.world.level.Level level)