Class I18n.FileResourceClassLoader

java.lang.Object
java.lang.ClassLoader
dev.satyrn.papermc.api.lang.v1.I18n.FileResourceClassLoader
Enclosing class:
I18n

public static final class I18n.FileResourceClassLoader extends ClassLoader
Custom class loader which loads locale bundles from the plugin data folder.
Since:
1.8.0
  • Constructor Details

    • FileResourceClassLoader

      public FileResourceClassLoader(@NotNull @NotNull ClassLoader classLoader, @NotNull @NotNull org.bukkit.plugin.Plugin plugin)
      Creates a new file resource class loader.
      Parameters:
      classLoader - The class loader.
      plugin - The plugin.
      Since:
      1.8.0
  • Method Details

    • getResource

      @Nullable public @Nullable URL getResource(@NotNull @NotNull String name)
      Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.

      The name of a resource is a '/'-separated path name that identifies the resource.

      Resources in named modules are subject to the encapsulation rules specified by Module.getResourceAsStream. Additionally, and except for the special case where the resource has a name ending with ".class", this method will only find resources in packages of named modules when the package is opened unconditionally (even if the caller of this method is in the same module as the resource).

      Overrides:
      getResource in class ClassLoader
      Parameters:
      name - The resource name
      Returns:
      URL object for reading the resource; null if the resource could not be found, a URL could not be constructed to locate the resource, the resource is in a package that is not opened unconditionally, or access to the resource is denied by the security manager.
      Throws:
      NullPointerException - If name is null When overriding this method it is recommended that an implementation ensures that any delegation is consistent with the getResources(String) method.
      Since:
      1.8.0
    • getResourceAsStream

      @Nullable public @Nullable InputStream getResourceAsStream(String name)
      Returns an input stream for reading the specified resource.

      The search order is described in the documentation for getResource(String).

      Resources in named modules are subject to the encapsulation rules specified by Module.getResourceAsStream. Additionally, and except for the special case where the resource has a name ending with ".class", this method will only find resources in packages of named modules when the package is opened unconditionally.

      Overrides:
      getResourceAsStream in class ClassLoader
      Parameters:
      name - The resource name
      Returns:
      An input stream for reading the resource; null if the resource could not be found, the resource is in a package that is not opened unconditionally, or access to the resource is denied by the security manager.
      Throws:
      NullPointerException - If name is null
      Since:
      1.8.0