Class ModuleHelper
java.lang.Object
eu.cloudnetservice.driver.util.ModuleHelper
This module helper class provides helper methods for cloudnet modules that also operate as a plugin on the services.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EventManagerprivate static final org.slf4j.Loggerprivate final NetworkClientprivate final RPCHandlerRegistryprivate final ServiceRegistry -
Constructor Summary
ConstructorsConstructorDescriptionModuleHelper(@NonNull EventManager eventManager, @NonNull NetworkClient networkClient, @NonNull ServiceRegistry serviceRegistry, @NonNull RPCHandlerRegistry rpcHandlerRegistry) -
Method Summary
Modifier and TypeMethodDescriptionbooleancopyJarContainingClass(@NonNull Class<?> clazz, @NonNull Path target) Copies the caller class location from the class path to the given target path.voidcopyPluginConfigurationFileForEnvironment(@NonNull Class<?> clazz, @NonNull ServiceEnvironmentType type, @NonNull Path file) Copies the appropriate plugin configuration file for the given service environment type.voidunregisterAll(@NonNull ClassLoader classLoader) Unregisters all kind of listeners and bindings: Registered events in theEventManagerRegistered services in theServiceRegistryRegistered bindings for theDefaultObjectMapper.DEFAULT_MAPPERRegistered rpc handlers in theRPCHandlerRegistryRegistered language files inI18nRegistered packet listeners in thePacketListenerRegistry
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
eventManager
-
networkClient
-
serviceRegistry
-
rpcHandlerRegistry
-
-
Constructor Details
-
ModuleHelper
@Inject public ModuleHelper(@NonNull @NonNull EventManager eventManager, @NonNull @NonNull NetworkClient networkClient, @NonNull @NonNull ServiceRegistry serviceRegistry, @NonNull @NonNull RPCHandlerRegistry rpcHandlerRegistry)
-
-
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.limboloohp.yml if the given environment is LIMBO_LOOHP.
- 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 currentServiceEnvironmentTypeof 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
Unregisters all kind of listeners and bindings:- Registered events in the
EventManager - Registered services in the
ServiceRegistry - Registered bindings for the
DefaultObjectMapper.DEFAULT_MAPPER - Registered rpc handlers in the
RPCHandlerRegistry - Registered language files in
I18n - Registered packet listeners in the
PacketListenerRegistry
- Parameters:
classLoader- the class loader that registered all the mentioned listeners and bindings.- Throws:
NullPointerException- if the given class loader is null.
- Registered events in the
-