Skip to content

Commit

Permalink
Implement add and remove challenge from challenge level panels in Edi…
Browse files Browse the repository at this point in the history
…tLevelGUI.
  • Loading branch information
BONNe committed Jan 19, 2019
1 parent 6125eb5 commit c42652d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
14 changes: 13 additions & 1 deletion src/main/java/world/bentobox/challenges/ChallengesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public Challenges createChallenge(String reply)

public boolean validateChallengeUniqueID(World world, String reply)
{
return false;
return true;
}


Expand All @@ -568,4 +568,16 @@ public ChallengeLevels createLevel(String reply)
{
return new ChallengeLevels();
}


public void unlinkChallenge(ChallengeLevels challengeLevel, Challenges value)
{

}


public void linkChallenge(ChallengeLevels challengeLevel, Challenges value)
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.ItemParser;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.ChallengesManager;
import world.bentobox.challenges.database.object.ChallengeLevels;
import world.bentobox.challenges.database.object.Challenges;
import world.bentobox.challenges.panel.CommonGUI;
import world.bentobox.challenges.panel.util.ItemSwitchGUI;
import world.bentobox.challenges.panel.util.NumberGUI;
import world.bentobox.challenges.panel.util.SelectChallengeGUI;
import world.bentobox.challenges.panel.util.StringListGUI;


Expand Down Expand Up @@ -523,8 +525,20 @@ private PanelItem createButton(Button button)
description = Collections.emptyList();
icon = new ItemStack(Material.WATER_BUCKET);
clickHandler = (panel, user, clickType, slot) -> {
// TODO: Create Challenge List GUI
this.build();
ChallengesManager manager = this.addon.getChallengesManager();

// Get all challenge that is not in current challenge.
List<Challenges> challengeList = manager.getChallengesList();
challengeList.removeAll(manager.getChallenges(this.challengeLevel));

new SelectChallengeGUI(this.user, challengeList, (status, value) -> {
if (status)
{
manager.linkChallenge(this.challengeLevel, value);
}

this.build();
});

return true;
};
Expand All @@ -537,8 +551,16 @@ private PanelItem createButton(Button button)
description = Collections.emptyList();
icon = new ItemStack(Material.LAVA_BUCKET);
clickHandler = (panel, user, clickType, slot) -> {
// TODO: Create Levels List GUI
this.build();
ChallengesManager manager = this.addon.getChallengesManager();

new SelectChallengeGUI(this.user, manager.getChallenges(this.challengeLevel), (status, value) -> {
if (status)
{
manager.unlinkChallenge(this.challengeLevel, value);
}

this.build();
});

return true;
};
Expand Down

0 comments on commit c42652d

Please sign in to comment.