Skip to content

Commit

Permalink
Do not return null for a negative cooldown placeholder
Browse files Browse the repository at this point in the history
Fixes #669
  • Loading branch information
Krakenied committed Aug 28, 2024
1 parent 658a6a2 commit 63c5cd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,14 @@ public String onPlaceholderRequest(Player p, String params) {
break;
case "cooldown":
if (qPlayer.getQuestProgressFile().getQuestProgress(quest).isCompleted()) {
final String time = FormatUtils.time(TimeUnit.SECONDS.convert(qPlayer.getQuestProgressFile().getCooldownFor(quest), TimeUnit.MILLISECONDS));
if (!time.startsWith("-")) result = time;
final long questCooldown = qPlayer.getQuestProgressFile().getCooldownFor(quest);
if (questCooldown > 0) {
final long questCooldownMillis = TimeUnit.SECONDS.convert(questCooldown, TimeUnit.MILLISECONDS);
result = FormatUtils.time(questCooldownMillis);
} else {
// TODO handle it in a more proper way after storage rework
result = Messages.PLACEHOLDERAPI_NO_COOLDOWN.getMessage();
}
} else {
result = "0";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public enum Messages {
PLACEHOLDERAPI_FALSE("messages.placeholderapi-false", "false"),
PLACEHOLDERAPI_NO_TRACKED_QUEST("messages.placeholderapi-no-tracked-quest", "No tracked quest"),
PLACEHOLDERAPI_QUEST_NOT_STARTED("messages.placeholderapi-quest-not-started", "Quest not started"),
PLACEHOLDERAPI_NO_COOLDOWN("messages.placeholderapi-no-cooldown", "No cooldown"),
PLACEHOLDERAPI_NO_TIME_LIMIT("messages.placeholderapi-no-time-limit", "No time limit"),
PLACEHOLDERAPI_DATA_NOT_LOADED("messages.placeholderapi-data-not-loaded", "Data not loaded");

Expand Down

0 comments on commit 63c5cd0

Please sign in to comment.