Interface DefaultFunction<T>
- Type Parameters:
T
- The return type.
- All Superinterfaces:
Documentable
,Function<T>
A function that has been implemented in Java, instead of in Skript.
An example implementation is stated below.
DefaultFunction function = DefaultFunction.builder(addon, "floor", Long.class)
.description("Rounds a number down.")
.examples("floor(2.34) = 2")
.since("3.0")
.parameter("n", Number.class)
.build(args -> {
Object value = args.get("n");
if (value instanceof Long l)
return l;
return Math2.floor(((Number) value).doubleValue());
});
Functions.register(function);
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull DefaultFunction.Builder
<T> builder
(@NotNull SkriptAddon source, @NotNull String name, @NotNull Class<T> returnType) Creates a new builder for a function.@NotNull SkriptAddon
source()
Methods inherited from interface ch.njol.skript.doc.Documentable
description, examples, keywords, name, requires, since
-
Method Details
-
builder
@Contract("_, _, _ -> new") @NotNull static <T> @NotNull DefaultFunction.Builder<T> builder(@NotNull @NotNull SkriptAddon source, @NotNull @NotNull String name, @NotNull @NotNull Class<T> returnType) Creates a new builder for a function.- Type Parameters:
T
- The return type.- Parameters:
name
- The name of the function.returnType
- The type of the function.- Returns:
- The builder for a function.
-
source
- Returns:
- The addon this function was registered for.
-