Interface DataExtension
The class implementing this interface should be annotated with PluginInfo
.
If the extension is given to Plan API without the annotation it will be rejected.
Public methods in the class should be annotated with appropriate Provider annotations.
Provider annotations:
BooleanProvider
for boolean
values and conditions for Conditional
.
NumberProvider
for long
values. (Use this for integers by casting to long) Has option for formatting.
DoubleProvider
for double
values.
PercentageProvider
for double
values that represent a percentage.
StringProvider
for String
values.
TableProvider
for Table
s.
GroupProvider
for Player specific group names, such as permission groups.
DataBuilderProvider
for ExtensionDataBuilder
s.
Methods can have one of the following as method parameters:
UUID playerUUID
- UUID of the player the data is about
String playerName
- Name of the player the data is about
group
- Provided group the data is about (In case a group needs additional information)
nothing - The data is interpreted to be about the server.
The name of the method will be used as an identifier in the database, so that a single provider does not duplicate entries.
Only first 50 characters of the method name are stored.
If you need to change a method name add a class annotation with the old method name: InvalidateMethod
Some additional annotations are available for controlling appearance of the results:
Conditional
A boolean
returned by BooleanProvider
has to be true
for this method to be called.
Tab
The value of this provider should be placed on a tab with a specific name
TabInfo
Optional Structure information about a tab
TabOrder
Optional information about preferred tab
Method calls are asynchronous. You can control when the calls are made via callExtensionMethodsOn()
and Caller
.
You can check against implementation violations by using ExtensionExtractor.validateAnnotations()
in your Unit Tests.
Implementation violations:
- No PluginInfo
class annotation
- Class contains no public methods with Provider annotations
- Class contains private method with Provider annotation
- Non-primitive return type when primitive is required (eg. Boolean instead of boolean)
- Method doesn't have correct parameters (see above)
- BooleanProvider
is annotated with a Conditional
that requires same condition the provider provides.
- Conditional
without a BooleanProvider
that provides value for the condition
- Annotation variable is over 50 characters (Or 150 if description)
- Method name is over 50 characters (Used as an identifier for storage)
-
Method Summary
Modifier and TypeMethodDescriptiondefault CallEvents[]
Determines when DataExtension methods are called automatically by Plan.default String
Get the name of the plugin from PluginInfo annotation.default ExtensionDataBuilder
Obtain a newExtensionDataBuilder
.default ValueBuilder
valueBuilder
(String text) Obtain a newValueBuilder
to use withExtensionDataBuilder
.
-
Method Details
-
callExtensionMethodsOn
Determines when DataExtension methods are called automatically by Plan.Override this method to determine more suitable call times for your plugin. You can also use
Caller
to update manually.If an empty array is supplied the DataExtension methods are not called by Plan automatically.
- Returns:
- Event types that will trigger method calls to the DataExtension.
- See Also:
-
newExtensionDataBuilder
Obtain a newExtensionDataBuilder
.Requires Capability DATA_EXTENSION_BUILDER_API
- Returns:
- new builder.
-
valueBuilder
Obtain a newValueBuilder
to use withExtensionDataBuilder
.Requires Capability DATA_EXTENSION_BUILDER_API
- Returns:
- new builder.
-
getPluginName
Get the name of the plugin from PluginInfo annotation.Requires Capability DATA_EXTENSION_BUILDER_API
- Returns:
- new builder.
-