Skip to content

Skip - prefix variable names when saving. (Ephemeral variables) #7495

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

Merged
merged 6 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 4 additions & 9 deletions src/main/java/ch/njol/skript/lang/Variable.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,10 @@ public static boolean isValidVariableName(String name, boolean allowListVariable
/*
A lot of people already use '-' so we want to skip this warning iff they're using it here
*/
if (first == '-') {
for (VariablesStorage store : Variables.getStores()) {
@Nullable Pattern pattern = store.getNamePattern();
if (pattern != null && pattern.pattern().equals("(?!-).*"))
continue check_reserved_tokens;
}
}
Skript.warning("The character '" + token + "' is reserved at the start of variable names, " +
"and may be restricted in future versions");
if (first == '-')
continue;
Skript.warning("The character '" + token + "' is reserved at the start of variable names, "
+ "and may be restricted in future versions");
}
}
name = name.startsWith(LOCAL_VARIABLE_TOKEN) ? name.substring(LOCAL_VARIABLE_TOKEN.length()).trim() : name.trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public void run() {
* @see #variableNamePattern
*/
boolean accept(@Nullable String var) {
if (var == null)
if (var == null || var.startsWith("-"))
return false;

return variableNamePattern == null || variableNamePattern.matcher(var).matches();
Expand Down
Loading