Fix issue when completing challenge was not displayed in ChallengesGUI. (#60)

This commit is contained in:
BONNe 2019-01-28 21:01:26 +02:00
parent 7384afa262
commit 9918752589
3 changed files with 28 additions and 4 deletions

View File

@ -152,7 +152,7 @@ public class ChallengesPanels2 {
} 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;
});
}

View File

@ -161,8 +161,28 @@ public class TryToComplete
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;
}

View File

@ -325,12 +325,16 @@ public class ChallengesGUI extends CommonGUI
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)).