Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config Option 'variable changes until save' #7532

Open
wants to merge 4 commits into
base: dev/feature
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/ch/njol/skript/SkriptConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import ch.njol.skript.util.Version;
import ch.njol.skript.util.chat.ChatMessages;
import ch.njol.skript.util.chat.LinkParseMode;
import ch.njol.skript.variables.FlatFileStorage;
import ch.njol.skript.variables.Variables;
import co.aikar.timings.Timings;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -371,6 +372,9 @@ private static void userDisableHooks(Class<? extends Hook<?>> hookClass, boolean
public static final Option<Integer> runtimeErrorTimeoutDuration = new Option<>("runtime errors.error timeout length", 10);
public static final Option<Integer> runtimeWarningTimeoutDuration = new Option<>("runtime errors.warning timeout length", 10);

public static final Option<Integer> variableChangesUntilSave = new Option<>("variable changes until save", 1000)
.setter(FlatFileStorage::setRequiredChangesForResave);

/**
* This should only be used in special cases
*/
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/ch/njol/skript/variables/FlatFileStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class FlatFileStorage extends VariablesStorage {
* The amount of {@link #changes} needed
* for a new {@link #saveVariables(boolean) save}.
*/
private static final int REQUIRED_CHANGES_FOR_RESAVE = 1000;
private static int REQUIRED_CHANGES_FOR_RESAVE = 1000;

/**
* The amount of variable changes written since the last full save.
Expand Down Expand Up @@ -606,4 +606,17 @@ private static void writeCSV(PrintWriter printWriter, String... values) {
printWriter.println();
}

/**
* Change the required amount of variable changes until variables are saved.
* Cannot be zero or less.
* @param value
*/
public static void setRequiredChangesForResave(int value) {
if (value <= 0) {
Skript.warning("Variable changes until save cannot be zero or less. Using default of 1000.");
value = 1000;
}
REQUIRED_CHANGES_FOR_RESAVE = value;
}

}
8 changes: 8 additions & 0 deletions src/main/resources/config.sk
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ long parse time warning threshold: 0 seconds
# stating that the statement has taken a long time to parse.
# A value of 0 seconds means that this warning should be disabled.

variable changes until save: 1000
# This setting controls the total number of times that global variables need to be changed
# until saving variables to 'variables.csv'.
# 'set {a} to 1' is one change, 'set {b} to 2' now makes it two.
# You cannot provide a value of zero or less.
# WARNING: This setting should be used at your own discretion.
# This setting can lag your server depending on how often variables get saved and
# the number of variables needing to be saved.
TheAbsolutionism marked this conversation as resolved.
Show resolved Hide resolved

# ==== Runtime Errors ====

Expand Down