Interface DataExtension
-
public interface DataExtension
Interface to implement data extensions with.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
forboolean
values and conditions forConditional
.NumberProvider
forlong
values. (Use this for integers by casting to long) Has option for formatting.DoubleProvider
fordouble
values.PercentageProvider
fordouble
values that represent a percentage.StringProvider
forString
values.TableProvider
forTable
s.GroupProvider
for Player specific group names, such as permission groups.DataBuilderProvider
forExtensionDataBuilder
s.
Methods can have one of the following as method parameters:
UUID playerUUID
- UUID of the player the data is aboutString playerName
- Name of the player the data is aboutgroup
- 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
Aboolean
returned byBooleanProvider
has to betrue
for this method to be called.Tab
The value of this provider should be placed on a tab with a specific nameTabInfo
Optional Structure information about a tabTabOrder
Optional information about preferred tab
Method calls are asynchronous. You can control when the calls are made via
callExtensionMethodsOn()
andCaller
.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 aConditional
that requires same condition the provider provides. -Conditional
without aBooleanProvider
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)- See Also:
Required Annotation
,for method call event types.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default CallEvents[]
callExtensionMethodsOn()
Determines when DataExtension methods are called automatically by Plan.default java.lang.String
getPluginName()
Get the name of the plugin from PluginInfo annotation.default ExtensionDataBuilder
newExtensionDataBuilder()
Obtain a newExtensionDataBuilder
.default ValueBuilder
valueBuilder(java.lang.String text)
Obtain a newValueBuilder
to use withExtensionDataBuilder
.
-
-
-
Method Detail
-
callExtensionMethodsOn
default CallEvents[] 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:
for details when the methods are called.
-
newExtensionDataBuilder
default ExtensionDataBuilder newExtensionDataBuilder()
Obtain a newExtensionDataBuilder
.Requires Capability DATA_EXTENSION_BUILDER_API
- Returns:
- new builder.
-
valueBuilder
default ValueBuilder valueBuilder(java.lang.String text)
Obtain a newValueBuilder
to use withExtensionDataBuilder
.Requires Capability DATA_EXTENSION_BUILDER_API
- Returns:
- new builder.
-
getPluginName
default java.lang.String getPluginName()
Get the name of the plugin from PluginInfo annotation.Requires Capability DATA_EXTENSION_BUILDER_API
- Returns:
- new builder.
-
-