Class ModuleHelper

java.lang.Object
eu.cloudnetservice.driver.util.ModuleHelper

@Singleton public final class ModuleHelper extends Object
This module helper class provides helper methods for cloudnet modules that also operate as a plugin on the services.
Since:
4.0
  • Field Details

    • LOGGER

      private static final eu.cloudnetservice.common.log.Logger LOGGER
    • eventManager

      private final EventManager eventManager
    • networkClient

      private final NetworkClient networkClient
    • serviceRegistry

      private final ServiceRegistry serviceRegistry
    • rpcHandlerRegistry

      private final RPCHandlerRegistry rpcHandlerRegistry
  • Constructor Details

  • Method Details

    • copyJarContainingClass

      public boolean copyJarContainingClass(@NonNull @NonNull Class<?> clazz, @NonNull @NonNull Path target)
      Copies the caller class location from the class path to the given target path.
      Parameters:
      clazz - the class of which the associated class path entry should get copied.
      target - the target file to copy the file into - the file is not required to exist.
      Returns:
      true if the entry was copied successfully, false otherwise.
      Throws:
      NullPointerException - if clazz or target is null.
    • copyPluginConfigurationFileForEnvironment

      public void copyPluginConfigurationFileForEnvironment(@NonNull @NonNull Class<?> clazz, @NonNull @NonNull ServiceEnvironmentType type, @NonNull @NonNull Path file)
      Copies the appropriate plugin configuration file for the given service environment type. All the listed files will be copied and renamed to plugin.yml:
      • plugin.bungee.yml if the given environment is BUNGEECORD.
      • plugin.waterdogpe.yml if the given environment is WATERDOG_PE.
      • plugin.nukkit.yml if the given environment is NUKKIT.
      • plugin.bukkit.yml is used as a fallback - if the file does not exist it will not be used.
      Parameters:
      clazz - the class of which the associated class path entry should get copied.
      type - the current ServiceEnvironmentType of the service the file gets copied for.
      file - the target file of the plugin to copy the file for.
      Throws:
      NullPointerException - if clazz, type or file is null.
    • unregisterAll

      public void unregisterAll(@NonNull @NonNull ClassLoader classLoader)
      Unregisters all kind of listeners and bindings:
      Parameters:
      classLoader - the class loader that registered all the mentioned listeners and bindings.
      Throws:
      NullPointerException - if the given class loader is null.