Skip to content

Commit 7fa2967

Browse files
committed
Add config toggle
1 parent 54ff5c3 commit 7fa2967

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/main/java/ch/njol/skript/SkriptConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ private static void userDisableHooks(Class<? extends Hook<?>> hookClass, boolean
375375
public static final Option<Integer> variableChangesUntilSave = new Option<>("variable changes until save", 1000)
376376
.setter(FlatFileStorage::setRequiredChangesForResave);
377377

378+
public static final Option<Boolean> simplifySyntaxesOnParse = new Option<>("simplify syntax on parse", true)
379+
.optional(true);
380+
378381
/**
379382
* This should only be used in special cases
380383
*/

src/main/java/ch/njol/skript/lang/SkriptParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public class SkriptParser {
7171
public final static int ALL_FLAGS = PARSE_EXPRESSIONS | PARSE_LITERALS;
7272
private final int flags;
7373

74+
public final boolean doSimplification = SkriptConfig.simplifySyntaxesOnParse.value();
75+
7476
public final ParseContext context;
7577

7678
public SkriptParser(String expr) {
@@ -253,7 +255,7 @@ public boolean hasTag(String tag) {
253255
boolean success = element.init(parseResult.exprs, patternIndex, getParser().getHasDelayBefore(), parseResult);
254256
if (success) {
255257
log.printLog();
256-
if (element instanceof Simplifiable<?> simplifiable)
258+
if (doSimplification && element instanceof Simplifiable<?> simplifiable)
257259
//noinspection unchecked
258260
return (T) simplifiable.simplify();
259261
return element;

src/main/resources/config.sk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ variable changes until save: 1000
243243
# This setting can lag your server depending on how often variables get saved and
244244
# the number of variables needing to be saved.
245245

246+
simplify syntax on parse: true
247+
# This setting controls whether Skript should try to simplify the syntax of a statement
248+
# when parsing it. For example, 'set {a} to 1 + 10 * 5^2' will be simplified to 'set {a} to 251'.
249+
# This can be useful for performance, but could cause issues with some older addons. If you are encountering strange
250+
# issues, try disabling this setting and see if it helps. Otherwise, you can leave it enabled for better performance.
251+
246252
# ==== Runtime Errors ====
247253

248254
runtime errors:

0 commit comments

Comments
 (0)