Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Override
public Optional<HungerOverrideData> fill(DataHolder dataHolder, DataPriority overlap) {
HungerOverrideData man = new HungerOverrideData(this);
HungerOverrideData hold = dataHolder.getData(HungerOverrideData.class).orNull();
HungerOverrideData out = null;
switch (overlap){
case DATA_HOLDER:
out = hold;
break;
case DATA_MANIPULATOR:
out = man;
//fallthrough
case PRE_MERGE:
out = man;
if(dataHolder.getData(HungerOverrideData.class).isPresent()){
out.amount =+ hold.amount;
}
break;
case POST_MERGE:
out = hold;
out.amount =+ man.amount;
break;
}
return Optional.of(out);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment