@Override public void use(IPlayer player) throws ItemNotInBackpackException, ContextRequireException { player.getBackpack().removeItem(this); this.getAttributes() .forEach( (itemAttribute) -> { player.getStatistic(itemAttribute.getAttribute()).add(itemAttribute.getChangeValue()); }); }
@Override public void use(IPlayer player, IUsageContext usageContext) throws ItemNotInBackpackException, ContextRequireException { super.use(player); if (usageContext == null) { throw new ContextRequireException(this); } usageContext.registerOnFinishListener( () -> getAttributes() .forEach( itemAttribute -> player .getStatistic(itemAttribute.getAttribute()) .add(itemAttribute.getOpositeOfChangeValue()))); }