Skip to content

Commit

Permalink
Fix issue when completing challenge was not displayed in ChallengesGU…
Browse files Browse the repository at this point in the history
…I. (#60)
  • Loading branch information
BONNe committed Jan 28, 2019
1 parent 7384afa commit 9918752
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private void createItem(PanelBuilder panelBuilder, Challenge challenge) {
} else {
// Player click
itemBuilder.clickHandler((panel, player, c, s) -> {
new TryToComplete(addon, player, challenge, world, label, permPrefix);
new TryToComplete(addon, player, challenge, world, label, permPrefix).build();
return true;
});
}
Expand Down
22 changes: 21 additions & 1 deletion src/main/java/world/bentobox/challenges/panel/TryToComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,28 @@ public TryToComplete(ChallengesAddon addon,
this.manager = addon.getChallengesManager();
this.challenge = challenge;
this.topLabel = topLabel;
}


this.build();
/**
* This static method allows complete challenge and get result about completion.
* @param addon - Challenges Addon.
* @param user - User who performs challenge.
* @param challenge - Challenge that should be completed.
* @param world - World where completion may occur.
* @param topLabel - Label of the top command.
* @param permissionPrefix - Permission prefix for GameMode addon.
* @return true, if challenge is completed, otherwise false.
*/
public static boolean complete(ChallengesAddon addon,
User user,
Challenge challenge,
World world,
String topLabel,
String permissionPrefix)
{
return new TryToComplete(addon, user, challenge, world, topLabel, permissionPrefix).
build().meetsRequirements;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,16 @@ private PanelItem getChallengeButton(Challenge challenge)
name(challenge.getFriendlyName().isEmpty() ? challenge.getUniqueId() : challenge.getFriendlyName()).
description(GuiUtils.stringSplit(this.createChallengeDescription(challenge))).
clickHandler((panel, user1, clickType, slot) -> {
new TryToComplete(this.addon,
if (TryToComplete.complete(this.addon,
this.user,
challenge,
this.world,
this.topLabel,
this.permissionPrefix);
this.permissionPrefix))
{
this.build();
}

return true;
}).
glow(this.challengesManager.isChallengeComplete(this.user, challenge)).
Expand Down

0 comments on commit 9918752

Please sign in to comment.