mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-12-30 21:07:47 +01:00
Implement multi-linguistic server support.
Now server owners can specify different name, description and reward text for each challenge and level via locales file. Add showcase example.
This commit is contained in:
parent
477766c8f0
commit
01e6306ef2
@ -139,9 +139,16 @@ public abstract class CommonPanel
|
||||
|
||||
final String reference = Constants.DESCRIPTIONS + "challenge.";
|
||||
|
||||
// Get description in single string
|
||||
String description = Util.translateColorCodes(String.join("\n",
|
||||
challenge.getDescription()));
|
||||
// Get description from custom translations
|
||||
String description = this.user.getTranslationOrNothing(
|
||||
"challenges.challenges." + challenge.getUniqueId() + ".description");
|
||||
|
||||
if (description.isEmpty())
|
||||
{
|
||||
// Get data from object in single string.
|
||||
description = Util.translateColorCodes(String.join("\n", challenge.getDescription()));
|
||||
}
|
||||
|
||||
// Non-memory optimal code used for easier debugging and nicer code layout for my eye :)
|
||||
// Get status in single string
|
||||
String status = this.generateChallengeStatus(isCompletedOnce,
|
||||
@ -678,8 +685,16 @@ public abstract class CommonPanel
|
||||
return "";
|
||||
}
|
||||
|
||||
String rewardText = this.user.getTranslationOrNothing(
|
||||
"challenges.challenges." + challenge.getUniqueId() + ".repeat-reward-text");
|
||||
|
||||
if (rewardText.isEmpty())
|
||||
{
|
||||
rewardText = Util.translateColorCodes(String.join("\n", challenge.getRepeatRewardText()));
|
||||
}
|
||||
|
||||
return this.user.getTranslationOrNothing(reference + "lore",
|
||||
"[text]", Util.translateColorCodes(String.join("\n", challenge.getRepeatRewardText())),
|
||||
"[text]", rewardText,
|
||||
"[items]", items,
|
||||
"[experience]", experience,
|
||||
"[money]", money,
|
||||
@ -771,8 +786,16 @@ public abstract class CommonPanel
|
||||
return "";
|
||||
}
|
||||
|
||||
String rewardText = this.user.getTranslationOrNothing(
|
||||
"challenges.challenges." + challenge.getUniqueId() + ".reward-text");
|
||||
|
||||
if (rewardText.isEmpty())
|
||||
{
|
||||
rewardText = Util.translateColorCodes(String.join("\n", challenge.getRewardText()));
|
||||
}
|
||||
|
||||
return this.user.getTranslationOrNothing(reference + "lore",
|
||||
"[text]", Util.translateColorCodes(String.join("\n", challenge.getRewardText())),
|
||||
"[text]", rewardText,
|
||||
"[items]", items,
|
||||
"[experience]", experience,
|
||||
"[money]", money,
|
||||
@ -834,8 +857,16 @@ public abstract class CommonPanel
|
||||
// Get rewards in single string
|
||||
String rewards = !levelStatus.isUnlocked() ? "" : this.generateReward(level);
|
||||
|
||||
String description = this.user.getTranslationOrNothing(
|
||||
"challenges.levels." + level.getUniqueId() + ".description");
|
||||
|
||||
if (description.isEmpty())
|
||||
{
|
||||
description = Util.translateColorCodes(String.join("\n", level.getUnlockMessage()));
|
||||
}
|
||||
|
||||
String returnString = this.user.getTranslation(reference + "lore",
|
||||
"[text]", Util.translateColorCodes(levelStatus.getLevel().getUnlockMessage()),
|
||||
"[text]", description,
|
||||
"[waiver]", waiver,
|
||||
"[rewards]", rewards,
|
||||
"[status]", status);
|
||||
@ -966,8 +997,16 @@ public abstract class CommonPanel
|
||||
return "";
|
||||
}
|
||||
|
||||
String rewardText = this.user.getTranslationOrNothing(
|
||||
"challenges.levels." + level.getUniqueId() + ".reward-text");
|
||||
|
||||
if (rewardText.isEmpty())
|
||||
{
|
||||
rewardText = Util.translateColorCodes(String.join("\n", level.getRewardText()));
|
||||
}
|
||||
|
||||
return this.user.getTranslationOrNothing(reference + "lore",
|
||||
"[text]", Util.translateColorCodes(String.join("\n", level.getRewardText())),
|
||||
"[text]", rewardText,
|
||||
"[items]", items,
|
||||
"[experience]", experience,
|
||||
"[money]", money,
|
||||
@ -975,7 +1014,6 @@ public abstract class CommonPanel
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Variables
|
||||
// ---------------------------------------------------------------------
|
||||
|
@ -1141,46 +1141,71 @@ challenges:
|
||||
invalid-challenge: "&c Challenge [challenge] contains invalid data. It will not be loaded from database!"
|
||||
no-library-entries: "&c Cannot find any library entries. Nothing to show."
|
||||
not-hooked: "&c Challenges Addon could not find any GameMode."
|
||||
# Showcase for manual material translation
|
||||
materials:
|
||||
# Names should be lowercase.
|
||||
cobblestone: "Cobblestone"
|
||||
# Also supports descriptions.
|
||||
stone:
|
||||
name: "Stone"
|
||||
description: ""
|
||||
item-stacks:
|
||||
# Non-specific item meta translations.
|
||||
# TYPE is the item type
|
||||
# META is a content of item meta.
|
||||
generic: "[type] [meta]"
|
||||
# Non-specific meta translations. Will replace [meta]
|
||||
meta:
|
||||
upgraded: "Upgraded"
|
||||
extended: "Extended"
|
||||
potion-meta: "&e [type] [upgraded] [extended]"
|
||||
# Be aware, enchants are always listed below item in separate line.
|
||||
enchant-meta: " &7 - &e [type] [level]"
|
||||
skull-meta: ": &e [player-name]"
|
||||
book-meta: "&e [title] [author]"
|
||||
# Custom Enchantment Translation.
|
||||
enchant:
|
||||
menting: "Mending"
|
||||
unbreaking: "Unbreaking"
|
||||
# Custom Potion Translation.
|
||||
potion-effect:
|
||||
water_breathing: "Water Breathing"
|
||||
# You can also create specific item translations
|
||||
# Like translate all potions.
|
||||
potion:
|
||||
# This will overwrite generic translation.
|
||||
name: "[type] [upgraded] [extended]"
|
||||
# Type is either specific translation or potion effect.
|
||||
water_breathing: "Potion of Water Breathing"
|
||||
stone_shovel:
|
||||
# This will mean that only stone shovels will not show
|
||||
# meta information.
|
||||
name: "[type]"
|
||||
# # Showcase for manual material translation
|
||||
# materials:
|
||||
# # Names should be lowercase.
|
||||
# cobblestone: "Cobblestone"
|
||||
# # Also supports descriptions.
|
||||
# stone:
|
||||
# name: "Stone"
|
||||
# description: ""
|
||||
# item-stacks:
|
||||
# # Non-specific item meta translations.
|
||||
# # TYPE is the item type
|
||||
# # META is a content of item meta.
|
||||
# generic: "[type] [meta]"
|
||||
# # Non-specific meta translations. Will replace [meta]
|
||||
# meta:
|
||||
# upgraded: "Upgraded"
|
||||
# extended: "Extended"
|
||||
# potion-meta: "&e [type] [upgraded] [extended]"
|
||||
# # Be aware, enchants are always listed below item in separate line.
|
||||
# enchant-meta: " &7 - &e [type] [level]"
|
||||
# skull-meta: ": &e [player-name]"
|
||||
# book-meta: "&e [title] [author]"
|
||||
# # Custom Enchantment Translation.
|
||||
# enchant:
|
||||
# menting: "Mending"
|
||||
# unbreaking: "Unbreaking"
|
||||
# # Custom Potion Translation.
|
||||
# potion-effect:
|
||||
# water_breathing: "Water Breathing"
|
||||
# # You can also create specific item translations
|
||||
# # Like translate all potions.
|
||||
# potion:
|
||||
# # This will overwrite generic translation.
|
||||
# name: "[type] [upgraded] [extended]"
|
||||
# # Type is either specific translation or potion effect.
|
||||
# water_breathing: "Potion of Water Breathing"
|
||||
# stone_shovel:
|
||||
# # This will mean that only stone shovels will not show
|
||||
# # meta information.
|
||||
# name: "[type]"
|
||||
#
|
||||
# # Showcase how to support multi-linguistic challenges
|
||||
# challenges:
|
||||
# # Database ID name.
|
||||
# example_challenge_id:
|
||||
# name: "&2 Translated Name"
|
||||
# description: |-
|
||||
# &7 Translated Custom
|
||||
# &7 description
|
||||
# reward-text: |-
|
||||
# &7 Translated Reward
|
||||
# &7 text
|
||||
# repeat-reward-text: |-
|
||||
# &7 Translated Repeat
|
||||
# &7 Reward text
|
||||
# levels:
|
||||
# # Database ID name.
|
||||
# example_level_id:
|
||||
# name: "&2 Translated Name"
|
||||
# description: |-
|
||||
# &7 Translated Custom
|
||||
# &7 description
|
||||
# reward-text: |-
|
||||
# &7 Translated Reward
|
||||
# &7 text
|
||||
protection:
|
||||
flags:
|
||||
CHALLENGES_ISLAND_PROTECTION:
|
||||
|
Loading…
Reference in New Issue
Block a user