Added more mappings to FastItemStack

This commit is contained in:
Auxilor
2022-04-22 10:48:33 +01:00
parent 6b18b06763
commit afb498b4bf
8 changed files with 179 additions and 4 deletions

View File

@@ -212,6 +212,64 @@ public interface FastItemStack extends PersistentDataHolder {
*/
void setBaseTag(@Nullable PersistentDataContainer container);
/**
* Get the type of the item.
*
* @return The type.
*/
@NotNull
Material getType();
/**
* Set the type of the item.
*
* @param material The type.
*/
void setType(@NotNull Material material);
/**
* Get the amount of the item.
*
* @return The amount.
*/
int getAmount();
/**
* Set the amount of the item.
*
* @param amount The amount.
*/
void setAmount(int amount);
/**
* Get the custom model data.
*
* @return The data, or null if none.
*/
@Nullable
Integer getCustomModelData();
/**
* Set the custom model data.
*
* @param data The data, null to remove.
*/
void setCustomModelData(@Nullable Integer data);
/**
* Get the speed multiplier.
*
* @return The multiplier.
*/
double getDestroySpeedMultiplier();
/**
* Set the speed multiplier.
*
* @param multiplier The multiplier.
*/
void setDestroySpeedMultiplier(double multiplier);
/**
* Get the Bukkit ItemStack again.
*

View File

@@ -517,6 +517,32 @@ public final class Items {
return fis.unwrap();
}
/**
* Get the base NBT tag on an item.
*
* @param itemStack The ItemStack.
* @param multiplier The multiplier
* @return The item, modified. Not required to use, as this modifies the instance.
*/
@NotNull
public static ItemStack setDestroySpeedMultiplier(@NotNull final ItemStack itemStack,
final double multiplier) {
FastItemStack fis = FastItemStack.wrap(itemStack);
fis.setDestroySpeedMultiplier(multiplier);
return fis.unwrap();
}
/**
* Get the items destroy speed.
*
* @param itemStack The ItemStack.
* @return The speed multiplier.
*/
public static double getDestroySpeedMultiplier(@NotNull final ItemStack itemStack) {
FastItemStack fis = FastItemStack.wrap(itemStack);
return fis.getDestroySpeedMultiplier();
}
private Items() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}