Class CompatibilitySoundEnum

java.lang.Object
com.ranull.graves.compatibility.CompatibilitySoundEnum

public class CompatibilitySoundEnum extends Object
Handles Compatibility for Sound Enums to prevent runtime errors on versions older than 1.21.2.
  • Constructor Details

    • CompatibilitySoundEnum

      public CompatibilitySoundEnum()
  • Method Details

    • valueOf

      public static org.bukkit.Sound valueOf(String soundName)
      Retrieves the Sound value associated with the given sound name.

      For Minecraft 1.21.2 and newer, this method returns a constant from the Sound class directly. For versions older than 1.21.2, it uses reflection to access the corresponding enum value.

      If the sound name does not exist in the sound constants or enum, or if an exception occurs during retrieval, the method logs the error and returns null.

      Parameters:
      soundName - The name of the sound to retrieve. This should be the name of the sound as a string (e.g., "BLOCK_ANVIL_LAND").
      Returns:
      The corresponding Sound value, or null if the sound name is invalid or an error occurs.