Skip to content

Commit

Permalink
(Cherry Pick) Fix cast throwing if existing variable for command stor…
Browse files Browse the repository at this point in the history
…age exists (SkriptLang#5942) (SkriptLang#6026)

Fix cast throwing if existing variable for command storage exists (SkriptLang#5942)

* Fix cast throwing if existing variable for command storage exists

* Update src/main/java/ch/njol/skript/command/ScriptCommand.java



---------

Co-authored-by: LimeGlass <[email protected]>
Co-authored-by: Ayham Al Ali <[email protected]>
  • Loading branch information
3 people authored Sep 20, 2023
1 parent 438851a commit 06df281
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/ch/njol/skript/command/ScriptCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,13 @@ public Date getLastUsage(UUID uuid, Event event) {
} else {
String name = getStorageVariableName(event);
assert name != null;
return (Date) Variables.getVariable(name, null, false);
Object variable = Variables.getVariable(name, null, false);
if (!(variable instanceof Date)) {
Skript.warning("Variable {" + name + "} was not a date! You may be using this variable elsewhere. " +
"This warning is letting you know that this variable is now overridden for the command storage.");
return null;
}
return (Date) variable;
}
}

Expand Down

0 comments on commit 06df281

Please sign in to comment.