@@ -1083,39 +1083,39 @@ public Vector getSpecific(Object generic) {
1083
1083
});
1084
1084
}
1085
1085
1086
- private static MethodAccessor getSound = null ;
1087
- private static MethodAccessor getSoundEffect = null ;
1088
- private static FieldAccessor soundKey = null ;
1086
+ static MethodAccessor getSound = null ;
1087
+ static MethodAccessor getSoundEffect = null ;
1088
+ static FieldAccessor soundKey = null ;
1089
1089
1090
- private static MethodAccessor getSoundEffectByKey = null ;
1091
- private static MethodAccessor getSoundEffectBySound = null ;
1092
- private static MethodAccessor getSoundByEffect = null ;
1090
+ static MethodAccessor getSoundEffectByKey = null ;
1091
+ static MethodAccessor getSoundEffectBySound = null ;
1092
+ static MethodAccessor getSoundByEffect = null ;
1093
1093
1094
- private static Map <String , Sound > soundIndex = null ;
1094
+ static Map <String , Sound > soundIndex = null ;
1095
1095
1096
1096
public static EquivalentConverter <Sound > getSoundConverter () {
1097
1097
// Try to create sound converter for new versions greater 1.16.4
1098
- try {
1098
+ if ( MinecraftVersion . NETHER_UPDATE_4 . atOrAbove ()) {
1099
1099
if (getSoundEffectByKey == null || getSoundEffectBySound == null || getSoundByEffect == null ) {
1100
1100
Class <?> craftSound = MinecraftReflection .getCraftSoundClass ();
1101
1101
FuzzyReflection fuzzy = FuzzyReflection .fromClass (craftSound , true );
1102
1102
1103
1103
getSoundEffectByKey = Accessors .getMethodAccessor (fuzzy .getMethodByReturnTypeAndParameters (
1104
1104
"getSoundEffect" ,
1105
1105
MinecraftReflection .getSoundEffectClass (),
1106
- new Class <?>[]{ String .class }
1106
+ String .class
1107
1107
));
1108
1108
1109
1109
getSoundEffectBySound = Accessors .getMethodAccessor (fuzzy .getMethodByReturnTypeAndParameters (
1110
1110
"getSoundEffect" ,
1111
1111
MinecraftReflection .getSoundEffectClass (),
1112
- new Class <?>[]{ Sound .class }
1112
+ Sound .class
1113
1113
));
1114
1114
1115
1115
getSoundByEffect = Accessors .getMethodAccessor (fuzzy .getMethodByReturnTypeAndParameters (
1116
1116
"getBukkit" ,
1117
1117
Sound .class ,
1118
- new Class <?>[]{ MinecraftReflection .getSoundEffectClass ()}
1118
+ MinecraftReflection .getSoundEffectClass ()
1119
1119
));
1120
1120
}
1121
1121
@@ -1133,20 +1133,27 @@ public Object getGeneric(Sound specific) {
1133
1133
1134
1134
@ Override
1135
1135
public Sound getSpecific (Object generic ) {
1136
- return (Sound ) getSoundByEffect .invoke (null , generic );
1136
+ try {
1137
+ return (Sound ) getSoundByEffect .invoke (null , generic );
1138
+ } catch (IllegalStateException ex ) {
1139
+ if (ex .getCause () instanceof NullPointerException ) {
1140
+ // "null" sounds cause NPEs inside getSoundByEffect
1141
+ return null ;
1142
+ }
1143
+ throw ex ;
1144
+ }
1137
1145
}
1138
1146
});
1139
- } catch (Exception e ) {
1140
1147
}
1141
1148
1142
1149
// Fall back to sound converter from legacy versions before 1.16.4
1143
1150
if (getSound == null || getSoundEffect == null ) {
1144
1151
Class <?> craftSound = MinecraftReflection .getCraftSoundClass ();
1145
1152
FuzzyReflection fuzzy = FuzzyReflection .fromClass (craftSound , true );
1146
1153
getSound = Accessors .getMethodAccessor (
1147
- fuzzy .getMethodByReturnTypeAndParameters ("getSound" , String .class , new Class <?>[]{ Sound .class } ));
1154
+ fuzzy .getMethodByReturnTypeAndParameters ("getSound" , String .class , Sound .class ));
1148
1155
getSoundEffect = Accessors .getMethodAccessor (fuzzy .getMethodByReturnTypeAndParameters ("getSoundEffect" ,
1149
- MinecraftReflection .getSoundEffectClass (), new Class <?>[]{ String .class } ));
1156
+ MinecraftReflection .getSoundEffectClass (), String .class ));
1150
1157
}
1151
1158
1152
1159
return ignoreNull (new EquivalentConverter <Sound >() {
0 commit comments