public interface DataProcessor<M extends org.spongepowered.api.data.manipulator.DataManipulator<M,I>,I extends org.spongepowered.api.data.manipulator.ImmutableDataManipulator<I,M>>
Modifier and Type | Method and Description |
---|---|
Optional<M> |
createFrom(org.spongepowered.api.data.DataHolder dataHolder) |
Optional<M> |
fill(org.spongepowered.api.data.DataContainer container,
M m) |
Optional<M> |
fill(org.spongepowered.api.data.DataHolder dataHolder,
M manipulator,
org.spongepowered.api.data.merge.MergeFunction overlap) |
Optional<M> |
from(org.spongepowered.api.data.DataHolder dataHolder)
Attempts to get the given
DataManipulator of type T if
and only if the manipulator's required data exists from the
DataHolder . |
int |
getPriority()
Gets the priority of this processor.
|
org.spongepowered.api.data.DataTransactionResult |
remove(org.spongepowered.api.data.DataHolder dataHolder)
Attempts to remove the
DataManipulator type from the given DataHolder . |
org.spongepowered.api.data.DataTransactionResult |
set(org.spongepowered.api.data.DataHolder dataHolder,
M manipulator,
org.spongepowered.api.data.merge.MergeFunction function)
Sets the data from the
DataManipulator . |
boolean |
supports(org.spongepowered.api.data.DataHolder dataHolder) |
boolean |
supports(org.spongepowered.api.entity.EntityType entityType) |
Optional<I> |
with(org.spongepowered.api.data.key.Key<? extends org.spongepowered.api.data.value.BaseValue<?>> key,
Object value,
I immutable) |
int getPriority()
Key
can have
multiple DataProcessor
s such that mods introducing
changes to the game can provide their own DataProcessor
s
for specific cases. The notion is that the higher the priority, the
earlier the processor is used. If for any reason a processor's method
is returning an Optional.empty()
or
DataTransactionResult
with a failure, the next processor in
line will be used. By default, all Sponge processors are with a
priority of 100.boolean supports(org.spongepowered.api.data.DataHolder dataHolder)
boolean supports(org.spongepowered.api.entity.EntityType entityType)
Optional<M> from(org.spongepowered.api.data.DataHolder dataHolder)
DataManipulator
of type T
if
and only if the manipulator's required data exists from the
DataHolder
. This is conceptually different from
createFrom(DataHolder)
since a new instance
isn't returned even if the DataManipulator
is applicable.
This is a processor method for CompositeValueStore.get(Class)
.
dataHolder
- The data holderOptional<M> fill(org.spongepowered.api.data.DataHolder dataHolder, M manipulator, org.spongepowered.api.data.merge.MergeFunction overlap)
org.spongepowered.api.data.DataTransactionResult set(org.spongepowered.api.data.DataHolder dataHolder, M manipulator, org.spongepowered.api.data.merge.MergeFunction function)
DataManipulator
. Usually, if a
DataHolder
is being offered a DataManipulator
with a
MergeFunction
, the MergeFunction
logic should always
be settled first, before offering the finalized DataManipulator
to the DataHolder
. In the case of implementation, what really
happens is that all pre-logic before data is actually "offered" to a
DataHolder
, the data is filtered for various reasons from
various plugins. After the data is finished being manipulated
by the various sources, including the possibly provided
MergeFunction
, the DataManipulator
is finally offered
to the DataHolder
. The resulting DataTransactionResult
is almost always made ahead of time.dataHolder
- The data holder to set the data ontomanipulator
- The manipulator to set the data fromOptional<I> with(org.spongepowered.api.data.key.Key<? extends org.spongepowered.api.data.value.BaseValue<?>> key, Object value, I immutable)
org.spongepowered.api.data.DataTransactionResult remove(org.spongepowered.api.data.DataHolder dataHolder)
DataManipulator
type from the given DataHolder
.
If the DataHolder
can not support removing the data outright,
false
should be returned.
dataHolder
- The data holder to remove the data from