Class GuiUtils

java.lang.Object
dev.piglin.piglinworldapi.util.GuiUtils

public class GuiUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    fillWith​(@Nullable org.bukkit.inventory.ItemStack item, org.bukkit.inventory.Inventory inventory)
    Replaces Material.AIR with the specified item
    static void
    fillWithBarriers​(@Nullable org.bukkit.plugin.Plugin plugin, org.bukkit.inventory.Inventory inventory)
    Replaces Material.AIR with your plugin's barrier (which is AIR by default, see loadBarrier(Plugin))
    static org.bukkit.inventory.ItemStack
    getBarrier​(org.bukkit.plugin.Plugin plugin)
    Tries to get your plugin's barrier item.
    static void
    loadBarrier​(org.bukkit.plugin.Plugin plugin)
    Loads "gui.barrier" item in the plugin's configuration
    static org.bukkit.inventory.ItemStack
    read​(org.bukkit.configuration.ConfigurationSection section, HashMap<String,​String> replacements, org.bukkit.OfflinePlayer player)
    Reads the ItemStack from ConfigurationSection.
    static org.bukkit.inventory.ItemStack
    replace​(org.bukkit.inventory.ItemStack base, org.bukkit.configuration.ConfigurationSection section, HashMap<String,​String> replacements, org.bukkit.OfflinePlayer player)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 section
      replacements - 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 replace
      section - replacements If the section contains any of these fields, they replace default fields in base
                                                                   name: "Item name with %placeholders% and {replacements}"
                                                                   lore: [ "Array of lines with %placeholders% and {replacements}" ]
                                                                   custom model data: 42
                                                                   
      replacements - 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, see loadBarrier(Plugin))
      Parameters:
      plugin - Your plugin
      inventory - 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 item
      inventory - 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