Skip to content

Commit 699cf5a

Browse files
committed
re-implement indexOf simplify()
1 parent 6facf33 commit 699cf5a

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/main/java/ch/njol/skript/expressions/ExprIndicesOf.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package ch.njol.skript.expressions;
22

3-
import ch.njol.skript.lang.SyntaxStringBuilder;
4-
import ch.njol.skript.lang.Variable;
3+
import ch.njol.skript.lang.*;
4+
import ch.njol.skript.lang.simplification.SimplifiedLiteral;
55
import ch.njol.skript.util.LiteralUtils;
66
import ch.njol.util.Pair;
77
import org.bukkit.event.Event;
@@ -12,8 +12,6 @@
1212
import ch.njol.skript.doc.Examples;
1313
import ch.njol.skript.doc.Name;
1414
import ch.njol.skript.doc.Since;
15-
import ch.njol.skript.lang.Expression;
16-
import ch.njol.skript.lang.ExpressionType;
1715
import ch.njol.skript.lang.SkriptParser.ParseResult;
1816
import ch.njol.skript.lang.util.SimpleExpression;
1917
import ch.njol.util.Kleenean;
@@ -221,6 +219,16 @@ public Class<?> getReturnType() {
221219
return String.class;
222220
}
223221

222+
@Override
223+
public Expression<?> simplify() {
224+
if (this.position && this.string
225+
&& value instanceof Literal<?> && objects instanceof Literal<?>
226+
) {
227+
return SimplifiedLiteral.fromExpression(this);
228+
}
229+
return this;
230+
}
231+
224232
@Override
225233
public String toString(@Nullable Event event, boolean debug) {
226234
SyntaxStringBuilder builder = new SyntaxStringBuilder(event, debug);

0 commit comments

Comments
 (0)