Package com.djrapitops.plan.extension
Interface ExtensionService
-
public interface ExtensionService
Interface for registeringDataExtension
s.Obtaining instance: - Obtain instance with
getInstance()
. - Make sure to catch a possible NoClassDefFoundError in case Plan is not installed - Catch IllegalStateException in case ExtensionService is not enabledRegistering
DataExtension
: - Register yourDataExtension
withregister(DataExtension)
- Catch a possible IllegalArgumentException in case the DataExtension implementation is invalid.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ExtensionService.Holder
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static ExtensionService
getInstance()
Obtain instance of ExtensionService.java.util.Optional<Caller>
register(DataExtension extension)
Register yourDataExtension
implementation.void
unregister(DataExtension extension)
Unregister yourDataExtension
implementation.
-
-
-
Method Detail
-
getInstance
static ExtensionService getInstance()
Obtain instance of ExtensionService.- Returns:
- ExtensionService implementation.
- Throws:
java.lang.NoClassDefFoundError
- If Plan is not installed and this class can not be found or if older Plan version is installed.java.lang.IllegalStateException
- If Plan is installed, but not enabled.
-
register
java.util.Optional<Caller> register(DataExtension extension)
Register yourDataExtension
implementation.You can use
ExtensionExtractor.validateAnnotations()
in your Unit Tests to prevent IllegalArgumentExceptions here at runtime.- Parameters:
extension
- Your DataExtension implementation, seeDataExtension
for requirements.- Returns:
- Optional
Caller
that can be used to call for data update in Plan database manually - If the Optional is not present the user has disabled the extension in Plan config. - Throws:
java.lang.IllegalArgumentException
- If an implementation violation is found.
-
unregister
void unregister(DataExtension extension)
Unregister yourDataExtension
implementation.This method should be used if calling methods on the DataExtension suddenly becomes unavailable, due to plugin disable for example.
- Parameters:
extension
- Your DataExtension implementation that was registered before.
-
-