Interface DefaultFunction<T>

Type Parameters:
T - The return type.
All Superinterfaces:
Documentable, Function<T>

public sealed interface DefaultFunction<T> extends Function<T>, Documentable
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:
  • 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

      @NotNull @NotNull SkriptAddon source()
      Returns:
      The addon this function was registered for.