Class LootTableHandler

java.lang.Object
com.ryandw11.structure.loottables.LootTableHandler

public class LootTableHandler extends Object
This handles the loot tables.

Get this handler via CustomStructuresAPI.getLootTableHandler().

  • Constructor Details

    • LootTableHandler

      public LootTableHandler()
  • Method Details

    • addLootTable

      public boolean addLootTable(LootTable lootTable)
      Add a loot table to the LootTableHandler.

      Addons should be using CustomStructureAddon.registerLootTable(LootTable) to add custom LootTables since the LootTableHandler is reset every time the plugin is reloaded.

      Parameters:
      lootTable - The loot table to add.
      Returns:
      If the loot table was added successfully.
    • addLootItem

      public boolean addLootItem(String typeName, Class<? extends ConfigLootItem> lootItemClass)
      Add a loot item to the LootTableHandler.

      Addons should be using CustomStructureAddon.registerLootItem(String, Class) to add custom LootItems since the LootTableHandler is reset every time the plugin is reloaded.

      Parameters:
      typeName - The type name for the LootItem. (All names are set to be upper-case).
      lootItemClass - The loot item class.
      Returns:
      If the loot item was added successfully.
    • getLootTableByName

      public LootTable getLootTableByName(String lootTableName)
      Get the loot table by the name.

      This will automatically load a loot table

      If the name starts with minecraft:, it will try to load a minecraft loot table.

      Parameters:
      lootTableName - The name of the loot table.
      Returns:
      The loot table. This will return null if the loot table does not exist or loads with an error.
    • getLootTables

      public Map<String,​LootTable> getLootTables()
      Get the map of loot tables.

      This returns an unmodifiable map.

      Returns:
      The unmodifiable map of loot tables.
    • getLootTablesNames

      public List<String> getLootTablesNames()
      Get a list with the names of all loot tables.
      Returns:
      The list with names of all loot tables.
    • getLootItemClassByName

      public Class<? extends ConfigLootItem> getLootItemClassByName(String typeName)
      Get a loot item's class by its type name. (Built-In loot items won't be returned).
      Parameters:
      typeName - The type name. (All type names are uppercase).
      Returns:
      The loot item's class.
    • getLootItems

      public Map<String,​Class<? extends ConfigLootItem>> getLootItems()
      Get loot items.
      Returns:
      The unmodifiable map of loot items.