Class Icon
GUI
.-
Field Summary
-
Constructor Summary
ConstructorDescriptionIcon
(String id, IconType type, MaterialAdapter material, ValueContainer<Short> amount, short damage, boolean keepOpen, boolean glowing, int position) Constructs a new icon specifying only the essential options and assuming the others as their default values.Icon
(String id, IconType type, MaterialAdapter material, ValueContainer<Short> amount, short damage, boolean keepOpen, boolean glowing, int position, String skullOwner, String skullTextureURL, Color leatherArmorColor, List<String> commands, List<ItemFlagAdapter> itemFlags, Map<Language, String> displayNames, Map<Language, List<String>> lores, Map<EnchantmentAdapter, Integer> enchantments) Constructs a new icon specifying all the available options.Constructs a new icon specifying another icon's values. -
Method Summary
Modifier and TypeMethodDescriptionstatic int[]
calcIconCoords
(int position) Calculates an icon's X and Y coordinates using its position.static int
calcIconPosition
(int x, int y) Calculates an icon's position using its X and Y coordinates.formatPlaceholders
(String input, GUI gui, Language language, boolean translateColors) Translates an input string containing placeholders for the specified GUI and language usingGUI.getStringPlaceholdersTranslator()
.formatPlaceholders
(List<String> input, GUI gui, Language language, boolean translateColors) Translates an input string list containing placeholders for the specified GUI and language usingGUI.getStringListPlaceholdersTranslator()
.Gets this icon's items' amount.Gets the commands that will be executed when this icon is clicked.short
Gets this icon's items' damage.Gets this icon's display names.Gets this icon's enchantments.getID()
Gets this icon's ID.Gets this icon's item flags.Gets this icon's leather armor's color.getLores()
Gets this icon's lores.Gets this icon's material.int
Gets this icon's position in the GUI's inventory.Gets this icon's skull's owner.Gets this icon's skull's texture's URL.getType()
Gets this icon's type.boolean
Checks if the glowing effect should be applied to this icon.boolean
Checks if the GUI should be kept open when this icon is clicked.static boolean
isValidIconID
(String iconID) Checks if the specified String is a valid icon ID.setAmount
(ValueContainer<Short> amount) Sets this icon's items' amount.setCommands
(List<String> commands) Sets the commands that will be executed when this icon is clicked.setDamage
(short damage) Sets this icon's items' damage.setDisplayNames
(Map<Language, String> displayNames) Sets this icon's display names.setEnchantments
(Map<EnchantmentAdapter, Integer> enchantments) Sets this icon's enchantments.setGlowing
(boolean glowing) Sets if the glowing effect should be applied to this icon.setItemFlags
(List<ItemFlagAdapter> itemFlags) Sets this icon's item flags.setKeepOpen
(boolean keepOpen) Sets if the GUI should be kept open when this icon is clicked.setLeatherArmorColor
(Color leatherArmorColor) Sets this icon's leather armor's color.Sets this icon's lores.setMaterial
(MaterialAdapter material) Sets this icon's material.setPosition
(int position) Sets this icon's position in the GUI's inventory.setSkullOwner
(String skullOwner) Sets this icon's skull's owner.setSkullTextureURL
(String skullTextureURL) Sets this icon's skull's texture's URL.toItemStackAdapter
(GUI gui, Language language) Generates an item stack for the specified language using this icon's values and translating placeholders usingformatPlaceholders(String, GUI, Language, boolean)
andformatPlaceholders(List, GUI, Language, boolean)
translating colors when necessary.updateSkullOwner
(ItemStackAdapter itemStack, GUI gui, Language language) Sets the skull's owner for the specified item stack if it is a player head.
-
Field Details
-
ICON_ID_PATTERN
Pattern representing the allowed icon IDs.Regex: "^[a-zA-Z0-9-_]{2,36}$"
- See Also:
-
-
Constructor Details
-
Icon
Constructs a new icon specifying another icon's values.Note: changes made to that icon's lists, maps and leather armor color will be reflected to this icon and vice versa.
- Parameters:
icon
- Icon to copy
-
Icon
public Icon(String id, IconType type, MaterialAdapter material, ValueContainer<Short> amount, short damage, boolean keepOpen, boolean glowing, int position) Constructs a new icon specifying only the essential options and assuming the others as their default values.Note:
GUIManager.createIcon(Configuration, String)
is capable of reading icons fromConfiguration
s. Use this constructor just to obtain custom icons via code.- Parameters:
id
- Icon's IDtype
- Icon's typematerial
- Icon's materialamount
- Icon's items' amount [1 - 64]damage
- Icon's items' damage [0 - max durability]keepOpen
- Whether the GUI will remain open on clickglowing
- Whether the glowing effect should be appliedposition
- Icon's position [0 - (InventoryAdapter.getSize()
- 1)]- Throws:
IllegalArgumentException
- If specified ID!
isValidIconID(String)
-
Icon
public Icon(String id, IconType type, MaterialAdapter material, ValueContainer<Short> amount, short damage, boolean keepOpen, boolean glowing, int position, String skullOwner, String skullTextureURL, Color leatherArmorColor, List<String> commands, List<ItemFlagAdapter> itemFlags, Map<Language, String> displayNames, Map<Language, List<String>> lores, Map<EnchantmentAdapter, Integer> enchantments) Constructs a new icon specifying all the available options.Note:
GUIManager.createIcon(Configuration, String)
is capable of reading icons fromConfiguration
s. Use this constructor just to obtain custom icons via code.It is recommended to use thread-safe collections.
- Parameters:
id
- Icon's IDtype
- Icon's typematerial
- Icon's materialamount
- Icon's items' amount [1 - 64]damage
- Icon's items' damage [0 - max durability]keepOpen
- Whether the GUI will remain open on clickglowing
- Whether the glowing effect should be appliedposition
- Icon's position [0 - (InventoryAdapter.getSize()
- 1)]skullOwner
- Icon's skull's ownerskullTextureURL
- Icon's skull's texture's URLleatherArmorColor
- Icon's leather armor's colorcommands
- Icon's commands executed on clickitemFlags
- Icon's item flagsdisplayNames
- Icon's display nameslores
- Icon's loresenchantments
- Icon's enchantments- Throws:
IllegalArgumentException
- If specified ID!
isValidIconID(String)
-
-
Method Details
-
getID
Gets this icon's ID.- Returns:
- Icon's ID
-
getType
Gets this icon's type.- Returns:
- Icon's type
-
getMaterial
Gets this icon's material.- Returns:
- Icon's material
-
setMaterial
Sets this icon's material.- Parameters:
material
- Icon's material- Returns:
- This icon
-
getAmount
Gets this icon's items' amount.- Returns:
- Icon's items' amount [1 - 64]
-
setAmount
Sets this icon's items' amount.- Parameters:
amount
- Icon's items' amount [1 - 64]- Returns:
- This icon
-
getDamage
public short getDamage()Gets this icon's items' damage.- Returns:
- Icon's items' damage [0 - max durability]
-
setDamage
Sets this icon's items' damage.- Parameters:
damage
- Icon's items' damage [0 - max durability]- Returns:
- This icon
-
isKeepOpen
public boolean isKeepOpen()Checks if the GUI should be kept open when this icon is clicked.- Returns:
- Whether the GUI will remain open on click
-
setKeepOpen
Sets if the GUI should be kept open when this icon is clicked.- Parameters:
keepOpen
- Whether the GUI will remain open on click- Returns:
- This icon
-
isGlowing
public boolean isGlowing()Checks if the glowing effect should be applied to this icon.- Returns:
- Whether the glowing effect should be applied
-
setGlowing
Sets if the glowing effect should be applied to this icon.- Parameters:
glowing
- Whether the glowing effect should be applied- Returns:
- This icon
-
getPosition
public int getPosition()Gets this icon's position in the GUI's inventory.- Returns:
- Icon's position [0 - (
InventoryAdapter.getSize()
- 1)]
-
setPosition
Sets this icon's position in the GUI's inventory.- Parameters:
position
- Icon's position [0 - (InventoryAdapter.getSize()
- 1)]- Returns:
- This icon
-
getSkullOwner
Gets this icon's skull's owner.Will return
null
if the skull's owner has not been specified.- Returns:
- Icon's skull's owner
-
setSkullOwner
Sets this icon's skull's owner.You can specify
null
to remove the skull's owner.- Parameters:
skullOwner
- Icon's skull's owner- Returns:
- This icon
-
getSkullTextureURL
Gets this icon's skull's texture's URL.Will return
null
if the skull's texture's URL has not been specified.- Returns:
- Icon's skull's texture's URL
-
setSkullTextureURL
Sets this icon's skull's texture's URL.You can specify
null
to remove the skull's texture's URL.- Parameters:
skullTextureURL
- Icon's skull's texture's URL- Returns:
- This icon
-
getLeatherArmorColor
Gets this icon's leather armor's color.Will return
null
if the leather armor's color has not been specified.- Returns:
- Icon's leather armor's color
-
setLeatherArmorColor
Sets this icon's leather armor's color.If you need to reset the color to the default value, specify
null
and the following hex code will be applied: "#A06540".- Parameters:
leatherArmorColor
- Icon's leather armor's color- Returns:
- This icon
-
getCommands
Gets the commands that will be executed when this icon is clicked.You may modify the returned list.
- Returns:
- Icon's commands
-
setCommands
Sets the commands that will be executed when this icon is clicked.- Parameters:
commands
- Icon's commands- Returns:
- This icon
-
getItemFlags
Gets this icon's item flags.You may modify the returned list.
- Returns:
- Icon's item flags
-
setItemFlags
Sets this icon's item flags.- Parameters:
itemFlags
- Icon's item flags- Returns:
- This icon
-
getDisplayNames
Gets this icon's display names.You may modify the returned map.
- Returns:
- Icon's display names
-
setDisplayNames
Sets this icon's display names.- Parameters:
displayNames
- Icon's display names- Returns:
- This icon
-
getLores
Gets this icon's lores.You may modify the returned map.
- Returns:
- Icon's lores
-
setLores
Sets this icon's lores.- Parameters:
lores
- Icon's lores- Returns:
- This icon
-
getEnchantments
Gets this icon's enchantments.You may modify the returned map.
- Returns:
- Icon's enchantments
-
setEnchantments
Sets this icon's enchantments.- Parameters:
enchantments
- Icon's enchantments- Returns:
- This icon
-
toItemStackAdapter
Generates an item stack for the specified language using this icon's values and translating placeholders usingformatPlaceholders(String, GUI, Language, boolean)
andformatPlaceholders(List, GUI, Language, boolean)
translating colors when necessary.This method takes no time to execute but it does not consider
getSkullOwner()
. To change a player head icon skull's owner useupdateSkullOwner(ItemStackAdapter, GUI, Language)
.Note:
getSkullTextureURL()
is considered because it takes no time to set.- Parameters:
gui
- GUI containing this iconlanguage
- Language used to translate the placeholders- Returns:
- New item stack
-
updateSkullOwner
public CompletableFuture<ItemStackAdapter> updateSkullOwner(ItemStackAdapter itemStack, GUI gui, Language language) Sets the skull's owner for the specified item stack if it is a player head.When the future is completed, you need to manually set the icon to the inventory using
InventoryAdapter.setItem(ItemStackAdapter, int)
to update it.The future will be completed instantly in the following cases:
!
ItemStackAdapter.isPlayerHead()
getSkullOwner()
== null
(when skull owner is removed)getSkullOwner()
's skin is cached (caching is automatic)
- Parameters:
itemStack
- Original item stackgui
- GUI containing this iconlanguage
- Language used to translate the placeholders- Returns:
- New item stack
- See Also:
-
formatPlaceholders
Translates an input string containing placeholders for the specified GUI and language usingGUI.getStringPlaceholdersTranslator()
.- Parameters:
input
- Input containing placeholdersgui
- GUI containing this iconlanguage
- Language used to translate the placeholderstranslateColors
- Whether toChatColor.translate(String)
the output- Returns:
- Translated placeholders
-
formatPlaceholders
public List<String> formatPlaceholders(List<String> input, GUI gui, Language language, boolean translateColors) Translates an input string list containing placeholders for the specified GUI and language usingGUI.getStringListPlaceholdersTranslator()
.- Parameters:
input
- Input containing placeholdersgui
- GUI containing this iconlanguage
- Language used to translate the placeholderstranslateColors
- Whether toChatColor.translate(String)
the output- Returns:
- Translated placeholders
-
isValidIconID
Checks if the specified String is a valid icon ID.- Parameters:
iconID
- Icon ID to check- Returns:
- Whether the specified icon ID is valid
- See Also:
-
calcIconPosition
public static int calcIconPosition(int x, int y) Calculates an icon's position using its X and Y coordinates.- Parameters:
x
- Icon's X coordinate [1 - 9]y
- Icon's Y coordinate [1 - (InventoryAdapter.getSize()
/ 9)]- Returns:
- Icon's position [0 - (
InventoryAdapter.getSize()
- 1)] - See Also:
-
calcIconCoords
public static int[] calcIconCoords(int position) Calculates an icon's X and Y coordinates using its position.- Parameters:
position
- Icon's position [0 - (InventoryAdapter.getSize()
- 1)]- Returns:
- Icon's X and Y coordinates
- See Also:
-