Class check EnumPropertyMixin#getIdFor

This should prevent invalid usages with the wrong enum type.
This commit is contained in:
Spottedleaf
2024-08-08 23:00:12 -07:00
parent 2b5c570ec3
commit 4b8778cbe7

View File

@@ -52,6 +52,7 @@ abstract class EnumPropertyMixin<T extends Enum<T> & StringRepresentable> extend
@Override
public final int moonrise$getIdFor(final T value) {
return this.idLookupTable[value.ordinal()];
final Class<T> target = this.getValueClass();
return ((value.getClass() != target && value.getDeclaringClass() != target)) ? -1 : this.idLookupTable[value.ordinal()];
}
}