Module gomint.api

Class ResourceManager


  • public class ResourceManager
    extends Object
    Version:
    1.0
    Author:
    geNAZt
    • Constructor Detail

      • ResourceManager

        public ResourceManager​(ClassLoader classLoader)
        Constructs a new ResourceManager which handles the loading and getting, reloading and cleanup for Resources
        Parameters:
        classLoader - The classLoader for which this ResourceManager should load Resources
    • Method Detail

      • registerLoader

        public void registerLoader​(ResourceLoader loader)
        Register a new ResourceLoader. It must implement the ResourceLoadFailedException and have a Constructor which takes two Arguments, JavaPlugin as first and a String as second Parameter. It also needs to have a empty default Constructor so you can register the ResourceLoader without it having loaded any Resource in it.

        The JavaPlugin will be the Plugin for which this loader should load. The String is the second parameter from LocaleManager.load(Locale, String)

        Parameters:
        loader - New loader which can be used to load Resources
      • load

        public void load​(Locale locale,
                         String param)
                  throws ResourceLoadFailedException
        Load a new Resource for the locale. The Loaders gets selected based of the ending of the Parameter. If a Locale has been loaded before it gets unloaded and the new one gets loaded instead. So you can overload old Resources with new ones
        Parameters:
        locale - Locale for which this Resource should be loaded
        param - The param from LocaleManager.load(Locale, String)
        Throws:
        ResourceLoadFailedException - when loading failed
      • isLoaded

        public boolean isLoaded​(Locale locale)
        Checks if a Locale has been loaded into this ResourceManager
        Parameters:
        locale - Locale which should be checked for
        Returns:
        true if loaded / false if not
      • reload

        public void reload()
        Reload all ResourceLoaders

        If one of the ResourceLoaders reports an error upon reloading it will get printed to the Plugins Logger

      • cleanup

        public void cleanup()
        If the Plugin should be unloaded remove all loaded Things and unref the plugin
      • getLoadedLocales

        public List<Locale> getLoadedLocales()
        Get a copy of the Key from the loaded Locales Map
        Returns:
        ArrayList of Locales