diff --git a/src/bot/bot/constants.py b/src/bot/bot/constants.py index cc24859..43fffa1 100644 --- a/src/bot/bot/constants.py +++ b/src/bot/bot/constants.py @@ -9,20 +9,6 @@ class DIMENSION: THE_NETHER = -1 THE_END = 1 - DISPLAY_TRANSLATION = { - 0: RTextTranslation( - 'createWorld.customize.preset.overworld', - color=RColor.green - ), - -1: RTextTranslation( - 'advancements.nether.root.title', - color=RColor.dark_red - ), - 1: RTextTranslation( - 'advancements.end.root.title', - color=RColor.light_purple - ) - } STR_TRANSLATION = { 0: 'minecraft:overworld', -1: 'minecraft:the_nether', diff --git a/src/bot/bot/location.py b/src/bot/bot/location.py index c9c254a..a71c69f 100644 --- a/src/bot/bot/location.py +++ b/src/bot/bot/location.py @@ -1,6 +1,7 @@ from typing import List, Dict, Any -from mcdreforged.api.rtext import RTextTranslation +import minecraft_data_api as api +from mcdreforged.api.rtext import RText, RColor from bot.constants import DIMENSION @@ -33,12 +34,24 @@ def str_dimension(self) -> str: return DIMENSION.STR_TRANSLATION[self.dimension] @property - def display_dimension(self) -> RTextTranslation: + def display_dimension(self) -> RText: """ - Get RTextTranslation dimension to display. - :return: RTextTranslation. + Get dimension RText to display. + :return: RText. """ - return DIMENSION.DISPLAY_TRANSLATION[self.dimension] + # get translation + translation: RText = api.get_dimension_translation_text(self.dimension) + + # set color + if self.dimension == DIMENSION.OVERWORLD: + translation.set_color(RColor.green) + elif self.dimension == DIMENSION.THE_NETHER: + translation.set_color(RColor.dark_red) + elif self.dimension == DIMENSION.THE_END: + translation.set_color(RColor.light_purple) + + # return + return translation @staticmethod def from_dict(data: Dict[str, Any]) -> 'Location':