Add timeout for repeatable challenges.

Relates #71
This commit is contained in:
BONNe 2021-09-24 13:08:33 +03:00
parent 644c7d6ba5
commit 1b01995546
1 changed files with 31 additions and 4 deletions

View File

@ -190,6 +190,12 @@ public class Challenge implements DataObject
@Expose @Expose
private boolean repeatable; 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 * Description of the repeat rewards. If blank, it will be autogenerated
*/ */
@ -442,6 +448,17 @@ public class Challenge implements DataObject
} }
/**
* Gets timeout.
*
* @return the timeout
*/
public long getTimeout()
{
return timeout;
}
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Section: Setters // Section: Setters
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@ -698,6 +715,17 @@ public class Challenge implements DataObject
} }
/**
* Sets timeout.
*
* @param timeout the timeout
*/
public void setTimeout(long timeout)
{
this.timeout = timeout;
}
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Section: Other methods // Section: Other methods
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@ -715,7 +743,7 @@ public class Challenge implements DataObject
public boolean matchGameMode(String gameMode) public boolean matchGameMode(String gameMode)
{ {
return gameMode != null && return gameMode != null &&
this.uniqueId.regionMatches(true, 0, gameMode, 0, gameMode.length()); this.uniqueId.regionMatches(true, 0, gameMode, 0, gameMode.length());
} }
@ -746,13 +774,11 @@ public class Challenge implements DataObject
return true; return true;
} }
if (!(obj instanceof Challenge)) if (!(obj instanceof Challenge other))
{ {
return false; return false;
} }
Challenge other = (Challenge) obj;
if (uniqueId == null) if (uniqueId == null)
{ {
return other.uniqueId == null; return other.uniqueId == null;
@ -831,6 +857,7 @@ public class Challenge implements DataObject
collect(Collectors.toCollection(() -> new ArrayList<>(this.repeatItemReward.size())))); collect(Collectors.toCollection(() -> new ArrayList<>(this.repeatItemReward.size()))));
clone.setRepeatMoneyReward(this.repeatMoneyReward); clone.setRepeatMoneyReward(this.repeatMoneyReward);
clone.setRepeatRewardCommands(new ArrayList<>(this.repeatRewardCommands)); clone.setRepeatRewardCommands(new ArrayList<>(this.repeatRewardCommands));
clone.setTimeout(this.timeout);
} }
catch (Exception e) catch (Exception e)
{ {