@Override public DataTransactionResult removeFrom(ValueContainer<?> container) { if (this.supports(container)) { final ItemStack skull = (ItemStack) container; final Optional<GameProfile> oldData = getVal(skull); if (SkullUtils.setProfile(skull, null)) { if (oldData.isPresent()) { return DataTransactionBuilder.successReplaceResult( Collections.emptySet(), Collections.singleton(constructImmutableValue(oldData.get()))); } else { return DataTransactionBuilder.successNoData(); } } } return DataTransactionBuilder.failNoData(); }
@Override protected boolean supports(ItemStack container) { return SkullUtils.isValidItemStack(container) && SkullUtils.getSkullType(container).equals(SkullTypes.PLAYER); }
@Override protected boolean set(ItemStack container, GameProfile value) { return SkullUtils.setProfile(container, value); }
@Override protected Optional<GameProfile> getVal(ItemStack container) { return SkullUtils.getProfile(container); }