mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-28 05:25:21 +01:00
Added challenge descriptions.
This commit is contained in:
parent
fb05ccd786
commit
89220d67d3
@ -6,24 +6,29 @@
|
||||
### Credits ###
|
||||
# Tastybento: maintainer
|
||||
|
||||
challenges:
|
||||
challenges:
|
||||
completed-times: "Completed [donetimes] out of [maxtimes]"
|
||||
max-reached: "Max reached [donetimes] out of [maxtimes]"
|
||||
challenge:
|
||||
format: "[description]"
|
||||
parameters: "[Level]"
|
||||
description: "Open the challenges menu"
|
||||
complete: "Complete"
|
||||
exp-reward: "Exp reward"
|
||||
first-time-rewards: "First time reward(s)"
|
||||
complete: "&BComplete"
|
||||
exp-reward: "&6Exp reward: [reward]"
|
||||
first-time-rewards: "&6First time reward(s)"
|
||||
gui-title: "BSkyBlock Challenges"
|
||||
incomplete: "Incomplete"
|
||||
itemTakeWarning: "All required items are taken when you complete this challenge!"
|
||||
level: "Level"
|
||||
item-take-warning: "&cAll required items are|&ctaken when you complete|&cthis challenge!"
|
||||
items-closeby: "&cAll required items|&cmust be close to you|&con your island!"
|
||||
level: "&FLevel: [level]"
|
||||
max-reached: "Max reached [donetimes] out of [maxtimes]"
|
||||
money-reward: "Money reward"
|
||||
money-reward: "&6Money reward: $[reward]"
|
||||
name: "Challenge Name"
|
||||
name-has-completed: "[name] has completed the [challenge] challenge!"
|
||||
navigation: "Click to see [level] challenges!"
|
||||
not-repeatable: "This Challenge is not repeatable!"
|
||||
repeat-rewards: "Repeat reward(s)"
|
||||
rewards: "Reward(s)"
|
||||
repeat-rewards: "&6Repeat reward(s)"
|
||||
rewards: "&FReward(s)"
|
||||
to-complete: "Complete [challengesToDo] more [thisLevel] challenges to unlock this level!"
|
||||
you-completed: "You completed the [challenge] challenge!"
|
||||
you-repeated: "You repeated the [challenge] challenge!"
|
||||
|
@ -1,5 +1,8 @@
|
||||
package bskyblock.addon.challenges.panel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@ -11,6 +14,7 @@ import bskyblock.addon.challenges.LevelStatus;
|
||||
import bskyblock.addon.challenges.commands.ChallengesCommand;
|
||||
import bskyblock.addon.challenges.database.object.Challenges;
|
||||
import bskyblock.addon.challenges.database.object.Challenges.ChallengeType;
|
||||
import us.tastybento.bskyblock.Constants;
|
||||
import us.tastybento.bskyblock.api.panels.Panel;
|
||||
import us.tastybento.bskyblock.api.panels.PanelItem;
|
||||
import us.tastybento.bskyblock.api.panels.builders.PanelBuilder;
|
||||
@ -86,8 +90,7 @@ public class ChallengesPanels {
|
||||
PanelItem item = new PanelItemBuilder()
|
||||
.icon(challenge.getIcon())
|
||||
.name(challenge.getFriendlyName().isEmpty() ? challenge.getUniqueId() : challenge.getFriendlyName())
|
||||
.description(challenge.getDescription())
|
||||
// TODO Complete the description
|
||||
.description(challengeDescription(challenge, user))
|
||||
.glow(completed)
|
||||
.clickHandler((player,c) -> {
|
||||
if (!challenge.getChallengeType().equals(ChallengeType.ICON)) {
|
||||
@ -147,4 +150,88 @@ public class ChallengesPanels {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the challenge description for the "item" in the inventory
|
||||
*
|
||||
* @param challenge
|
||||
* @param player
|
||||
* @return List of strings splitting challenge string into 25 chars long
|
||||
*/
|
||||
private List<String> challengeDescription(Challenges challenge, User user) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
String level = challenge.getLevel();
|
||||
if (!level.isEmpty()) {
|
||||
result.addAll(splitTrans(user, "challenges.level", "[level]", level));
|
||||
}
|
||||
// Check if completed or not
|
||||
|
||||
boolean complete = addon.getChallengesManager().isChallengeComplete(user, challenge.getUniqueId());
|
||||
int maxTimes = challenge.getMaxTimes();
|
||||
long doneTimes = addon.getChallengesManager().checkChallengeTimes(user, challenge);
|
||||
if (complete) {
|
||||
result.add(user.getTranslation("challenges.complete"));
|
||||
}
|
||||
if (challenge.isRepeatable()) {
|
||||
if (maxTimes == 0) {
|
||||
|
||||
// Check if the player has maxed out the challenge
|
||||
if (doneTimes < maxTimes) {
|
||||
result.addAll(splitTrans(user, "challenges.completed-times","[donetimes]", String.valueOf(doneTimes),"[maxtimes]", String.valueOf(maxTimes)));
|
||||
} else {
|
||||
result.addAll(splitTrans(user, "challenges.maxed-reached","[donetimes]", String.valueOf(doneTimes),"[maxtimes]", String.valueOf(maxTimes)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!complete || (complete && challenge.isRepeatable())) {
|
||||
result.addAll(challenge.getDescription());
|
||||
if (challenge.getChallengeType().equals(ChallengeType.INVENTORY)) {
|
||||
if (challenge.isTakeItems()) {
|
||||
result.addAll(splitTrans(user, "challenges.item-take-warning"));
|
||||
}
|
||||
} else if (challenge.getChallengeType().equals(ChallengeType.ISLAND)) {
|
||||
result.addAll(splitTrans(user, "challenges.items-closeby"));
|
||||
}
|
||||
}
|
||||
if (complete && (!challenge.getChallengeType().equals(ChallengeType.INVENTORY) || !challenge.isRepeatable())) {
|
||||
result.addAll(splitTrans(user, "challenges.not-repeatable"));
|
||||
return result;
|
||||
}
|
||||
double moneyReward = 0;
|
||||
int expReward = 0;
|
||||
String rewardText = "";
|
||||
if (!complete) {
|
||||
// First time
|
||||
moneyReward = challenge.getMoneyReward();
|
||||
rewardText = challenge.getRewardText();
|
||||
expReward = challenge.getExpReward();
|
||||
if (!rewardText.isEmpty()) {
|
||||
result.addAll(splitTrans(user, "challenges.first-time-rewards"));
|
||||
}
|
||||
} else {
|
||||
// Repeat challenge
|
||||
moneyReward = challenge.getRepeatMoneyReward();
|
||||
rewardText = challenge.getRepeatRewardText();
|
||||
expReward = challenge.getRepeatExpReward();
|
||||
if (!rewardText.isEmpty()) {
|
||||
result.addAll(splitTrans(user, "challenges.repeat-rewards"));
|
||||
}
|
||||
|
||||
}
|
||||
if (!rewardText.isEmpty()) {
|
||||
result.addAll(splitTrans(user,rewardText));
|
||||
}
|
||||
if (expReward > 0) {
|
||||
result.addAll(splitTrans(user,"challenges.exp-reward", "[reward]", String.valueOf(expReward)));
|
||||
}
|
||||
if (addon.getBSkyBlock().getSettings().isUseEconomy() && moneyReward > 0) {
|
||||
result.addAll(splitTrans(user,"challenges.money-reward", "[reward]", String.valueOf(moneyReward)));
|
||||
}
|
||||
// Final placeholder change for [label]
|
||||
result.replaceAll(x -> x.replace("[label]", Constants.ISLANDCOMMAND));
|
||||
return result;
|
||||
}
|
||||
|
||||
private Collection<? extends String> splitTrans(User user, String string, String...strings) {
|
||||
return addon.getChallengesManager().stringSplit(user.getTranslation(string, strings));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user