Class LootTableManager

java.lang.Object
net.minestom.server.gamedata.loottables.LootTableManager

public final class LootTableManager
extends java.lang.Object
Handles loading and configuration of loot tables
  • Constructor Details

  • Method Details

    • registerConditionDeserializer

      public <T extends Condition> void registerConditionDeserializer​(NamespaceID namespaceID, com.google.gson.JsonDeserializer<T> factory)
      Registers a condition factory to the given namespaceID
      Parameters:
      namespaceID -
      factory -
    • registerTableType

      public void registerTableType​(NamespaceID namespaceID, LootTableType type)
      Registers a loot table type to the given namespaceID
      Parameters:
      namespaceID -
      type -
    • registerEntryType

      public void registerEntryType​(NamespaceID namespaceID, LootTableEntryType type)
      Registers a loot table entry type to the given namespaceID
      Parameters:
      namespaceID -
      type -
    • registerFunction

      public void registerFunction​(NamespaceID namespaceID, LootTableFunction function)
      Registers a loot table function to the given namespaceID
      Parameters:
      namespaceID -
      function -
    • load

      public LootTable load​(NamespaceID name) throws java.io.FileNotFoundException
      Throws:
      java.io.FileNotFoundException
    • load

      public LootTable load​(NamespaceID name, java.io.Reader reader)
      Loads a loot table with the given name. Loot tables can be cached, so 'reader' is used only on cache misses
      Parameters:
      name - the name to cache the loot table with
      reader - the reader to read the loot table from, if none cached. **Will** be closed no matter the results of this call
      Returns:
    • getTableType

      public LootTableType getTableType​(NamespaceID id)
      Returns the registered table type corresponding to the given namespace ID. If none is registered, throws IllegalArgumentException
      Parameters:
      id -
      Returns:
    • getEntryType

      public LootTableEntryType getEntryType​(NamespaceID id)
      Returns the registered entry type corresponding to the given namespace ID. If none is registered, throws IllegalArgumentException
      Parameters:
      id -
      Returns:
    • getFunction

      public LootTableFunction getFunction​(NamespaceID id)
      Returns the registered table type corresponding to the given namespace ID. If none is registered, returns LootTableFunction.IDENTITY
      Parameters:
      id -
      Returns:
    • getConditionDeserializer

      public com.google.gson.JsonDeserializer<? extends Condition> getConditionDeserializer​(NamespaceID id)