Package com.ranull.graves.compatibility
Class CompatibilitySoundEnum
java.lang.Object
com.ranull.graves.compatibility.CompatibilitySoundEnum
Handles Compatibility for Sound Enums to prevent runtime errors on versions older than 1.21.2.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
CompatibilitySoundEnum
public CompatibilitySoundEnum()
-
-
Method Details
-
valueOf
Retrieves theSound
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, ornull
if the sound name is invalid or an error occurs.
-