Class Changer.ChangerUtils

java.lang.Object
ch.njol.skript.classes.Changer.ChangerUtils
Enclosing interface:
Changer<T>

public abstract static class Changer.ChangerUtils extends Object
  • Constructor Details

    • ChangerUtils

      public ChangerUtils()
  • Method Details

    • change

      public static <T> void change(@NotNull @NotNull Changer<T> changer, Object[] what, Object @Nullable [] delta, Changer.ChangeMode mode)
    • acceptsChange

      public static boolean acceptsChange(@NotNull @NotNull Expression<?> expression, Changer.ChangeMode mode, Class<?>... types)
      Tests whether an expression accepts changes of a certain type. If multiple types are given it test for whether any of the types is accepted.
      Parameters:
      expression - The expression to test
      mode - The ChangeMode to use in the test
      types - The types to test for
      Returns:
      Whether expression.change(event, type[], mode) can be used or not.
    • acceptsChangeTypes

      public static boolean acceptsChangeTypes(Class<?>[] validTypes, Class<?> @NotNull ... types)
      Tests whether any of the given types is accepted by the given array of valid types.
      Parameters:
      validTypes - The valid types. All array classes should be unwrapped to their component type before calling.
      types - The types to test for
      Returns:
      Whether any of the types is accepted by the valid types.
    • getArithmeticChangeTypes

      public static <T> Class<?>[] getArithmeticChangeTypes(Class<T> type, Changer.ChangeMode mode, Predicate<OperationInfo<T,?,?>> filter)
      Gets the types that can be added/removed via arithmetic for the given type. This is used to determine accepted change types for add/remove when no changer is present.
      Type Parameters:
      T - The type to get arithmetic change types for.
      Parameters:
      type - The type to get arithmetic change types for.
      mode - Whether to get addition or subtraction types. Only Changer.ChangeMode.ADD and Changer.ChangeMode.REMOVE are supported.
      filter - A filter to apply to the available operations. Used for custom constraints on the operations, like ensuring the return type matches the left type.
      Returns:
      The types that can be added/removed via arithmetic for the given type and mode, after applying the filter.