Package dev.piglin.piglinworldapi.util
Class GuiUtils
java.lang.Object
dev.piglin.piglinworldapi.util.GuiUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfillWith(@Nullable org.bukkit.inventory.ItemStack item, org.bukkit.inventory.Inventory inventory)Replaces Material.AIR with the specified itemstatic voidfillWithBarriers(@Nullable org.bukkit.plugin.Plugin plugin, org.bukkit.inventory.Inventory inventory)Replaces Material.AIR with your plugin's barrier (which is AIR by default, seeloadBarrier(Plugin))static org.bukkit.inventory.ItemStackgetBarrier(org.bukkit.plugin.Plugin plugin)Tries to get your plugin's barrier item.static voidloadBarrier(org.bukkit.plugin.Plugin plugin)Loads "gui.barrier" item in the plugin's configurationstatic org.bukkit.inventory.ItemStackread(org.bukkit.configuration.ConfigurationSection section, HashMap<String,String> replacements, org.bukkit.OfflinePlayer player)Reads the ItemStack from ConfigurationSection.static org.bukkit.inventory.ItemStackreplace(org.bukkit.inventory.ItemStack base, org.bukkit.configuration.ConfigurationSection section, HashMap<String,String> replacements, org.bukkit.OfflinePlayer player)
-
Constructor Details
-
GuiUtils
public GuiUtils()
-
-
Method Details
-
loadBarrier
public static void loadBarrier(org.bukkit.plugin.Plugin plugin)Loads "gui.barrier" item in the plugin's configuration- Parameters:
plugin- The plugin
-
read
public static org.bukkit.inventory.ItemStack read(org.bukkit.configuration.ConfigurationSection section, HashMap<String,String> replacements, org.bukkit.OfflinePlayer player)Reads the ItemStack from ConfigurationSection. The section should be in following format:item: # Optional base: {bukkit serialized itemstack or none} # If base is not specified, the next line must be specified, and the second line is optional material: MATERIAL with %placeholders% and {replacements} (for {color}_BANNER or {item}_SLAB) amount: optional, default is 1 # Replacements name: "Item name with %placeholders% and {replacements}" lore: [ "Array of lines with %placeholders% and {replacements}" ] custom model data: 42- Parameters:
section- The sectionreplacements- Replacements (StringUtils.replace(String, HashMap, OfflinePlayer))player- The player- Returns:
- The ItemStack
-
replace
public static org.bukkit.inventory.ItemStack replace(org.bukkit.inventory.ItemStack base, org.bukkit.configuration.ConfigurationSection section, HashMap<String,String> replacements, org.bukkit.OfflinePlayer player)- Parameters:
base- The base ItemStack to replacesection- replacements If the section contains any of these fields, they replace default fields in basename: "Item name with %placeholders% and {replacements}" lore: [ "Array of lines with %placeholders% and {replacements}" ] custom model data: 42replacements- Replacements (StringUtils.replace(String, HashMap, OfflinePlayer))player- The player- Returns:
- The ItemStack with replaced data
-
fillWithBarriers
public static void fillWithBarriers(@Nullable @Nullable org.bukkit.plugin.Plugin plugin, org.bukkit.inventory.Inventory inventory)Replaces Material.AIR with your plugin's barrier (which is AIR by default, seeloadBarrier(Plugin))- Parameters:
plugin- Your plugininventory- The inventory
-
fillWith
public static void fillWith(@Nullable @Nullable org.bukkit.inventory.ItemStack item, org.bukkit.inventory.Inventory inventory)Replaces Material.AIR with the specified item- Parameters:
item- The iteminventory- The inventory
-
getBarrier
public static org.bukkit.inventory.ItemStack getBarrier(org.bukkit.plugin.Plugin plugin)Tries to get your plugin's barrier item. Loads the item if not found (loadBarrier(Plugin))- Parameters:
plugin- Your plugin- Returns:
- The barrier item
-