Package ch.njol.skript.classes
Interface Changer<T>
- All Known Implementing Classes:
BlockClassInfo.BlockChanger,EntityClassInfo.EntityChanger,InventoryClassInfo.InventoryChanger,PlayerClassInfo.PlayerChanger,SlotClassInfo.SlotChanger
public interface Changer<T>
An interface to declare changeable values. All Expressions implement something similar like this by default, but refuse any change if
Expression.acceptChange(ChangeMode)
isn't overridden.
Some useful Changers can be found in DefaultChangers
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumstatic class -
Method Summary
Modifier and TypeMethodDescriptionClass<?> @Nullable []Tests whether this changer supports the given mode, and if yes what type(s) it expects the elements ofdeltato be.voidchange(T[] what, Object @Nullable [] delta, Changer.ChangeMode mode)
-
Method Details
-
acceptChange
Tests whether this changer supports the given mode, and if yes what type(s) it expects the elements ofdeltato be.Unlike
Expression.acceptChange(ChangeMode)this method must not print errors.- Parameters:
mode- TheChanger.ChangeModeto test.- Returns:
- An array of types that
change(Object[], Object[], ChangeMode)accepts as itsdeltaparameter (which can be arrays to denote that multiple of that type are accepted), or null if the given mode is not supported. ForChanger.ChangeMode.DELETEandChanger.ChangeMode.RESETthis can return any non-null array to mark them as supported.
-
change
- Parameters:
what- The objects to changedelta- An array with one or more instances of one or more of the the classes returned byacceptChange(ChangeMode)for the given change mode (null forChanger.ChangeMode.DELETEandChanger.ChangeMode.RESET). This can be a Object[], thus casting is not allowed.mode- TheChanger.ChangeModeto test.- Throws:
UnsupportedOperationException- (optional) if this method was called on an unsupported ChangeMode.
-