mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2025-08-05 16:49:30 +00:00
SPIGOT-7675: Fix FoodComponent config deserialization
Be more lenient when converting floating point numbers during config deserialization of item data.
This commit is contained in:
parent
b148ed3322
commit
d6607c7dd6
1 changed files with 13 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue