mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-28 13:36:06 +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.";
|
final String reference = Constants.DESCRIPTIONS + "challenge.";
|
||||||
|
|
||||||
// Get description in single string
|
// Get description from custom translations
|
||||||
String description = Util.translateColorCodes(String.join("\n",
|
String description = this.user.getTranslationOrNothing(
|
||||||
challenge.getDescription()));
|
"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 :)
|
// Non-memory optimal code used for easier debugging and nicer code layout for my eye :)
|
||||||
// Get status in single string
|
// Get status in single string
|
||||||
String status = this.generateChallengeStatus(isCompletedOnce,
|
String status = this.generateChallengeStatus(isCompletedOnce,
|
||||||
@ -678,8 +685,16 @@ public abstract class CommonPanel
|
|||||||
return "";
|
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",
|
return this.user.getTranslationOrNothing(reference + "lore",
|
||||||
"[text]", Util.translateColorCodes(String.join("\n", challenge.getRepeatRewardText())),
|
"[text]", rewardText,
|
||||||
"[items]", items,
|
"[items]", items,
|
||||||
"[experience]", experience,
|
"[experience]", experience,
|
||||||
"[money]", money,
|
"[money]", money,
|
||||||
@ -771,8 +786,16 @@ public abstract class CommonPanel
|
|||||||
return "";
|
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",
|
return this.user.getTranslationOrNothing(reference + "lore",
|
||||||
"[text]", Util.translateColorCodes(String.join("\n", challenge.getRewardText())),
|
"[text]", rewardText,
|
||||||
"[items]", items,
|
"[items]", items,
|
||||||
"[experience]", experience,
|
"[experience]", experience,
|
||||||
"[money]", money,
|
"[money]", money,
|
||||||
@ -834,8 +857,16 @@ public abstract class CommonPanel
|
|||||||
// Get rewards in single string
|
// Get rewards in single string
|
||||||
String rewards = !levelStatus.isUnlocked() ? "" : this.generateReward(level);
|
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",
|
String returnString = this.user.getTranslation(reference + "lore",
|
||||||
"[text]", Util.translateColorCodes(levelStatus.getLevel().getUnlockMessage()),
|
"[text]", description,
|
||||||
"[waiver]", waiver,
|
"[waiver]", waiver,
|
||||||
"[rewards]", rewards,
|
"[rewards]", rewards,
|
||||||
"[status]", status);
|
"[status]", status);
|
||||||
@ -966,8 +997,16 @@ public abstract class CommonPanel
|
|||||||
return "";
|
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",
|
return this.user.getTranslationOrNothing(reference + "lore",
|
||||||
"[text]", Util.translateColorCodes(String.join("\n", level.getRewardText())),
|
"[text]", rewardText,
|
||||||
"[items]", items,
|
"[items]", items,
|
||||||
"[experience]", experience,
|
"[experience]", experience,
|
||||||
"[money]", money,
|
"[money]", money,
|
||||||
@ -975,7 +1014,6 @@ public abstract class CommonPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Section: Variables
|
// Section: Variables
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -1141,46 +1141,71 @@ challenges:
|
|||||||
invalid-challenge: "&c Challenge [challenge] contains invalid data. It will not be loaded from database!"
|
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."
|
no-library-entries: "&c Cannot find any library entries. Nothing to show."
|
||||||
not-hooked: "&c Challenges Addon could not find any GameMode."
|
not-hooked: "&c Challenges Addon could not find any GameMode."
|
||||||
# Showcase for manual material translation
|
# # Showcase for manual material translation
|
||||||
materials:
|
# materials:
|
||||||
# Names should be lowercase.
|
# # Names should be lowercase.
|
||||||
cobblestone: "Cobblestone"
|
# cobblestone: "Cobblestone"
|
||||||
# Also supports descriptions.
|
# # Also supports descriptions.
|
||||||
stone:
|
# stone:
|
||||||
name: "Stone"
|
# name: "Stone"
|
||||||
description: ""
|
# description: ""
|
||||||
item-stacks:
|
# item-stacks:
|
||||||
# Non-specific item meta translations.
|
# # Non-specific item meta translations.
|
||||||
# TYPE is the item type
|
# # TYPE is the item type
|
||||||
# META is a content of item meta.
|
# # META is a content of item meta.
|
||||||
generic: "[type] [meta]"
|
# generic: "[type] [meta]"
|
||||||
# Non-specific meta translations. Will replace [meta]
|
# # Non-specific meta translations. Will replace [meta]
|
||||||
meta:
|
# meta:
|
||||||
upgraded: "Upgraded"
|
# upgraded: "Upgraded"
|
||||||
extended: "Extended"
|
# extended: "Extended"
|
||||||
potion-meta: "&e [type] [upgraded] [extended]"
|
# potion-meta: "&e [type] [upgraded] [extended]"
|
||||||
# Be aware, enchants are always listed below item in separate line.
|
# # Be aware, enchants are always listed below item in separate line.
|
||||||
enchant-meta: " &7 - &e [type] [level]"
|
# enchant-meta: " &7 - &e [type] [level]"
|
||||||
skull-meta: ": &e [player-name]"
|
# skull-meta: ": &e [player-name]"
|
||||||
book-meta: "&e [title] [author]"
|
# book-meta: "&e [title] [author]"
|
||||||
# Custom Enchantment Translation.
|
# # Custom Enchantment Translation.
|
||||||
enchant:
|
# enchant:
|
||||||
menting: "Mending"
|
# menting: "Mending"
|
||||||
unbreaking: "Unbreaking"
|
# unbreaking: "Unbreaking"
|
||||||
# Custom Potion Translation.
|
# # Custom Potion Translation.
|
||||||
potion-effect:
|
# potion-effect:
|
||||||
water_breathing: "Water Breathing"
|
# water_breathing: "Water Breathing"
|
||||||
# You can also create specific item translations
|
# # You can also create specific item translations
|
||||||
# Like translate all potions.
|
# # Like translate all potions.
|
||||||
potion:
|
# potion:
|
||||||
# This will overwrite generic translation.
|
# # This will overwrite generic translation.
|
||||||
name: "[type] [upgraded] [extended]"
|
# name: "[type] [upgraded] [extended]"
|
||||||
# Type is either specific translation or potion effect.
|
# # Type is either specific translation or potion effect.
|
||||||
water_breathing: "Potion of Water Breathing"
|
# water_breathing: "Potion of Water Breathing"
|
||||||
stone_shovel:
|
# stone_shovel:
|
||||||
# This will mean that only stone shovels will not show
|
# # This will mean that only stone shovels will not show
|
||||||
# meta information.
|
# # meta information.
|
||||||
name: "[type]"
|
# 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:
|
protection:
|
||||||
flags:
|
flags:
|
||||||
CHALLENGES_ISLAND_PROTECTION:
|
CHALLENGES_ISLAND_PROTECTION:
|
||||||
|
Loading…
Reference in New Issue
Block a user