@@ -91,29 +91,17 @@ public static String[] getDefaultPatterns(String property, String fromType) {
9191 * @param <T> The return type.
9292 * @param <E> The Expression type.
9393 * @return The registered {@link SyntaxInfo}.
94+ * @deprecated Use {@link #infoBuilder(Class, Class, String, String, boolean)} to build a {@link SyntaxInfo}
95+ * and then register it using {@code registry} ({@link SyntaxRegistry#register(SyntaxRegistry.Key, SyntaxInfo)}).
9496 */
9597 @ ApiStatus .Experimental
98+ @ Deprecated (since = "INSERT VERSION" , forRemoval = true )
9699 public static <E extends Expression <T >, T > SyntaxInfo .Expression <E , T > register (SyntaxRegistry registry , Class <E > expressionClass , Class <T > returnType , String property , String fromType ) {
97- SyntaxInfo .Expression <E , T > info = SyntaxInfo .Expression .builder (expressionClass , returnType )
98- .priority (DEFAULT_PRIORITY )
99- .addPatterns (getPatterns (property , fromType ))
100- .build ();
100+ SyntaxInfo .Expression <E , T > info = infoBuilder (expressionClass , returnType , property , fromType , false ).build ();
101101 registry .register (SyntaxRegistry .EXPRESSION , info );
102102 return info ;
103103 }
104104
105- /**
106- * Registers an expression as {@link ExpressionType#PROPERTY} with the two default property patterns "property of %types%" and "%types%'[s] property"
107- *
108- * @param expressionClass the PropertyExpression class being registered.
109- * @param type the main expression type the property is based off of.
110- * @param property the name of the property.
111- * @param fromType should be plural to support multiple objects but doesn't have to be.
112- */
113- public static <T > void register (Class <? extends Expression <T >> expressionClass , Class <T > type , String property , String fromType ) {
114- Skript .registerExpression (expressionClass , type , ExpressionType .PROPERTY , getPatterns (property , fromType ));
115- }
116-
117105 /**
118106 * Registers an expression with the two default property patterns "property [of %types%]" and "%types%'[s] property"
119107 * This method also makes the expression type optional to force a default expression on the property expression.
@@ -126,17 +114,51 @@ public static <T> void register(Class<? extends Expression<T>> expressionClass,
126114 * @param <T> The return type.
127115 * @param <E> The Expression type.
128116 * @return The registered {@link SyntaxInfo}.
117+ * @deprecated Use {@link #infoBuilder(Class, Class, String, String, boolean)} to build a {@link SyntaxInfo}
118+ * and then register it using {@code registry} ({@link SyntaxRegistry#register(SyntaxRegistry.Key, SyntaxInfo)}).
129119 */
130120 @ ApiStatus .Experimental
121+ @ Deprecated (since = "INSERT VERSION" , forRemoval = true )
131122 public static <E extends Expression <T >, T > SyntaxInfo .Expression <E , T > registerDefault (SyntaxRegistry registry , Class <E > expressionClass , Class <T > returnType , String property , String fromType ) {
132- SyntaxInfo .Expression <E , T > info = SyntaxInfo .Expression .builder (expressionClass , returnType )
133- .priority (DEFAULT_PRIORITY )
134- .addPatterns (getDefaultPatterns (property , fromType ))
135- .build ();
123+ SyntaxInfo .Expression <E , T > info = infoBuilder (expressionClass , returnType , property , fromType , true ).build ();
136124 registry .register (SyntaxRegistry .EXPRESSION , info );
137125 return info ;
138126 }
139127
128+ /**
129+ * Registers an expression with the two default property patterns "property [of %types%]" and "%types%'[s] property"
130+ * This method also makes the expression type optional to force a default expression on the property expression.
131+ *
132+ * @param expressionClass The expression class to be represented by the info.
133+ * @param returnType The class representing the expression's return type.
134+ * @param property The property name. For example, {@code length} in {@code length of %strings%}.
135+ * @param type The type(s) on which the property is present. Should typically be plural.
136+ * For example, {@code strings} in {@code length of %strings%}.
137+ * @param isDefault Whether {@code type} can be optional in the patterns (e.g., filled by a {@link ch.njol.skript.lang.DefaultExpression}).
138+ * @param <T> The return type.
139+ * @param <E> The Expression type.
140+ * @return The registered {@link SyntaxInfo}.
141+ */
142+ @ ApiStatus .Experimental
143+ public static <E extends Expression <T >, T > SyntaxInfo .Expression .Builder <? extends SyntaxInfo .Expression .Builder <?, E , T >, E , T > infoBuilder (
144+ Class <E > expressionClass , Class <T > returnType , String property , String type , boolean isDefault ) {
145+ return SyntaxInfo .Expression .builder (expressionClass , returnType )
146+ .priority (DEFAULT_PRIORITY )
147+ .addPatterns (patternsOf (property , type , isDefault ));
148+ }
149+
150+ /**
151+ * Registers an expression as {@link ExpressionType#PROPERTY} with the two default property patterns "property of %types%" and "%types%'[s] property"
152+ *
153+ * @param expressionClass the PropertyExpression class being registered.
154+ * @param type the main expression type the property is based off of.
155+ * @param property the name of the property.
156+ * @param fromType should be plural to support multiple objects but doesn't have to be.
157+ */
158+ public static <T > void register (Class <? extends Expression <T >> expressionClass , Class <T > type , String property , String fromType ) {
159+ Skript .registerExpression (expressionClass , type , ExpressionType .PROPERTY , getPatterns (property , fromType ));
160+ }
161+
140162 /**
141163 * Registers an expression as {@link ExpressionType#PROPERTY} with the two default property patterns "property [of %types%]" and "%types%'[s] property"
142164 * This method also makes the expression type optional to force a default expression on the property expression.
0 commit comments