From 31b2fed8bc082b440dfd9e1e21b55a13cd75568c Mon Sep 17 00:00:00 2001 From: BONNe Date: Tue, 12 Feb 2019 16:24:41 +0200 Subject: [PATCH] Implement remove one time challenge option in ChallengesGUI. --- .../challenges/panel/user/ChallengesGUI.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java b/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java index 9cca572..b6e70f6 100644 --- a/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java @@ -4,7 +4,6 @@ package world.bentobox.challenges.panel.user; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; import java.util.List; import world.bentobox.bentobox.api.panels.PanelItem; @@ -145,6 +144,13 @@ public class ChallengesGUI extends CommonGUI private void addFreeChallenges(PanelBuilder panelBuilder, int firstItemIndex) { List freeChallenges = this.challengesManager.getFreeChallenges(this.world); + + if (this.addon.getChallengesSettings().isRemoveCompleteOneTimeChallenges()) + { + freeChallenges.removeIf(challenge -> !challenge.isRepeatable() && + this.challengesManager.isChallengeComplete(this.user, challenge)); + } + final int freeChallengesCount = freeChallenges.size(); if (freeChallengesCount > 18) @@ -208,6 +214,13 @@ public class ChallengesGUI extends CommonGUI if (this.lastSelectedLevel != null) { List challenges = this.challengesManager.getLevelChallenges(this.lastSelectedLevel.getLevel()); + + if (this.addon.getChallengesSettings().isRemoveCompleteOneTimeChallenges()) + { + challenges.removeIf(challenge -> !challenge.isRepeatable() && + this.challengesManager.isChallengeComplete(this.user, challenge)); + } + final int challengesCount = challenges.size(); if (challengesCount > 18)