Module gomint.api

Class ResourceManager

  • public class ResourceManager
    extends Object
    • Constructor Detail

      • ResourceManager

        public ResourceManager​(ClassLoader classLoader)
        Constructs a new ResourceManager which handles the loading and getting, reloading and cleanup for Resources
        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)

        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
        locale - Locale for which this Resource should be loaded
        param - The param from LocaleManager.load(Locale, String)
        ResourceLoadFailedException - when loading failed
      • isLoaded

        public boolean isLoaded​(Locale locale)
        Checks if a Locale has been loaded into this ResourceManager
        locale - Locale which should be checked for
        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
        ArrayList of Locales