Skip to content

Commit

Permalink
Add timeout for repeatable challenges.
Browse files Browse the repository at this point in the history
Relates #71
  • Loading branch information
BONNe committed Sep 24, 2021
1 parent 644c7d6 commit 1b01995
Showing 1 changed file with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ public enum ChallengeType
@Expose
private boolean repeatable;

/**
* Timeout for repeatable challenge before it can be completed again.
*/
@Expose
private long timeout;

/**
* Description of the repeat rewards. If blank, it will be autogenerated
*/
Expand Down Expand Up @@ -442,6 +448,17 @@ public List<String> getRepeatRewardCommands()
}


/**
* Gets timeout.
*
* @return the timeout
*/
public long getTimeout()
{
return timeout;
}


// ---------------------------------------------------------------------
// Section: Setters
// ---------------------------------------------------------------------
Expand Down Expand Up @@ -698,6 +715,17 @@ public void setRequirements(Requirements requirements)
}


/**
* Sets timeout.
*
* @param timeout the timeout
*/
public void setTimeout(long timeout)
{
this.timeout = timeout;
}


// ---------------------------------------------------------------------
// Section: Other methods
// ---------------------------------------------------------------------
Expand All @@ -715,7 +743,7 @@ public void setRequirements(Requirements requirements)
public boolean matchGameMode(String gameMode)
{
return gameMode != null &&
this.uniqueId.regionMatches(true, 0, gameMode, 0, gameMode.length());
this.uniqueId.regionMatches(true, 0, gameMode, 0, gameMode.length());
}


Expand Down Expand Up @@ -746,13 +774,11 @@ public boolean equals(Object obj)
return true;
}

if (!(obj instanceof Challenge))
if (!(obj instanceof Challenge other))
{
return false;
}

Challenge other = (Challenge) obj;

if (uniqueId == null)
{
return other.uniqueId == null;
Expand Down Expand Up @@ -831,6 +857,7 @@ public Challenge clone()
collect(Collectors.toCollection(() -> new ArrayList<>(this.repeatItemReward.size()))));
clone.setRepeatMoneyReward(this.repeatMoneyReward);
clone.setRepeatRewardCommands(new ArrayList<>(this.repeatRewardCommands));
clone.setTimeout(this.timeout);
}
catch (Exception e)
{
Expand Down

0 comments on commit 1b01995

Please sign in to comment.