Class MappingDataLoader


  • public class MappingDataLoader
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static it.unimi.dsi.fastutil.objects.Object2IntMap<java.lang.String> arrayToMap​(com.google.gson.JsonArray array)
      Returns a map of the array entries hashed by their id value.
      static void enableMappingsCache()  
      static java.util.Map<java.lang.String,​com.google.gson.JsonObject> getMappingsCache()
      Returns the cached mappings.
      static @Nullable java.io.InputStream getResource​(java.lang.String name)  
      static it.unimi.dsi.fastutil.objects.Object2IntMap<java.lang.String> indexedObjectToMap​(com.google.gson.JsonObject object)
      Returns a map of the object entries hashed by their id value.
      static boolean isCacheJsonMappings()
      Returns true if a selected number of mappings should be cached.
      static @Nullable com.google.gson.JsonObject loadData​(java.lang.String name)
      Loads the file from the bundled resources.
      static @Nullable com.google.gson.JsonObject loadData​(java.lang.String name, boolean cacheIfEnabled)
      Loads the file from the bundled resources.
      static @Nullable com.google.gson.JsonObject loadFromDataDir​(java.lang.String name)
      Loads the file from the plugin folder if present, else from the bundled resources.
      static void mapIdentifiers​(int[] output, com.google.gson.JsonArray oldIdentifiers, com.google.gson.JsonArray newIdentifiers, boolean warnOnMissing)  
      static void mapIdentifiers​(int[] output, com.google.gson.JsonArray oldIdentifiers, com.google.gson.JsonArray newIdentifiers, @Nullable com.google.gson.JsonObject diffIdentifiers, boolean warnOnMissing)  
      static void mapIdentifiers​(int[] output, com.google.gson.JsonObject oldIdentifiers, com.google.gson.JsonObject newIdentifiers)  
      static void mapIdentifiers​(int[] output, com.google.gson.JsonObject oldIdentifiers, com.google.gson.JsonObject newIdentifiers, @Nullable com.google.gson.JsonObject diffIdentifiers)  
      static void mapIdentifiers​(Int2IntBiMap output, com.google.gson.JsonObject oldIdentifiers, com.google.gson.JsonObject newIdentifiers, @Nullable com.google.gson.JsonObject diffIdentifiers)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MappingDataLoader

        public MappingDataLoader()
    • Method Detail

      • isCacheJsonMappings

        public static boolean isCacheJsonMappings()
        Returns true if a selected number of mappings should be cached. If enabled, cleanup should be done after the cache is no longer needed.
        Returns:
        true if mappings should be cached
      • enableMappingsCache

        public static void enableMappingsCache()
      • getMappingsCache

        public static java.util.Map<java.lang.String,​com.google.gson.JsonObject> getMappingsCache()
        Returns the cached mappings. Cleared after ViaVersion has been fully loaded.
        Returns:
        cached mapping file json objects
        See Also:
        isCacheJsonMappings()
      • loadFromDataDir

        public static @Nullable com.google.gson.JsonObject loadFromDataDir​(java.lang.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 static @Nullable com.google.gson.JsonObject loadData​(java.lang.String name)
        Loads the file from the bundled resources. Uses the cache if enabled.
        Returns:
        loaded json object from bundled resources if present
      • loadData

        public static @Nullable com.google.gson.JsonObject loadData​(java.lang.String name,
                                                                    boolean cacheIfEnabled)
        Loads the file from the bundled resources. Uses the cache if enabled.
        Parameters:
        cacheIfEnabled - whether loaded files should be cached
        Returns:
        loaded json object from bundled resources if present
      • mapIdentifiers

        public static void mapIdentifiers​(Int2IntBiMap output,
                                          com.google.gson.JsonObject oldIdentifiers,
                                          com.google.gson.JsonObject newIdentifiers,
                                          @Nullable com.google.gson.JsonObject diffIdentifiers)
      • mapIdentifiers

        public static void mapIdentifiers​(int[] output,
                                          com.google.gson.JsonObject oldIdentifiers,
                                          com.google.gson.JsonObject newIdentifiers)
      • mapIdentifiers

        public static void mapIdentifiers​(int[] output,
                                          com.google.gson.JsonObject oldIdentifiers,
                                          com.google.gson.JsonObject newIdentifiers,
                                          @Nullable com.google.gson.JsonObject diffIdentifiers)
      • mapIdentifiers

        public static void mapIdentifiers​(int[] output,
                                          com.google.gson.JsonArray oldIdentifiers,
                                          com.google.gson.JsonArray newIdentifiers,
                                          boolean warnOnMissing)
      • mapIdentifiers

        public static void mapIdentifiers​(int[] output,
                                          com.google.gson.JsonArray oldIdentifiers,
                                          com.google.gson.JsonArray newIdentifiers,
                                          @Nullable com.google.gson.JsonObject diffIdentifiers,
                                          boolean warnOnMissing)
      • indexedObjectToMap

        public static it.unimi.dsi.fastutil.objects.Object2IntMap<java.lang.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 static it.unimi.dsi.fastutil.objects.Object2IntMap<java.lang.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
      • getResource

        public static @Nullable java.io.InputStream getResource​(java.lang.String name)