Skip to content

Commit

Permalink
Fix cast throwing if existing variable for command storage exists (#5942
Browse files Browse the repository at this point in the history
)

* Fix cast throwing if existing variable for command storage exists

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

Co-authored-by: Ayham Al Ali <20037329+AyhamAl-Ali@users.noreply.github.com>

---------

Co-authored-by: Ayham Al Ali <20037329+AyhamAl-Ali@users.noreply.github.com>
Co-authored-by: Moderocky <admin@moderocky.com>
  • Loading branch information
3 people authored Sep 17, 2023
1 parent 5b59105 commit 66b08b8
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 @@ -474,7 +474,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 66b08b8

Please sign in to comment.