Class ItemUtils
java.lang.Object
ua.mcchickenstudio.opencreative.utils.ItemUtils
ItemUtils
This class represents an utils for changing items.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull org.bukkit.inventory.ItemStackaddLoreAtBegin(@NotNull org.bukkit.inventory.ItemStack item, @NotNull String loreLine) static @NotNull org.bukkit.inventory.ItemStackaddLoreAtEnd(@NotNull org.bukkit.inventory.ItemStack item, @NotNull String loreLine) static @NotNull org.bukkit.inventory.ItemStackclearItemFlags(@NotNull org.bukkit.inventory.ItemStack itemStack) static @NotNull org.bukkit.inventory.ItemStackclearItemMeta(@NotNull org.bukkit.inventory.ItemStack itemStack) static @NotNull org.bukkit.inventory.ItemStackcreateItem(@NotNull org.bukkit.Material material, int amount) static @NotNull org.bukkit.inventory.ItemStackcreateItem(@NotNull org.bukkit.Material material, int amount, @NotNull String localizationPath) Returns item stack with name and description found in localization file.static @NotNull org.bukkit.inventory.ItemStackcreateItem(@NotNull org.bukkit.Material material, int amount, @NotNull String localizationPath, @NotNull String persistentData) Returns item stack with name, description found in localization file and persistent data.static @NotNull org.bukkit.inventory.ItemStackcreateItem(@NotNull org.bukkit.Material material, int amount, @NotNull String localizationPath, Object value) Returns item stack with name and description found in localization file.static @NotNull org.bukkit.inventory.ItemStackcreateItem(@NotNull org.bukkit.inventory.ItemStack item, @NotNull String localizationPath) Returns item stack with name and description found in localization file.static @NotNull org.bukkit.inventory.ItemStackcreateItem(@NotNull org.bukkit.inventory.ItemStack item, @NotNull String localizationPath, @NotNull String persistentData) Returns item stack with name, description found in localization file and persistent data.static booleandoesItemRequireSpecialData(@NotNull org.bukkit.inventory.ItemStack item) Checks whether item should be saved as bytes array instead of just material.static org.bukkit.inventory.ItemStackfixItem(@NotNull org.bukkit.inventory.ItemStack item) Removes bad things from item: enchants with big level, attribute modifiers, books with a lot of pages, containers with containers; or replaces items with air.static @NotNull org.bukkit.inventory.ItemStackfixItem(@NotNull org.bukkit.inventory.ItemStack item, int displayNameMaxLength, int loreLineMaxLength, int loreLinesLimit, int maxEnchantLevel, int bookPagesLimit, boolean removeClickableBooks, int containerBigItemsLimit, int entitiesLimit, boolean removeCustomEggs, boolean removeBossEggs, boolean removeAttributes, boolean clearCommandBlocksData) Removes bad things from item: enchants with big level, attribute modifiers, books with a lot of pages, containers with containers; or replaces items with air.static @NotNull org.bukkit.NamespacedKeystatic @NotNull org.bukkit.NamespacedKeystatic @NotNull org.bukkit.NamespacedKeystatic @NotNull org.bukkit.NamespacedKeystatic @NotNull org.bukkit.NamespacedKeystatic @NotNull org.bukkit.NamespacedKeystatic @NotNull org.bukkit.NamespacedKeystatic @NotNull org.bukkit.NamespacedKeystatic intgetInsideBadItemsAmount(@NotNull org.bukkit.inventory.ItemStack item, int limit) static @NotNull org.bukkit.NamespacedKeystatic @NotNull org.bukkit.NamespacedKeystatic @NotNull StringgetItemType(@NotNull org.bukkit.inventory.ItemStack item) static @NotNull org.bukkit.NamespacedKeystatic @NotNull org.bukkit.inventory.ItemStackgetItemWithIgnoreData(@NotNull org.bukkit.inventory.ItemStack item, boolean removeAmount, boolean removeName, boolean removeLore, boolean removeFlags, boolean removeEnchantments, boolean removeMaterial, boolean removeDurability) static @NotNull org.bukkit.inventory.meta.ItemMetagetOrCreateItemMeta(@NotNull org.bukkit.inventory.ItemStack item) static @NotNull StringgetPersistentData(@NotNull org.bukkit.inventory.ItemStack item, @NotNull org.bukkit.NamespacedKey key) static intgetPersistentDataAmount(@NotNull org.bukkit.inventory.ItemStack item) static @NotNull ValueTypegetValueType(@NotNull org.bukkit.inventory.ItemStack item) static booleanitemEquals(org.bukkit.inventory.ItemStack itemStack, org.bukkit.inventory.ItemStack itemStack2) static @NotNull org.bukkit.inventory.ItemStackloadItemFromByteArray(@NotNull String text) Loads item from byte array in text.static @NotNull org.bukkit.inventory.ItemStackreplacePlaceholderInLore(@NotNull org.bukkit.inventory.ItemStack item, @NotNull String placeholder, @NotNull Object value) static @NotNull org.bukkit.inventory.ItemStackreplacePlaceholderInName(@NotNull org.bukkit.inventory.ItemStack item, @NotNull String placeholder, @NotNull Object value) static @NotNull StringsaveItemAsByteArray(@Nullable org.bukkit.inventory.ItemStack item) Saves item as byte array in text.static @NotNull org.bukkit.inventory.ItemStacksetDisplayName(@NotNull org.bukkit.inventory.ItemStack item, @Nullable String displayName) static @NotNull org.bukkit.inventory.ItemStackstatic @NotNull org.bukkit.inventory.ItemStacksetPersistentData(@NotNull org.bukkit.inventory.ItemStack item, @NotNull org.bukkit.NamespacedKey key, double value) static @NotNull org.bukkit.inventory.ItemStacksetPersistentData(@NotNull org.bukkit.inventory.ItemStack item, @NotNull org.bukkit.NamespacedKey key, @NotNull String value)
-
Constructor Details
-
ItemUtils
public ItemUtils()
-
-
Method Details
-
getCodingValueKey
@NotNull public static @NotNull org.bukkit.NamespacedKey getCodingValueKey() -
getCodingVariableTypeKey
@NotNull public static @NotNull org.bukkit.NamespacedKey getCodingVariableTypeKey() -
getCodingDoNotDropMeKey
@NotNull public static @NotNull org.bukkit.NamespacedKey getCodingDoNotDropMeKey() -
getCodingLocationX
@NotNull public static @NotNull org.bukkit.NamespacedKey getCodingLocationX() -
getCodingLocationY
@NotNull public static @NotNull org.bukkit.NamespacedKey getCodingLocationY() -
getCodingLocationZ
@NotNull public static @NotNull org.bukkit.NamespacedKey getCodingLocationZ() -
getCodingParticleTypeKey
@NotNull public static @NotNull org.bukkit.NamespacedKey getCodingParticleTypeKey() -
getItemTypeKey
@NotNull public static @NotNull org.bukkit.NamespacedKey getItemTypeKey() -
getItemIdKey
@NotNull public static @NotNull org.bukkit.NamespacedKey getItemIdKey() -
getCodingTargetTypeKey
@NotNull public static @NotNull org.bukkit.NamespacedKey getCodingTargetTypeKey() -
getItemEntityInvisible
@NotNull public static @NotNull org.bukkit.NamespacedKey getItemEntityInvisible() -
setPersistentData
@NotNull public static @NotNull org.bukkit.inventory.ItemStack setPersistentData(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull org.bukkit.NamespacedKey key, @NotNull @NotNull String value) -
setPersistentData
@NotNull public static @NotNull org.bukkit.inventory.ItemStack setPersistentData(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull org.bukkit.NamespacedKey key, double value) -
createItem
@NotNull public static @NotNull org.bukkit.inventory.ItemStack createItem(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull String localizationPath, @NotNull @NotNull String persistentData) Returns item stack with name, description found in localization file and persistent data. -
createItem
@NotNull public static @NotNull org.bukkit.inventory.ItemStack createItem(@NotNull @NotNull org.bukkit.Material material, int amount, @NotNull @NotNull String localizationPath, @NotNull @NotNull String persistentData) Returns item stack with name, description found in localization file and persistent data. -
createItem
@NotNull public static @NotNull org.bukkit.inventory.ItemStack createItem(@NotNull @NotNull org.bukkit.Material material, int amount, @NotNull @NotNull String localizationPath) Returns item stack with name and description found in localization file. -
createItem
@NotNull public static @NotNull org.bukkit.inventory.ItemStack createItem(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull String localizationPath) Returns item stack with name and description found in localization file. -
createItem
-
createItem
@NotNull public static @NotNull org.bukkit.inventory.ItemStack createItem(@NotNull @NotNull org.bukkit.Material material, int amount) -
clearItemFlags
@NotNull public static @NotNull org.bukkit.inventory.ItemStack clearItemFlags(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) -
clearItemMeta
@NotNull public static @NotNull org.bukkit.inventory.ItemStack clearItemMeta(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) -
itemEquals
public static boolean itemEquals(org.bukkit.inventory.ItemStack itemStack, org.bukkit.inventory.ItemStack itemStack2) -
replacePlaceholderInName
-
replacePlaceholderInLore
-
setDisplayName
@NotNull public static @NotNull org.bukkit.inventory.ItemStack setDisplayName(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @Nullable @Nullable String displayName) -
setLore
-
addLoreAtBegin
@NotNull public static @NotNull org.bukkit.inventory.ItemStack addLoreAtBegin(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull String loreLine) -
addLoreAtEnd
@NotNull public static @NotNull org.bukkit.inventory.ItemStack addLoreAtEnd(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull String loreLine) -
getValueType
@NotNull public static @NotNull ValueType getValueType(@NotNull @NotNull org.bukkit.inventory.ItemStack item) -
getItemType
@NotNull public static @NotNull String getItemType(@NotNull @NotNull org.bukkit.inventory.ItemStack item) -
getPersistentData
@NotNull public static @NotNull String getPersistentData(@NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull org.bukkit.NamespacedKey key) -
getItemWithIgnoreData
@NotNull public static @NotNull org.bukkit.inventory.ItemStack getItemWithIgnoreData(@NotNull @NotNull org.bukkit.inventory.ItemStack item, boolean removeAmount, boolean removeName, boolean removeLore, boolean removeFlags, boolean removeEnchantments, boolean removeMaterial, boolean removeDurability) -
getOrCreateItemMeta
@NotNull public static @NotNull org.bukkit.inventory.meta.ItemMeta getOrCreateItemMeta(@NotNull @NotNull org.bukkit.inventory.ItemStack item) -
fixItem
public static org.bukkit.inventory.ItemStack fixItem(@NotNull @NotNull org.bukkit.inventory.ItemStack item) Removes bad things from item: enchants with big level, attribute modifiers, books with a lot of pages, containers with containers; or replaces items with air.- Parameters:
item- item to fix.
-
fixItem
@NotNull public static @NotNull org.bukkit.inventory.ItemStack fixItem(@NotNull @NotNull org.bukkit.inventory.ItemStack item, int displayNameMaxLength, int loreLineMaxLength, int loreLinesLimit, int maxEnchantLevel, int bookPagesLimit, boolean removeClickableBooks, int containerBigItemsLimit, int entitiesLimit, boolean removeCustomEggs, boolean removeBossEggs, boolean removeAttributes, boolean clearCommandBlocksData) Removes bad things from item: enchants with big level, attribute modifiers, books with a lot of pages, containers with containers; or replaces items with air.- Parameters:
item- item to fix.displayNameMaxLength- maximum length of item's display name.loreLineMaxLength- maximum length of item's lore line.loreLinesLimit- maximum amount of item's lore lines.maxEnchantLevel- maximum enchant level.bookPagesLimit- limit of books pages.removeClickableBooks- remove clickable components in books or not.containerBigItemsLimit- limit of big items (books, containers) in container.entitiesLimit- limit of entities in entities blocks storage (beehives).removeCustomEggs- removes custom spawn eggs.removeBossEggs- removes boss spawn eggs.removeAttributes- removes attribute modifiers (scale).clearCommandBlocksData- removes commands from command blocks.
-
getInsideBadItemsAmount
public static int getInsideBadItemsAmount(@NotNull @NotNull org.bukkit.inventory.ItemStack item, int limit) -
getPersistentDataAmount
public static int getPersistentDataAmount(@NotNull @NotNull org.bukkit.inventory.ItemStack item) -
saveItemAsByteArray
@NotNull public static @NotNull String saveItemAsByteArray(@Nullable @Nullable org.bukkit.inventory.ItemStack item) Saves item as byte array in text.- Parameters:
item- item to serialize.- Returns:
- string of byte array, that can be used in configs, or empty text "".
-
loadItemFromByteArray
@NotNull public static @NotNull org.bukkit.inventory.ItemStack loadItemFromByteArray(@NotNull @NotNull String text) Loads item from byte array in text.- Parameters:
text- text with item's byte array to deserialize.- Returns:
- item from byte array, or empty (air x0) item.
-
doesItemRequireSpecialData
public static boolean doesItemRequireSpecialData(@NotNull @NotNull org.bukkit.inventory.ItemStack item) Checks whether item should be saved as bytes array instead of just material.- Parameters:
item- item to check.- Returns:
- true - item can have special data, so it should be saved as bytes array to contain all information, false - can be saved as material.
-