mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-21 07:41:30 +01:00
SPIGOT-7675: Fix FoodComponent config deserialization
Be more lenient when converting floating point numbers during config deserialization of item data. By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
parent
79d9816660
commit
764529d82b
@ -102,6 +102,19 @@ public final class SerializableMeta implements ConfigurationSerializable {
|
|||||||
if (clazz.isInstance(object)) {
|
if (clazz.isInstance(object)) {
|
||||||
return clazz.cast(object);
|
return clazz.cast(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SPIGOT-7675 - More lenient conversion of floating point numbers from other number types:
|
||||||
|
if (clazz == Float.class || clazz == Double.class) {
|
||||||
|
if (Number.class.isInstance(object)) {
|
||||||
|
Number number = Number.class.cast(object);
|
||||||
|
if (clazz == Float.class) {
|
||||||
|
return clazz.cast(number.floatValue());
|
||||||
|
} else {
|
||||||
|
return clazz.cast(number.doubleValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
if (!nullable) {
|
if (!nullable) {
|
||||||
throw new NoSuchElementException(map + " does not contain " + field);
|
throw new NoSuchElementException(map + " does not contain " + field);
|
||||||
|
Loading…
Reference in New Issue
Block a user