Skip to content

Commit

Permalink
Fix sound loading causing issues on Paper
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgH93 committed Dec 12, 2024
1 parent 29a6a56 commit 1e4abf9
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
import at.pcgamingfreaks.Minepacks.Bukkit.ShrinkApproach;
import at.pcgamingfreaks.Minepacks.MagicValues;
import at.pcgamingfreaks.Reflection;
import at.pcgamingfreaks.Version;

import org.bukkit.*;
import org.jetbrains.annotations.NotNull;

import java.io.FileNotFoundException;
import java.lang.reflect.Field;
import java.util.*;
import java.util.logging.Level;

Expand Down Expand Up @@ -509,7 +511,15 @@ private Sound getSound(String option, String autoValue)
if(soundName.equals("DISABLED") || soundName.equals("FALSE")) return null;
try
{
return Sound.valueOf(soundName);
if (MCVersion.isNewerOrEqualThan(MCVersion.MC_1_21))
{
Field f = Reflection.getField(Sound.class, soundName);
if (f != null) return (Sound) f.get(null);
}
else
{
return Sound.valueOf(soundName);
}
}
catch(Exception ignored)
{
Expand Down

0 comments on commit 1e4abf9

Please sign in to comment.