Skip to content

Commit

Permalink
Fix issue when each save added unnecessary "|" at the end of rewards …
Browse files Browse the repository at this point in the history
…and unlock message. (#123)

Algorithm that I used to join output list into single string, always added "|" at the end. Last "|" should be removed.
  • Loading branch information
BONNe committed Sep 2, 2019
1 parent 707625a commit 29a7714
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,16 @@ else if (this.challenge.getChallengeType().equals(Challenge.ChallengeType.OTHER)
new StringListGUI(this.user, this.challenge.getRewardText(), lineLength, (status, value) -> {
if (status)
{
this.challenge.setRewardText(value.stream().map(s -> s + "|").collect(Collectors.joining()));
String singleLineMessage = value.stream().
map(s -> s + "|").
collect(Collectors.joining());

if (singleLineMessage.endsWith("|"))
{
singleLineMessage = singleLineMessage.substring(0, singleLineMessage.length() - 1);
}

this.challenge.setRewardText(singleLineMessage);
}

this.build();
Expand Down Expand Up @@ -1055,7 +1064,16 @@ else if (this.challenge.getChallengeType().equals(Challenge.ChallengeType.OTHER)
new StringListGUI(this.user, this.challenge.getRepeatRewardText(), lineLength, (status, value) -> {
if (status)
{
this.challenge.setRepeatRewardText(value.stream().map(s -> s + "|").collect(Collectors.joining()));
String singleLineMessage = value.stream().
map(s -> s + "|").
collect(Collectors.joining());

if (singleLineMessage.endsWith("|"))
{
singleLineMessage = singleLineMessage.substring(0, singleLineMessage.length() - 1);
}

this.challenge.setRepeatRewardText(singleLineMessage);
}

this.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,16 @@ private PanelItem createButton(Button button)
new StringListGUI(this.user, this.challengeLevel.getUnlockMessage(), lineLength, (status, value) -> {
if (status)
{
this.challengeLevel.setUnlockMessage(value.stream().map(s -> s + "|").collect(Collectors.joining()));
String singleLineMessage = value.stream().
map(s -> s + "|").
collect(Collectors.joining());

if (singleLineMessage.endsWith("|"))
{
singleLineMessage = singleLineMessage.substring(0, singleLineMessage.length() - 1);
}

this.challengeLevel.setUnlockMessage(singleLineMessage);
}

this.build();
Expand Down Expand Up @@ -486,7 +495,16 @@ private PanelItem createButton(Button button)
new StringListGUI(this.user, this.challengeLevel.getRewardText(), lineLength, (status, value) -> {
if (status)
{
this.challengeLevel.setRewardText(value.stream().map(s -> s + "|").collect(Collectors.joining()));
String singleLineMessage = value.stream().
map(s -> s + "|").
collect(Collectors.joining());

if (singleLineMessage.endsWith("|"))
{
singleLineMessage = singleLineMessage.substring(0, singleLineMessage.length() - 1);
}

this.challengeLevel.setRewardText(singleLineMessage);
}

this.build();
Expand Down

0 comments on commit 29a7714

Please sign in to comment.