diff --git a/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistrator.java b/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistrator.java index 245a4c375a3..c1d471545fa 100644 --- a/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistrator.java +++ b/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistrator.java @@ -338,6 +338,9 @@ protected Value constructValue(final H dataHolder, final E element) { @Override protected Optional getFrom(final H dataHolder) { + if (registration.get == null) { + return Optional.empty(); + } if (this.isBooleanKey) { return (Optional) OptBool.of((Boolean) registration.get.apply(dataHolder)); } @@ -487,6 +490,9 @@ protected Value constructValue(final H dataHolder, final E element) { @Override protected Optional getFrom(final H dataHolder) { + if (registration.get == null) { + return Optional.empty(); + } if (this.isBooleanKey) { return (Optional) OptBool.of((Boolean) registration.get.apply(dataHolder)); } @@ -495,6 +501,9 @@ protected Optional getFrom(final H dataHolder) { @Override protected Optional set(final H dataHolder, final E value) { + if (registration.set == null) { + return Optional.empty(); + } return Optional.ofNullable(registration.set.apply(dataHolder, value)); }