1919package ch .njol .skript .lang .function ;
2020
2121import ch .njol .skript .Skript ;
22+ import ch .njol .skript .SkriptConfig ;
2223import ch .njol .skript .classes .ClassInfo ;
2324import ch .njol .skript .lang .Expression ;
2425import ch .njol .skript .lang .ParseContext ;
@@ -45,8 +46,9 @@ public final class Parameter<T> {
4546
4647 /**
4748 * Name of this parameter. Will be used as name for the local variable
48- * that contains value of it inside function. This is always in lower case;
49- * variable names are case-insensitive.
49+ * that contains value of it inside function.
50+ * If {@link SkriptConfig#caseInsensitiveVariables} is {@code true},
51+ * then the valid variable names may not necessarily match this string in casing.
5052 */
5153 final String name ;
5254
@@ -69,7 +71,7 @@ public final class Parameter<T> {
6971
7072 @ SuppressWarnings ("null" )
7173 public Parameter (String name , ClassInfo <T > type , boolean single , @ Nullable Expression <? extends T > def ) {
72- this .name = name != null ? name . toLowerCase ( Locale . ENGLISH ) : null ;
74+ this .name = name ;
7375 this .type = type ;
7476 this .def = def ;
7577 this .single = single ;
@@ -119,6 +121,7 @@ public static <T> Parameter<T> newInstance(String name, ClassInfo<T> type, boole
119121 @ Nullable
120122 public static List <Parameter <?>> parse (String args ) {
121123 List <Parameter <?>> params = new ArrayList <>();
124+ boolean caseInsensitive = SkriptConfig .caseInsensitiveVariables .value ();
122125 int j = 0 ;
123126 for (int i = 0 ; i <= args .length (); i = SkriptParser .next (args , i , ParseContext .DEFAULT )) {
124127 if (i == -1 ) {
@@ -138,8 +141,12 @@ public static List<Parameter<?>> parse(String args) {
138141 return null ;
139142 }
140143 String paramName = "" + n .group (1 );
144+ // for comparing without affecting the original name, in case the config option for case insensitivity changes.
145+ String lowerParamName = paramName .toLowerCase (Locale .ENGLISH );
141146 for (Parameter <?> p : params ) {
142- if (p .name .toLowerCase (Locale .ENGLISH ).equals (paramName .toLowerCase (Locale .ENGLISH ))) {
147+ // only force lowercase if we don't care about case in variables
148+ String otherName = caseInsensitive ? p .name .toLowerCase (Locale .ENGLISH ) : p .name ;
149+ if (otherName .equals (caseInsensitive ? lowerParamName : paramName )) {
143150 Skript .error ("Each argument's name must be unique, but the name '" + paramName + "' occurs at least twice." );
144151 return null ;
145152 }
0 commit comments