66import org .bukkit .event .Event ;
77import org .jetbrains .annotations .Contract ;
88import org .jetbrains .annotations .Nullable ;
9+ import org .jetbrains .annotations .Unmodifiable ;
910import org .skriptlang .skript .lang .converter .Converter ;
1011
11- import java .util .Arrays ;
12+ import java .util .Collection ;
1213import java .util .Optional ;
14+ import java .util .SequencedCollection ;
1315import java .util .function .BiPredicate ;
1416import java .util .function .Function ;
1517
@@ -57,21 +59,24 @@ static <E extends Event, V> EventValue<E, V> simple(Class<E> eventClass, Class<V
5759 *
5860 * @return the event type this event value is defined for
5961 */
62+ @ Contract (pure = true )
6063 Class <E > eventClass ();
6164
6265 /**
6366 * The type of the value produced by this event value.
6467 *
6568 * @return the value type
6669 */
70+ @ Contract (pure = true )
6771 Class <V > valueClass ();
6872
6973 /**
7074 * Patterns used to identify this event value from user input.
7175 *
7276 * @return the patterns
7377 */
74- String @ Nullable [] patterns ();
78+ @ Contract (pure = true )
79+ @ Unmodifiable SequencedCollection <String > patterns ();
7580
7681 /**
7782 * Validates that this event value can be used in the provided event context.
@@ -88,6 +93,7 @@ static <E extends Event, V> EventValue<E, V> simple(Class<E> eventClass, Class<V
8893 * @param input the identifier provided by the user
8994 * @return {@code true} if the validation succeeds
9095 */
96+ @ Contract (pure = true )
9197 boolean matchesInput (String input );
9298
9399 /**
@@ -96,13 +102,15 @@ static <E extends Event, V> EventValue<E, V> simple(Class<E> eventClass, Class<V
96102 * @param event the event instance
97103 * @return the value obtained from the event, which may be {@code null}
98104 */
105+ @ Contract (pure = true )
99106 V get (E event );
100107
101108 /**
102109 * The converter used to obtain the value from the event.
103110 *
104111 * @return the converter
105112 */
113+ @ Contract (pure = true )
106114 Converter <E , V > converter ();
107115
108116 /**
@@ -111,6 +119,7 @@ static <E extends Event, V> EventValue<E, V> simple(Class<E> eventClass, Class<V
111119 * @param mode the change mode
112120 * @return {@code true} if a changer is supported
113121 */
122+ @ Contract (pure = true )
114123 boolean hasChanger (ChangeMode mode );
115124
116125 /**
@@ -119,27 +128,31 @@ static <E extends Event, V> EventValue<E, V> simple(Class<E> eventClass, Class<V
119128 * @param mode the change mode
120129 * @return an {@link Optional} containing the changer if available
121130 */
131+ @ Contract (pure = true )
122132 Optional <Changer <E , V >> changer (ChangeMode mode );
123133
124134 /**
125135 * The time state this event value is registered for.
126136 *
127137 * @return the time state
128138 */
139+ @ Contract (pure = true )
129140 Time time ();
130141
131142 /**
132143 * Event types explicitly excluded from using this event value.
133144 *
134- * @return an array of excluded event classes or {@code null} if none
145+ * @return a list of excluded event classes
135146 */
136- Class <? extends E > @ Nullable [] excludedEvents ();
147+ @ Contract (pure = true )
148+ @ Unmodifiable Collection <Class <? extends E >> excludedEvents ();
137149
138150 /**
139151 * An optional error message shown when this value is excluded for a matching event.
140152 *
141153 * @return the exclusion error message or {@code null}
142154 */
155+ @ Contract (pure = true )
143156 @ Nullable String excludedErrorMessage ();
144157
145158 /**
@@ -149,9 +162,8 @@ static <E extends Event, V> EventValue<E, V> simple(Class<E> eventClass, Class<V
149162 * @param eventValue the event value to compare against
150163 * @return {@code true} if they match
151164 */
152- default boolean matches (EventValue <?, ?> eventValue ) {
153- return matches (eventValue .eventClass (), eventValue .valueClass (), eventValue .patterns ());
154- }
165+ @ Contract (pure = true )
166+ boolean matches (EventValue <?, ?> eventValue );
155167
156168 /**
157169 * Checks whether this event value matches the provided event class, value class,
@@ -162,8 +174,9 @@ default boolean matches(EventValue<?, ?> eventValue) {
162174 * @param patterns the patterns to compare against
163175 * @return {@code true} if they match
164176 */
165- default boolean matches (Class <? extends Event > eventClass , Class <?> valueClass , String [] patterns ) {
166- return matches (eventClass , valueClass ) && Arrays .equals (patterns (), patterns );
177+ @ Contract (pure = true )
178+ default boolean matches (Class <? extends Event > eventClass , Class <?> valueClass , SequencedCollection <String > patterns ) {
179+ return matches (eventClass , valueClass ) && patterns ().equals (patterns );
167180 }
168181
169182 /**
@@ -173,6 +186,7 @@ default boolean matches(Class<? extends Event> eventClass, Class<?> valueClass,
173186 * @param valueClass the value class to compare against
174187 * @return {@code true} if they match
175188 */
189+ @ Contract (pure = true )
176190 default boolean matches (Class <? extends Event > eventClass , Class <?> valueClass ) {
177191 return eventClass ().equals (eventClass ) && valueClass ().equals (valueClass );
178192 }
@@ -319,37 +333,6 @@ interface Changer<E extends Event, V> {
319333
320334 }
321335
322- /**
323- * A changer that does not require a value to be passed (e.g. for {@link ChangeMode#DELETE} or {@link ChangeMode#RESET}).
324- *
325- * @param <E> the event type
326- * @param <V> the value type
327- */
328- @ FunctionalInterface
329- interface NoValueChanger <E extends Event , V > extends Changer <E , V > {
330-
331- /**
332- * Applies a change to the given event instance without a value.
333- *
334- * @param event the event instance
335- */
336- void change (E event );
337-
338- /**
339- * {@inheritDoc}
340- * <p>
341- * This implementation ignores the provided value and calls {@link #change(Event)}.
342- *
343- * @param event the event instance
344- * @param value the value (ignored)
345- */
346- @ Override
347- default void change (E event , V value ) {
348- change (event );
349- }
350-
351- }
352-
353336 /**
354337 * A builder for creating {@link EventValue} instances.
355338 *
0 commit comments