Rewards lore (#248)

* Ignore failing test because method now doesn't do anything.

* Add spaces after color codes to make gitLocalize more accurate.

* Added a rewards title and made the lore prettier.
This commit is contained in:
tastybento 2020-07-12 04:43:15 -07:00 committed by GitHub
parent dfeef0ab8c
commit 7060799bcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1113 additions and 1106 deletions

View File

@ -36,6 +36,7 @@ import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.util.Util;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.ChallengesManager;
import world.bentobox.challenges.database.object.Challenge;
@ -231,19 +232,19 @@ public abstract class CommonGUI
this.pageIndex = 0;
this.returnButton = new PanelItemBuilder().
name(this.user.getTranslation("challenges.gui.buttons.return")).
icon(Material.OAK_DOOR).
clickHandler((panel, user1, clickType, i) -> {
name(this.user.getTranslation("challenges.gui.buttons.return")).
icon(Material.OAK_DOOR).
clickHandler((panel, user1, clickType, i) -> {
if (this.parentGUI == null)
{
this.user.closeInventory();
if (this.parentGUI == null)
{
this.user.closeInventory();
return true;
}
this.parentGUI.build();
return true;
}
this.parentGUI.build();
return true;
}).build();
}).build();
}
@ -263,7 +264,6 @@ public abstract class CommonGUI
* @param button Button that must be returned.
* @return PanelItem with requested functionality.
*/
@SuppressWarnings("deprecation")
protected PanelItem getButton(CommonButtons button)
{
ItemStack icon;
@ -344,213 +344,215 @@ public abstract class CommonGUI
ChallengesManager manager = this.addon.getChallengesManager();
final boolean isCompletedOnce =
manager.isChallengeComplete(user.getUniqueId(), world, challenge);
manager.isChallengeComplete(user.getUniqueId(), world, challenge);
final long doneTimes = challenge.isRepeatable() ?
manager.getChallengeTimes(this.user, this.world, challenge) : isCompletedOnce ? 0 : 1;
manager.getChallengeTimes(this.user, this.world, challenge) : isCompletedOnce ? 0 : 1;
boolean isCompletedAll = isCompletedOnce && challenge.isRepeatable() &&
challenge.getMaxTimes() > 0 &&
doneTimes >= challenge.getMaxTimes();
boolean isCompletedAll = isCompletedOnce && challenge.isRepeatable() &&
challenge.getMaxTimes() > 0 &&
doneTimes >= challenge.getMaxTimes();
this.addon.getChallengesSettings().getChallengeLoreMessage().forEach(messagePart -> {
switch (messagePart)
{
case LEVEL:
{
ChallengeLevel level = manager.getLevel(challenge);
if (level == null)
{
result.add(this.user.getTranslation("challenges.errors.missing-level",
"[level]", challenge.getLevel()));
}
else
{
result.add(this.user
.getTranslation("challenges.gui.challenge-description.level",
"[level]", level.getFriendlyName()));
}
break;
}
case STATUS:
{
if (isCompletedOnce)
{
result.add(this.user
.getTranslation("challenges.gui.challenge-description.completed"));
}
break;
}
case COUNT:
{
if (challenge.isRepeatable())
{
if (challenge.getMaxTimes() > 0)
{
if (isCompletedAll)
this.addon.getChallengesSettings().getChallengeLoreMessage().forEach(messagePart -> {
switch (messagePart)
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.maxed-reached",
"[donetimes]",
String.valueOf(doneTimes),
"[maxtimes]",
String.valueOf(challenge.getMaxTimes())));
}
else
case LEVEL:
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.completed-times-of",
"[donetimes]",
String.valueOf(doneTimes),
"[maxtimes]",
String.valueOf(challenge.getMaxTimes())));
}
}
else
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.completed-times",
"[donetimes]",
String.valueOf(doneTimes)));
}
}
break;
}
case DESCRIPTION:
{
result.addAll(challenge.getDescription());
break;
}
case WARNINGS:
{
if (!isCompletedAll)
{
if (challenge.getChallengeType().equals(Challenge.ChallengeType.INVENTORY))
{
if (challenge.<InventoryRequirements>getRequirements().isTakeItems())
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.warning-items-take"));
}
}
else if (challenge.getChallengeType().equals(Challenge.ChallengeType.ISLAND))
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.objects-close-by"));
ChallengeLevel level = manager.getLevel(challenge);
IslandRequirements requirements = challenge.getRequirements();
if (requirements.isRemoveEntities() && !requirements.getRequiredEntities().isEmpty())
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.warning-entities-kill"));
}
if (requirements.isRemoveBlocks() && !requirements.getRequiredBlocks().isEmpty())
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.warning-blocks-remove"));
}
}
}
break;
}
case ENVIRONMENT:
{
// Display only if there are limited environments
if (!isCompletedAll &&
!challenge.getEnvironment().isEmpty() &&
challenge.getEnvironment().size() != 3)
{
result.add(this.user.getTranslation("challenges.gui.challenge-description.environment"));
if (challenge.getEnvironment().contains(World.Environment.NORMAL))
{
result.add(this.user.getTranslation("challenges.gui.descriptions.normal"));
}
if (challenge.getEnvironment().contains(World.Environment.NETHER))
{
result.add(this.user.getTranslation("challenges.gui.descriptions.nether"));
}
if (challenge.getEnvironment().contains(World.Environment.THE_END))
{
result.add(this.user.getTranslation("challenges.gui.descriptions.the-end"));
}
}
break;
}
case REQUIREMENTS:
{
if (!isCompletedAll)
{
switch (challenge.getChallengeType())
{
case INVENTORY:
result.addAll(this.getInventoryRequirements(challenge.getRequirements()));
if (level == null)
{
result.add(this.user.getTranslation("challenges.errors.missing-level",
"[level]", challenge.getLevel()));
}
else
{
result.add(this.user
.getTranslation("challenges.gui.challenge-description.level",
"[level]", level.getFriendlyName()));
}
break;
case ISLAND:
result.addAll(this.getIslandRequirements(challenge.getRequirements()));
}
case STATUS:
{
if (isCompletedOnce)
{
result.add(this.user
.getTranslation("challenges.gui.challenge-description.completed"));
}
break;
case OTHER:
result.addAll(this.getOtherRequirements(challenge.getRequirements()));
}
case COUNT:
{
if (challenge.isRepeatable())
{
if (challenge.getMaxTimes() > 0)
{
if (isCompletedAll)
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.maxed-reached",
"[donetimes]",
String.valueOf(doneTimes),
"[maxtimes]",
String.valueOf(challenge.getMaxTimes())));
}
else
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.completed-times-of",
"[donetimes]",
String.valueOf(doneTimes),
"[maxtimes]",
String.valueOf(challenge.getMaxTimes())));
}
}
else
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.completed-times",
"[donetimes]",
String.valueOf(doneTimes)));
}
}
break;
}
}
}
case DESCRIPTION:
{
result.addAll(challenge.getDescription());
break;
}
case WARNINGS:
{
if (!isCompletedAll)
{
if (challenge.getChallengeType().equals(Challenge.ChallengeType.INVENTORY))
{
if (challenge.<InventoryRequirements>getRequirements().isTakeItems())
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.warning-items-take"));
}
}
else if (challenge.getChallengeType().equals(Challenge.ChallengeType.ISLAND))
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.objects-close-by"));
break;
}
case REWARD_TEXT:
{
if (isCompletedAll)
{
result.add(this.user.getTranslation("challenges.gui.challenge-description.not-repeatable"));
}
else
{
if (isCompletedOnce)
{
result.add(challenge.getRepeatRewardText());
}
else
{
result.add(challenge.getRewardText());
}
}
break;
}
case REWARD_OTHER:
{
if (!isCompletedAll)
{
result.addAll(this.getChallengeRewardOthers(challenge, isCompletedOnce));
}
break;
}
case REWARD_ITEMS:
{
if (!isCompletedAll)
{
result.addAll(this.getChallengeRewardItems(challenge, isCompletedOnce));
}
break;
}
case REWARD_COMMANDS:
{
if (!isCompletedAll)
{
result.addAll(this.getChallengeRewardCommands(challenge, isCompletedOnce, user));
}
break;
}
}
});
IslandRequirements requirements = challenge.getRequirements();
result.replaceAll(x -> x.replace("[label]", this.topLabel));
if (requirements.isRemoveEntities() && !requirements.getRequiredEntities().isEmpty())
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.warning-entities-kill"));
}
return result;
if (requirements.isRemoveBlocks() && !requirements.getRequiredBlocks().isEmpty())
{
result.add(this.user.getTranslation(
"challenges.gui.challenge-description.warning-blocks-remove"));
}
}
}
break;
}
case ENVIRONMENT:
{
// Display only if there are limited environments
if (!isCompletedAll &&
!challenge.getEnvironment().isEmpty() &&
challenge.getEnvironment().size() != 3)
{
result.add(this.user.getTranslation("challenges.gui.challenge-description.environment"));
if (challenge.getEnvironment().contains(World.Environment.NORMAL))
{
result.add(this.user.getTranslation("challenges.gui.descriptions.normal"));
}
if (challenge.getEnvironment().contains(World.Environment.NETHER))
{
result.add(this.user.getTranslation("challenges.gui.descriptions.nether"));
}
if (challenge.getEnvironment().contains(World.Environment.THE_END))
{
result.add(this.user.getTranslation("challenges.gui.descriptions.the-end"));
}
}
break;
}
case REQUIREMENTS:
{
if (!isCompletedAll)
{
switch (challenge.getChallengeType())
{
case INVENTORY:
result.addAll(this.getInventoryRequirements(challenge.getRequirements()));
break;
case ISLAND:
result.addAll(this.getIslandRequirements(challenge.getRequirements()));
break;
case OTHER:
result.addAll(this.getOtherRequirements(challenge.getRequirements()));
break;
}
}
break;
}
case REWARD_TEXT:
{
if (isCompletedAll)
{
result.add(this.user.getTranslation("challenges.gui.challenge-description.not-repeatable"));
}
else
{
// Show a title to the rewards
result.add(this.user.getTranslation("challenges.gui.challenge-description.rewards-title"));
if (isCompletedOnce)
{
result.add(challenge.getRepeatRewardText());
}
else
{
result.add(challenge.getRewardText());
}
}
break;
}
case REWARD_OTHER:
{
if (!isCompletedAll)
{
result.addAll(this.getChallengeRewardOthers(challenge, isCompletedOnce));
}
break;
}
case REWARD_ITEMS:
{
if (!isCompletedAll)
{
result.addAll(this.getChallengeRewardItems(challenge, isCompletedOnce));
}
break;
}
case REWARD_COMMANDS:
{
if (!isCompletedAll)
{
result.addAll(this.getChallengeRewardCommands(challenge, isCompletedOnce, user));
}
break;
}
}
});
result.replaceAll(x -> x.replace("[label]", this.topLabel));
return result;
}
@ -661,7 +663,7 @@ public abstract class CommonGUI
for (String command : rewardCommands)
{
result.add(this.user.getTranslation("challenges.gui.descriptions.command",
"[command]", command.replace("[player]", user.getName()).replace("[SELF]", "")));
"[command]", command.replace("[player]", user.getName()).replace("[SELF]", "")));
}
}
@ -718,7 +720,7 @@ public abstract class CommonGUI
result.add(this.user.getTranslation("challenges.gui.challenge-description.required-items"));
Utils.groupEqualItems(requirements.getRequiredItems()).forEach(itemStack ->
result.addAll(this.generateItemStackDescription(itemStack)));
result.addAll(this.generateItemStackDescription(itemStack)));
}
return result;
@ -744,7 +746,7 @@ public abstract class CommonGUI
for (Map.Entry<Material, Integer> entry : challenge.getRequiredBlocks().entrySet())
{
result.add(this.user.getTranslation("challenges.gui.descriptions.block",
"[block]", entry.getKey().name(),
"[block]", Util.prettifyText(entry.getKey().name()),
"[count]", Integer.toString(entry.getValue())));
}
}
@ -757,7 +759,7 @@ public abstract class CommonGUI
for (Map.Entry<EntityType, Integer> entry : challenge.getRequiredEntities().entrySet())
{
result.add(this.user.getTranslation("challenges.gui.descriptions.entity",
"[entity]", entry.getKey().name(),
"[entity]", Util.prettifyText(entry.getKey().name()),
"[count]", Integer.toString(entry.getValue())));
}
}
@ -787,105 +789,105 @@ public abstract class CommonGUI
// Check if unlock message should appear.
boolean hasCompletedOne = status.isComplete() || status.isUnlocked() &&
level.getChallenges().stream().anyMatch(challenge ->
level.getChallenges().stream().anyMatch(challenge ->
this.addon.getChallengesManager().isChallengeComplete(user.getUniqueId(), world, challenge));
this.addon.getChallengesSettings().getLevelLoreMessage().forEach(messagePart -> {
switch (messagePart)
{
case LEVEL_STATUS:
case LEVEL_STATUS:
{
if (status.isComplete())
{
if (status.isComplete())
{
result.add(this.user.getTranslation("challenges.gui.level-description.completed"));
}
break;
result.add(this.user.getTranslation("challenges.gui.level-description.completed"));
}
case CHALLENGE_COUNT:
break;
}
case CHALLENGE_COUNT:
{
if (!status.isComplete() && status.isUnlocked())
{
if (!status.isComplete() && status.isUnlocked())
{
int doneChallengeCount = (int) level.getChallenges().stream().
int doneChallengeCount = (int) level.getChallenges().stream().
filter(challenge -> this.addon.getChallengesManager().isChallengeComplete(user.getUniqueId(), world, challenge)).
count();
result.add(this.user.getTranslation("challenges.gui.level-description.completed-challenges-of",
result.add(this.user.getTranslation("challenges.gui.level-description.completed-challenges-of",
"[number]", Integer.toString(doneChallengeCount),
"[max]", Integer.toString(level.getChallenges().size())));
}
break;
}
case UNLOCK_MESSAGE:
{
if (!hasCompletedOne)
{
result.add(level.getUnlockMessage());
}
break;
}
case WAIVER_AMOUNT:
break;
}
case UNLOCK_MESSAGE:
{
if (!hasCompletedOne)
{
if (status.isUnlocked() && !status.isComplete())
{
result.add(this.user.getTranslation("challenges.gui.level-description.waver-amount",
result.add(level.getUnlockMessage());
}
break;
}
case WAIVER_AMOUNT:
{
if (status.isUnlocked() && !status.isComplete())
{
result.add(this.user.getTranslation("challenges.gui.level-description.waver-amount",
"[value]", Integer.toString(level.getWaiverAmount())));
}
break;
}
case LEVEL_REWARD_TEXT:
{
if (status.isUnlocked() && !status.isComplete())
{
result.add(level.getRewardText());
}
break;
}
case LEVEL_REWARD_OTHER:
{
if (status.isUnlocked() && !status.isComplete())
{
if (level.getRewardExperience() > 0)
{
result.add(this.user.getTranslation("challenges.gui.level-description.experience-reward",
"[value]", Integer.toString(level.getRewardExperience())));
}
break;
}
case LEVEL_REWARD_TEXT:
{
if (status.isUnlocked() && !status.isComplete())
if (this.addon.isEconomyProvided() && level.getRewardMoney() > 0)
{
result.add(level.getRewardText());
}
break;
}
case LEVEL_REWARD_OTHER:
{
if (status.isUnlocked() && !status.isComplete())
{
if (level.getRewardExperience() > 0)
{
result.add(this.user.getTranslation("challenges.gui.level-description.experience-reward",
"[value]", Integer.toString(level.getRewardExperience())));
}
if (this.addon.isEconomyProvided() && level.getRewardMoney() > 0)
{
result.add(this.user.getTranslation("challenges.gui.level-description.money-reward",
result.add(this.user.getTranslation("challenges.gui.level-description.money-reward",
"[value]", Integer.toString(level.getRewardMoney())));
}
}
break;
}
case LEVEL_REWARD_ITEMS:
break;
}
case LEVEL_REWARD_ITEMS:
{
if (status.isUnlocked() && !status.isComplete() && !level.getRewardItems().isEmpty())
{
if (status.isUnlocked() && !status.isComplete() && !level.getRewardItems().isEmpty())
{
result.add(this.user.getTranslation("challenges.gui.level-description.reward-items"));
result.add(this.user.getTranslation("challenges.gui.level-description.reward-items"));
Utils.groupEqualItems(level.getRewardItems()).forEach(itemStack ->
result.addAll(this.generateItemStackDescription(itemStack)));
}
break;
Utils.groupEqualItems(level.getRewardItems()).forEach(itemStack ->
result.addAll(this.generateItemStackDescription(itemStack)));
}
case LEVEL_REWARD_COMMANDS:
break;
}
case LEVEL_REWARD_COMMANDS:
{
if (status.isUnlocked() && !status.isComplete() && !level.getRewardCommands().isEmpty())
{
if (status.isUnlocked() && !status.isComplete() && !level.getRewardCommands().isEmpty())
{
result.add(this.user.getTranslation("challenges.gui.level-description.reward-commands"));
result.add(this.user.getTranslation("challenges.gui.level-description.reward-commands"));
for (String command : level.getRewardCommands())
{
result.add(this.user.getTranslation("challenges.gui.descriptions.command",
for (String command : level.getRewardCommands())
{
result.add(this.user.getTranslation("challenges.gui.descriptions.command",
"[command]", command.replace("[player]", user.getName()).replace("[SELF]", "")));
}
}
break;
}
break;
}
}
});
@ -905,12 +907,13 @@ public abstract class CommonGUI
* @param itemStack Object which lore must be generated
* @return List with generated description
*/
@SuppressWarnings("deprecation")
protected List<String> generateItemStackDescription(ItemStack itemStack)
{
List<String> result = new ArrayList<>();
result.add(this.user.getTranslation("challenges.gui.item-description.item",
"[item]", itemStack.getType().name(),
"[item]", Util.prettifyText(itemStack.getType().name()),
"[count]", Integer.toString(itemStack.getAmount())));
if (itemStack.hasItemMeta())
@ -959,22 +962,22 @@ public abstract class CommonGUI
if (data.isExtended() && data.isUpgraded())
{
result.add(this.user.getTranslation("challenges.gui.item-description.potion-type-extended-upgraded",
"[name]", data.getType().name()));
"[name]", Util.prettifyText(data.getType().name())));
}
else if (data.isUpgraded())
{
result.add(this.user.getTranslation("challenges.gui.item-description.potion-type-upgraded",
"[name]", data.getType().name()));
"[name]", Util.prettifyText(data.getType().name())));
}
else if (data.isExtended())
{
result.add(this.user.getTranslation("challenges.gui.item-description.potion-type-extended",
"[name]", data.getType().name()));
"[name]", Util.prettifyText(data.getType().name())));
}
else
{
result.add(this.user.getTranslation("challenges.gui.item-description.potion-type",
"[name]", data.getType().name()));
"[name]", Util.prettifyText(data.getType().name())));
}
if (((PotionMeta) meta).hasCustomEffects())
@ -983,7 +986,7 @@ public abstract class CommonGUI
((PotionMeta) meta).getCustomEffects().forEach(potionEffect ->
result.add(this.user.getTranslation("challenges.gui.item-description.potion-effect",
"[effect]", potionEffect.getType().getName(),
"[effect]", Util.prettifyText(potionEffect.getType().getName()),
"[duration]", Integer.toString(potionEffect.getDuration()),
"[amplifier]", Integer.toString(potionEffect.getAmplifier()))));
}
@ -999,14 +1002,14 @@ public abstract class CommonGUI
else if (meta instanceof SpawnEggMeta)
{
result.add(this.user.getTranslation("challenges.gui.item-description.egg-meta",
"[mob]", ((SpawnEggMeta) meta).getSpawnedType().name()));
"[mob]", Util.prettifyText(((SpawnEggMeta) meta).getSpawnedType().name())));
}
else if (meta instanceof TropicalFishBucketMeta)
{
result.add(this.user.getTranslation("challenges.gui.item-description.fish-meta",
"[pattern]", ((TropicalFishBucketMeta) meta).getPattern().name(),
"[pattern-color]", ((TropicalFishBucketMeta) meta).getPatternColor().name(),
"[body-color]", ((TropicalFishBucketMeta) meta).getBodyColor().name()));
"[pattern]", Util.prettifyText(((TropicalFishBucketMeta) meta).getPattern().name()),
"[pattern-color]", Util.prettifyText(((TropicalFishBucketMeta) meta).getPatternColor().name()),
"[body-color]", Util.prettifyText(((TropicalFishBucketMeta) meta).getBodyColor().name())));
// parse ne
}
@ -1026,9 +1029,9 @@ public abstract class CommonGUI
}
// ---------------------------------------------------------------------
// Section: Chat Input Methods
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Section: Chat Input Methods
// ---------------------------------------------------------------------
/**
@ -1043,44 +1046,44 @@ public abstract class CommonGUI
final User user = this.user;
Conversation conversation =
new ConversationFactory(BentoBox.getInstance()).withFirstPrompt(
new StringPrompt()
{
/**
* @see Prompt#getPromptText(ConversationContext)
*/
@Override
public String getPromptText(ConversationContext conversationContext)
{
// Close input GUI.
user.closeInventory();
if (message != null)
new ConversationFactory(BentoBox.getInstance()).withFirstPrompt(
new StringPrompt()
{
// Create Edit Text message.
TextComponent component = new TextComponent(user.getTranslation("challenges.gui.descriptions.admin.click-to-edit"));
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, message));
// Send question and message to player.
user.getPlayer().spigot().sendMessage(component);
}
/**
* @see Prompt#getPromptText(ConversationContext)
*/
@Override
public String getPromptText(ConversationContext conversationContext)
{
// Close input GUI.
user.closeInventory();
// There are no editable message. Just return question.
return question;
}
if (message != null)
{
// Create Edit Text message.
TextComponent component = new TextComponent(user.getTranslation("challenges.gui.descriptions.admin.click-to-edit"));
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, message));
// Send question and message to player.
user.getPlayer().spigot().sendMessage(component);
}
// There are no editable message. Just return question.
return question;
}
/**
* @see Prompt#acceptInput(ConversationContext, String)
*/
@Override
public Prompt acceptInput(ConversationContext conversationContext, String answer)
{
// Add answer to consumer.
consumer.accept(answer);
// End conversation
return Prompt.END_OF_CONVERSATION;
}
}).
/**
* @see Prompt#acceptInput(ConversationContext, String)
*/
@Override
public Prompt acceptInput(ConversationContext conversationContext, String answer)
{
// Add answer to consumer.
consumer.accept(answer);
// End conversation
return Prompt.END_OF_CONVERSATION;
}
}).
withLocalEcho(false).
// On cancel conversation will be closed.
withEscapeSequence("cancel").

View File

@ -54,35 +54,35 @@ challenges:
gui:
title:
admin:
gui-title: '&aChallenges Admin'
edit-challenge-title: '&aEdit Challenge'
edit-level-title: '&aEdit Level'
settings-title: '&aEdit Settings'
choose-challenge-title: '&aChoose Challenge'
choose-level-title: '&aChoose Level'
choose-user-title: '&aChoose Player'
manage-blocks: '&aManage Blocks'
manage-entities: '&aManage Entities'
confirm-title: '&aConfirmation'
manage-items: '&aManage Items'
manage-numbers: '&aNumber Pad'
select-block: '&aSelect Block'
select-challenge: '&aSelect Challenge'
select-entity: '&aSelect Entity'
toggle-environment: '&aToggle Environment'
edit-text-fields: '&aEdit Text Fields'
gui-title: '&a Challenges Admin'
edit-challenge-title: '&a Edit Challenge'
edit-level-title: '&a Edit Level'
settings-title: '&a Edit Settings'
choose-challenge-title: '&a Choose Challenge'
choose-level-title: '&a Choose Level'
choose-user-title: '&a Choose Player'
manage-blocks: '&a Manage Blocks'
manage-entities: '&a Manage Entities'
confirm-title: '&a Confirmation'
manage-items: '&a Manage Items'
manage-numbers: '&a Number Pad'
select-block: '&a Select Block'
select-challenge: '&a Select Challenge'
select-entity: '&a Select Entity'
toggle-environment: '&a Toggle Environment'
edit-text-fields: '&a Edit Text Fields'
library-title: '&aDownloadable Libraries'
library-title: '&a Downloadable Libraries'
lore-add: '&aAdd Lore Element'
lore-remove: '&aRemove Lore Element'
lore-edit: '&aEdit Lore'
lore-add: '&a Add Lore Element'
lore-remove: '&a Remove Lore Element'
lore-edit: '&a Edit Lore'
type-select: "&aChoose Challenge Type"
challenges: '&6Challenges'
game-modes: '&6Choose GameMode'
type-select: "&a Choose Challenge Type"
challenges: '&6 Challenges'
game-modes: '&6 Choose GameMode'
multiple-complete: '&6How many times?'
multiple-complete: '&6 How many times?'
buttons:
admin:
complete: 'Complete user challenge'
@ -180,9 +180,9 @@ challenges:
download: 'Download Libraries'
type:
island: '&6Island Type'
inventory: '&6Inventory Type'
other: '&6Other Type'
island: '&6 Island Type'
inventory: '&6 Inventory Type'
other: '&6 Other Type'
next: 'Next'
previous: 'Previous'
return: 'Return'
@ -252,13 +252,13 @@ challenges:
remove-experience: 'Remove required experience.'
required-level: |-
Define the required island level for this challenge.
&cRequires Level addon.'
&c Requires Level addon.'
required-money: |-
Define the required money in player"s account.
&cRequires Vault and an Economy plugin.'
&c Requires Vault and an Economy plugin.'
remove-money: |-
Remove required money from player"s account.
&cRequires Vault and an Economy plugin.'
&c Requires Vault and an Economy plugin.'
reward-text: 'Change message that will be sent to player after challenges completion.'
reward-items: |-
Change first time completion reward items.
@ -266,7 +266,7 @@ challenges:
reward-experience: 'Change first time completion reward experience.'
reward-money: |-
Change first time completion reward money.
&cRequires Vault and Economy plugin.
&c Requires Vault and Economy plugin.
reward-commands: |-
Define reward commands that will be called after first time completion.
***Adding "[SELF]" at the start means that command will be run by player, e.g. "/kill"
@ -281,7 +281,7 @@ challenges:
repeat-reward-experience: 'Change repeated completion reward experience.'
repeat-reward-money: |-
Change repeated completion reward money.
&cRequires Vault and an Economy plugin.
&c Requires Vault and an Economy plugin.
repeat-reward-commands: |-
Define reward commands that will be executed after challenge repeated completion.
***Adding "[SELF]" at the start means that command will be run by player, e.g. "/kill"
@ -315,18 +315,18 @@ challenges:
0 means forever.
island-store: |-
Enable/disable challenges data storing per island. This means that challenges will be the same for the whole team if this is enabled.
&cWill NOT convert data on click. PROGRESS WILL BE LOST.'
&c Will NOT convert data on click. PROGRESS WILL BE LOST.'
default-locked-icon: |-
Change default locked level icon.
This option can be overwritten by each level.'
gui-mode: |-
Enable/disable single challenges GUI.
&2Requires a server restart.'
&2 Requires a server restart.'
visibility-mode: 'Show/hide undeployed challenges.'
click-to-edit: '&4Click here to edit input.'
edit-text-line: '&6Edit text message!'
add-text-line: '&6Add new text message!'
click-to-edit: '&4 Click here to edit input.'
edit-text-line: '&6 Edit text message!'
add-text-line: '&6 Add new text message!'
input-mode: 'Switch between chat and anvil input modes.'
title-enable: 'Enable/disable the title message that will be shown to player"s when they complete a challenge.'
title-showtime: 'Modify how long title messages will be visible to the player.'
@ -339,10 +339,10 @@ challenges:
library: 'Open GUI that shows all available public Challenges Libraries.'
library-author: 'by &e[author]'
library-version: '&9Made in Challenges [version]'
library-lang: '&aLanguage: [lang]'
library-gamemode: '&aPrimary for [gamemode]'
library-author: 'by &e [author]'
library-version: '&9 Made in Challenges [version]'
library-lang: '&a Language: [lang]'
library-gamemode: '&a Primary for [gamemode]'
download: |-
Manually update available challenges libraries.
@ -425,13 +425,13 @@ challenges:
Reward commands.
List of commands that will be rewarded defined in challengeLevel.rewardCommands
current-value: |-
&6Current value: [value].
&6 Current value: [value].
enabled: 'Active'
disabled: 'Disabled'
type:
island: '&arequire blocks or mobs around player'
inventory: '&arequire items in the player"s inventory'
other: '&arequire things from other plugins/addons'
island: '&a require blocks or mobs around player'
inventory: '&a require items in the player"s inventory'
other: '&a require things from other plugins/addons'
the-end: '- The End'
nether: '- Nether'
normal: '- Overworld'
@ -445,8 +445,8 @@ challenges:
level-unlocked: 'Click to see [level] challenges!'
level-locked: 'Complete [count] more [level] challenges to unlock this level!'
increase-by: "&aIncrease completion count by [value]"
reduce-by: "&cReduce completion count by [value]"
increase-by: "&a Increase completion count by [value]"
reduce-by: "&c Reduce completion count by [value]"
visibility:
visible: "All challenges are visible to everyone"
@ -454,35 +454,36 @@ challenges:
toggleable: "Toggle if undeployed challenges should be displayed"
challenge-description:
level: '&fLevel: [level]'
completed: '&bCompleted'
level: '&f Level: [level]'
completed: '&b Completed'
completed-times-of: 'Completed [donetimes] out of [maxtimes]'
maxed-reached: 'Completed [donetimes] out of [maxtimes]'
completed-times: 'Completed [donetimes]'
warning-items-take: '&cAll required items are taken from your inventory when you complete this challenge!'
objects-close-by: '&cAll required blocks and entities must be close to you on your island!'
warning-entities-kill: '&cAll required entities will be killed when you complete this challenge!'
warning-blocks-remove: '&cAll required blocks will be removed when you complete this challenge!'
not-repeatable: '&cThis challenge is not repeatable!'
experience-reward: '&6Exp reward: [value]'
money-reward: '&6Money reward: $[value]'
required-experience: '&6Required exp: [value]'
required-money: '&6Required money: $[value]'
required-island-level: '&6Required island level: [value]'
warning-items-take: '&c All required items are taken from your inventory when you complete this challenge!'
objects-close-by: '&c All required blocks and entities must be close to you on your island!'
warning-entities-kill: '&c All required entities will be killed when you complete this challenge!'
warning-blocks-remove: '&c All required blocks will be removed when you complete this challenge!'
not-repeatable: '&c This challenge is not repeatable!'
experience-reward: '&6 Exp reward: [value]'
money-reward: '&6 Money reward: $[value]'
required-experience: '&6 Required exp: [value]'
required-money: '&6 Required money: $[value]'
required-island-level: '&6 Required island level: [value]'
environment: 'Required Environments:'
reward-items: '&6Reward Items:'
reward-commands: '&6Reward Commands:'
rewards-title: '&a Rewards:'
reward-items: '&6 Reward Items:'
reward-commands: '&6 Reward Commands:'
required-items: 'Required Items:'
required-entities: 'Required Entities:'
required-blocks: 'Required Blocks:'
level-description:
completed: '&bCompleted'
completed-challenges-of: '&3You have completed [number] out of [max] challenges in this level.'
waver-amount: '&6[value] challenges can be skipped to unlock next level.'
experience-reward: '&6Exp reward: [value]'
money-reward: '&6Money reward: $[value]'
reward-items: '&6Reward Items:'
reward-commands: '&6Reward Commands:'
completed: '&b Completed'
completed-challenges-of: '&3 You have completed [number] out of [max] challenges in this level.'
waver-amount: '&6 [value] challenges can be skipped to unlock next level.'
experience-reward: '&6 Exp reward: [value]'
money-reward: '&6 Money reward: $[value]'
reward-items: '&6 Reward Items:'
reward-commands: '&6 Reward Commands:'
item-description:
item: '- [count] x [item]'
item-meta: ' ([meta])'
@ -503,7 +504,7 @@ challenges:
fish-meta: ' [body-color] with [pattern-color] [pattern]'
questions:
prefix: "&2[SERVER]: "
prefix: "&2 [SERVER]: "
admin:
number: "Write a number in the chat and press enter."
@ -527,29 +528,29 @@ challenges:
admin:
hit-things: 'Click the things to add them to the list of required things. Right click when done.'
you-added: 'You added one [thing] to the challenge'
challenge-created: '[challenge]&r created!'
complete-wipe: '&cHopefully you have backups, because you just erased all the Challenges Addon databases!'
challenge-created: '[challenge]&r created!'
complete-wipe: '&c Hopefully you have backups, because you just erased all the Challenges Addon databases!'
challenge-wipe: '&cHopefully you have backups, because you just erased all the Challenges and their levels!'
players-wipe: '&cHopefully you have backups, because you just erase all the player completed challenges!'
challenge-wipe: '&c Hopefully you have backups, because you just erased all the Challenges and their levels!'
players-wipe: '&c Hopefully you have backups, because you just erase all the player completed challenges!'
completed: '&2You completed challenge [name] for [player]!'
already-completed: '&2This challenge was already completed!'
reset: '&2You reset challenge [name] for [player]!'
reset-all: '&2All [player] challenges were reset!'
not-completed: '&2This challenge is not completed yet!'
completed: '&2 You completed challenge [name] for [player]!'
already-completed: '&2 This challenge was already completed!'
reset: '&2 You reset challenge [name] for [player]!'
reset-all: '&2 All [player] challenges were reset!'
not-completed: '&2 This challenge is not completed yet!'
migrate-start: '&2Start migrating challenges addon data.'
migrate-end: '&2Challenges addon data updated to new format.'
migrate-not: '&2All data is valid.'
migrate-start: '&2 Start migrating challenges addon data.'
migrate-end: '&2 Challenges addon data updated to new format.'
migrate-not: '&2 All data is valid.'
start-downloading: '&5Starting to download and import Challenges Library.'
you-completed-challenge: '&2You completed the [value] &r&2challenge!'
you-repeated-challenge: '&2You repeated the [value] &r&2challenge!'
you-repeated-challenge-multiple: '&2You repeated the [value] &r&2challenge [count] times!'
you-completed-level: '&2You completed the [value] &r&2level!'
name-has-completed-challenge: '&5[name] has completed the [value] &r&5challenge!'
name-has-completed-level: '&5[name] has completed the [value] &r&5level!'
start-downloading: '&5 Starting to download and import Challenges Library.'
you-completed-challenge: '&2 You completed the [value] &r &2 challenge!'
you-repeated-challenge: '&2 You repeated the [value] &r &2 challenge!'
you-repeated-challenge-multiple: '&2 You repeated the [value] &r &2 challenge [count] times!'
you-completed-level: '&2 You completed the [value] &r &2 level!'
name-has-completed-challenge: '&5 [name] has completed the [value] &r &5 challenge!'
name-has-completed-level: '&5 [name] has completed the [value] &r &5 level!'
import-levels: 'Start importing Levels'
import-challenges: 'Start importing Challenges'
no-levels: 'Warning: No levels defined in challenges.yml'
@ -560,47 +561,47 @@ challenges:
defaults-file-overwrite: 'defaults.json exists. It will be overwritten.'
defaults-file-completed: 'defaults.json file is populated with challenges from [world]!'
errors:
no-name: '&cMissing challenge name'
unknown-challenge: '&cUnknown challenge'
unique-id: '&cUniqueID "[id]" is not valid.'
wrong-icon: '&cGiven material "[value]" is not valid and cannot be used as icon.'
no-name: '&c Missing challenge name'
unknown-challenge: '&c Unknown challenge'
unique-id: '&c UniqueID "[id]" is not valid.'
wrong-icon: '&c Given material "[value]" is not valid and cannot be used as icon.'
not-valid-integer: |-
&cGiven integer "[value]" is not valid!
&c Given integer "[value]" is not valid!
Value should be between [min] and [max].
not-a-integer: '&cGiven value "[value]" is not an integer!'
not-deployed: '&cChallenge is not deployed!'
not-on-island: '&cYou must be on your island to do that!'
challenge-level-not-available: '&cYou have not unlocked the required level to complete this challenge.'
not-repeatable: '&cThis challenge is not repeatable!'
wrong-environment: '&cYou are in the wrong environment!'
not-enough-items: '&cYou do not have enough [items] to complete this challenge!'
not-close-enough: '&cYou must be standing within [number] blocks of all required items.'
you-still-need: '&cYou still need [amount] x [item]'
missing-addon: '&cCannot complete challenge: Required addon or plugin is missing.'
incorrect: '&cCannot complete challenge: Requirements are incorrect.'
not-enough-money: '&cIt is necessary to have [value] on your account to complete the challenge.'
not-enough-experience: '&cIt is necessary to have [value] EXP to complete this challenge.'
island-level: '&cYour island must be level [number] or greater to complete this challenge!'
import-no-file: '&cCould not find challenges.yml file to import!'
no-load: '&cError: Could not load challenges.yml. [message]'
load-error: '&cError: Cannot load [value].'
no-rank: "&cYou do not have rank that is high enough to do that."
cannot-remove-items: '&cSome items cannot be removed from your inventory!'
exist-challenges-or-levels: '&cChallenges already exist in your world. Cannot proceed!'
defaults-file-exist: '&cdefaults.json already exists. Use overwrite mode to replace it!'
defaults-file-error: '&cThere was an error while creating defaults.json file! Check console!'
no-challenges: '&cChallenges are not implemented in this world yet!'
no-challenges-admin: '&cChallenges are not implemented in this world yet! Use &5/[command] &cto add them!'
missing-level: '&cChallenge Level [level] is not defined in the database. It may cause errors!'
missing-arguments: '&cCommand is missing arguments.'
no-multiple-permission: "&cYou do not have permission to complete this challenge multiple times at once."
not-a-integer: '&c Given value "[value]" is not an integer!'
not-deployed: '&c Challenge is not deployed!'
not-on-island: '&c You must be on your island to do that!'
challenge-level-not-available: '&c You have not unlocked the required level to complete this challenge.'
not-repeatable: '&c This challenge is not repeatable!'
wrong-environment: '&c You are in the wrong environment!'
not-enough-items: '&c You do not have enough [items] to complete this challenge!'
not-close-enough: '&c You must be standing within [number] blocks of all required items.'
you-still-need: '&c You still need [amount] x [item]'
missing-addon: '&c Cannot complete challenge: Required addon or plugin is missing.'
incorrect: '&c Cannot complete challenge: Requirements are incorrect.'
not-enough-money: '&c It is necessary to have [value] on your account to complete the challenge.'
not-enough-experience: '&c It is necessary to have [value] EXP to complete this challenge.'
island-level: '&c Your island must be level [number] or greater to complete this challenge!'
import-no-file: '&c Could not find challenges.yml file to import!'
no-load: '&c Error: Could not load challenges.yml. [message]'
load-error: '&c Error: Cannot load [value].'
no-rank: "&c You do not have rank that is high enough to do that."
cannot-remove-items: '&c Some items cannot be removed from your inventory!'
exist-challenges-or-levels: '&c Challenges already exist in your world. Cannot proceed!'
defaults-file-exist: '&c defaults.json already exists. Use overwrite mode to replace it!'
defaults-file-error: '&c There was an error while creating defaults.json file! Check console!'
no-challenges: '&c Challenges are not implemented in this world yet!'
no-challenges-admin: '&c Challenges are not implemented in this world yet! Use &5 /[command] &c to add them!'
missing-level: '&c Challenge Level [level] is not defined in the database. It may cause errors!'
missing-arguments: '&c Command is missing arguments.'
no-multiple-permission: "&c You do not have permission to complete this challenge multiple times at once."
protection:
flags:
CHALLENGES_ISLAND_PROTECTION:
description: "&5&oToggle who can\n&5&ocomplete challenges"
description: "&5 &o Toggle who can\n&5 &o complete challenges"
name: "Challenges protection"
CHALLENGES_WORLD_PROTECTION:
description: "&5&oEnable/disable\n&5&orequirement for players to\n&5&obe on their island to\n&5&ocomplete a challenge."
description: "&5 &o Enable/disable\n&5 &o requirement for players to\n&5 &o be on their island to\n&5 &o complete a challenge."
name: "Challenges Island limitation"
hint: "No challenges outside island"
version: 11

View File

@ -39,6 +39,7 @@ import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@ -333,6 +334,7 @@ public class ChallengesManagerTest {
/**
* Test method for {@link world.bentobox.challenges.ChallengesManager#removeFromCache(java.util.UUID)}.
*/
@Ignore("This method does not do anything so there is no need to test right now.")
@Test
public void testRemoveFromCache() {
cm.removeFromCache(playerID);