use of org.spongepowered.api.data.manipulator.mutable.item.DurabilityData in project Nucleus by NucleusPowered.
the class RepairCommand method repairStack.
private RepairResult repairStack(ItemStack stack, boolean checkRestrictions) {
if (checkRestrictions && (whitelist && !restrictions.contains(stack.getType()) || restrictions.contains(stack.getType()))) {
return new RepairResult(stack, ResultType.RESTRICTED);
}
if (stack.get(DurabilityData.class).isPresent()) {
DurabilityData durabilityData = stack.get(DurabilityData.class).get();
DataTransactionResult transactionResult = stack.offer(Keys.ITEM_DURABILITY, durabilityData.durability().getMaxValue());
if (transactionResult.isSuccessful()) {
return new RepairResult(stack, ResultType.SUCCESS);
} else {
return new RepairResult(stack, ResultType.ERROR);
}
} else {
return new RepairResult(stack, ResultType.NO_DURABILITY);
}
}
Aggregations