|
1 | 1 | package ch.njol.skript.classes; |
2 | 2 |
|
| 3 | +import com.google.common.base.Preconditions; |
3 | 4 | import org.bukkit.event.Event; |
4 | 5 | import org.jetbrains.annotations.NotNull; |
5 | 6 | import org.jetbrains.annotations.Nullable; |
@@ -104,17 +105,18 @@ public static boolean acceptsChangeTypes(Class<?>[] validTypes, Class<?> @NotNul |
104 | 105 | * Gets the types that can be added/removed via arithmetic for the given type. |
105 | 106 | * This is used to determine accepted change types for add/remove when no changer is present. |
106 | 107 | * @param type The type to get arithmetic change types for. |
107 | | - * @param mode Whether to get addition or subtraction types. |
| 108 | + * @param mode Whether to get addition or subtraction types. Only {@link ChangeMode#ADD} and {@link ChangeMode#REMOVE} are supported. |
108 | 109 | * @param filter A filter to apply to the available operations. Used for custom constraints on the operations, like |
109 | 110 | * ensuring the return type matches the left type. |
110 | 111 | * @return The types that can be added/removed via arithmetic for the given type and mode, after applying the filter. |
111 | 112 | * @param <T> The type to get arithmetic change types for. |
112 | 113 | */ |
113 | 114 | public static <T> Class<?>[] getArithmeticChangeTypes(Class<T> type, ChangeMode mode, Predicate<OperationInfo<T, ? ,?>> filter) { |
114 | | - List<OperationInfo<T, ?, ?>> opInfos = List.of(); |
| 115 | + Preconditions.checkState(mode == ChangeMode.ADD || mode == ChangeMode.REMOVE, "Only ADD and REMOVE modes are supported for arithmetic change types"); |
| 116 | + List<OperationInfo<T, ?, ?>> opInfos; |
115 | 117 | if (mode == ChangeMode.ADD) { |
116 | 118 | opInfos = Arithmetics.getOperations(Operator.ADDITION, type); |
117 | | - } else if (mode == ChangeMode.REMOVE) { |
| 119 | + } else { |
118 | 120 | opInfos = Arithmetics.getOperations(Operator.SUBTRACTION, type); |
119 | 121 | } |
120 | 122 | return opInfos.stream() |
|
0 commit comments