(to)
* @author Peter Güttinger
* @see Converters#registerConverter(Class, Class, Function)
diff --git a/src/main/java/io/github/syst3ms/skriptparser/types/conversions/Converters.java b/src/main/java/io/github/syst3ms/skriptparser/types/conversions/Converters.java
index 8784b2ce9..35b8dbdb9 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/types/conversions/Converters.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/types/conversions/Converters.java
@@ -23,11 +23,11 @@ public abstract class Converters {
*/
public static final int ALL_CHAINING = 0;
/**
- * A flag declaring a converter may only be the getFirst part of a {@link ChainedConverter}
+ * A flag declaring a converter may only be the first part of a {@link ChainedConverter}
*/
public static final int NO_LEFT_CHAINING = 1;
/**
- * A flag declaring a converter may only be the getSecond part of a {@link ChainedConverter}
+ * A flag declaring a converter may only be the second part of a {@link ChainedConverter}
*/
public static final int NO_RIGHT_CHAINING = 2;
/**
diff --git a/src/main/java/io/github/syst3ms/skriptparser/util/DoubleOptional.java b/src/main/java/io/github/syst3ms/skriptparser/util/DoubleOptional.java
index 23cee8437..e1c8f6000 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/util/DoubleOptional.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/util/DoubleOptional.java
@@ -17,8 +17,8 @@
*
* Note that the two values aren't really independent : either both are set, or both are empty.
*
- * @param the type of the getFirst value
- * @param the type of the getSecond value
+ * @param the type of the first value
+ * @param the type of the second value
*/
public class DoubleOptional {
/**
@@ -27,12 +27,12 @@ public class DoubleOptional {
private static final DoubleOptional, ?> EMPTY = new DoubleOptional<>();
/**
- * If non-null, the getFirst value is present ; if null, it is absent.
+ * If non-null, the first value is present ; if null, it is absent.
*/
@Nullable
private final T1 first;
/**
- * If non-null, the getSecond value is present ; if null, it is absent.
+ * If non-null, the second value is present ; if null, it is absent.
*/
@Nullable
private final T2 second;
@@ -48,8 +48,8 @@ private DoubleOptional() {
/**
* Constructs a non-empty instance.
*
- * @param first the getFirst value
- * @param second the getSecond value
+ * @param first the first value
+ * @param second the second value
* @throws NullPointerException if either parameters are {@literal null}.
*/
private DoubleOptional(T1 first, T2 second) {
@@ -60,8 +60,8 @@ private DoubleOptional(T1 first, T2 second) {
/**
* Returns an empty {@code DoubleOptional} instance.
*
- * @param the type of the getFirst non-existent value
- * @param the type of the getSecond non-existent value
+ * @param the type of the first non-existent value
+ * @param the type of the second non-existent value
* @return an empty {@code DoubleOptional}
*/
@SuppressWarnings("unchecked")
@@ -73,12 +73,12 @@ public static DoubleOptional empty() {
* Returns an {@code Optional} describing the given non-{@code null}
* value.
*
- * @param first the getFirst value to describe, which must be non-{@code null}
- * @param second the getSecond value to describe, which must be non-{@code null}
- * @param the type of the getFirst value
- * @param the type fo the getSecond value
+ * @param first the first value to describe, which must be non-{@code null}
+ * @param second the second value to describe, which must be non-{@code null}
+ * @param the type of the first value
+ * @param the type fo the second value
* @return a {@code DoubleOptional} with the value present
- * @throws NullPointerException if either getFirst or getSecond are {@code null}
+ * @throws NullPointerException if either first or second are {@code null}
*/
public static DoubleOptional of(T1 first, T2 second) {
return new DoubleOptional<>(first, second);
@@ -88,10 +88,10 @@ public static DoubleOptional of(T1 first, T2 second) {
* Returns a {@code DoubleOptional} describing the given values, if
* both non-{@code null}, otherwise returns an empty {@code DoubleOptional}.
*
- * @param first the getFirst possibly {@code null} value to describe
+ * @param first the first possibly {@code null} value to describe
* @param second the secpond possibly {@code null} value to describe
- * @param the type of the getFirst value
- * @param the type of the getSecond value
+ * @param the type of the first value
+ * @param the type of the second value
* @return a {@code DoubleOptional} with both values present if the specified values
* are both non-{@code null}, otherwise an empty {@code DoubleOptional}
*/
@@ -103,10 +103,10 @@ public static DoubleOptional ofNullable(@Nullable T1 first, @Nu
* Returns a {@code DoubleOptional} describing the values represented by two {@link Optional}s if both
* are present, otherwise returns an empty {@code DoubleOptional}.
*
- * @param first a possibly empty {@link Optional} describing the getFirst value
- * @param second a possibly empty {@link Optional} describing the getSecond value
- * @param the type of the getFirst value
- * @param the type of the getSecond value
+ * @param first a possibly empty {@link Optional} describing the first value
+ * @param second a possibly empty {@link Optional} describing the second value
+ * @param the type of the first value
+ * @param the type of the second value
* @return a {@code DoubleOptional} describing the two values described by the two {@link Optional}s,
* if both are present, otherwise an empty {@code DoubleOptional}
*/
@@ -116,27 +116,27 @@ public static DoubleOptional ofOptional(Optional first, Opt
}
/**
- * If the getFirst value is present, returns the value, otherwise throws a {@link NoSuchElementException}.
+ * If the first value is present, returns the value, otherwise throws a {@link NoSuchElementException}.
*
- * @return the non-null getFirst value of this {@code DoubleOptional}
- * @throws NoSuchElementException if no getFirst value is present
+ * @return the non-null first value of this {@code DoubleOptional}
+ * @throws NoSuchElementException if no first value is present
*/
- public T1 getFirst() {
+ public T1 first() {
if (first == null) {
- throw new NoSuchElementException("No getFirst value present");
+ throw new NoSuchElementException("No first value present");
}
return first;
}
/**
- * If the getSecond value is present, returns the value, otherwise throws a {@link NoSuchElementException}.
+ * If the second value is present, returns the value, otherwise throws a {@link NoSuchElementException}.
*
- * @return the non-null getSecond value of this {@code DoubleOptional}
- * @throws NoSuchElementException if no getSecond value is present
+ * @return the non-null second value of this {@code DoubleOptional}
+ * @throws NoSuchElementException if no second value is present
*/
- public T2 getSecond() {
+ public T2 second() {
if (second == null) {
- throw new NoSuchElementException("No getSecond value present");
+ throw new NoSuchElementException("No second value present");
}
return second;
}
@@ -171,7 +171,7 @@ public void ifPresent(BiConsumer super T1, ? super T2> action) {
}
/**
- * If both values are present, does the getFirst action using both values, otherwise does the getSecond action.
+ * If both values are present, does the first action using both values, otherwise does the second action.
*
* @param action the action to be performed if both values are present
* @param emptyAction the action to be performed if either values are absent
@@ -207,10 +207,10 @@ public DoubleOptional filter(BiPredicate super T1, ? super T2> predica
*
* If either mapping function returns {@code null}, the result will be an empty {@code DoubleOptional}.
*
- * @param firstMapper the mapping function to apply to the getFirst value, if present
- * @param secondMapper the mapping function to apply to the getSecond value, if present
- * @param the new type of the getFirst value
- * @param the new type of the getSecond value
+ * @param firstMapper the mapping function to apply to the first value, if present
+ * @param secondMapper the mapping function to apply to the second value, if present
+ * @param the new type of the first value
+ * @param the new type of the second value
* @return a {@code DoubleOptional} describing the result of applying mapping functions
* to each of the values if present, and an empty {@code DoubleOptional} otherwise.
*/
@@ -251,8 +251,8 @@ public Optional mapToOptional(BiFunction super T1, ? super T2, ? extend
* {@code DoubleOptional}.
*
* @param mapper the mapping function taking in both values (if present) and returning a {@code DoubleOptional}
- * @param the type of the getFirst value of the new {@code DoubleOptional}
- * @param the type of the getSecond value of the new {@code DoubleOptional}
+ * @param the type of the first value of the new {@code DoubleOptional}
+ * @param the type of the second value of the new {@code DoubleOptional}
* @return the result of applying the mapping function to both values if present, and an empty {@code DoubleOptional}
* otherwise
* @throws NullPointerException if the mapping function returns {@code null}
@@ -309,10 +309,10 @@ public DoubleOptional or(Supplier extends DoubleOptional extends T1,
}
/**
- * If the getFirst value is present, returns it, otherwise returns {@code other}.
+ * If the first value is present, returns it, otherwise returns {@code other}.
*
- * @param other the value to be returned if the getFirst value is not present (may be {@code null})
- * @return the getFirst value if present, otherwise {@code other}
+ * @param other the value to be returned if the first value is not present (may be {@code null})
+ * @return the first value if present, otherwise {@code other}
*/
@Contract("!null -> !null")
@Nullable
@@ -321,10 +321,10 @@ public T1 firstOrElse(@Nullable T1 other) {
}
/**
- * If the getSecond value is present, returns it, otherwise returns {@code other}.
+ * If the second value is present, returns it, otherwise returns {@code other}.
*
- * @param other the value to be returned if the getSecond value is not present (may be {@code null})
- * @return the getSecond value if present, otherwise {@code other}
+ * @param other the value to be returned if the second value is not present (may be {@code null})
+ * @return the second value if present, otherwise {@code other}
*/
@Contract("!null -> !null")
@Nullable
@@ -333,13 +333,13 @@ public T2 secondOrElse(@Nullable T2 other) {
}
/**
- * If the getFirst value is present, returns it, otherwise throws an exception produced by the given
+ * If the first value is present, returns it, otherwise throws an exception produced by the given
* exception-supplying function.
*
- * @param exceptionSupplier the function producing the exception to be thrown if the getFirst value is not present
+ * @param exceptionSupplier the function producing the exception to be thrown if the first value is not present
* @param the type of exception that may be thrown
- * @return the getFirst value if present
- * @throws X if the getFirst value is not present
+ * @return the first value if present
+ * @throws X if the first value is not present
*/
public T1 firstOrElseThrow(Supplier extends X> exceptionSupplier) throws X {
if (first != null) {
@@ -350,13 +350,13 @@ public T1 firstOrElseThrow(Supplier extends X> exception
}
/**
- * If the getSecond value is present, returns it, otherwise throws an exception produced by the given
+ * If the second value is present, returns it, otherwise throws an exception produced by the given
* exception-supplying function.
*
- * @param exceptionSupplier the function producing the exception to be thrown if the getSecond value is not present
+ * @param exceptionSupplier the function producing the exception to be thrown if the second value is not present
* @param the type of exception that may be thrown
- * @return the getSecond value if present
- * @throws X if the getSecond value is not present
+ * @return the second value if present
+ * @throws X if the second value is not present
*/
public T2 secondOrElseThrow(Supplier extends X> exceptionSupplier) throws X {
if (second != null) {
diff --git a/src/main/java/io/github/syst3ms/skriptparser/util/DurationUtils.java b/src/main/java/io/github/syst3ms/skriptparser/util/DurationUtils.java
index 8e683728b..4f679543c 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/util/DurationUtils.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/util/DurationUtils.java
@@ -10,7 +10,7 @@ public class DurationUtils {
* clean alternative for this.
*/
private static final String[] unitPatterns = {"years?", "weeks?", "days?", "hours?", "minutes?", "seconds?", "ticks?", "milli(second)?s?"};
- private static final String[] unitNames = {"year", "week", "day", "hour", "minute", "getSecond", "tick", "millisecond"};
+ private static final String[] unitNames = {"year", "week", "day", "hour", "minute", "second", "tick", "millisecond"};
/**
* The amount of milliseconds it takes for a tick to pass.
* A 'tick' is a predetermined time-unit of 50 milliseconds.
diff --git a/src/main/java/io/github/syst3ms/skriptparser/util/FileUtils.java b/src/main/java/io/github/syst3ms/skriptparser/util/FileUtils.java
index 407a99de2..621791acf 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/util/FileUtils.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/util/FileUtils.java
@@ -28,7 +28,7 @@ public class FileUtils {
* before a line break to indicate to the parser that it should be considered as a single line. For example :
*
* set {large_list::*} to "one long string", \
- * "a getSecond long string", \
+ * "a second long string", \
* "yet another long string" \
* "an even longer string which would make reading very awkward otherwise", \
* "nearing the end of the list" and \
diff --git a/src/main/java/io/github/syst3ms/skriptparser/util/Pair.java b/src/main/java/io/github/syst3ms/skriptparser/util/Pair.java
index 25cb6433c..0b7c2fb26 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/util/Pair.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/util/Pair.java
@@ -3,15 +3,15 @@
/**
* A simple pair of two values.
*
- * @param type of the getFirst value
- * @param type of the getSecond value
+ * @param type of the first value
+ * @param type of the second value
*/
public record Pair(T getFirst, U getSecond) {
/**
- * Retrieves the getFirst element
+ * Retrieves the first element
*
- * @return the getFirst element
+ * @return the first element
*/
@Override
public T getFirst() {
@@ -19,9 +19,9 @@ public T getFirst() {
}
/**
- * Retrieves the getSecond element
+ * Retrieves the second element
*
- * @return the getSecond element
+ * @return the second element
*/
@Override
public U getSecond() {
diff --git a/src/main/java/io/github/syst3ms/skriptparser/util/RecentElementList.java b/src/main/java/io/github/syst3ms/skriptparser/util/RecentElementList.java
index 2eeb40661..b78896968 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/util/RecentElementList.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/util/RecentElementList.java
@@ -16,7 +16,7 @@
* them against a string that's being parsed.
*
* To illustrate the behaviour of this class, imagine you use some syntax A 8 times, then use syntax B once. The very
- * next time the parser does the "recent syntaxes" check, it will check syntax A getFirst, because it was used more than syntax B.
+ * next time the parser does the "recent syntaxes" check, it will check syntax A first, because it was used more than syntax B.
*
* @param the type of {@link SyntaxInfo}
*/
diff --git a/src/main/java/io/github/syst3ms/skriptparser/util/SkriptDate.java b/src/main/java/io/github/syst3ms/skriptparser/util/SkriptDate.java
index 0611312e6..809e81da7 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/util/SkriptDate.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/util/SkriptDate.java
@@ -12,8 +12,7 @@
import java.util.TimeZone;
public class SkriptDate implements Comparable {
- // TODO make a config for this
- public final static String DATE_FORMAT = "EEEE dd MMMM yyyy HH:mm:ss.SSS"; // Add 'zzzXXX' to display time zone as well
+ public static String DATE_FORMAT = "EEEE dd MMMM yyyy HH:mm:ss.SSS"; // Add 'zzzXXX' to display time zone as well
public final static Locale DATE_LOCALE = Locale.US;
private static final TimeZone defaultTimeZone = TimeZone.getDefault();
@@ -93,6 +92,10 @@ public static TimeZone getDefaultTimeZone() {
return defaultTimeZone;
}
+ public static void setDefaultDateFormat(String format) {
+ DATE_FORMAT = format;
+ }
+
/**
* @return the amount of milliseconds that have passed
* since midnight, January 1st, 1970 in the UTC time zone
diff --git a/src/main/java/io/github/syst3ms/skriptparser/util/StringUtils.java b/src/main/java/io/github/syst3ms/skriptparser/util/StringUtils.java
index 4b04991e9..f5cea9291 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/util/StringUtils.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/util/StringUtils.java
@@ -163,12 +163,12 @@ public static Optional getBracketContent(String s, int start, char closi
}
/**
- * Find the getFirst occurrence of a string in another one, ignoring case
+ * Find the first occurrence of a string in another one, ignoring case
*
* @param haystack the string to look in
* @param needle the string to look for
* @param start where to look from
- * @return the index of the getFirst occurrence
+ * @return the index of the first occurrence
*/
public static int indexOfIgnoreCase(String haystack, String needle, int start) {
if (needle.isEmpty() || haystack.isEmpty()) {
@@ -311,7 +311,7 @@ else if (plural)
}
/**
- * Capitalizes the getFirst word or all words in a string.
+ * Capitalizes the first word or all words in a string.
* A word is separated by a space character.
*
* @param str the string to change
@@ -401,7 +401,7 @@ else if (Character.isLowerCase(c))
}
/**
- * Mirrors the string. This means the last character will be put getFirst and vice versa.
+ * Mirrors the string. This means the last character will be put first and vice versa.
*
* @param str the string to change
* @return the mirrored string
diff --git a/src/main/java/io/github/syst3ms/skriptparser/util/Time.java b/src/main/java/io/github/syst3ms/skriptparser/util/Time.java
index 40bb1d017..834b6d4d5 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/util/Time.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/util/Time.java
@@ -15,8 +15,7 @@
* @author Mwexim
*/
public class Time implements Comparable {
- // TODO make a config for this
- public final static String TIME_FORMAT = "HH:mm:ss.SSS";
+ public static String TIME_FORMAT = "HH:mm:ss.SSS";
public final static Locale TIME_LOCALE = Locale.US;
/**
@@ -85,6 +84,10 @@ public static Time of(SkriptDate date) {
return new Time(lcd.toLocalTime());
}
+ public static void setDefaultTimeFormat(String format) {
+ TIME_FORMAT = format;
+ }
+
/**
* Parses a given string as a time, using one of the three patterns.
*
diff --git a/src/main/java/io/github/syst3ms/skriptparser/util/math/NumberMath.java b/src/main/java/io/github/syst3ms/skriptparser/util/math/NumberMath.java
index 5c8bd73d4..648f5162f 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/util/math/NumberMath.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/util/math/NumberMath.java
@@ -383,7 +383,7 @@ private static List sieveOfEratosthenes(int start, int end) {
boolean[] isComposite = new boolean[size];
List computedPrimes = new ArrayList<>();
- // We getFirst disqualify multiples of primes that have been generated before
+ // We first disqualify multiples of primes that have been generated before
if (cachedPrimes != null) {
for (int gen : cachedPrimes) {
if (gen * gen > end)
diff --git a/src/main/java/io/github/syst3ms/skriptparser/util/math/PowerIterator.java b/src/main/java/io/github/syst3ms/skriptparser/util/math/PowerIterator.java
index b640e9ce8..9628fa279 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/util/math/PowerIterator.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/util/math/PowerIterator.java
@@ -8,7 +8,7 @@
* This API allows to efficiently calculate the various powers of x in a taylor series by storing intermediate results.
* For example xn can be calculated using one multiplication by storing the previously calculated xn-1 and x.
*
- * {@link #getCurrentPower()} will be called getFirst to retrieve the initial value.
+ * {@link #getCurrentPower()} will be called first to retrieve the initial value.
*
* For later iterations {@link #calculateNextPower()} will be called before {@link #getCurrentPower()}.
*
diff --git a/src/main/java/io/github/syst3ms/skriptparser/util/math/SeriesCalculator.java b/src/main/java/io/github/syst3ms/skriptparser/util/math/SeriesCalculator.java
index 6f17446c6..1676fbf96 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/util/math/SeriesCalculator.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/util/math/SeriesCalculator.java
@@ -106,7 +106,7 @@ protected BigRational getFactor(int index) {
/**
* Returns the factor of the highest term already calculated.
- *
When called for the getFirst time will return the factor of the getFirst term (index 0).
+ * When called for the first time will return the factor of the first term (index 0).
* After this call the method {@link #calculateNextFactor()} will be called to prepare for the next term.
*
* @return the factor of the highest term
diff --git a/src/main/java/io/github/syst3ms/skriptparser/variables/VariableStorage.java b/src/main/java/io/github/syst3ms/skriptparser/variables/VariableStorage.java
index 3d219c7d0..bb9b16958 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/variables/VariableStorage.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/variables/VariableStorage.java
@@ -252,7 +252,7 @@ protected void loadVariable(String name, @NotNull String type, @NotNull JsonElem
/**
* Called after all storages have been loaded, and variables
* have been redistributed if settings have changed.
- * This should commit the getFirst transaction.
+ * This should commit the first transaction.
*/
protected abstract void allLoaded();
diff --git a/src/main/java/io/github/syst3ms/skriptparser/variables/Variables.java b/src/main/java/io/github/syst3ms/skriptparser/variables/Variables.java
index 461846650..5a6d59634 100644
--- a/src/main/java/io/github/syst3ms/skriptparser/variables/Variables.java
+++ b/src/main/java/io/github/syst3ms/skriptparser/variables/Variables.java
@@ -8,6 +8,7 @@
import io.github.syst3ms.skriptparser.log.ErrorType;
import io.github.syst3ms.skriptparser.log.SkriptLogger;
import io.github.syst3ms.skriptparser.parsing.ParserState;
+import io.github.syst3ms.skriptparser.types.TypeManager.StringMode;
import io.github.syst3ms.skriptparser.util.MultiMap;
import org.jetbrains.annotations.Nullable;
@@ -153,7 +154,7 @@ public static Optional extends Expression> parseVariable(String input,
var vs = VariableString.newInstance(
input.startsWith(LOCAL_VARIABLE_TOKEN) ? input.substring(LOCAL_VARIABLE_TOKEN.length()).strip() : input,
parserState,
- logger
+ logger, StringMode.VARIABLE
);
var finalS = input;
return vs.map(v -> new Variable<>(v, finalS.startsWith(LOCAL_VARIABLE_TOKEN), finalS.endsWith(LIST_SEPARATOR + "*"), types));