Class MappingDataLoader

java.lang.Object
com.viaversion.viaversion.api.data.MappingDataLoader

public class MappingDataLoader extends Object
  • Field Details

    • INSTANCE

      public static final MappingDataLoader INSTANCE
    • MAPPINGS_READER

      public static final com.viaversion.nbt.io.TagReader<com.viaversion.nbt.tag.CompoundTag> MAPPINGS_READER
  • Constructor Details

    • MappingDataLoader

      public MappingDataLoader(Class<?> dataLoaderClass, String dataPath)
  • Method Details

    • loadGlobalIdentifiers

      public static void loadGlobalIdentifiers()
    • identifierFromGlobalId

      public @Nullable String identifierFromGlobalId(String registry, int globalId)
      Returns the global id of the identifier in the registry.
      Parameters:
      registry - registry key
      globalId - global id
      Returns:
      identifier
      Throws:
      IllegalArgumentException - if the registry key is invalid
    • clearCache

      public void clearCache()
    • loadFromDataDir

      public @Nullable com.google.gson.JsonObject loadFromDataDir(String name)
      Loads the file from the plugin folder if present, else from the bundled resources.
      Returns:
      loaded json object, or null if not found or invalid
    • loadData

      public @Nullable com.google.gson.JsonObject loadData(String name)
      Loads the file from the bundled resources.
      Returns:
      loaded json object from bundled resources if present
    • loadNBT

      public @Nullable com.viaversion.nbt.tag.CompoundTag loadNBT(String name, boolean cache)
    • loadNBT

      public @Nullable com.viaversion.nbt.tag.CompoundTag loadNBT(String name)
    • loadNBTFromFile

      public @Nullable com.viaversion.nbt.tag.CompoundTag loadNBTFromFile(String name)
    • loadMappings

      public @Nullable Mappings loadMappings(com.viaversion.nbt.tag.CompoundTag mappingsTag, String key)
    • loadMappings

      @Beta public <M extends Mappings, V> @Nullable Mappings loadMappings(com.viaversion.nbt.tag.CompoundTag mappingsTag, String key, MappingDataLoader.MappingHolderSupplier<V> holderSupplier, MappingDataLoader.AddConsumer<V> addConsumer, MappingDataLoader.MappingsSupplier<M,V> mappingsSupplier)
    • identifiersFromGlobalIds

      public @Nullable List<String> identifiersFromGlobalIds(com.viaversion.nbt.tag.CompoundTag mappingsTag, String key)
    • indexedObjectToMap

      public it.unimi.dsi.fastutil.objects.Object2IntMap<String> indexedObjectToMap(com.google.gson.JsonObject object)
      Returns a map of the object entries hashed by their id value.
      Parameters:
      object - json object
      Returns:
      map with indexes hashed by their id value
    • arrayToMap

      public it.unimi.dsi.fastutil.objects.Object2IntMap<String> arrayToMap(com.google.gson.JsonArray array)
      Returns a map of the array entries hashed by their id value.
      Parameters:
      array - json array
      Returns:
      map with indexes hashed by their id value
    • getLogger

      public Logger getLogger()
    • getDataFolder

      public File getDataFolder()
    • getResource

      public @Nullable InputStream getResource(String name)