use of org.spongepowered.common.data.ValueProcessor in project SpongeCommon by SpongePowered.
the class MixinDataHolder method remove.
@Override
public DataTransactionResult remove(Key<?> key) {
TimingsManager.DATA_GROUP_HANDLER.startTimingIfSync();
SpongeTimings.dataRemoveKey.startTimingIfSync();
final Optional<ValueProcessor<?, ?>> optional = DataUtil.getWildValueProcessor(checkNotNull(key));
if (optional.isPresent()) {
final DataTransactionResult result = optional.get().removeFrom(this);
SpongeTimings.dataRemoveKey.stopTimingIfSync();
TimingsManager.DATA_GROUP_HANDLER.stopTimingIfSync();
return result;
} else if (this instanceof IMixinCustomDataHolder) {
final DataTransactionResult result = ((IMixinCustomDataHolder) this).removeCustom(key);
SpongeTimings.dataRemoveKey.stopTimingIfSync();
TimingsManager.DATA_GROUP_HANDLER.stopTimingIfSync();
return result;
}
SpongeTimings.dataRemoveKey.stopTimingIfSync();
TimingsManager.DATA_GROUP_HANDLER.stopTimingIfSync();
return DataTransactionResult.failNoData();
}
use of org.spongepowered.common.data.ValueProcessor in project SpongeCommon by SpongePowered.
the class MixinDataHolder method offer.
@Override
public <E> DataTransactionResult offer(Key<? extends BaseValue<E>> key, E value) {
TimingsManager.DATA_GROUP_HANDLER.startTimingIfSync();
SpongeTimings.dataOfferKey.startTimingIfSync();
final Optional<ValueProcessor<E, ? extends BaseValue<E>>> optional = DataUtil.getBaseValueProcessor(key);
if (optional.isPresent()) {
final DataTransactionResult result = optional.get().offerToStore(this, value);
SpongeTimings.dataOfferKey.stopTimingIfSync();
TimingsManager.DATA_GROUP_HANDLER.stopTimingIfSync();
return result;
} else if (this instanceof IMixinCustomDataHolder) {
final DataTransactionResult result = ((IMixinCustomDataHolder) this).offerCustom(key, value);
SpongeTimings.dataOfferKey.stopTimingIfSync();
TimingsManager.DATA_GROUP_HANDLER.stopTimingIfSync();
return result;
}
SpongeTimings.dataOfferKey.stopTimingIfSync();
TimingsManager.DATA_GROUP_HANDLER.stopTimingIfSync();
return DataTransactionResult.failNoData();
}
Aggregations